diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 70c2d88e82e57f101dfe863bb0247474968cc4f8..016854fea90b068e36b90cad95bb11149cf8efba 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -281,6 +281,7 @@ set(protobuf_generated_dir ${OPENAIR_BIN_DIR})
 
 # RRC
 ######
+
 add_list2_option(RRC_ASN1_VERSION "Rel14" "ASN.1 version of RRC interface" "Rel8" "Rel10" "Rel14" "CBA")
 
 if (${RRC_ASN1_VERSION} STREQUAL "Rel8")
@@ -293,23 +294,37 @@ else()
   set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn)
 endif  (${RRC_ASN1_VERSION} STREQUAL "Rel8")
 
-set (RRC_FULL_DIR ${asn1_generated_dir}/${RRC_ASN1_VERSION})
+set (RRC_FULL_DIR ${asn1_generated_dir}/RRC_${RRC_ASN1_VERSION})
+
 if(NOT EXISTS ${asn1c_call})
   message( FATAL_ERROR "The script ${asn1c_call} must be present" )
 endif(NOT EXISTS ${asn1c_call})
-execute_process(COMMAND ${asn1c_call}  ${RRC_FULL_DIR} ${RRC_GRAMMAR}
-                RESULT_VARIABLE ret)
+
+message("calling asn1c -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${RRC_FULL_DIR} ${RRC_GRAMMAR}")
+execute_process(COMMAND ${asn1c_call}  
+			${RRC_FULL_DIR} 
+			${RRC_GRAMMAR}
+			RRC
+                	RESULT_VARIABLE ret)
+
 if (NOT ${ret} STREQUAL 0)
   message(FATAL_ERROR "${asn1c_call}: error")
 endif (NOT ${ret} STREQUAL 0)
+
 if(NOT EXISTS ${fix_asn1c_call})
   message( FATAL_ERROR "The script ${fix_asn1c_call} must be present" )
 endif(NOT EXISTS ${fix_asn1c_call})
-execute_process(COMMAND ${fix_asn1c_call} ${RRC_FULL_DIR} RRC ${RRC_ASN1_VERSION}
-                RESULT_VARIABLE ret)
+
+execute_process(COMMAND ${fix_asn1c_call} 
+			${RRC_FULL_DIR} 
+			RRC 
+			${RRC_ASN1_VERSION}
+                	RESULT_VARIABLE ret)
+
 if (NOT ${ret} STREQUAL 0)
   message(FATAL_ERROR "${fix_asn1c_call}: error")
 endif (NOT ${ret} STREQUAL 0)
+
 file(GLOB rrc_source ${RRC_FULL_DIR}/*.c)
 file(GLOB rrc_h ${RRC_FULL_DIR}/*.h)
 set(rrc_h ${rrc_h} ${RRC_FULL_DIR}/asn1_constants.h)
@@ -328,14 +343,78 @@ add_custom_command (
   DEPENDS ${RRC_GRAMMAR}
   )
 
+
+#NR RRC
+######
+
+add_list2_option(NR_RRC_ASN1_VERSION "NR_Rel15" "ASN.1 version of NR_RRC interface")
+
+if (${NR_RRC_ASN1_VERSION} STREQUAL "NR_Rel15")
+  set (NR_RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-RRC-Definitions.asn)
+endif  (${NR_RRC_ASN1_VERSION} STREQUAL "NR_Rel15")
+
+set (NR_RRC_FULL_DIR ${asn1_generated_dir}/${NR_RRC_ASN1_VERSION})
+
+if(NOT EXISTS ${asn1c_call})
+message( FATAL_ERROR "The script ${asn1c_call} must be present" )
+endif(NOT EXISTS ${asn1c_call})
+
+message("calling ASN1C_PREFIX=NR_ asn1c -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${RRC_FULL_DIR} ${RRC_GRAMMAR}")
+execute_process(COMMAND ${asn1c_call}  
+			${NR_RRC_FULL_DIR} 
+			${NR_RRC_GRAMMAR}
+			NR_RRC
+                        RESULT_VARIABLE ret)
+
+if (NOT ${ret} STREQUAL 0)
+   message(FATAL_ERROR "${asn1c_call}: error")
+endif (NOT ${ret} STREQUAL 0)
+
+if(NOT EXISTS ${fix_asn1c_call})
+  message( FATAL_ERROR "The script ${fix_asn1c_call} must be present" )
+endif(NOT EXISTS ${fix_asn1c_call})
+
+execute_process(COMMAND ${fix_asn1c_call} 
+			${NR_RRC_FULL_DIR} 
+			NR_RRC 
+			${NR_RRC_ASN1_VERSION}
+			RESULT_VARIABLE ret)
+
+if (NOT ${ret} STREQUAL 0)
+  message(FATAL_ERROR "${fix_asn1c_call}: error")
+endif (NOT ${ret} STREQUAL 0)
+
+file(GLOB nr_rrc_source ${NR_RRC_FULL_DIR}/*.c)
+file(GLOB nr_rrc_h ${NR_RRC_FULL_DIR}/*.h)
+set(nr_rrc_h ${nr_rrc_h} ${NR_RRC_FULL_DIR}/asn1_constants.h)
+set_source_files_properties(${nr_rrc_source} PROPERTIES COMPILE_FLAGS -w) # suppress warnings from generated code
+add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source}
+    ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c)
+include_directories ("${NR_RRC_FULL_DIR}")
+
+# add the command to generate the source code
+# Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
+
+add_custom_command (
+  OUTPUT ${NR_RRC_FULL_DIR}/asn1_constants.h
+  COMMAND ${asn1c_call}  ${NR_RRC_FULL_DIR} ${NR_RRC_GRAMMAR} RRC
+  COMMAND ${fix_asn1c_call}  ${NR_RRC_FULL_DIR} RRC ${NR_RRC_ASN1_VERSION}
+  DEPENDS ${RRC_GRAMMAR}
+  )
+
 # S1AP
 # Same limitation as described in RRC: unknown generated file list
 # so we generate it at cmake time
 ##############
-add_list1_option(S1AP_VERSION R10 "S1AP Asn.1 grammar version" R8 R9 R10)
+add_list1_option(S1AP_VERSION R14 "S1AP Asn.1 grammar version" R8 R9 R10 R14)
 
 set(S1AP_DIR ${OPENAIR3_DIR}/S1AP)
-if (${S1AP_VERSION} STREQUAL "R10")
+
+if (${S1AP_VERSION} STREQUAL "R14")
+  set (ASN1RELDIR R14.4)
+  add_definitions("-DUPDATE_RELEASE_9 -DUPDATE_RELEASE_10 -DUPDATE_RELEASE_14")
+  set(S1AP_ASN_FILES s1ap-14.4.0.asn1)
+elseif (${S1AP_VERSION} STREQUAL "R10")
   set (ASN1RELDIR R10.5)
   add_definitions("-DUPDATE_RELEASE_9 -DUPDATE_RELEASE_10")
 elseif (${S1AP_VERSION} STREQUAL "R9")
@@ -343,52 +422,33 @@ elseif (${S1AP_VERSION} STREQUAL "R9")
   add_definitions("-DUPDATE_RELEASE_9")
 else(${S1AP_VERSION} STREQUAL "R8")
   set (ASN1RELDIR R8.10)
-endif(${S1AP_VERSION} STREQUAL "R10")
+endif(${S1AP_VERSION} STREQUAL "R14")
+
 set(S1AP_ASN_DIR ${S1AP_DIR}/MESSAGES/ASN1/${ASN1RELDIR})
-set(S1AP_ASN_FILES
-  ${S1AP_ASN_DIR}/S1AP-CommonDataTypes.asn
-  ${S1AP_ASN_DIR}/S1AP-Constants.asn
-  ${S1AP_ASN_DIR}/S1AP-IEs.asn
-  ${S1AP_ASN_DIR}/S1AP-PDU.asn
-  )
-set(S1AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR})
-#message("calling ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}")
-execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}
-                RESULT_VARIABLE ret)
-if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "${asn1c_call}: error")
-endif (NOT ${ret} STREQUAL 0)
-execute_process(COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR}
-                RESULT_VARIABLE ret)
-if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "asn1tostruct.py: error")
-endif (NOT ${ret} STREQUAL 0)
-execute_process(COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION}
+set(S1AP_C_DIR ${asn1_generated_dir}/S1AP_${ASN1RELDIR})
+
+message("calling ASN1C_PREFIX=S1AP_ asn1c -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${S1AP_C_DIR} ${S1AP_ASN_DIR}/${S1AP_ASN_FILES}")
+
+execute_process(COMMAND mkdir -p ${S1AP_C_DIR}
+                COMMAND env "ASN1C_PREFIX=S1AP_" asn1c -pdu=all -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${S1AP_C_DIR} ${S1AP_ASN_DIR}/${S1AP_ASN_FILES}
                 RESULT_VARIABLE ret)
+
 if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "${fix_asn1c_call}: error")
+  message(FATAL_ERROR "${ret}: error")
 endif (NOT ${ret} STREQUAL 0)
-file(GLOB S1AP_source ${S1AP_C_DIR}/*.c)
 
-set(S1AP_OAI_generated
-  ${S1AP_C_DIR}/s1ap_decoder.c
-  ${S1AP_C_DIR}/s1ap_encoder.c
-  ${S1AP_C_DIR}/s1ap_xer_print.c
-  ${S1AP_C_DIR}/s1ap_compare.c
-  ${S1AP_C_DIR}/s1ap_ies_defs.h
-  )
+file(GLOB S1AP_source ${S1AP_C_DIR}/*.c)
 file(GLOB s1ap_h ${S1AP_C_DIR}/*.h)
 set(s1ap_h ${s1ap_h} )
 
 add_custom_command (
-  OUTPUT ${S1AP_OAI_generated}
-  COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}
-  COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR}
-  COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION}
-  DEPENDS ${S1AP_ASN_FILES}
-  )
+  OUTPUT ${S1AP_C_DIR}/S1AP_asn_constant.h
+  COMMAND mkdir -p ${S1AP_C_DIR}
+  COMMAND env "ASN1C_PREFIX=S1AP_" asn1c -pdu=all -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${S1AP_C_DIR} ${S1AP_ASN_DIR}/${S1AP_ASN_FILES}
+  DEPENDS ${S1AP_ASN_DIR}/${S1AP_ASN_FILES}
+)
+
 add_library(S1AP_LIB
-  ${S1AP_OAI_generated}
   ${S1AP_source}
   ${S1AP_DIR}/s1ap_common.c
   )
@@ -397,10 +457,9 @@ include_directories ("${S1AP_C_DIR}")
 include_directories ("${S1AP_DIR}")
 
 add_library(S1AP_ENB
-  ${S1AP_C_DIR}/s1ap_ies_defs.h
+  # ${S1AP_C_DIR}/s1ap_ies_defs.h
   ${S1AP_DIR}/s1ap_eNB.c
   ${S1AP_DIR}/s1ap_eNB_context_management_procedures.c
-  ${S1AP_DIR}/s1ap_eNB_decoder.c
   ${S1AP_DIR}/s1ap_eNB_encoder.c
   ${S1AP_DIR}/s1ap_eNB_handlers.c
   ${S1AP_DIR}/s1ap_eNB_itti_messaging.c
@@ -410,6 +469,7 @@ add_library(S1AP_ENB
   ${S1AP_DIR}/s1ap_eNB_overload.c
   ${S1AP_DIR}/s1ap_eNB_trace.c
   ${S1AP_DIR}/s1ap_eNB_ue_context.c
+  ${S1AP_DIR}/s1ap_eNB_decoder.c
   )
 
 
@@ -418,61 +478,39 @@ add_library(S1AP_ENB
 # Same limitation as described in RRC/S1AP: unknown generated file list
 # so we generate it at cmake time
 ##############
-add_list1_option(X2AP_VERSION R11 "X2AP Asn.1 grammar version" R10 R11)
+add_list1_option(X2AP_VERSION R14 "X2AP Asn.1 grammar version" R10 R11 R14)
 set(X2AP_DIR ${OPENAIR2_DIR}/X2AP)
-if (${X2AP_VERSION} STREQUAL "R11")
+if (${X2AP_VERSION} STREQUAL "R14")
+  set (ASN1RELDIR R14.5)
+  set (X2AP_ASN_FILES x2ap-14.5.0.asn1)
+elseif (${X2AP_VERSION} STREQUAL "R11")
   set (ASN1RELDIR R11.2)
 elseif (${X2AP_VERSION} STREQUAL "R10")
   set (ASN1RELDIR R.UNKNOWN)
-endif(${X2AP_VERSION} STREQUAL "R11")
+endif(${X2AP_VERSION} STREQUAL "R14")
 set(X2AP_ASN_DIR ${X2AP_DIR}/MESSAGES/ASN1/${ASN1RELDIR})
-set(X2AP_ASN_FILES
-  ${X2AP_ASN_DIR}/X2AP-CommonDataTypes.asn
-  ${X2AP_ASN_DIR}/X2AP-Constants.asn
-  ${X2AP_ASN_DIR}/X2AP-IEs.asn
-  ${X2AP_ASN_DIR}/X2AP-PDU.asn
-  ${X2AP_ASN_DIR}/X2AP-Containers.asn
-  )
 
-set(X2AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR})
-#message("calling ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}")
-execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}
+set(X2AP_C_DIR ${asn1_generated_dir}/X2AP_${ASN1RELDIR})
+message("calling asn1c -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${X2AP_C_DIR} ${X2AP_ASN_DIR}/${X2AP_ASN_FILES}")
+execute_process(COMMAND mkdir -p ${X2AP_C_DIR}
+                COMMAND env "ASN1C_PREFIX=X2AP_" asn1c -pdu=all -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${X2AP_C_DIR} ${X2AP_ASN_DIR}/${X2AP_ASN_FILES}
                 RESULT_VARIABLE ret)
 if (NOT ${ret} STREQUAL 0)
   message(FATAL_ERROR "${asn1c_call}: error")
 endif (NOT ${ret} STREQUAL 0)
-execute_process(COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR}
-                RESULT_VARIABLE ret)
-if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "asn1tostruct.py: error")
-endif (NOT ${ret} STREQUAL 0)
-execute_process(COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION}
-                RESULT_VARIABLE ret)
-if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "${fix_asn1c_call}: error")
-endif (NOT ${ret} STREQUAL 0)
 file(GLOB X2AP_source ${X2AP_C_DIR}/*.c)
 
-set(X2AP_OAI_generated
-  ${X2AP_C_DIR}/x2ap_decoder.c
-  ${X2AP_C_DIR}/x2ap_encoder.c
-  ${X2AP_C_DIR}/x2ap_xer_print.c
-  ${X2AP_C_DIR}/x2ap_ies_defs.h
-  )
 file(GLOB x2ap_h ${X2AP_C_DIR}/*.h)
 set(x2ap_h ${x2ap_h} )
 
-#message("calling ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR}")
 add_custom_command (
-  OUTPUT ${X2AP_OAI_generated}
-  COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}
-  COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR}
-  COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION}
-  DEPENDS ${X2AP_ASN_FILES}
+  OUTPUT ${X2AP_C_DIR}/X2AP_asn_constant.h
+  COMMAND mkdir -p ${X2AP_C_DIR}
+  COMMAND env "ASN1C_PREFIX=X2AP_" asn1c -pdu=all -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D ${X2AP_C_DIR} ${X2AP_ASN_DIR}/${X2AP_ASN_FILES}
+  DEPENDS ${X2AP_ASN_DIR}/${X2AP_ASN_FILES}
   )
 
 add_library(X2AP_LIB
-  ${X2AP_OAI_generated}
   ${X2AP_source}
   ${X2AP_DIR}/x2ap_common.c
   )
@@ -485,7 +523,7 @@ include_directories ("${X2AP_DIR}")
 add_list1_option(NB_ANTENNAS_RX "2" "Number of antennas in reception" "1" "2" "4")
 add_list1_option(NB_ANTENNAS_TX "4" "Number of antennas in transmission" "1" "2" "4")
 
-add_list2_option(RF_BOARD "EXMIMO" "RF head type" "None" "EXMIMO" "OAI_USRP" "OAI_BLADERF" "CPRIGW" "OAI_LMSSDR" "OAI_ADRV9371_ZC706")
+add_list2_option(RF_BOARD "EXMIMO" "RF head type" "None" "EXMIMO" "OAI_USRP" "OAI_BLADERF" "CPRIGW" "OAI_LMSSDR")
 
 add_list2_option(TRANSP_PRO "None" "Transport protocol type" "None" "ETHERNET")
 #NOKIA config enhancement
@@ -508,11 +546,6 @@ set (SHLIB_LOADER_SOURCES
 )
 # include RF devices / transport protocols library modules
 ######################################################################
-if (HWLAT)
-  add_definitions(-DHWLAT )
-endif()
-
-
 
 include_directories("${OPENAIR_TARGETS}/ARCH/EXMIMO/USERSPACE/LIB/")
 include_directories ("${OPENAIR_TARGETS}/ARCH/EXMIMO/DEFS/")
@@ -758,9 +791,6 @@ include_directories("${OPENAIR3_DIR}/UDP")
 include_directories("${OPENAIR3_DIR}/GTPV1-U")
 include_directories("${OPENAIR_DIR}/targets/COMMON")
 include_directories("${OPENAIR_DIR}/targets/ARCH/COMMON")
-include_directories("${OPENAIR_DIR}/targets/ARCH/ADRV9371_ZC706/USERSPACE/LIB/")
-include_directories("${OPENAIR_DIR}/targets/ARCH/ADRV9371_ZC706/USERSPACE/libini/")
-include_directories("${OPENAIR_DIR}/targets/ARCH/ADRV9371_ZC706/DEFS/")
 include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/USERSPACE/LIB/")
 include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/DEFS")
 include_directories("${OPENAIR2_DIR}/ENB_APP")
@@ -1054,12 +1084,6 @@ set(PHY_TURBOSRC
   ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c
   ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c
   ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder.c
-  )
-set(PHY_LDPCSRC
-  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
-  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c
-  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
-  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
 )
 set(PHY_POLARSRC
   ${OPENAIR1_DIR}/PHY/CODING/nrPolar_init.c
@@ -1202,7 +1226,7 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz_ue.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_time.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_timefreq.c
-  ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c
+  ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c
@@ -1263,6 +1287,7 @@ if (${SMBV})
 endif  (${SMBV})
 
 if (${COMPILATION_AVX2} STREQUAL "True")
+  #set(PHY_SRC ${PHY_SRC} ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c)
   set(PHY_SRC_UE ${PHY_SRC_UE} ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c)
 endif ()
 
@@ -1373,12 +1398,12 @@ set(L2_SRC_UE
 set (MAC_SRC
   ${PHY_INTERFACE_DIR}/IF_Module.c
   ${MAC_DIR}/main.c
-  #${MAC_DIR}/main_ue.c
-  #${MAC_DIR}/ue_procedures.c
-  #${MAC_DIR}/ra_procedures.c
+  ${MAC_DIR}/main_ue.c
+  ${MAC_DIR}/ue_procedures.c
+  ${MAC_DIR}/ra_procedures.c
   ${MAC_DIR}/l1_helpers.c
   ${MAC_DIR}/rar_tools.c
-  #${MAC_DIR}/rar_tools_ue.c
+  ${MAC_DIR}/rar_tools_ue.c
   ${MAC_DIR}/eNB_scheduler.c
   ${MAC_DIR}/eNB_scheduler_dlsch.c
   ${MAC_DIR}/eNB_scheduler_ulsch.c
@@ -1389,7 +1414,7 @@ set (MAC_SRC
   ${MAC_DIR}/eNB_scheduler_phytest.c
   ${MAC_DIR}/pre_processor.c
   ${MAC_DIR}/config.c
-  #${MAC_DIR}/config_ue.c
+  ${MAC_DIR}/config_ue.c
  )
 
 set (MAC_SRC_UE
@@ -1945,7 +1970,7 @@ add_definitions(-DASN1_MINIMUM_VERSION=924)
 # add executables for operation
 #################################
 
-# lte-softmodem is eNB implementation
+# lte-softmodem is both eNB and UE implementation
 ###################################################
 
 add_executable(lte-softmodem
@@ -1984,7 +2009,7 @@ target_link_libraries (lte-softmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${CR
 target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES})
 target_link_libraries (lte-softmodem ${T_LIB})
 
-# lte-softmodem-nos1 is eNB implementation
+# lte-softmodem-nos1 is both eNB and UE implementation
 ###################################################
 add_executable(lte-softmodem-nos1
   ${rrc_h}
@@ -2020,38 +2045,6 @@ target_link_libraries (lte-softmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt
 target_link_libraries (lte-softmodem-nos1  ${LIB_LMS_LIBRARIES})
 target_link_libraries (lte-softmodem-nos1 ${T_LIB})
 
-
-# lte-hwlat
-###################################################
-add_executable(lte-hwlat
-  ${HW_SOURCE}
-  ${OPENAIR_TARGETS}/RT/USER/lte-hwlat.c
-  ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
-  )
-target_link_libraries (lte-hwlat
-  -Wl,--start-group
-  -Wl,--end-group )
-
-target_link_libraries (lte-hwlat rt pthread m )
-target_link_libraries (lte-hwlat ${CMAKE_DL_LIBS}  )
-target_link_libraries (lte-hwlat ${OPENAIR_TARGETS}/ARCH/ADRV9371_ZC706/slib/libadrv9371_zc706.so )
-
-
-# lte-hwlat-test
-###################################################
-add_executable(lte-hwlat-test
-  ${HW_SOURCE}
-  ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c
-  ${OPENAIR_TARGETS}/RT/USER/lte-hwlat2.c
-  ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
-  )
-target_link_libraries (lte-hwlat-test
-  -Wl,--start-group
-  -Wl,--end-group )
-
-target_link_libraries (lte-hwlat-test rt pthread m )
-target_link_libraries (lte-hwlat-test ${CMAKE_DL_LIBS}  )
-
 # lte-uesoftmodem is  UE implementation
 #######################################
 
@@ -2087,7 +2080,7 @@ target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${
 target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES})
 target_link_libraries (lte-uesoftmodem ${T_LIB})
 
-# lte-softmodem-nos1 is UE implementation
+# lte-softmodem-nos1 is both eNB and UE implementation
 ###################################################
 add_executable(lte-uesoftmodem-nos1
   ${rrc_h}
@@ -2379,10 +2372,10 @@ if (${T_TRACER})
         #all "add_executable" definitions (except tests, rb_tool, updatefw)
         lte-softmodem lte-softmodem-nos1 oaisim oaisim_nos1
         dlsim_tm4 dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim
-        pdcchsim pucchsim prachsim syncsim lte-hwlat
+        pdcchsim pucchsim prachsim syncsim
         #all "add_library" definitions
         ITTI RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB
-        oai_adrv9371_zc706devif oai_exmimodevif oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif
+        oai_exmimodevif oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif
         oai_eth_transpro
         FLPT_MSG ASYNC_IF FLEXRAN_AGENT HASHTABLE MSC UTIL OMG_SUMO SECU_OSA
         SECU_CN SCHED_LIB PHY L2 default_sched remote_sched RAL CN_UTILS
diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai
index 6344ad2533947c2f529d54ba9b731df8d5d8e6b6..c1ca7d8ef9e494f78e8cb71b9bd66bc02371510f 100755
--- a/cmake_targets/build_oai
+++ b/cmake_targets/build_oai
@@ -48,6 +48,7 @@ DEADLINE_SCHEDULER_FLAG_USER="False"
 FORCE_DEADLINE_SCHEDULER_FLAG_USER=""
 CPU_AFFINITY_FLAG_USER="False" #Only valid when lowlatecy flag is set to False
 REL="Rel14"
+NR_REL="NR_Rel15"
 HW="None"
 TP="None"
 NOS1=0
@@ -582,6 +583,7 @@ function main() {
     echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >>  $cmake_file
     echo "set ( XFORMS $XFORMS )"                  >>  $cmake_file
     echo "set ( RRC_ASN1_VERSION \"${REL}\")"      >>  $cmake_file
+    echo "set ( NR_RRC_ASN1_VERSION \"${NR_REL}\")"      >>  $cmake_file
     echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )"     >>  $cmake_file
     echo "set ( RF_BOARD \"${HW}\")"               >>  $cmake_file
     echo "set ( TRANSP_PRO \"${TP}\")"             >>  $cmake_file
diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper
index 616100768ee1606097d0761ed512605e320ac51c..f0ae7e79c8240c34f0b196613f0e54f556601122 100755
--- a/cmake_targets/tools/build_helper
+++ b/cmake_targets/tools/build_helper
@@ -147,7 +147,7 @@ clean_all_files() {
  set_openair_env
  dir=$OPENAIR_DIR/cmake_targets
  rm -rf $dir/log $OPENAIR_DIR/targets/bin/* 
- rm -rf $dir/build_oai $dir/lte-simulators/build
+ rm -rf $dir/lte_build_oai $dir/lte-simulators/build
  rm -rf $dir/oaisim_build_oai/build $dir/oaisim_build_oai/CMakeLists.txt
  rm -rf $dir/autotests/bin $dir/autotests/log $dir/autotests/*/build 
 }
@@ -242,36 +242,6 @@ install_protobuf_c_from_source(){
     ) >& $protobuf_c_install_log
 }
 
-install_libiio_driver_from_source(){
-    libiio_install_log=$OPENAIR_DIR/cmake_targets/log/libiio_install_log.txt
-    echo_info "\nInstalling LibIIO driver from sources. The log file for LibIIO driver installation is here: $libiio_install_log "
-    (
-     cd /tmp
-     echo "Downloading LibIIO driver"
-     rm -rf /tmp/libiio
-     git clone https://github.com/analogdevicesinc/libiio.git
-     cd libiio
-     git checkout 2016_R2
-     cmake ./
-	 make all
-     $SUDO make install
-    ) >& $libiio_install_log
-}
-
-check_install_libiio_driver(){
-    if [[ "$OS_DISTRO" == "ubuntu" ]]; then
-   		$SUDO apt-get install -y --allow-unauthenticated libxml2
-   		$SUDO apt-get install -y --allow-unauthenticated libxml2-dev
-   		$SUDO apt-get install -y --allow-unauthenticated bison
-   		$SUDO apt-get install -y --allow-unauthenticated flex
-   		$SUDO apt-get install -y --allow-unauthenticated libcdk5-dev
-   		$SUDO apt-get install -y --allow-unauthenticated cmake 
-		$SUDO apt-get install -y --allow-unauthenticated libaio-dev
-		$SUDO apt-get install -y --allow-unauthenticated libavahi-client-dev
-		install_libiio_driver_from_source
-    fi
-}
-
 install_usrp_uhd_driver_from_source(){
     uhd_install_log=$OPENAIR_DIR/cmake_targets/log/uhd_install_log.txt
     echo_info "\nInstalling UHD driver from sources. The log file for UHD driver installation is here: $uhd_install_log "
@@ -689,8 +659,11 @@ install_asn1c_from_source(){
     echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log "
     (
     $SUDO rm -rf /tmp/asn1c
-    GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c
+    # GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c
+    git clone https://github.com/velichkov/asn1c /tmp/asn1c
     cd /tmp/asn1c
+    git checkout s1ap
+    test -f configure || autoreconf -iv
     ./configure
     make -j`nproc`
     $SUDO make install
diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1
index fe819c27162df2174c27cc2cc93aa250b00c3bd1..cba93f589853330ace893b7bd2049c01375f8129 100755
--- a/cmake_targets/tools/fix_asn1
+++ b/cmake_targets/tools/fix_asn1
@@ -94,7 +94,7 @@ function patch_rrc()
   case "$version" in
     Rel14 )
       echo "patching RRC files release 14"
-      apply_patches "$directory" RRC_Rel14 ${#RRC_Rel14[*]}
+      #apply_patches "$directory" RRC_Rel14 ${#RRC_Rel14[*]}
       ;;
     Rel10 )
       echo "patching RRC files release 10"
@@ -109,12 +109,31 @@ function patch_rrc()
   esac
 }
 
+function patch_nr_rrc()
+{
+  local directory="$1"
+  local version="$2"
+
+  case "$version" in
+    NR_Rel15 )
+      echo "patching NR_RRC files release 15"
+      apply_patches "$directory" NR_RRC_Rel15 ${#NR_RRC_Rel15[*]}
+      ;;
+    * )
+      error unknwon/unhandled NR_RRC version \'"$version"\'
+      ;;
+  esac
+}
+
+
 function patch_x2ap()
 {
   local directory="$1"
   local version="$2"
 
   case "$version" in
+    R14 )
+      ;;
     R11 )
       echo "patching X2AP files release 11.2"
       apply_patches "$directory" X2AP_Rel11_2 ${#X2AP_Rel11_2[*]}
@@ -131,6 +150,8 @@ function patch_s1ap()
   local version="$2"
 
   case "$version" in
+    R14 )
+      ;;
     R10 )
       #nothing to do anymore (fixes went to asn1c)
       ;;
@@ -161,6 +182,9 @@ function main()
     RRC )
       patch_rrc "$directory" "$version"
       ;;
+    NR_RRC )
+      patch_nr_rrc "$directory" "$version"
+      ;;
     X2AP )
       patch_x2ap "$directory" "$version"
       ;;
diff --git a/cmake_targets/tools/generate_asn1 b/cmake_targets/tools/generate_asn1
index 79becbf28881395dd495bad7921ee11dce02100b..fb38455a126a809026fb306e8663a53a4ed01c2a 100755
--- a/cmake_targets/tools/generate_asn1
+++ b/cmake_targets/tools/generate_asn1
@@ -6,9 +6,11 @@ mkdir -p $1
 cd $1
 shift
 
+local module="$2"
+
 #if this script is called with only 2 arguments (so 1 here after the shift), it's for RRC
 #(there may be a better way...)
-if [ $# -eq 1 ]; then
+if [ $# -eq 2 ]; then
 
 #asn1c does not work well with extension groups, we need the following fix:
 # replace [[ by '<name> SEQUENCE {'
@@ -99,7 +101,21 @@ echo done with asnfix
 
 echo running asn1c
 
-asn1c -gen-PER -fcompound-names fixed_grammar.asn 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample
+case "$module" in
+  RRC )
+  	asn1c -gen-PER -fcompound-names -no-gen-example fixed_grammar.asn 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample	
+  ;;
+  NR_RRC )
+    	export ASN1C_PREFIX=NR_
+  	asn1c -gen-PER -fcompound-names -no-gen-example fixed_grammar.asn 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample	
+  ;;
+  S1AP )
+	export ASN1C_PREFIX=S1AP_
+  	asn1c -gen-PER -fcompound-names -no-gen-example fixed_grammar.asn 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample	
+  ;;
+esac
+
+
 
 rm -f fixed_grammar.asn
 
@@ -107,7 +123,19 @@ echo asn1c done
 
 else
 
-asn1c -gen-PER -fcompound-names $* 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample
+case "$module" in
+  RRC )
+  	asn1c -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example $* 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample
+  ;; 
+  NR_RRC )
+    	export ASN1C_PREFIX=NR_
+  	asn1c -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example $* 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample	
+  ;;
+  S1AP )
+    	export ASN1C_PREFIX=S1AP_
+    	asn1c -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example $* 2>&1 | grep -v -- '->' | grep -v '^Compiled' |grep -v sample	
+  ;;
+esac
 
 fi
 
diff --git a/common/ran_context.h b/common/ran_context.h
index 1496791099db7e979c4c750b4e6187e7d2fd44b5..e616595d15f1b184fcb39338ef897c1c4e0cea0e 100644
--- a/common/ran_context.h
+++ b/common/ran_context.h
@@ -49,15 +49,21 @@
 
 #include "PHY/defs_L1_NB_IoT.h"
 #include "RRC/LTE/defs_NB_IoT.h"
+#include "RRC/NR/defs_NR.h"
+
 typedef struct {
   /// RAN context config file name
   char *config_file_name;
   /// Number of RRC instances in this node
   int nb_inst;
+  /// Number of NB_IoT RRC instances in this node
+  int nb_nb_iot_rrc_inst;
+  /// Number of NR RRC instances in this node
+  int nb_nr_inst;
   /// Number of Component Carriers per instance in this node
   int *nb_CC;
-  /// Number of NB_IoT instances in this node
-  int nb_nb_iot_rrc_inst;
+  /// Number of NR Component Carriers per instance in this node
+  int *nb_nr_CC;
   /// Number of MACRLC instances in this node
   int nb_macrlc_inst;
   /// Number of NB_IoT MACRLC instances in this node
@@ -84,6 +90,8 @@ typedef struct {
   struct eNB_RRC_INST_s **rrc;
   /// NB_IoT RRC context variables
   //struct eNB_RRC_INST_NB_IoT_s **nb_iot_rrc;
+  /// NR RRC context variables
+  struct gNB_RRC_INST_s **nrrrc;
   /// MAC context variables
   struct eNB_MAC_INST_s **mac;
   /// NB_IoT MAC context variables
diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nr_fapi_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nr_fapi_ue_interface.h
new file mode 100644
index 0000000000000000000000000000000000000000..fcfb7e7b25c5ea6971d0adeac1550a0a30e8d51b
--- /dev/null
+++ b/nfapi/open-nFAPI/nfapi/public_inc/nr_fapi_ue_interface.h
@@ -0,0 +1,3886 @@
+/*
+ * Copyright 2017 Cisco Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+
+#ifndef _NFAPI_INTERFACE_NR_EXTENSION_H_
+#define _NFAPI_INTERFACE_NR_EXTENSION_H_
+#define _NFAPI_INTERFACE_H_
+
+#include "stddef.h"
+
+// Constants - update based on implementation
+#define NFAPI_MAX_PHY_RF_INSTANCES 2
+#define NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH 16
+#define NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH 3
+#define NFAPI_MAX_NUM_RF_BANDS 16
+
+// The following definition control the size of arrays used in the interface.
+// These may be changed if desired. They are used in the encoder to make sure 
+// that the user has not specified a 'count' larger than the max array, and also
+// used by the decoder when decode an array. If the 'count' received is larger
+// than the array it is to be stored in the decode fails.
+#define NFAPI_MAX_NUM_ANTENNAS 8
+#define NFAPI_MAX_NUM_SUBBANDS 13
+#define NFAPI_MAX_BF_VECTORS 8
+#define NFAPI_MAX_CC 1
+#define NFAPI_MAX_NUM_PHYSICAL_ANTENNAS 8
+#define NFAPI_MAX_RSSI 8
+#define NFAPI_MAX_PSC_LIST 32
+#define NFAPI_MAX_PCI_LIST 32
+#define NFAPI_MAX_CARRIER_LIST 32
+#define NFAPI_MAX_ARFCN_LIST 128
+#define NFAPI_MAX_LTE_CELLS_FOUND 8
+#define NFAPI_MAX_UTRAN_CELLS_FOUND 8
+#define NFAPI_MAX_GSM_CELLS_FOUND 8
+#define NFAPI_MAX_NB_IOT_CELLS_FOUND 8
+#define NFAPI_MAX_SI_PERIODICITY 8
+#define NFAPI_MAX_SI_INDEX 8
+#define NFAPI_MAX_MIB_LENGTH 32
+#define NFAPI_MAX_SIB_LENGTH 256
+#define NFAPI_MAX_SI_LENGTH 256
+#define NFAPI_MAX_OPAQUE_DATA 64
+#define NFAPI_MAX_NUM_SCHEDULED_UES 8 // Used in the TPM structure
+#define NFAPI_MAX_PNF_PHY 5
+#define NFAPI_MAX_PNF_PHY_RF_CONFIG 5
+#define NFAPI_MAX_PNF_RF  5
+#define NFAPI_MAX_NMM_FREQUENCY_BANDS 32
+#define NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS 100
+#define NFAPI_MAX_UL_DL_CONFIGURATIONS 5
+#define NFAPI_MAX_CSI_RS_RESOURCE_CONFIG 4
+#define NFAPI_MAX_ANTENNA_PORT_COUNT 8
+#define NFAPI_MAX_EPDCCH_PRB 8
+#define NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS 8
+#define NFAPI_MAX_NUMBER_ACK_NACK_TDD 8
+#define NFAPI_MAX_RO_DL 8
+
+#define NFAPI_HEADER_LENGTH 8
+#define NFAPI_P7_HEADER_LENGTH 16
+
+#define NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE 0xF000
+#define NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE 0xFFFF
+
+#define NFAPI_VERSION_3_0_11	0x000
+#define NFAPI_VERSION_3_0_12    0x001
+
+// The IANA agreed port definition of the P5 SCTP VNF enpoint 
+// http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=7701
+#define NFAPI_P5_SCTP_PORT		7701
+
+typedef unsigned int	uint32_t;
+typedef unsigned short	uint16_t;
+typedef unsigned char	uint8_t;
+typedef signed int		int32_t;
+typedef signed short	int16_t;
+typedef signed char		int8_t;
+
+typedef struct {
+	uint16_t phy_id;
+	uint16_t message_id;
+	uint16_t message_length;
+	uint16_t spare;
+} nfapi_p4_p5_message_header_t;
+
+typedef struct {
+	uint16_t phy_id;
+	uint16_t message_id;
+	uint16_t message_length;
+	uint16_t m_segment_sequence; /* This consists of 3 fields - namely, M, Segement & Sequence number*/
+	uint32_t checksum;
+	uint32_t transmit_timestamp;
+} nfapi_p7_message_header_t;
+
+#define NFAPI_PHY_ID_NA 0
+
+//#define NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x80) >> 7 )
+//#define NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x70) >> 4 )
+#define NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x8000) >> 15 )
+#define NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x7F00) >> 8 )
+#define NFAPI_P7_GET_SEQUENCE(_mss) ( (_mss) & 0x00FF )
+#define NFAPI_P7_SET_MSS(_more, _segm, _sequ) ( (((_more) & 0x1) << 7) | (((_segm) & 0x7) << 4) | ((_sequ) & 0xF) )
+
+typedef struct {
+	uint16_t tag;
+	uint16_t length;
+} nfapi_tl_t;
+#define NFAPI_TAG_LENGTH_PACKED_LEN 4
+
+// Convenience methods to convert between SFN/SFN formats
+#define NFAPI_SFNSF2DEC(_sfnsf) ((((_sfnsf) >> 4) * 10) + ((_sfnsf) & 0xF))
+#define NFAPI_SFNSFDEC2SFNSF(_sfnsf_dec) ((((_sfnsf_dec) / 10) << 4) | (((_sfnsf_dec) - (((_sfnsf_dec) / 10) * 10)) & 0xF))
+
+#define NFAPI_SFNSF2SFN(_sfnsf) ((_sfnsf) >> 4)
+#define NFAPI_SFNSF2SF(_sfnsf) ((_sfnsf) & 0xF)
+
+#define NFAPI_MAX_SFNSFDEC 10240
+
+typedef nfapi_tl_t* nfapi_vendor_extension_tlv_t;
+
+
+// nFAPI Message IDs
+typedef enum {
+	NFAPI_DL_CONFIG_REQUEST = 0x0080,
+	NFAPI_UL_CONFIG_REQUEST,
+	NFAPI_SUBFRAME_INDICATION,
+	NFAPI_HI_DCI0_REQUEST,
+	NFAPI_TX_REQUEST,
+	NFAPI_HARQ_INDICATION,
+	NFAPI_CRC_INDICATION,
+	NFAPI_RX_ULSCH_INDICATION,
+	NFAPI_RACH_INDICATION,
+	NFAPI_SRS_INDICATION,
+	NFAPI_RX_SR_INDICATION,
+	NFAPI_RX_CQI_INDICATION,
+	NFAPI_LBT_DL_CONFIG_REQUEST,
+	NFAPI_LBT_DL_INDICATION,
+	NFAPI_NB_HARQ_INDICATION,
+	NFAPI_NRACH_INDICATION,
+
+	NFAPI_PNF_PARAM_REQUEST = 0x0100,
+	NFAPI_PNF_PARAM_RESPONSE,
+	NFAPI_PNF_CONFIG_REQUEST,
+	NFAPI_PNF_CONFIG_RESPONSE,
+	NFAPI_PNF_START_REQUEST,
+	NFAPI_PNF_START_RESPONSE,
+	NFAPI_PNF_STOP_REQUEST,
+	NFAPI_PNF_STOP_RESPONSE,
+	NFAPI_PARAM_REQUEST,
+	NFAPI_PARAM_RESPONSE,
+	NFAPI_CONFIG_REQUEST,
+	NFAPI_CONFIG_RESPONSE,
+	NFAPI_START_REQUEST,
+	NFAPI_START_RESPONSE,
+	NFAPI_STOP_REQUEST,
+	NFAPI_STOP_RESPONSE,
+	NFAPI_MEASUREMENT_REQUEST,
+	NFAPI_MEASUREMENT_RESPONSE,
+
+	NFAPI_UL_NODE_SYNC = 0x0180,
+	NFAPI_DL_NODE_SYNC,
+	NFAPI_TIMING_INFO,
+
+
+	NFAPI_RSSI_REQUEST = 0x0200,
+	NFAPI_RSSI_RESPONSE,
+	NFAPI_RSSI_INDICATION,
+	NFAPI_CELL_SEARCH_REQUEST,
+	NFAPI_CELL_SEARCH_RESPONSE,
+	NFAPI_CELL_SEARCH_INDICATION,
+	NFAPI_BROADCAST_DETECT_REQUEST,
+	NFAPI_BROADCAST_DETECT_RESPONSE,
+	NFAPI_BROADCAST_DETECT_INDICATION,
+	NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST,
+	NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE,
+	NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION,
+	NFAPI_SYSTEM_INFORMATION_REQUEST,
+	NFAPI_SYSTEM_INFORMATION_RESPONSE,
+	NFAPI_SYSTEM_INFORMATION_INDICATION,
+	NFAPI_NMM_STOP_REQUEST,
+	NFAPI_NMM_STOP_RESPONSE,
+
+	NFAPI_VENDOR_EXT_MSG_MIN = 0x0300,
+	NFAPI_VENDOR_EXT_MSG_MAX = 0x03FF,
+
+
+	NFAPI_MAX_MESSAGE_ID,
+} nfapi_message_id_e;
+
+// nFAPI Error Codes
+typedef enum {
+	NFAPI_MSG_OK = 0,
+	NFAPI_MSG_INVALID_STATE,
+	NFAPI_MSG_INVALID_CONFIG,
+	NFAPI_SFN_OUT_OF_SYNC,
+	NFAPI_MSG_SUBFRAME_ERR,
+	NFAPI_MSG_BCH_MISSING,
+	NFAPI_MSG_INVALID_SFN,
+	NFAPI_MSG_HI_ERR,
+	NFAPI_MSG_TX_ERR,
+	
+	NFAPI_LBT_NO_PDU_IN_DL_REQ,
+	NFAPI_LBT_NO_VALID_CONFIG_REQ_RECEIVED,
+	NFAPI_FAPI_E_LBT_SF_SFN_PASSED_END_SF_SFN,
+	NFAPI_FAPI_E_LBT_OVERLAP,
+	NFAPI_MSG_BCH_PRESENT,
+	
+	NFAPI_NBIOT_UNEXPECTED_REQ,
+
+	// This is special return code that indicates that a response has
+	// been send via P9
+	NFAPI_MSG_P9_RESPONSE = 0xAA
+} nfapi_error_code_e;
+
+
+typedef enum {
+	NFAPI_P4_MSG_OK = 100,
+	NFAPI_P4_MSG_INVALID_STATE = 101,
+	NFAPI_P4_MSG_INVALID_CONFIG = 102,
+	NFAPI_P4_MSG_RAT_NOT_SUPPORTED = 103,
+	NFAPI_P4_MSG_NMM_STOP_OK = 200,
+	NFAPI_P4_MSG_NMM_STOP_IGNOREDED = 201,
+	NFAPI_P4_MSG_NMM_STOP_INVALID_STATE = 202,
+	NFAPI_P4_MSG_PROCEDURE_COMPLETE = 300,
+	NFAPI_P4_MSG_PROCEDURE_STOPPED = 301,
+	NFAPI_P4_MSG_PARTIAL_RESULTS = 302,
+	NFAPI_P4_MSG_TIMEOUT = 303
+} nfapi_p4_error_code_e;
+
+// nFAPI enums
+typedef enum {
+	NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE = 0,
+	NFAPI_DL_CONFIG_BCH_PDU_TYPE,
+	NFAPI_DL_CONFIG_MCH_PDU_TYPE,
+	NFAPI_DL_CONFIG_DLSCH_PDU_TYPE,
+	NFAPI_DL_CONFIG_PCH_PDU_TYPE,
+	NFAPI_DL_CONFIG_PRS_PDU_TYPE,
+	NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE,
+	NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE,
+	NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE,
+	NFAPI_DL_CONFIG_NBCH_PDU_TYPE,
+	NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE,
+	NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE
+} nfapi_dl_config_pdu_type_e;
+
+typedef enum {
+	NFAPI_DL_DCI_FORMAT_1 = 0,
+	NFAPI_DL_DCI_FORMAT_1A,
+	NFAPI_DL_DCI_FORMAT_1B,
+	NFAPI_DL_DCI_FORMAT_1C,
+	NFAPI_DL_DCI_FORMAT_1D,
+	NFAPI_DL_DCI_FORMAT_2,
+	NFAPI_DL_DCI_FORMAT_2A,
+	NFAPI_DL_DCI_FORMAT_2B,
+	NFAPI_DL_DCI_FORMAT_2C
+} nfapi_dl_dci_format_e;
+
+typedef enum {
+	NFAPI_UL_DCI_FORMAT_0 = 0,
+	NFAPI_UL_DCI_FORMAT_3,
+	NFAPI_UL_DCI_FORMAT_3A,
+	NFAPI_UL_DCI_FORMAT_4
+} nfapi_ul_dci_format_e;
+
+typedef enum {
+	NFAPI_UL_CONFIG_ULSCH_PDU_TYPE = 0,
+	NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE,
+	NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE,
+	NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE,
+	NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE,
+	NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE,
+	NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE,
+	NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE,
+	NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE,
+	NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE,
+	NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE,
+	NFAPI_UL_CONFIG_SRS_PDU_TYPE,
+	NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE,
+	NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE,
+	NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE,
+	NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE,
+	NFAPI_UL_CONFIG_NULSCH_PDU_TYPE,
+	NFAPI_UL_CONFIG_NRACH_PDU_TYPE,
+} nfapi_ul_config_pdu_type_e;
+
+typedef enum {
+	NFAPI_HI_DCI0_HI_PDU_TYPE = 0,
+	NFAPI_HI_DCI0_DCI_PDU_TYPE,
+	NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE,
+	NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE,
+	NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE,
+} nfapi_hi_dci0_pdu_type_e;
+
+typedef enum {
+	NFAPI_HARQ_ACK = 1,
+	NFAPI_HARQ_NACK,
+	NFAPI_HARQ_ACK_OR_NACK,
+	NFAPI_HARQ_DTX,
+	NFAPI_HARQ_ACK_OR_DTX,
+	NFAPI_HARQ_NACK_OR_DTX,
+	NFAPI_HARQ_ACK_OR_NACK_OR_DTX
+} nfapi_harq_type_e;
+
+typedef enum {
+	NFAPI_CSI_REPORT_TYPE_PERIODIC = 0,
+	NFAPI_CSI_REPORT_TYPE_APERIODIC
+} nfapi_csi_report_type_e;
+
+typedef enum {
+	NFAPI_DL_BW_SUPPORTED_6 = 1,
+	NFAPI_DL_BW_SUPPORTED_15 = 2,
+	NFAPI_DL_BW_SUPPORTED_25 = 4,
+	NFAPI_DL_BW_SUPPORTED_50 = 8,
+	NFAPI_DL_BW_SUPPORTED_75 = 16,
+	NFAPI_DL_BW_SUPPORTED_100 = 32
+} nfapi_dl_bandwith_supported_e;
+
+typedef enum {
+	NFAPI_UL_BW_SUPPORTED_6 = 1,
+	NFAPI_UL_BW_SUPPORTED_15 = 2,
+	NFAPI_UL_BW_SUPPORTED_25 = 4,
+	NFAPI_UL_BW_SUPPORTED_50 = 8,
+	NFAPI_UL_BW_SUPPORTED_75 = 16,
+	NFAPI_UL_BW_SUPPORTED_100 = 32
+} nfapi_ul_bandwith_supported_e;
+
+typedef enum {
+	NFAPI_3GPP_REL_SUPPORTED_8 = 0,
+	NFAPI_3GPP_REL_SUPPORTED_9 = 1,
+	NFAPI_3GPP_REL_SUPPORTED_10 = 2,
+	NFAPI_3GPP_REL_SUPPORTED_11 = 4,
+	NFAPI_3GPP_REL_SUPPORTED_12 = 8,
+  NFAPI_3GPP_REL_SUPPORTED_15 = 64
+} nfapi_3gpp_release_supported_e;
+
+
+typedef enum {
+	NFAPI_DUPLEXING_MODE_TDD = 0,
+	NFAPI_DUPLEXING_MODE_FDD = 1,
+	NFAPI_DUPLEXING_MODE_HD_FDD = 2,
+} nfapi_duplexing_mode_e;
+
+typedef enum {
+	NFAPI_CP_NORMAL = 0,
+	NFAPI_CP_EXTENDED = 1
+} nfapi_cyclic_prefix_type_e;
+
+typedef enum {
+	NFAPI_RAT_TYPE_LTE = 0,
+	NFAPI_RAT_TYPE_UTRAN = 1,
+	NFAPI_RAT_TYPE_GERAN = 2,
+	NFAPI_RAT_TYPE_NB_IOT = 3,
+  NFAPI_RAT_TYPE_NR = 4
+} nfapi_rat_type_e;
+
+typedef enum {
+	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING,
+	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING,
+	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING,
+	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION,
+	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3,
+	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_4,
+	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_5
+} nfapi_harq_indication_tdd_ack_nackformat_e;
+
+
+typedef enum {
+	NFAPI_LBT_DL_CONFIG_REQUEST_PDSCH_PDU_TYPE = 0,
+	NFAPI_LBT_DL_CONFIG_REQUEST_DRS_PDU_TYPE
+} nfapi_lbt_dl_config_pdu_type_e;
+
+typedef enum {
+	NFAPI_LBT_DL_RSP_PDSCH_PDU_TYPE = 0,
+	NFAPI_LBT_DL_RSP_DRS_PDU_TYPE
+} nfapi_lbt_dl_rsp_pdu_type_e;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t length;
+	uint8_t value[NFAPI_MAX_OPAQUE_DATA];
+} nfapi_opaqaue_data_t;
+
+// Utility functions to turn enums into char*
+const char* nfapi_error_code_to_str(nfapi_error_code_e value);
+
+
+// P5 Sub Structures
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t nfapi_sync_mode;
+	uint8_t location_mode;
+	uint16_t location_coordinates_length;
+	uint8_t location_coordinates[NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH];
+	uint32_t dl_config_timing;
+	uint32_t tx_timing;
+	uint32_t ul_config_timing;
+	uint32_t hi_dci0_timing;
+	uint16_t maximum_number_phys;
+	uint16_t maximum_total_bandwidth;
+	uint8_t maximum_total_number_dl_layers;
+	uint8_t maximum_total_number_ul_layers;
+	uint8_t shared_bands;
+	uint8_t shared_pa;
+	int16_t maximum_total_power;
+	uint8_t oui[NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH];
+} nfapi_pnf_param_general_t;
+#define NFAPI_PNF_PARAM_GENERAL_TAG 0x1000
+
+
+
+
+
+typedef struct {
+	uint16_t rf_config_index;
+} nfapi_rf_config_info_t;
+
+typedef struct {
+	uint16_t phy_config_index;
+	uint16_t number_of_rfs;
+	nfapi_rf_config_info_t rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
+	uint16_t number_of_rf_exclusions;
+	nfapi_rf_config_info_t excluded_rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
+	uint16_t downlink_channel_bandwidth_supported;
+	uint16_t uplink_channel_bandwidth_supported;
+	uint8_t number_of_dl_layers_supported;
+	uint8_t number_of_ul_layers_supported;
+	uint16_t maximum_3gpp_release_supported;
+	uint8_t nmm_modes_supported;
+} nfapi_pnf_phy_info_t;
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_phys;
+	nfapi_pnf_phy_info_t phy[NFAPI_MAX_PNF_PHY];
+} nfapi_pnf_phy_t;
+#define NFAPI_PNF_PHY_TAG 0x1001
+
+typedef struct {
+	uint16_t phy_config_index;
+	uint16_t transmission_mode_7_supported;
+	uint16_t transmission_mode_8_supported;
+	uint16_t two_antenna_ports_for_pucch;
+	uint16_t transmission_mode_9_supported;
+	uint16_t simultaneous_pucch_pusch;
+	uint16_t four_layer_tx_with_tm3_and_tm4;
+} nfapi_pnf_phy_rel10_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_phys;
+	nfapi_pnf_phy_rel10_info_t phy[NFAPI_MAX_PNF_PHY];
+} nfapi_pnf_phy_rel10_t;
+#define NFAPI_PNF_PHY_REL10_TAG 0x100A
+
+typedef struct {
+	uint16_t phy_config_index;
+	uint16_t edpcch_supported;
+	uint16_t multi_ack_csi_reporting;
+	uint16_t pucch_tx_diversity;
+	uint16_t ul_comp_supported;
+	uint16_t transmission_mode_5_supported;
+} nfapi_pnf_phy_rel11_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_phys;
+	nfapi_pnf_phy_rel11_info_t phy[NFAPI_MAX_PNF_PHY];
+} nfapi_pnf_phy_rel11_t;
+#define NFAPI_PNF_PHY_REL11_TAG 0x100B
+
+
+typedef struct {
+	uint16_t phy_config_index;
+	uint16_t csi_subframe_set;
+	uint16_t enhanced_4tx_codebook;
+	uint16_t drs_supported;
+	uint16_t ul_64qam_supported;
+	uint16_t transmission_mode_10_supported;
+	uint16_t alternative_bts_indices;
+} nfapi_pnf_phy_rel12_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_phys;
+	nfapi_pnf_phy_rel12_info_t phy[NFAPI_MAX_PNF_PHY];
+} nfapi_pnf_phy_rel12_t;
+#define NFAPI_PNF_PHY_REL12_TAG 0x100C
+
+typedef struct {
+	uint16_t phy_config_index;
+	uint16_t pucch_format4_supported;
+	uint16_t pucch_format5_supported;
+	uint16_t more_than_5_ca_support;
+	uint16_t laa_supported;
+	uint16_t laa_ending_in_dwpts_supported;
+	uint16_t laa_starting_in_second_slot_supported;
+	uint16_t beamforming_supported;
+	uint16_t csi_rs_enhancement_supported;
+	uint16_t drms_enhancement_supported;
+	uint16_t srs_enhancement_supported;
+} nfapi_pnf_phy_rel13_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_phys;
+	nfapi_pnf_phy_rel13_info_t phy[NFAPI_MAX_PNF_PHY];
+} nfapi_pnf_phy_rel13_t;
+#define NFAPI_PNF_PHY_REL13_TAG 0x100D
+
+typedef struct {
+	uint16_t phy_config_index;
+	uint16_t number_of_rfs;
+	nfapi_rf_config_info_t rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
+	uint16_t number_of_rf_exclusions;
+	nfapi_rf_config_info_t excluded_rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
+	uint8_t number_of_dl_layers_supported;
+	uint8_t number_of_ul_layers_supported;
+	uint16_t maximum_3gpp_release_supported;
+	uint8_t nmm_modes_supported;
+} nfapi_pnf_phy_rel13_nb_iot_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_phys;
+	nfapi_pnf_phy_rel13_nb_iot_info_t phy[NFAPI_MAX_PNF_PHY];
+} nfapi_pnf_phy_rel13_nb_iot_t;
+#define NFAPI_PNF_PHY_REL13_NB_IOT_TAG 0x100E
+
+typedef struct {
+  uint16_t phy_config_index;
+} nfapi_pnf_phy_rel15_info_t;
+
+typedef struct {
+  nfapi_tl_t tl;
+  uint16_t number_of_phys;
+  nfapi_pnf_phy_rel15_info_t phy[NFAPI_MAX_PNF_PHY];
+} nfapi_pnf_phy_rel15_t;
+#define NFAPI_PNF_PHY_REL15_TAG 0x100H
+
+
+typedef struct {
+	uint16_t rf_config_index;
+	uint16_t band;
+	int16_t maximum_transmit_power; 
+	int16_t minimum_transmit_power;
+	uint8_t number_of_antennas_suppported;
+	uint32_t minimum_downlink_frequency;
+	uint32_t maximum_downlink_frequency;
+	uint32_t minimum_uplink_frequency;
+	uint32_t maximum_uplink_frequency;
+} nfapi_pnf_rf_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_rfs;
+	nfapi_pnf_rf_info_t rf[NFAPI_MAX_PNF_RF];
+} nfapi_pnf_rf_t;
+#define NFAPI_PNF_RF_TAG 0x1002
+
+typedef struct {
+	uint16_t phy_id;
+	uint16_t phy_config_index;
+	uint16_t rf_config_index;
+} nfapi_phy_rf_config_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_phy_rf_config_info;
+	nfapi_phy_rf_config_info_t phy_rf_config[NFAPI_MAX_PHY_RF_INSTANCES];
+} nfapi_pnf_phy_rf_config_t;
+#define NFAPI_PNF_PHY_RF_TAG 0x1003
+
+// Generic strucutre for single tlv value.
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t value;
+} nfapi_uint16_tlv_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	int16_t value;
+} nfapi_int16_tlv_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t value;
+} nfapi_uint8_tlv_t;
+
+typedef struct {
+	nfapi_uint16_tlv_t phy_state;
+} nfapi_l1_status;
+
+#define NFAPI_L1_STATUS_PHY_STATE_TAG 0x00FA
+
+typedef struct {
+	nfapi_uint16_tlv_t dl_bandwidth_support;
+	nfapi_uint16_tlv_t ul_bandwidth_support;
+	nfapi_uint16_tlv_t dl_modulation_support;
+	nfapi_uint16_tlv_t ul_modulation_support;
+	nfapi_uint16_tlv_t phy_antenna_capability;
+	nfapi_uint16_tlv_t release_capability;
+	nfapi_uint16_tlv_t mbsfn_capability;
+} nfapi_phy_capabilities_t;
+
+#define NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG 0x00C8
+#define NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG 0x00C9
+#define NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG 0x00CA
+#define NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG 0x00CB
+#define NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG 0x00CC
+#define NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG 0x00CD
+#define NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG 0x00CE
+
+
+typedef struct {
+	nfapi_uint16_tlv_t data_report_mode;
+	nfapi_uint16_tlv_t sfnsf;
+} nfapi_l23_config_t;
+
+
+#define NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG 0x00F0
+#define NFAPI_L23_CONFIG_SFNSF_TAG 0x00F1
+
+typedef struct {
+  nfapi_uint16_tlv_t numerology_index_mu;
+	nfapi_uint16_tlv_t duplex_mode;
+	nfapi_uint16_tlv_t pcfich_power_offset;
+	nfapi_uint16_tlv_t pb;
+	nfapi_uint16_tlv_t dl_cyclic_prefix_type;
+	nfapi_uint16_tlv_t ul_cyclic_prefix_type;
+} nfapi_subframe_config_t;
+
+#define NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG 0x0001
+#define NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG 0x0002
+#define NFAPI_SUBFRAME_CONFIG_PB_TAG 0x0003
+#define NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG 0x0004
+#define NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG 0x0005
+#define NFAPI_SUBFRAME_CONFIG_NUMEROLOGY_INDEX_MU_TAG 0x0006
+
+typedef struct {
+	nfapi_uint16_tlv_t dl_channel_bandwidth;
+	nfapi_uint16_tlv_t ul_channel_bandwidth;
+	nfapi_uint16_tlv_t reference_signal_power;
+	nfapi_uint16_tlv_t tx_antenna_ports;
+	nfapi_uint16_tlv_t rx_antenna_ports;
+} nfapi_rf_config_t;
+
+#define NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG 0x000A
+#define NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG 0x000B
+#define NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG 0x000C
+#define NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG 0x000D
+#define NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG 0x000E
+
+typedef struct {
+	nfapi_uint16_tlv_t phich_resource;
+	nfapi_uint16_tlv_t phich_duration;
+	nfapi_uint16_tlv_t phich_power_offset;
+} nfapi_phich_config_t;
+
+#define NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG 0x0014
+#define NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015
+#define NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016
+
+typedef enum {
+  NFAPI_HALF_FRAME_INDEX_FIRST_HALF = 0,
+  NFAPI_HALF_FRAME_INDEX_SECOND_HALF = 1
+} nfapi_half_frame_index_e;
+
+typedef struct {
+	nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers;
+	nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers;
+	nfapi_uint16_tlv_t physical_cell_id;
+  nfapi_half_frame_index_e half_frame_index;
+  nfapi_uint16_tlv_t ssb_subcarrier_offset;
+  nfapi_uint16_tlv_t ssb_position_in_burst;
+  nfapi_uint16_tlv_t ssb_periodicity;
+  nfapi_uint16_tlv_t ss_pbch_block_power;
+} nfapi_sch_config_t;
+
+#define NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001E
+#define NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001F
+#define NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG 0x0020
+#define NFAPI_SCH_CONFIG_HALF_FRAME_INDEX_TAG 0x0021
+#define NFAPI_SCH_CONFIG_SSB_SUBCARRIER_OFFSET_TAG 0x0022
+#define NFAPI_SCH_CONFIG_SSB_POSITION_IN_BURST 0x0023
+#define NFAPI_SCH_CONFIG_SSB_PERIODICITY 0x0024
+#define NFAPI_SCH_CONFIG_SS_PBCH_BLOCK_POWER 0x0025
+
+typedef struct {
+	nfapi_uint16_tlv_t configuration_index;
+	nfapi_uint16_tlv_t root_sequence_index;
+	nfapi_uint16_tlv_t zero_correlation_zone_configuration;
+	nfapi_uint16_tlv_t high_speed_flag;
+	nfapi_uint16_tlv_t frequency_offset;
+} nfapi_prach_config_t;
+
+#define NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG 0x0028
+#define NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG 0x0029
+#define NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x002A
+#define NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG 0x002B
+#define NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG 0x002C
+
+typedef struct {
+	nfapi_uint16_tlv_t hopping_mode;
+	nfapi_uint16_tlv_t hopping_offset;
+	nfapi_uint16_tlv_t number_of_subbands;
+} nfapi_pusch_config_t;
+
+#define NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG 0x0032
+#define NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG 0x0033
+#define NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG 0x0034
+
+typedef struct {
+	nfapi_uint16_tlv_t delta_pucch_shift;
+	nfapi_uint16_tlv_t n_cqi_rb;
+	nfapi_uint16_tlv_t n_an_cs;
+	nfapi_uint16_tlv_t n1_pucch_an;
+} nfapi_pucch_config_t;
+
+#define NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG 0x003C
+#define NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG 0x003D
+#define NFAPI_PUCCH_CONFIG_N_AN_CS_TAG 0x003E
+#define NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG 0x003F
+
+typedef struct {
+	nfapi_uint16_tlv_t bandwidth_configuration;
+	nfapi_uint16_tlv_t max_up_pts;
+	nfapi_uint16_tlv_t srs_subframe_configuration;
+	nfapi_uint16_tlv_t srs_acknack_srs_simultaneous_transmission;
+} nfapi_srs_config_t;
+
+#define NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG 0x0046
+#define NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG 0x0047
+#define NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG 0x0048
+#define NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG 0x0049
+
+typedef struct {
+	nfapi_uint16_tlv_t uplink_rs_hopping;
+	nfapi_uint16_tlv_t group_assignment;
+	nfapi_uint16_tlv_t cyclic_shift_1_for_drms;
+} nfapi_uplink_reference_signal_config_t;
+
+#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG 0x0050
+#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG 0x0051
+#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG 0x0052
+
+
+typedef struct {
+	nfapi_uint16_tlv_t ed_threshold_lbt_pdsch;
+	nfapi_uint16_tlv_t ed_threshold_lbt_drs;
+	nfapi_uint16_tlv_t pd_threshold;
+	nfapi_uint16_tlv_t multi_carrier_type;
+	nfapi_uint16_tlv_t multi_carrier_tx;
+	nfapi_uint16_tlv_t multi_carrier_freeze;
+	nfapi_uint16_tlv_t tx_antenna_ports_drs;
+	nfapi_uint16_tlv_t tx_power_drs;
+} nfapi_laa_config_t;
+
+#define NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG 0x0064
+#define NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG 0x0065
+#define NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG 0x0066
+#define NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG 0x0067
+#define NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG 0x0068
+#define NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG 0x0069
+#define NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG 0x006A
+#define NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG 0x006B
+
+typedef struct {
+
+	nfapi_uint16_tlv_t pbch_repetitions_enable_r13;
+	nfapi_uint16_tlv_t prach_catm_root_sequence_index;
+	nfapi_uint16_tlv_t prach_catm_zero_correlation_zone_configuration;
+	nfapi_uint16_tlv_t prach_catm_high_speed_flag;
+	nfapi_uint16_tlv_t prach_ce_level_0_enable;
+	nfapi_uint16_tlv_t prach_ce_level_0_configuration_index;
+	nfapi_uint16_tlv_t prach_ce_level_0_frequency_offset;
+	nfapi_uint16_tlv_t prach_ce_level_0_number_of_repetitions_per_attempt;
+	nfapi_uint16_tlv_t prach_ce_level_0_starting_subframe_periodicity;
+	nfapi_uint16_tlv_t prach_ce_level_0_hopping_enable;
+	nfapi_uint16_tlv_t prach_ce_level_0_hopping_offset;
+	nfapi_uint16_tlv_t prach_ce_level_1_enable;
+	nfapi_uint16_tlv_t prach_ce_level_1_configuration_index;
+	nfapi_uint16_tlv_t prach_ce_level_1_frequency_offset;
+	nfapi_uint16_tlv_t prach_ce_level_1_number_of_repetitions_per_attempt;
+	nfapi_uint16_tlv_t prach_ce_level_1_starting_subframe_periodicity;
+	nfapi_uint16_tlv_t prach_ce_level_1_hopping_enable;
+	nfapi_uint16_tlv_t prach_ce_level_1_hopping_offset;
+	nfapi_uint16_tlv_t prach_ce_level_2_enable;
+	nfapi_uint16_tlv_t prach_ce_level_2_configuration_index;
+	nfapi_uint16_tlv_t prach_ce_level_2_frequency_offset;
+	nfapi_uint16_tlv_t prach_ce_level_2_number_of_repetitions_per_attempt;
+	nfapi_uint16_tlv_t prach_ce_level_2_starting_subframe_periodicity;
+	nfapi_uint16_tlv_t prach_ce_level_2_hopping_enable;
+	nfapi_uint16_tlv_t prach_ce_level_2_hopping_offset;
+	nfapi_uint16_tlv_t prach_ce_level_3_enable;
+	nfapi_uint16_tlv_t prach_ce_level_3_configuration_index;
+	nfapi_uint16_tlv_t prach_ce_level_3_frequency_offset;
+	nfapi_uint16_tlv_t prach_ce_level_3_number_of_repetitions_per_attempt;
+	nfapi_uint16_tlv_t prach_ce_level_3_starting_subframe_periodicity;
+	nfapi_uint16_tlv_t prach_ce_level_3_hopping_enable;
+	nfapi_uint16_tlv_t prach_ce_level_3_hopping_offset;
+	nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodea;
+	nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodeb;
+} nfapi_emtc_config_t;
+
+#define NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG 0x0078
+#define NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG 0x0079
+#define NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x007A
+#define NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG 0x007B
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG 0x007C
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG 0x007D
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG 0x007E
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x007F
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG 0x0080
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG 0x0081
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG 0x0082
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG 0x0083
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG 0x0084
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG 0x0085
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0086
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG 0x0087
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG 0x0088
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG 0x0089
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG 0x008A
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG 0x008B
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG 0x008C
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x008D
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG 0x008E
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG 0x008F
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG 0x0090
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG 0x0091
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG 0x0092
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG 0x0093
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0094
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG 0x0095
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG 0x0096
+#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG 0x0097
+#define NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG 0x0098
+#define NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG 0x0099
+
+typedef struct {
+	nfapi_uint16_tlv_t operating_mode;
+	nfapi_uint16_tlv_t anchor;
+	nfapi_uint16_tlv_t prb_index;
+	nfapi_uint16_tlv_t control_region_size;
+	nfapi_uint16_tlv_t assumed_crs_aps;
+	nfapi_uint16_tlv_t nprach_config_0_enabled;
+	nfapi_uint16_tlv_t nprach_config_0_sf_periodicity;
+	nfapi_uint16_tlv_t nprach_config_0_start_time;
+	nfapi_uint16_tlv_t nprach_config_0_subcarrier_offset;
+	nfapi_uint16_tlv_t nprach_config_0_number_of_subcarriers;
+	nfapi_uint16_tlv_t nprach_config_0_cp_length;
+	nfapi_uint16_tlv_t nprach_config_0_number_of_repetitions_per_attempt;
+	nfapi_uint16_tlv_t nprach_config_1_enabled;
+	nfapi_uint16_tlv_t nprach_config_1_sf_periodicity;
+	nfapi_uint16_tlv_t nprach_config_1_start_time;
+	nfapi_uint16_tlv_t nprach_config_1_subcarrier_offset;
+	nfapi_uint16_tlv_t nprach_config_1_number_of_subcarriers;
+	nfapi_uint16_tlv_t nprach_config_1_cp_length;
+	nfapi_uint16_tlv_t nprach_config_1_number_of_repetitions_per_attempt;
+	nfapi_uint16_tlv_t nprach_config_2_enabled;
+	nfapi_uint16_tlv_t nprach_config_2_sf_periodicity;
+	nfapi_uint16_tlv_t nprach_config_2_start_time;
+	nfapi_uint16_tlv_t nprach_config_2_subcarrier_offset;
+	nfapi_uint16_tlv_t nprach_config_2_number_of_subcarriers;
+	nfapi_uint16_tlv_t nprach_config_2_cp_length;
+	nfapi_uint16_tlv_t nprach_config_2_number_of_repetitions_per_attempt;
+	nfapi_uint16_tlv_t three_tone_base_sequence;
+	nfapi_uint16_tlv_t six_tone_base_sequence;
+	nfapi_uint16_tlv_t twelve_tone_base_sequence;
+	nfapi_uint16_tlv_t three_tone_cyclic_shift;
+	nfapi_uint16_tlv_t six_tone_cyclic_shift;
+	nfapi_uint16_tlv_t dl_gap_config_enable;
+	nfapi_uint16_tlv_t dl_gap_threshold;
+	nfapi_uint16_tlv_t dl_gap_periodicity;
+	nfapi_uint16_tlv_t dl_gap_duration_coefficient;
+} nfapi_nb_iot_config_t;
+
+#define NFAPI_NB_IOT_CONFIG_OPERATING_MODE_TAG 0x00A5
+#define NFAPI_NB_IOT_CONFIG_ANCHOR_TAG 0x00A6
+#define NFAPI_NB_IOT_CONFIG_PRB_INDEX_TAG 0x00A7
+#define NFAPI_NB_IOT_CONFIG_CONTROL_REGION_SIZE_TAG 0x00A8
+#define NFAPI_NB_IOT_CONFIG_ASSUMED_CRS_APS_TAG 0x00A9
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_ENABLED_TAG 0x00AA
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SF_PERIODICITY_TAG 0x00AB
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_START_TIME_TAG 0x00AC
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SUBCARRIER_OFFSET_TAG 0x00AD
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_SUBCARRIERS_TAG 0x00AE
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_CP_LENGTH_TAG 0x00AF
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B0
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_ENABLED_TAG 0x00B1
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SF_PERIODICITY_TAG 0x00B2
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_START_TIME_TAG 0x00B3
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SUBCARRIER_OFFSET_TAG 0x00B4
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_SUBCARRIERS_TAG 0x00B5
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_CP_LENGTH_TAG 0x00B6
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B7
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_ENABLED_TAG 0x00B8
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SF_PERIODICITY_TAG 0x00B9
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_START_TIME_TAG 0x00BA
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SUBCARRIER_OFFSET_TAG 0x00BB
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_SUBCARRIERS_TAG 0x00BC
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_CP_LENGTH_TAG 0x00BD
+#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00BE
+#define NFAPI_NB_IOT_CONFIG_THREE_TONE_BASE_SEQUENCE_TAG 0x00BF
+#define NFAPI_NB_IOT_CONFIG_SIX_TONE_BASE_SEQUENCE_TAG 0x00C0
+#define NFAPI_NB_IOT_CONFIG_TWELVE_TONE_BASE_SEQUENCE_TAG 0x00C1
+#define NFAPI_NB_IOT_CONFIG_THREE_TONE_CYCLIC_SHIFT_TAG 0x00C2
+#define NFAPI_NB_IOT_CONFIG_SIX_TONE_CYCLIC_SHIFT_TAG 0x00C3
+#define NFAPI_NB_IOT_CONFIG_DL_GAP_CONFIG_ENABLE_TAG 0x00C4
+#define NFAPI_NB_IOT_CONFIG_DL_GAP_THRESHOLD_TAG 0x00C5
+#define NFAPI_NB_IOT_CONFIG_DL_GAP_PERIODICITY_TAG 0x00C6
+#define NFAPI_NB_IOT_CONFIG_DL_GAP_DURATION_COEFFICIENT_TAG 0x00C7
+
+typedef struct {
+	nfapi_uint16_tlv_t laa_support;
+	nfapi_uint16_tlv_t pd_sensing_lbt_support;
+	nfapi_uint16_tlv_t multi_carrier_lbt_support;
+	nfapi_uint16_tlv_t partial_sf_support;
+} nfapi_laa_capability_t;
+
+#define NFAPI_LAA_CAPABILITY_LAA_SUPPORT_TAG 0x00D1
+#define NFAPI_LAA_CAPABILITY_PD_SENSING_LBT_SUPPORT_TAG 0x00D2
+#define NFAPI_LAA_CAPABILITY_MULTI_CARRIER_LBT_SUPPORT_TAG 0x00D3
+#define NFAPI_LAA_CAPABILITY_PARTIAL_SF_SUPPORT_TAG 0x00D4
+
+typedef struct {
+	nfapi_uint16_tlv_t nb_iot_support;
+	nfapi_uint16_tlv_t nb_iot_operating_mode_capability;
+} nfapi_nb_iot_capability_t;
+
+#define NFAPI_LAA_CAPABILITY_NB_IOT_SUPPORT_TAG 0x00D5
+#define NFAPI_LAA_CAPABILITY_NB_IOT_OPERATING_MODE_CAPABILITY_TAG 0x00D6
+
+typedef struct {
+	nfapi_uint16_tlv_t subframe_assignment;
+	nfapi_uint16_tlv_t special_subframe_patterns;
+} nfapi_tdd_frame_structure_t;
+
+#define NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG 0x005A
+#define NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG 0x005B
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_rf_bands;
+	uint16_t rf_band[NFAPI_MAX_NUM_RF_BANDS];
+} nfapi_rf_bands_t;
+#define NFAPI_PHY_RF_BANDS_TAG 0x0114
+
+#define NFAPI_IPV4_ADDRESS_LENGTH 4
+#define NFAPI_IPV6_ADDRESS_LENGTH 16
+
+// Convience enum to allow the ip addres type to be distinguished
+typedef enum {
+	NFAPI_IP_ADDRESS_IPV4 = 0,
+	NFAPI_IP_ADDRESS_IPV6
+} nfapi_ip_address_type_e;
+
+// The type could be infered from the length, but it is clearer in 
+// code to have a type variable set
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t type;
+	union {
+		uint8_t ipv4_address[NFAPI_IPV4_ADDRESS_LENGTH];
+		uint8_t ipv6_address[NFAPI_IPV6_ADDRESS_LENGTH];
+	} u;
+} nfapi_ip_address_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t address[NFAPI_IPV4_ADDRESS_LENGTH];
+} nfapi_ipv4_address_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t address[NFAPI_IPV6_ADDRESS_LENGTH];
+} nfapi_ipv6_address_t;
+
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_rf_bands;
+	uint16_t bands[NFAPI_MAX_NMM_FREQUENCY_BANDS];
+} nfapi_nmm_frequency_bands_t;
+
+//These TLVs are used exclusively by nFAPI
+typedef struct
+{
+	// These TLVs are used to setup the transport connection between VNF and PNF
+	nfapi_ipv4_address_t p7_vnf_address_ipv4;
+	nfapi_ipv6_address_t p7_vnf_address_ipv6;
+	nfapi_uint16_tlv_t p7_vnf_port;
+
+	nfapi_ipv4_address_t p7_pnf_address_ipv4;
+	nfapi_ipv6_address_t p7_pnf_address_ipv6;
+	nfapi_uint16_tlv_t p7_pnf_port;
+	
+	// These TLVs are used to setup the transport connection between VNF and PNF
+	nfapi_uint8_tlv_t dl_ue_per_sf;
+	nfapi_uint8_tlv_t ul_ue_per_sf;
+
+	// These TLVs are used by PNF to report its RF capabilities to the VNF software
+	nfapi_rf_bands_t rf_bands;
+
+	// These TLVs are used by the VNF to configure the synchronization with the PNF.
+	nfapi_uint8_tlv_t timing_window;
+	nfapi_uint8_tlv_t timing_info_mode;
+	nfapi_uint8_tlv_t timing_info_period;
+
+	// These TLVs are used by the VNF to configure the RF in the PNF
+	nfapi_uint16_tlv_t max_transmit_power;
+	nfapi_uint16_tlv_t earfcn;
+
+	nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands;
+	nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands;
+	nfapi_nmm_frequency_bands_t nmm_lte_frequency_bands;
+	nfapi_uint8_tlv_t nmm_uplink_rssi_supported;
+
+} nfapi_nfapi_t;
+
+#define NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG 0x0100
+#define NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG 0x0101
+#define NFAPI_NFAPI_P7_VNF_PORT_TAG 0x0102
+#define NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG 0x0103
+#define NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG 0x0104
+#define NFAPI_NFAPI_P7_PNF_PORT_TAG 0x0105
+
+#define NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG 0x010A
+#define NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG 0x010B
+#define NFAPI_NFAPI_RF_BANDS_TAG 0x0114
+#define NFAPI_NFAPI_TIMING_WINDOW_TAG 0x011E
+#define NFAPI_NFAPI_TIMING_INFO_MODE_TAG 0x011F
+#define NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG 0x0120
+#define NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG 0x0128
+#define NFAPI_NFAPI_EARFCN_TAG 0x0129
+#define NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG 0x0130
+#define NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG 0x0131
+#define NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG 0x0132
+#define NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG 0x0133
+
+
+// P5 Message Structures
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_param_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_pnf_param_general_t pnf_param_general;
+	nfapi_pnf_phy_t pnf_phy;
+	nfapi_pnf_rf_t pnf_rf;
+	nfapi_pnf_phy_rel10_t pnf_phy_rel10;
+	nfapi_pnf_phy_rel11_t pnf_phy_rel11;
+	nfapi_pnf_phy_rel12_t pnf_phy_rel12;
+	nfapi_pnf_phy_rel13_t pnf_phy_rel13;
+	nfapi_pnf_phy_rel13_nb_iot_t pnf_phy_rel13_nb_iot;
+  nfapi_pnf_phy_rel15_t pnf_phy_rel15;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_param_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_pnf_phy_rf_config_t pnf_phy_rf_config;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_config_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_config_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_start_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_start_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_stop_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_pnf_stop_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_param_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint8_t error_code;
+	uint8_t num_tlv;
+	// fdd or tdd in idle or configured tlvs
+	nfapi_l1_status l1_status;
+	nfapi_phy_capabilities_t phy_capabilities;
+	nfapi_laa_capability_t laa_capability;
+	nfapi_nb_iot_capability_t nb_iot_capability;
+	
+	nfapi_subframe_config_t subframe_config;
+	nfapi_rf_config_t rf_config;
+	nfapi_phich_config_t phich_config;
+	nfapi_sch_config_t sch_config;
+	nfapi_prach_config_t prach_config;
+	nfapi_pusch_config_t pusch_config;
+	nfapi_pucch_config_t pucch_config;
+	nfapi_srs_config_t srs_config;
+	nfapi_uplink_reference_signal_config_t uplink_reference_signal_config;
+	nfapi_tdd_frame_structure_t tdd_frame_structure_config;
+	nfapi_l23_config_t l23_config;
+	nfapi_nb_iot_config_t nb_iot_config;
+
+	// addition nfapi tlvs as per table 2-16 in idle or configure
+	nfapi_nfapi_t nfapi_config;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_param_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint8_t num_tlv;
+	nfapi_subframe_config_t subframe_config;
+	nfapi_rf_config_t rf_config;
+	nfapi_phich_config_t phich_config;
+	nfapi_sch_config_t sch_config;
+	nfapi_prach_config_t prach_config;
+	nfapi_pusch_config_t pusch_config;
+	nfapi_pucch_config_t pucch_config;
+	nfapi_srs_config_t srs_config;
+	nfapi_uplink_reference_signal_config_t uplink_reference_signal_config;
+	nfapi_laa_config_t laa_config;
+	nfapi_emtc_config_t emtc_config;
+	nfapi_tdd_frame_structure_t tdd_frame_structure_config;
+	nfapi_l23_config_t l23_config;
+	nfapi_nb_iot_config_t nb_iot_config;
+	
+	// addition nfapi tlvs as per table 2-16 in idle or configure
+	nfapi_nfapi_t nfapi_config;
+
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_config_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_config_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_start_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_start_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_stop_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_stop_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_uint16_tlv_t dl_rs_tx_power;
+	nfapi_uint16_tlv_t received_interference_power;
+	nfapi_uint16_tlv_t thermal_noise_power;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_measurement_request_t;
+
+#define NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG 0x1004
+#define NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG 0x1005
+#define NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG 0x1006
+
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_resource_blocks;
+	int16_t received_interference_power[NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS];
+} nfapi_received_interference_power_measurement_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_int16_tlv_t dl_rs_tx_power_measurement;
+	nfapi_received_interference_power_measurement_t received_interference_power_measurement;
+	nfapi_int16_tlv_t thermal_noise_power_measurement;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_measurement_response_t;
+
+#define NFAPI_MEASUREMENT_RESPONSE_DL_RS_POWER_MEASUREMENT_TAG 0x1007
+#define NFAPI_MEASUREMENT_RESPONSE_RECEIVED_INTERFERENCE_POWER_MEASUREMENT_TAG 0x1008
+#define NFAPI_MEASUREMENT_RESPONSE_THERMAL_NOISE_MEASUREMENT_TAG 0x1009
+
+// P7 Sub Structures
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t dci_format;
+	uint8_t cce_idx;
+	uint8_t aggregation_level;
+	uint16_t rnti;
+	uint8_t resource_allocation_type;
+	uint8_t virtual_resource_block_assignment_flag;
+	uint32_t resource_block_coding;
+	uint8_t mcs_1;
+	uint8_t redundancy_version_1;
+	uint8_t new_data_indicator_1;
+	uint8_t transport_block_to_codeword_swap_flag;
+	uint8_t mcs_2;
+	uint8_t redundancy_version_2;
+	uint8_t new_data_indicator_2;
+	uint8_t harq_process;
+	uint8_t tpmi;
+	uint8_t pmi;
+	uint8_t precoding_information;
+	uint8_t tpc;
+	uint8_t downlink_assignment_index;
+	uint8_t ngap;
+	uint8_t transport_block_size_index;
+	uint8_t downlink_power_offset;
+	uint8_t allocate_prach_flag;
+	uint8_t preamble_index;
+	uint8_t prach_mask_index;
+	uint8_t rnti_type;
+	uint16_t transmission_power;
+} nfapi_dl_config_dci_dl_pdu_rel8_t;
+#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG 0x2001
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t mcch_flag;
+	uint8_t mcch_change_notification;
+	uint8_t scrambling_identity;
+} nfapi_dl_config_dci_dl_pdu_rel9_t;
+#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG 0x2002
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t cross_carrier_scheduling_flag;
+	uint8_t carrier_indicator;
+	uint8_t srs_flag;
+	uint8_t srs_request;
+	uint8_t antenna_ports_scrambling_and_layers;
+	uint8_t total_dci_length_including_padding;
+	uint8_t n_dl_rb;
+} nfapi_dl_config_dci_dl_pdu_rel10_t;
+#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG 0x2003
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t harq_ack_resource_offset;
+	uint8_t pdsch_re_mapping_quasi_co_location_indicator;
+} nfapi_dl_config_dci_dl_pdu_rel11_t;
+
+#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG 0x2039
+
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t primary_cell_type;
+	uint8_t ul_dl_configuration_flag;
+	uint8_t number_ul_dl_configurations;
+	uint8_t ul_dl_configuration_indication[NFAPI_MAX_UL_DL_CONFIGURATIONS];
+} nfapi_dl_config_dci_dl_pdu_rel12_t;
+
+#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG 0x203a
+
+
+
+typedef struct {
+	uint8_t subband_index;
+	uint8_t scheduled_ues;
+	uint16_t precoding_value[NFAPI_MAX_NUM_PHYSICAL_ANTENNAS][NFAPI_MAX_NUM_SCHEDULED_UES];
+} nfapi_dl_config_dci_dl_tpm_subband_info_t;
+
+typedef struct {
+	uint8_t num_prb_per_subband;
+	uint8_t number_of_subbands;
+	uint8_t num_antennas;
+	nfapi_dl_config_dci_dl_tpm_subband_info_t subband_info[NFAPI_MAX_NUM_SUBBANDS];
+} nfapi_dl_config_dci_dl_tpm_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t laa_end_partial_sf_flag;
+	uint8_t laa_end_partial_sf_configuration;
+	uint8_t initial_lbt_sf;
+	uint8_t codebook_size_determination;
+	uint8_t drms_table_flag;
+	uint8_t tpm_struct_flag;
+	nfapi_dl_config_dci_dl_tpm_t tpm;
+} nfapi_dl_config_dci_dl_pdu_rel13_t;
+
+#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG 0x203b
+
+typedef struct {
+	nfapi_dl_config_dci_dl_pdu_rel8_t dci_dl_pdu_rel8;
+	nfapi_dl_config_dci_dl_pdu_rel9_t dci_dl_pdu_rel9;
+	nfapi_dl_config_dci_dl_pdu_rel10_t dci_dl_pdu_rel10;
+	nfapi_dl_config_dci_dl_pdu_rel11_t dci_dl_pdu_rel11;
+	nfapi_dl_config_dci_dl_pdu_rel12_t dci_dl_pdu_rel12;
+	nfapi_dl_config_dci_dl_pdu_rel13_t dci_dl_pdu_rel13;
+} nfapi_dl_config_dci_dl_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t pdu_index;
+	uint16_t transmission_power;
+} nfapi_dl_config_bch_pdu_rel8_t;
+#define NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG 0x2004
+
+typedef struct {
+	nfapi_dl_config_bch_pdu_rel8_t bch_pdu_rel8;
+} nfapi_dl_config_bch_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t pdu_index;
+	uint16_t rnti;
+	uint8_t resource_allocation_type;
+	uint32_t resource_block_coding;
+	uint8_t modulation;
+	uint16_t transmission_power;
+	uint16_t mbsfn_area_id;
+} nfapi_dl_config_mch_pdu_rel8_t;
+#define NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG 0x2005
+
+typedef struct {
+	nfapi_dl_config_mch_pdu_rel8_t mch_pdu_rel8;
+} nfapi_dl_config_mch_pdu;
+
+
+typedef struct {
+	uint8_t subband_index;
+	uint8_t num_antennas;
+	uint16_t bf_value[NFAPI_MAX_NUM_ANTENNAS];
+} nfapi_bf_vector_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t pdu_index;
+	uint16_t rnti;
+	uint8_t resource_allocation_type;
+	uint8_t virtual_resource_block_assignment_flag;
+	uint32_t resource_block_coding;
+	uint8_t modulation;
+	uint8_t redundancy_version;
+	uint8_t transport_blocks;
+	uint8_t transport_block_to_codeword_swap_flag;
+	uint8_t transmission_scheme;
+	uint8_t number_of_layers;
+	uint8_t number_of_subbands;
+	uint8_t codebook_index[NFAPI_MAX_NUM_SUBBANDS];
+	uint8_t ue_category_capacity;
+	uint8_t pa;
+	uint8_t delta_power_offset_index;
+	uint8_t ngap;
+	uint8_t nprb;
+	uint8_t transmission_mode;
+	uint8_t num_bf_prb_per_subband;
+	uint8_t num_bf_vector;
+	nfapi_bf_vector_t bf_vector[NFAPI_MAX_BF_VECTORS];
+} nfapi_dl_config_dlsch_pdu_rel8_t;
+#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG 0x2006
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t nscid;
+} nfapi_dl_config_dlsch_pdu_rel9_t;
+#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG 0x2007
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t csi_rs_flag;
+	uint8_t csi_rs_resource_config_r10;
+	uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10;
+	uint8_t csi_rs_number_nzp_configuration;
+	uint8_t csi_rs_resource_config[NFAPI_MAX_CSI_RS_RESOURCE_CONFIG];
+	uint8_t pdsch_start;
+} nfapi_dl_config_dlsch_pdu_rel10_t;
+#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG 0x2008
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t drms_config_flag;
+	uint16_t drms_scrambling;
+	uint8_t csi_config_flag;
+	uint16_t csi_scrambling;
+	uint8_t pdsch_re_mapping_flag;
+	uint8_t pdsch_re_mapping_atenna_ports;
+	uint8_t pdsch_re_mapping_freq_shift;
+} nfapi_dl_config_dlsch_pdu_rel11_t;
+#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG 0x203C
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t altcqi_table_r12;
+	uint8_t maxlayers;
+	uint8_t n_dl_harq;
+} nfapi_dl_config_dlsch_pdu_rel12_t;
+#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG 0x203D
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t dwpts_symbols;
+	uint8_t initial_lbt_sf;
+	uint8_t ue_type;
+	uint8_t pdsch_payload_type;
+	uint16_t initial_transmission_sf_io;
+	uint8_t drms_table_flag;
+} nfapi_dl_config_dlsch_pdu_rel13_t;
+#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG 0x203E
+
+typedef struct {
+	nfapi_dl_config_dlsch_pdu_rel8_t dlsch_pdu_rel8;
+	nfapi_dl_config_dlsch_pdu_rel9_t dlsch_pdu_rel9;
+	nfapi_dl_config_dlsch_pdu_rel10_t dlsch_pdu_rel10;
+	nfapi_dl_config_dlsch_pdu_rel11_t dlsch_pdu_rel11;
+	nfapi_dl_config_dlsch_pdu_rel12_t dlsch_pdu_rel12;
+	nfapi_dl_config_dlsch_pdu_rel13_t dlsch_pdu_rel13;
+} nfapi_dl_config_dlsch_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t pdu_index;
+	uint16_t p_rnti;
+	uint8_t resource_allocation_type;
+	uint8_t virtual_resource_block_assignment_flag;
+	uint32_t resource_block_coding;
+	uint8_t mcs;
+	uint8_t redundancy_version;
+	uint8_t number_of_transport_blocks;
+	uint8_t transport_block_to_codeword_swap_flag;
+	uint8_t transmission_scheme;
+	uint8_t number_of_layers;
+	uint8_t codebook_index;
+	uint8_t ue_category_capacity;
+	uint8_t pa;
+	uint16_t transmission_power;
+	uint8_t nprb;
+	uint8_t ngap;
+} nfapi_dl_config_pch_pdu_rel8_t;
+#define NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG 0x2009
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t ue_mode;
+	uint16_t initial_transmission_sf_io;
+} nfapi_dl_config_pch_pdu_rel13_t;
+#define NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG 0x203F
+
+typedef struct {
+	nfapi_dl_config_pch_pdu_rel8_t pch_pdu_rel8;
+	nfapi_dl_config_pch_pdu_rel13_t pch_pdu_rel13;
+} nfapi_dl_config_pch_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t transmission_power;
+	uint8_t prs_bandwidth;
+	uint8_t prs_cyclic_prefix_type;
+	uint8_t prs_muting;
+} nfapi_dl_config_prs_pdu_rel9_t;
+#define NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG 0x200A
+
+typedef struct {
+	nfapi_dl_config_prs_pdu_rel9_t prs_pdu_rel9;
+} nfapi_dl_config_prs_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t csi_rs_antenna_port_count_r10;
+	uint8_t csi_rs_resource_config_r10;
+	uint16_t transmission_power;
+	uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10;
+	uint8_t csi_rs_number_of_nzp_configuration;
+	uint8_t csi_rs_resource_config[NFAPI_MAX_CSI_RS_RESOURCE_CONFIG];
+} nfapi_dl_config_csi_rs_pdu_rel10_t;
+#define NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG 0x200B
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t csi_rs_class;
+	uint8_t cdm_type;
+	uint8_t num_bf_vector;
+	struct {
+		uint8_t csi_rs_resource_index;
+		uint16_t bf_value[NFAPI_MAX_ANTENNA_PORT_COUNT];
+	} bf_vector[NFAPI_MAX_BF_VECTORS];
+
+}nfapi_dl_config_csi_rs_pdu_rel13_t;
+#define NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG 0x2040
+
+typedef struct {
+	nfapi_dl_config_csi_rs_pdu_rel10_t csi_rs_pdu_rel10;
+	nfapi_dl_config_csi_rs_pdu_rel13_t csi_rs_pdu_rel13;
+} nfapi_dl_config_csi_rs_pdu;
+
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG 0x2001
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG 0x2002
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG 0x2003
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG 0x2039
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG 0x203a
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG 0x203b
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t epdcch_resource_assignment_flag;
+	uint16_t epdcch_id;
+	uint8_t epdcch_start_symbol;
+	uint8_t epdcch_num_prb;
+	uint8_t epdcch_prb_index[NFAPI_MAX_EPDCCH_PRB];
+	nfapi_bf_vector_t bf_vector;
+} nfapi_dl_config_epdcch_parameters_rel11_t;
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG 0x2041
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t dwpts_symbols;
+	uint8_t initial_lbt_sf;
+} nfapi_dl_config_epdcch_parameters_rel13_t;
+#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG 0x2042
+
+typedef struct {
+	nfapi_dl_config_dci_dl_pdu_rel8_t			epdcch_pdu_rel8;
+	nfapi_dl_config_dci_dl_pdu_rel9_t			epdcch_pdu_rel9;
+	nfapi_dl_config_dci_dl_pdu_rel10_t			epdcch_pdu_rel10;
+	nfapi_dl_config_dci_dl_pdu_rel11_t			epdcch_pdu_rel11;
+	nfapi_dl_config_dci_dl_pdu_rel12_t			epdcch_pdu_rel12;
+	nfapi_dl_config_dci_dl_pdu_rel13_t			epdcch_pdu_rel13;
+	nfapi_dl_config_epdcch_parameters_rel11_t	epdcch_params_rel11;
+	nfapi_dl_config_epdcch_parameters_rel13_t	epdcch_params_rel13;
+} nfapi_dl_config_epdcch_pdu;
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t mpdcch_narrow_band;
+	uint8_t number_of_prb_pairs;
+	uint8_t resource_block_assignment;
+	uint8_t mpdcch_tansmission_type;
+	uint8_t start_symbol;
+	uint8_t ecce_index;
+	uint8_t aggregation_level;
+	uint8_t rnti_type;
+	uint16_t rnti;
+	uint8_t ce_mode;
+	uint16_t drms_scrambling_init;
+	uint16_t initial_transmission_sf_io;
+	uint16_t transmission_power;
+	uint8_t dci_format;
+	uint16_t resource_block_coding;
+	uint8_t mcs;
+	uint8_t pdsch_reptition_levels;
+	uint8_t redundancy_version;
+	uint8_t new_data_indicator;
+	uint8_t harq_process;
+	uint8_t tpmi_length;
+	uint8_t tpmi;
+	uint8_t pmi_flag;
+	uint8_t pmi;
+	uint8_t harq_resource_offset;
+	uint8_t dci_subframe_repetition_number;
+	uint8_t tpc;
+	uint8_t downlink_assignment_index_length;
+	uint8_t downlink_assignment_index;
+	uint8_t allocate_prach_flag;
+	uint8_t preamble_index;
+	uint8_t prach_mask_index;
+	uint8_t starting_ce_level;
+	uint8_t srs_request;
+	uint8_t antenna_ports_and_scrambling_identity_flag;
+	uint8_t antenna_ports_and_scrambling_identity;
+	uint8_t frequency_hopping_enabled_flag;
+	uint8_t paging_direct_indication_differentiation_flag;
+	uint8_t direct_indication;
+	uint8_t total_dci_length_including_padding;
+	uint8_t number_of_tx_antenna_ports;
+	uint16_t precoding_value[NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS];
+} nfapi_dl_config_mpdcch_pdu_rel13_t;
+#define NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG 0x205B
+
+
+typedef struct {
+	nfapi_dl_config_mpdcch_pdu_rel13_t mpdcch_pdu_rel13;
+} nfapi_dl_config_mpdcch_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t pdu_index;
+	uint16_t transmission_power;
+	uint16_t hyper_sfn_2_lsbs;
+} nfapi_dl_config_nbch_pdu_rel13_t;
+
+#define NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG 0x205C
+
+typedef struct {
+	nfapi_dl_config_nbch_pdu_rel13_t nbch_pdu_rel13;
+} nfapi_dl_config_nbch_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t pdu_index;
+	uint8_t ncce_index;
+	uint8_t aggregation_level;
+	uint8_t start_symbol;
+	uint8_t rnti_type;
+	uint16_t rnti;
+	uint8_t scrambling_reinitialization_batch_index;
+	uint8_t nrs_antenna_ports_assumed_by_the_ue;
+	uint8_t dci_format;
+	uint8_t scheduling_delay;
+	uint8_t resource_assignment;
+	uint8_t repetition_number;
+	uint8_t mcs;
+	uint8_t new_data_indicator;
+	uint8_t harq_ack_resource;
+	uint8_t npdcch_order_indication;
+	uint8_t starting_number_of_nprach_repetitions;
+	uint8_t subcarrier_indication_of_nprach;
+	uint8_t paging_direct_indication_differentation_flag;
+	uint8_t direct_indication;
+	uint8_t dci_subframe_repetition_number;
+	uint8_t total_dci_length_including_padding;
+} nfapi_dl_config_npdcch_pdu_rel13_t;
+
+#define NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG 0x205D
+
+typedef struct {
+	nfapi_dl_config_npdcch_pdu_rel13_t npdcch_pdu_rel13;
+} nfapi_dl_config_npdcch_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t pdu_index;
+	uint8_t start_symbol;
+	uint8_t rnti_type;
+	uint16_t rnti;
+	uint16_t resource_assignment;
+	uint16_t repetition_number;
+	uint8_t modulation;
+	uint8_t number_of_subframes_for_resource_assignment;
+	uint8_t scrambling_sequence_initialization_cinit;
+	uint16_t sf_idx;
+	uint8_t nrs_antenna_ports_assumed_by_the_ue;
+} nfapi_dl_config_ndlsch_pdu_rel13_t;
+
+#define NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG 0x205E
+
+typedef struct {
+	nfapi_dl_config_ndlsch_pdu_rel13_t ndlsch_pdu_rel13;
+} nfapi_dl_config_ndlsch_pdu;
+
+
+typedef struct {
+	uint8_t pdu_type;
+	uint8_t pdu_size;
+	union {
+		nfapi_dl_config_dci_dl_pdu	dci_dl_pdu;
+		nfapi_dl_config_bch_pdu		bch_pdu;
+		nfapi_dl_config_mch_pdu		mch_pdu;
+		nfapi_dl_config_dlsch_pdu	dlsch_pdu;
+		nfapi_dl_config_pch_pdu		pch_pdu;
+		nfapi_dl_config_prs_pdu		prs_pdu;
+		nfapi_dl_config_csi_rs_pdu	csi_rs_pdu;
+		nfapi_dl_config_epdcch_pdu	epdcch_pdu;
+		nfapi_dl_config_mpdcch_pdu	mpdcch_pdu;
+		nfapi_dl_config_nbch_pdu	nbch_pdu;
+		nfapi_dl_config_npdcch_pdu	npdcch_pdu;
+		nfapi_dl_config_ndlsch_pdu	ndlsch_pdu;
+	};
+} nfapi_dl_config_request_pdu_t;
+
+#define NFAPI_DL_CONFIG_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_pdcch_ofdm_symbols;
+	uint8_t number_dci;
+	uint16_t number_pdu;
+	uint8_t number_pdsch_rnti;
+	uint16_t transmission_power_pcfich;
+	nfapi_dl_config_request_pdu_t* dl_config_pdu_list;
+} nfapi_dl_config_request_body_t;
+#define NFAPI_DL_CONFIG_REQUEST_BODY_TAG 0x2000
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint16_t size;
+	uint16_t rnti;
+	uint8_t resource_block_start;
+	uint8_t number_of_resource_blocks;
+	uint8_t modulation_type;
+	uint8_t cyclic_shift_2_for_drms;
+	uint8_t frequency_hopping_enabled_flag;
+	uint8_t frequency_hopping_bits;
+	uint8_t new_data_indication;
+	uint8_t redundancy_version;
+	uint8_t harq_process_number;
+	uint8_t ul_tx_mode;
+	uint8_t current_tx_nb;
+	uint8_t n_srs;
+} nfapi_ul_config_ulsch_pdu_rel8_t;
+#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG 0x200D
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t resource_allocation_type;
+	uint32_t resource_block_coding;
+	uint8_t transport_blocks;
+	uint8_t transmission_scheme;
+	uint8_t number_of_layers;
+	uint8_t codebook_index;
+	uint8_t disable_sequence_hopping_flag;
+} nfapi_ul_config_ulsch_pdu_rel10_t;
+#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG 0x200E
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t virtual_cell_id_enabled_flag;
+	uint16_t npusch_identity;
+	uint8_t dmrs_config_flag;
+	uint16_t ndmrs_csh_identity;
+} nfapi_ul_config_ulsch_pdu_rel11_t;
+
+#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG 0x2043
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t  ue_type;
+	uint16_t total_number_of_repetitions;
+	uint16_t repetition_number;
+	uint16_t initial_transmission_sf_io;
+	uint8_t  empty_symbols_due_to_re_tunning;
+} nfapi_ul_config_ulsch_pdu_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG 0x2044
+
+typedef struct {
+	nfapi_ul_config_ulsch_pdu_rel8_t ulsch_pdu_rel8;
+	nfapi_ul_config_ulsch_pdu_rel10_t ulsch_pdu_rel10;
+	nfapi_ul_config_ulsch_pdu_rel11_t ulsch_pdu_rel11;
+	nfapi_ul_config_ulsch_pdu_rel13_t ulsch_pdu_rel13;
+} nfapi_ul_config_ulsch_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t dl_cqi_pmi_size_rank_1;
+	uint8_t dl_cqi_pmi_size_rank_greater_1;
+	uint8_t ri_size;
+	uint8_t delta_offset_cqi;
+	uint8_t delta_offset_ri;
+} nfapi_ul_config_cqi_ri_information_rel8_t;
+#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG 0x2010
+
+typedef struct {
+	uint8_t dl_cqi_pmi_ri_size;
+	uint8_t control_type;
+} nfapi_ul_config_periodic_cqi_pmi_ri_report_t;
+
+typedef struct {
+	uint8_t number_of_cc;
+	struct {
+		uint8_t ri_size;
+		uint8_t dl_cqi_pmi_size[8];
+	} cc[NFAPI_MAX_CC];
+} nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t report_type;
+	uint8_t delta_offset_cqi;
+	uint8_t delta_offset_ri;
+	union {
+		nfapi_ul_config_periodic_cqi_pmi_ri_report_t periodic_cqi_pmi_ri_report;
+		nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t aperiodic_cqi_pmi_ri_report;
+	};
+} nfapi_ul_config_cqi_ri_information_rel9_t;
+#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG 0x2011
+
+typedef struct {
+	uint16_t dl_cqi_pmi_ri_size_2;
+} nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t;
+
+typedef struct {
+} nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t report_type; // Convience parameter, not sent on the wire
+	union {
+		nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t periodic_cqi_pmi_ri_report;
+		nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t aperiodic_cqi_pmi_ri_report;
+	};
+} nfapi_ul_config_cqi_ri_information_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG 0x2045
+
+typedef struct {
+	nfapi_ul_config_cqi_ri_information_rel8_t cqi_ri_information_rel8;
+	nfapi_ul_config_cqi_ri_information_rel9_t cqi_ri_information_rel9;
+	nfapi_ul_config_cqi_ri_information_rel13_t cqi_ri_information_rel13;
+} nfapi_ul_config_cqi_ri_information;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t harq_size;
+	uint8_t delta_offset_harq;
+	uint8_t ack_nack_mode;
+} nfapi_ul_config_ulsch_harq_information_rel10_t;
+#define NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG 0x2012
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t harq_size_2;
+	uint8_t delta_offset_harq_2;
+} nfapi_ul_config_ulsch_harq_information_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG 0x2046
+
+typedef struct {
+	nfapi_ul_config_ulsch_harq_information_rel10_t harq_information_rel10;
+	nfapi_ul_config_ulsch_harq_information_rel13_t harq_information_rel13;
+} nfapi_ul_config_ulsch_harq_information;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t n_srs_initial;
+	uint8_t initial_number_of_resource_blocks;
+} nfapi_ul_config_initial_transmission_parameters_rel8_t;
+#define NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG 0x200F
+
+typedef struct {
+	nfapi_ul_config_initial_transmission_parameters_rel8_t initial_transmission_parameters_rel8;
+} nfapi_ul_config_initial_transmission_parameters;
+
+typedef struct {
+	nfapi_ul_config_ulsch_pdu ulsch_pdu;
+	nfapi_ul_config_cqi_ri_information cqi_ri_information;
+	nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
+} nfapi_ul_config_ulsch_cqi_ri_pdu;
+
+typedef struct {
+	nfapi_ul_config_ulsch_pdu ulsch_pdu;
+	nfapi_ul_config_ulsch_harq_information harq_information;
+	nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
+} nfapi_ul_config_ulsch_harq_pdu;
+
+typedef struct {
+	nfapi_ul_config_ulsch_pdu ulsch_pdu;
+	nfapi_ul_config_cqi_ri_information cqi_ri_information;
+	nfapi_ul_config_ulsch_harq_information harq_information;
+	nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
+} nfapi_ul_config_ulsch_cqi_harq_ri_pdu;
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint16_t rnti;
+} nfapi_ul_config_ue_information_rel8_t;
+#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG 0x2013
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t virtual_cell_id_enabled_flag;
+	uint16_t npusch_identity;
+} nfapi_ul_config_ue_information_rel11_t;
+
+#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG 0x2047
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t  ue_type;
+	uint8_t  empty_symbols;
+	uint16_t total_number_of_repetitions;
+	uint16_t repetition_number;
+} nfapi_ul_config_ue_information_rel13_t;
+
+#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG 0x2048
+
+typedef struct {
+	nfapi_ul_config_ue_information_rel8_t ue_information_rel8;
+	nfapi_ul_config_ue_information_rel11_t ue_information_rel11;
+	nfapi_ul_config_ue_information_rel13_t ue_information_rel13;
+} nfapi_ul_config_ue_information;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t pucch_index;
+	uint8_t dl_cqi_pmi_size;
+} nfapi_ul_config_cqi_information_rel8_t;
+#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG 0x2014
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_of_pucch_resource;
+	uint16_t pucch_index_p1;
+} nfapi_ul_config_cqi_information_rel10_t;
+#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG 0x2015
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t csi_mode;
+	uint16_t dl_cqi_pmi_size_2;
+	uint8_t starting_prb;
+	uint8_t n_prb;
+	uint8_t cdm_index;
+	uint8_t n_srs;
+} nfapi_ul_config_cqi_information_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG 0x2049
+
+typedef struct {
+	nfapi_ul_config_cqi_information_rel8_t cqi_information_rel8;
+	nfapi_ul_config_cqi_information_rel10_t cqi_information_rel10;
+	nfapi_ul_config_cqi_information_rel13_t cqi_information_rel13;
+} nfapi_ul_config_cqi_information;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t pucch_index;
+} nfapi_ul_config_sr_information_rel8_t;
+#define NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG 0x2016
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_of_pucch_resources;
+	uint16_t pucch_index_p1;
+} nfapi_ul_config_sr_information_rel10_t;
+#define NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG 0x2017
+
+typedef struct { 
+	nfapi_ul_config_sr_information_rel8_t sr_information_rel8;
+	nfapi_ul_config_sr_information_rel10_t sr_information_rel10;
+} nfapi_ul_config_sr_information;
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t harq_size;
+	uint8_t ack_nack_mode;
+	uint8_t number_of_pucch_resources;
+	uint16_t n_pucch_1_0;
+	uint16_t n_pucch_1_1;
+	uint16_t n_pucch_1_2;
+	uint16_t n_pucch_1_3;
+} nfapi_ul_config_harq_information_rel10_tdd_t;
+#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG 0x2018
+
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint16_t n_pucch_1_0;
+	uint8_t harq_size;
+} nfapi_ul_config_harq_information_rel8_fdd_t;
+#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG 0x2019
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t harq_size;
+	uint8_t ack_nack_mode;
+	uint8_t number_of_pucch_resources;
+	uint16_t n_pucch_1_0;
+	uint16_t n_pucch_1_1;
+	uint16_t n_pucch_1_2;
+	uint16_t n_pucch_1_3;
+} nfapi_ul_config_harq_information_rel9_fdd_t;
+#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG 0x201a
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t  num_ant_ports;
+	uint16_t n_pucch_2_0;
+	uint16_t n_pucch_2_1;
+	uint16_t n_pucch_2_2;
+	uint16_t n_pucch_2_3;	
+} nfapi_ul_config_harq_information_rel11_t;
+#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG 0x204A
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint16_t  harq_size_2;
+	uint8_t starting_prb;
+	uint8_t n_prb;
+	uint8_t cdm_index;
+	uint8_t n_srs;
+} nfapi_ul_config_harq_information_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG 0x204B
+
+typedef struct {
+	nfapi_ul_config_harq_information_rel10_tdd_t harq_information_rel10_tdd;
+	nfapi_ul_config_harq_information_rel8_fdd_t harq_information_rel8_fdd;
+	nfapi_ul_config_harq_information_rel9_fdd_t harq_information_rel9_fdd;
+	nfapi_ul_config_harq_information_rel11_t harq_information_rel11;
+	nfapi_ul_config_harq_information_rel13_t harq_information_rel13;
+} nfapi_ul_config_harq_information;
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint16_t size;
+	uint16_t rnti;
+	uint8_t srs_bandwidth;
+	uint8_t frequency_domain_position;
+	uint8_t srs_hopping_bandwidth;
+	uint8_t transmission_comb;
+	uint16_t i_srs;
+	uint8_t sounding_reference_cyclic_shift;
+} nfapi_ul_config_srs_pdu_rel8_t;
+#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG 0x201b
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t antenna_port;
+} nfapi_ul_config_srs_pdu_rel10_t;
+#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG 0x201c
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t number_of_combs;
+} nfapi_ul_config_srs_pdu_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG 0x204c
+
+typedef struct {
+	nfapi_ul_config_srs_pdu_rel8_t srs_pdu_rel8;
+	nfapi_ul_config_srs_pdu_rel10_t srs_pdu_rel10;
+	nfapi_ul_config_srs_pdu_rel13_t srs_pdu_rel13;
+} nfapi_ul_config_srs_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_cqi_information cqi_information;
+} nfapi_ul_config_uci_cqi_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_sr_information sr_information;
+} nfapi_ul_config_uci_sr_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_harq_information harq_information;
+} nfapi_ul_config_uci_harq_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_sr_information sr_information;
+	nfapi_ul_config_harq_information harq_information;
+} nfapi_ul_config_uci_sr_harq_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_cqi_information cqi_information;
+	nfapi_ul_config_harq_information harq_information;
+} nfapi_ul_config_uci_cqi_harq_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_cqi_information cqi_information;
+	nfapi_ul_config_sr_information sr_information;
+} nfapi_ul_config_uci_cqi_sr_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_cqi_information cqi_information;
+	nfapi_ul_config_sr_information sr_information;
+	nfapi_ul_config_harq_information harq_information;
+} nfapi_ul_config_uci_cqi_sr_harq_pdu;
+
+typedef struct {
+	nfapi_ul_config_ue_information ue_information;
+} nfapi_ul_config_harq_buffer_pdu;
+
+typedef struct {
+	nfapi_ul_config_ulsch_pdu ulsch_pdu;
+	nfapi_ul_config_cqi_information csi_information;
+} nfapi_ul_config_ulsch_uci_csi_pdu;
+
+typedef struct {
+	nfapi_ul_config_ulsch_pdu ulsch_pdu;
+	nfapi_ul_config_harq_information harq_information;
+} nfapi_ul_config_ulsch_uci_harq_pdu;
+
+typedef struct {
+	nfapi_ul_config_ulsch_pdu ulsch_pdu;
+	nfapi_ul_config_cqi_information csi_information;
+	nfapi_ul_config_harq_information harq_information;
+} nfapi_ul_config_ulsch_csi_uci_harq_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t harq_ack_resource;
+} nfapi_ul_config_nb_harq_information_rel13_fdd_t;
+#define NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG 0x2061
+
+typedef struct {
+	nfapi_ul_config_nb_harq_information_rel13_fdd_t nb_harq_information_rel13_fdd;
+} nfapi_ul_config_nb_harq_information;
+
+typedef struct {
+	nfapi_tl_t tl;	
+	uint8_t nulsch_format;
+	uint32_t handle;
+	uint16_t size;
+	uint16_t rnti;
+	uint8_t subcarrier_indication;
+	uint8_t resource_assignment;
+	uint8_t mcs;
+	uint8_t redudancy_version;
+	uint8_t repetition_number;
+	uint8_t new_data_indication;
+	uint8_t n_srs;
+	uint16_t scrambling_sequence_initialization_cinit;
+	uint16_t sf_idx;
+	nfapi_ul_config_ue_information ue_information;
+	nfapi_ul_config_nb_harq_information nb_harq_information;
+} nfapi_ul_config_nulsch_pdu_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG 0x205F
+
+typedef struct {
+	nfapi_ul_config_nulsch_pdu_rel13_t nulsch_pdu_rel13;
+} nfapi_ul_config_nulsch_pdu;
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t nprach_config_0;
+	uint8_t nprach_config_1;
+	uint8_t nprach_config_2;
+} nfapi_ul_config_nrach_pdu_rel13_t;
+#define NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG 0x2067
+
+typedef struct {
+	nfapi_ul_config_nrach_pdu_rel13_t nrach_pdu_rel13;
+} nfapi_ul_config_nrach_pdu;
+
+typedef struct {
+	uint8_t pdu_type;
+	uint8_t pdu_size;
+	union {
+		nfapi_ul_config_ulsch_pdu				ulsch_pdu;
+		nfapi_ul_config_ulsch_cqi_ri_pdu		ulsch_cqi_ri_pdu;
+		nfapi_ul_config_ulsch_harq_pdu			ulsch_harq_pdu;
+		nfapi_ul_config_ulsch_cqi_harq_ri_pdu	ulsch_cqi_harq_ri_pdu;
+		nfapi_ul_config_uci_cqi_pdu				uci_cqi_pdu;
+		nfapi_ul_config_uci_sr_pdu				uci_sr_pdu;
+		nfapi_ul_config_uci_harq_pdu			uci_harq_pdu;
+		nfapi_ul_config_uci_sr_harq_pdu			uci_sr_harq_pdu;
+		nfapi_ul_config_uci_cqi_harq_pdu		uci_cqi_harq_pdu;
+		nfapi_ul_config_uci_cqi_sr_pdu			uci_cqi_sr_pdu;
+		nfapi_ul_config_uci_cqi_sr_harq_pdu		uci_cqi_sr_harq_pdu;
+		nfapi_ul_config_srs_pdu					srs_pdu;
+		nfapi_ul_config_harq_buffer_pdu			harq_buffer_pdu;
+		nfapi_ul_config_ulsch_uci_csi_pdu		ulsch_uci_csi_pdu;
+		nfapi_ul_config_ulsch_uci_harq_pdu		ulsch_uci_harq_pdu;
+		nfapi_ul_config_ulsch_csi_uci_harq_pdu	ulsch_csi_uci_harq_pdu;
+		nfapi_ul_config_nulsch_pdu				nulsch_pdu;
+		nfapi_ul_config_nrach_pdu				nrach_pdu;
+	};
+} nfapi_ul_config_request_pdu_t;
+
+#define NFAPI_UL_CONFIG_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_of_pdus;
+	uint8_t rach_prach_frequency_resources;
+	uint8_t srs_present;
+	nfapi_ul_config_request_pdu_t* ul_config_pdu_list;
+} nfapi_ul_config_request_body_t;
+#define NFAPI_UL_CONFIG_REQUEST_BODY_TAG 0x200C
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t resource_block_start;
+	uint8_t cyclic_shift_2_for_drms;
+	uint8_t hi_value;
+	uint8_t i_phich;
+	uint16_t transmission_power;
+} nfapi_hi_dci0_hi_pdu_rel8_t;
+#define NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG 0x201e
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t flag_tb2;
+	uint8_t hi_value_2;
+} nfapi_hi_dci0_hi_pdu_rel10_t;
+#define NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG 0x201f
+
+typedef struct {
+	nfapi_hi_dci0_hi_pdu_rel8_t		hi_pdu_rel8;
+	nfapi_hi_dci0_hi_pdu_rel10_t	hi_pdu_rel10;
+} nfapi_hi_dci0_hi_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t dci_format;
+	uint8_t cce_index;
+	uint8_t aggregation_level;
+	uint16_t rnti;
+	uint8_t resource_block_start;
+	uint8_t number_of_resource_block;
+	uint8_t mcs_1;
+	uint8_t cyclic_shift_2_for_drms;
+	uint8_t frequency_hopping_enabled_flag;
+	uint8_t frequency_hopping_bits;
+	uint8_t new_data_indication_1;
+	uint8_t ue_tx_antenna_seleciton;
+	uint8_t tpc;
+	uint8_t cqi_csi_request;
+	uint8_t ul_index;
+	uint8_t dl_assignment_index;
+	uint32_t tpc_bitmap;
+	uint16_t transmission_power;
+} nfapi_hi_dci0_dci_pdu_rel8_t;
+#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG 0x2020
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t cross_carrier_scheduling_flag;
+	uint8_t carrier_indicator;
+	uint8_t size_of_cqi_csi_feild;
+	uint8_t srs_flag;
+	uint8_t srs_request;
+	uint8_t resource_allocation_flag;
+	uint8_t resource_allocation_type;
+	uint32_t resource_block_coding;
+	uint8_t mcs_2;
+	uint8_t new_data_indication_2;
+	uint8_t number_of_antenna_ports;
+	uint8_t tpmi;
+	uint8_t total_dci_length_including_padding;
+	uint8_t n_ul_rb;
+} nfapi_hi_dci0_dci_pdu_rel10_t;
+#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG 0x2021
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t pscch_resource;
+	uint8_t time_resource_pattern;
+} nfapi_hi_dci0_dci_pdu_rel12_t;
+
+#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG 0x204D
+
+typedef struct {
+	nfapi_hi_dci0_dci_pdu_rel8_t	dci_pdu_rel8;
+	nfapi_hi_dci0_dci_pdu_rel10_t	dci_pdu_rel10;
+	nfapi_hi_dci0_dci_pdu_rel12_t	dci_pdu_rel12;
+} nfapi_hi_dci0_dci_pdu;
+
+typedef nfapi_hi_dci0_dci_pdu_rel8_t nfapi_hi_dci0_epdcch_dci_pdu_rel8_t;
+#define NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG 0x2020
+
+typedef nfapi_hi_dci0_dci_pdu_rel10_t nfapi_hi_dci0_epdcch_dci_pdu_rel10_t;
+#define NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG 0x2021
+
+typedef nfapi_dl_config_epdcch_parameters_rel11_t nfapi_hi_dci0_epdcch_parameters_rel11_t;
+#define NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG 0x2041
+
+typedef struct {
+	nfapi_hi_dci0_epdcch_dci_pdu_rel8_t		epdcch_dci_pdu_rel8;
+	nfapi_hi_dci0_epdcch_dci_pdu_rel10_t	epdcch_dci_pdu_rel10;
+	nfapi_hi_dci0_epdcch_parameters_rel11_t	epdcch_parameters_rel11;
+} nfapi_hi_dci0_epdcch_dci_pdu;
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t mpdcch_narrowband;
+	uint8_t number_of_prb_pairs;
+	uint8_t resource_block_assignment;
+	uint8_t mpdcch_transmission_type;
+	uint8_t start_symbol;
+	uint8_t ecce_index;
+	uint8_t aggreagation_level;
+	uint8_t rnti_type;
+	uint16_t rnti;
+	uint8_t ce_mode;
+	uint16_t drms_scrambling_init;
+	uint16_t initial_transmission_sf_io;
+	uint16_t transmission_power;
+	uint8_t dci_format;
+	uint8_t resource_block_start;
+	uint8_t number_of_resource_blocks;
+	uint8_t mcs;
+	uint8_t pusch_repetition_levels;
+	uint8_t frequency_hopping_flag;
+	uint8_t new_data_indication;
+	uint8_t harq_process;
+	uint8_t redudency_version;
+	uint8_t tpc;
+	uint8_t csi_request;
+	uint8_t ul_inex;
+	uint8_t dai_presence_flag;
+	uint8_t dl_assignment_index;
+	uint8_t srs_request;
+	uint8_t dci_subframe_repetition_number;
+	uint32_t tcp_bitmap;
+	uint8_t total_dci_length_include_padding;
+	uint8_t number_of_tx_antenna_ports;
+	uint16_t precoding_value[NFAPI_MAX_ANTENNA_PORT_COUNT];
+} nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t;
+#define NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG 0x204E
+
+typedef struct {
+	nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t	mpdcch_dci_pdu_rel13;
+} nfapi_hi_dci0_mpdcch_dci_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t ncce_index;
+	uint8_t aggregation_level;
+	uint8_t start_symbol;
+	uint16_t rnti;
+	uint8_t scrambling_reinitialization_batch_index;
+	uint8_t nrs_antenna_ports_assumed_by_the_ue;
+	uint8_t subcarrier_indication;
+	uint8_t resource_assignment;
+	uint8_t scheduling_delay;
+	uint8_t mcs;
+	uint8_t redudancy_version;
+	uint8_t repetition_number;
+	uint8_t new_data_indicator;
+	uint8_t dci_subframe_repetition_number;
+} nfapi_hi_dci0_npdcch_dci_pdu_rel13_t;
+
+#define NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG 0x2062
+
+typedef struct {
+	nfapi_hi_dci0_npdcch_dci_pdu_rel13_t	npdcch_dci_pdu_rel13;
+} nfapi_hi_dci0_npdcch_dci_pdu;
+
+typedef struct {
+	uint8_t pdu_type;
+	uint8_t pdu_size;
+	union {
+		nfapi_hi_dci0_hi_pdu			hi_pdu;
+		nfapi_hi_dci0_dci_pdu			dci_pdu;
+		nfapi_hi_dci0_epdcch_dci_pdu	epdcch_dci_pdu;
+		nfapi_hi_dci0_mpdcch_dci_pdu	mpdcch_dci_pdu;
+		nfapi_hi_dci0_npdcch_dci_pdu	npdcch_dci_pdu;
+	};
+} nfapi_hi_dci0_request_pdu_t;
+
+#define NFAPI_HI_DCI0_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t sfnsf;
+	uint8_t number_of_dci;
+	uint8_t number_of_hi;
+	nfapi_hi_dci0_request_pdu_t* hi_dci0_pdu_list;
+} nfapi_hi_dci0_request_body_t;
+#define NFAPI_HI_DCI0_REQUEST_BODY_TAG 0x201D
+
+#define NFAPI_TX_MAX_SEGMENTS 32
+typedef struct {
+	uint16_t pdu_length;
+	uint16_t pdu_index;
+	uint8_t num_segments;
+	struct {
+		uint32_t segment_length;
+		uint8_t* segment_data;
+	} segments[NFAPI_TX_MAX_SEGMENTS];
+} nfapi_tx_request_pdu_t;
+
+#define NFAPI_TX_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_pdus;
+	nfapi_tx_request_pdu_t* tx_pdu_list;
+} nfapi_tx_request_body_t;
+#define NFAPI_TX_REQUEST_BODY_TAG 0x2022
+
+// P7 Message Structures
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint32_t t1;
+	int32_t delta_sfn_sf;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_dl_node_sync_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint32_t t1;
+	uint32_t t2;
+	uint32_t t3;	
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_ul_node_sync_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint32_t last_sfn_sf;
+	uint32_t time_since_last_timing_info;
+	uint32_t dl_config_jitter;
+	uint32_t tx_request_jitter;
+	uint32_t ul_config_jitter;
+	uint32_t hi_dci0_jitter;
+	int32_t dl_config_latest_delay;
+	int32_t tx_request_latest_delay;
+	int32_t ul_config_latest_delay;
+	int32_t hi_dci0_latest_delay;
+	int32_t dl_config_earliest_arrival;
+	int32_t tx_request_earliest_arrival;
+	int32_t ul_config_earliest_arrival;
+	int32_t hi_dci0_earliest_arrival;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_timing_info_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint16_t rnti;
+} nfapi_rx_ue_information;
+#define NFAPI_RX_UE_INFORMATION_TAG 0x2038
+
+typedef struct { 
+	uint8_t value_0;
+	uint8_t value_1;
+} nfapi_harq_indication_tdd_harq_data_bundling_t;
+
+typedef struct { 
+	uint8_t value_0;
+	uint8_t value_1;
+	uint8_t value_2;
+	uint8_t value_3;
+} nfapi_harq_indication_tdd_harq_data_multiplexing_t;
+
+typedef struct { 
+	uint8_t value_0;
+} nfapi_harq_indication_tdd_harq_data_special_bundling_t;
+
+typedef struct { 
+	uint8_t value_0;
+} nfapi_harq_indication_tdd_harq_data_t;
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t mode;
+	uint8_t number_of_ack_nack;
+	union{
+		nfapi_harq_indication_tdd_harq_data_bundling_t			bundling;
+		nfapi_harq_indication_tdd_harq_data_multiplexing_t		multiplex;
+		nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
+	} harq_data;
+} nfapi_harq_indication_tdd_rel8_t;
+#define NFAPI_HARQ_INDICATION_TDD_REL8_TAG 0x2027
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t mode;
+	uint8_t number_of_ack_nack;
+	union{
+		nfapi_harq_indication_tdd_harq_data_t	bundling;
+		nfapi_harq_indication_tdd_harq_data_t	multiplex;
+		nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
+		nfapi_harq_indication_tdd_harq_data_t	channel_selection;
+		nfapi_harq_indication_tdd_harq_data_t	format_3;
+	} harq_data[NFAPI_MAX_NUMBER_ACK_NACK_TDD];
+} nfapi_harq_indication_tdd_rel9_t;
+#define NFAPI_HARQ_INDICATION_TDD_REL9_TAG 0x2028
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t mode;
+	uint16_t number_of_ack_nack;
+	union{
+		nfapi_harq_indication_tdd_harq_data_t					bundling;
+		nfapi_harq_indication_tdd_harq_data_t					multiplex;
+		nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
+		nfapi_harq_indication_tdd_harq_data_t					channel_selection;
+		nfapi_harq_indication_tdd_harq_data_t			format_3;
+		nfapi_harq_indication_tdd_harq_data_t			format_4;
+		nfapi_harq_indication_tdd_harq_data_t			format_5;
+	} harq_data[NFAPI_MAX_NUMBER_ACK_NACK_TDD];
+} nfapi_harq_indication_tdd_rel13_t;
+#define NFAPI_HARQ_INDICATION_TDD_REL13_TAG 0x204F
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t harq_tb1;
+	uint8_t harq_tb2;
+} nfapi_harq_indication_fdd_rel8_t;
+#define NFAPI_HARQ_INDICATION_FDD_REL8_TAG 0x2029
+
+#define NFAPI_HARQ_ACK_NACK_REL9_MAX 10
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t mode;
+	uint8_t number_of_ack_nack;
+	uint8_t harq_tb_n[NFAPI_HARQ_ACK_NACK_REL9_MAX];
+} nfapi_harq_indication_fdd_rel9_t;
+#define NFAPI_HARQ_INDICATION_FDD_REL9_TAG 0x202a
+
+#define NFAPI_HARQ_ACK_NACK_REL13_MAX 22 // Need to check this max?
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t mode;
+	uint16_t number_of_ack_nack;
+	uint8_t harq_tb_n[NFAPI_HARQ_ACK_NACK_REL13_MAX];
+} nfapi_harq_indication_fdd_rel13_t;
+#define NFAPI_HARQ_INDICATION_FDD_REL13_TAG 0x2050
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t ul_cqi;
+	uint8_t channel;
+} nfapi_ul_cqi_information_t;
+#define NFAPI_UL_CQI_INFORMATION_TAG 0x2052
+
+// Only expect 1 harq_indication TLV.tag to be set
+// Would this be a better a an union, but not clear which combinations
+// are valid
+typedef struct {
+	uint16_t							instance_length;
+	nfapi_rx_ue_information				rx_ue_information;
+	nfapi_harq_indication_tdd_rel8_t	harq_indication_tdd_rel8;
+	nfapi_harq_indication_tdd_rel9_t	harq_indication_tdd_rel9;
+	nfapi_harq_indication_tdd_rel13_t	harq_indication_tdd_rel13;
+	nfapi_harq_indication_fdd_rel8_t	harq_indication_fdd_rel8;
+	nfapi_harq_indication_fdd_rel9_t	harq_indication_fdd_rel9;
+	nfapi_harq_indication_fdd_rel13_t	harq_indication_fdd_rel13;
+	nfapi_ul_cqi_information_t			ul_cqi_information;
+} nfapi_harq_indication_pdu_t;
+
+#define NFAPI_HARQ_IND_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_harqs;
+	nfapi_harq_indication_pdu_t* harq_pdu_list;
+} nfapi_harq_indication_body_t;
+#define NFAPI_HARQ_INDICATION_BODY_TAG 0x2026
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t crc_flag;
+} nfapi_crc_indication_rel8_t;
+#define NFAPI_CRC_INDICATION_REL8_TAG 0x202c
+
+typedef struct {
+	uint16_t					instance_length;
+	nfapi_rx_ue_information		rx_ue_information;
+	nfapi_crc_indication_rel8_t	crc_indication_rel8;
+} nfapi_crc_indication_pdu_t;
+
+#define NFAPI_CRC_IND_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_crcs;
+	nfapi_crc_indication_pdu_t* crc_pdu_list;
+} nfapi_crc_indication_body_t;
+#define NFAPI_CRC_INDICATION_BODY_TAG 0x202b
+
+typedef struct {
+	uint16_t					instance_length;
+	nfapi_rx_ue_information		rx_ue_information;
+	nfapi_ul_cqi_information_t	ul_cqi_information;
+} nfapi_sr_indication_pdu_t;
+
+#define NFAPI_SR_IND_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_srs;				// Question : should this be srs
+	nfapi_sr_indication_pdu_t* sr_pdu_list;
+} nfapi_sr_indication_body_t;
+#define NFAPI_SR_INDICATION_BODY_TAG 0x202d
+
+// The data offset should be set to 0 or 1 before encoding
+// If it is set to 1 the nfapi library will detemine the correct offset
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t data_offset;
+	uint8_t ul_cqi;
+	uint8_t ri;
+	uint16_t timing_advance;
+} nfapi_cqi_indication_rel8_t;
+#define NFAPI_CQI_INDICATION_REL8_TAG 0x202f
+
+#define NFAPI_CC_MAX 4
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t data_offset;
+	uint8_t ul_cqi;
+	uint8_t number_of_cc_reported;
+	uint8_t ri[NFAPI_CC_MAX];
+	uint16_t timing_advance;
+	uint16_t timing_advance_r9;
+} nfapi_cqi_indication_rel9_t;
+#define NFAPI_CQI_INDICATION_REL9_TAG 0x2030
+
+typedef struct {
+	uint16_t					instance_length;
+	nfapi_rx_ue_information		rx_ue_information;
+	nfapi_cqi_indication_rel8_t cqi_indication_rel8;
+	nfapi_cqi_indication_rel9_t cqi_indication_rel9;
+	nfapi_ul_cqi_information_t	ul_cqi_information;
+} nfapi_cqi_indication_pdu_t;
+
+#define NFAPI_CQI_RAW_MAX_LEN 12
+typedef struct {
+	uint8_t pdu[NFAPI_CQI_RAW_MAX_LEN];
+} nfapi_cqi_indication_raw_pdu_t;
+
+#define NFAPI_CQI_IND_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_cqis;
+	nfapi_cqi_indication_pdu_t*			cqi_pdu_list;
+	nfapi_cqi_indication_raw_pdu_t*		cqi_raw_pdu_list;
+} nfapi_cqi_indication_body_t;
+#define NFAPI_CQI_INDICATION_BODY_TAG 0x202e
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint16_t rnti;
+	uint8_t preamble;
+	uint16_t timing_advance;
+} nfapi_preamble_pdu_rel8_t;
+#define NFAPI_PREAMBLE_REL8_TAG 0x2032
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t timing_advance_r9;
+} nfapi_preamble_pdu_rel9_t;
+#define NFAPI_PREAMBLE_REL9_TAG 0x2033
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t rach_resource_type;
+} nfapi_preamble_pdu_rel13_t;
+#define NFAPI_PREAMBLE_REL13_TAG 0x2051
+
+typedef struct { 
+	uint16_t					instance_length;
+	nfapi_preamble_pdu_rel8_t	preamble_rel8;
+	nfapi_preamble_pdu_rel9_t	preamble_rel9;
+	nfapi_preamble_pdu_rel13_t	preamble_rel13;
+} nfapi_preamble_pdu_t;
+
+#define NFAPI_PREAMBLE_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_preambles;
+	nfapi_preamble_pdu_t*			preamble_list;
+} nfapi_rach_indication_body_t;
+#define NFAPI_RACH_INDICATION_BODY_TAG 0x2031
+
+#define NFAPI_NUM_RB_MAX 1000
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t doppler_estimation;
+	uint16_t timing_advance;
+	uint8_t number_of_resource_blocks;
+	uint8_t rb_start;
+	uint8_t snr[NFAPI_NUM_RB_MAX];
+} nfapi_srs_indication_fdd_rel8_t;
+#define NFAPI_SRS_INDICATION_FDD_REL8_TAG 0x2035
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint16_t timing_advance_r9;
+} nfapi_srs_indication_fdd_rel9_t;
+#define NFAPI_SRS_INDICATION_FDD_REL9_TAG 0x2036
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint8_t uppts_symbol;
+} nfapi_srs_indication_ttd_rel10_t;
+#define NFAPI_SRS_INDICATION_TDD_REL10_TAG 0x2037
+
+typedef struct { 
+	nfapi_tl_t tl;
+	uint16_t ul_rtoa;
+} nfapi_srs_indication_fdd_rel11_t;
+#define NFAPI_SRS_INDICATION_FDD_REL11_TAG 0x2053
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t num_prb_per_subband;
+	uint8_t number_of_subbands;
+	uint8_t num_atennas;
+	struct {
+		uint8_t subband_index;
+		uint16_t channel[NFAPI_MAX_NUM_PHYSICAL_ANTENNAS];
+	} subands[NFAPI_MAX_NUM_SUBBANDS];
+} nfapi_tdd_channel_measurement_t;
+#define NFAPI_TDD_CHANNEL_MEASUREMENT_TAG 0x2054
+
+typedef struct {
+	uint16_t							instance_length;
+	nfapi_rx_ue_information				rx_ue_information;
+	nfapi_srs_indication_fdd_rel8_t		srs_indication_fdd_rel8;
+	nfapi_srs_indication_fdd_rel9_t		srs_indication_fdd_rel9;
+	nfapi_srs_indication_ttd_rel10_t	srs_indication_tdd_rel10;
+	nfapi_srs_indication_fdd_rel11_t	srs_indication_fdd_rel11;
+	nfapi_tdd_channel_measurement_t		tdd_channel_measurement;
+} nfapi_srs_indication_pdu_t;
+
+#define NFAPI_SRS_IND_MAX_PDU 16
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_of_ues;
+	nfapi_srs_indication_pdu_t* srs_pdu_list;
+} nfapi_srs_indication_body_t;
+#define NFAPI_SRS_INDICATION_BODY_TAG 0x2034
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t length;
+	uint16_t offset;
+	uint8_t ul_cqi;
+	uint16_t timing_advance;
+} nfapi_rx_indication_rel8_t;
+#define NFAPI_RX_INDICATION_REL8_TAG 0x2024
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t timing_advance_r9;
+ } nfapi_rx_indication_rel9_t;
+#define NFAPI_RX_INDICATION_REL9_TAG 0x2025
+
+typedef struct {
+	nfapi_rx_ue_information rx_ue_information;
+	nfapi_rx_indication_rel8_t rx_indication_rel8;
+	nfapi_rx_indication_rel9_t rx_indication_rel9;
+	uint8_t* data;
+} nfapi_rx_indication_pdu_t;
+
+#define NFAPI_RX_IND_MAX_PDU 100
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_pdus;
+	nfapi_rx_indication_pdu_t* rx_pdu_list;
+} nfapi_rx_indication_body_t;
+#define NFAPI_RX_INDICATION_BODY_TAG 0x2023
+
+typedef struct {
+	nfapi_tl_t tl;	
+	uint8_t harq_tb1;
+} nfapi_nb_harq_indication_fdd_rel13_t;
+#define NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG 0x2064
+
+typedef struct {
+	uint16_t								instance_length;
+	nfapi_rx_ue_information					rx_ue_information;
+	nfapi_nb_harq_indication_fdd_rel13_t	nb_harq_indication_fdd_rel13;
+	nfapi_ul_cqi_information_t				ul_cqi_information;
+} nfapi_nb_harq_indication_pdu_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_harqs;
+	nfapi_nb_harq_indication_pdu_t* nb_harq_pdu_list;
+} nfapi_nb_harq_indication_body_t;
+#define NFAPI_NB_HARQ_INDICATION_BODY_TAG 0x2063
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t rnti;
+	uint8_t initial_sc;
+	uint16_t timing_advance;
+	uint8_t nrach_ce_level;
+} nfapi_nrach_indication_pdu_rel13_t;
+#define NFAPI_NRACH_INDICATION_REL13_TAG 0x2066
+
+typedef struct {
+	nfapi_nrach_indication_pdu_rel13_t		nrach_indication_rel13;
+} nfapi_nrach_indication_pdu_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_of_initial_scs_detected;
+	nfapi_nrach_indication_pdu_t* nrach_pdu_list;
+} nfapi_nrach_indication_body_t;
+#define NFAPI_NRACH_INDICATION_BODY_TAG 0x2065
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint32_t mp_cca;
+	uint32_t n_cca;
+	uint32_t offset;
+	uint32_t lte_txop_sf;
+	uint16_t txop_sfn_sf_end;
+	uint32_t lbt_mode;
+} nfapi_lbt_pdsch_req_pdu_rel13_t;
+#define NFAPI_LBT_PDSCH_REQ_PDU_REL13_TAG 0x2056
+
+typedef struct {
+	nfapi_lbt_pdsch_req_pdu_rel13_t lbt_pdsch_req_pdu_rel13;
+} nfapi_lbt_pdsch_req_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint32_t offset;
+	uint16_t sfn_sf_end;
+	uint32_t lbt_mode;
+} nfapi_lbt_drs_req_pdu_rel13_t;
+#define NFAPI_LBT_DRS_REQ_PDU_REL13_TAG 0x2057
+
+typedef struct {
+	nfapi_lbt_drs_req_pdu_rel13_t lbt_drs_req_pdu_rel13;
+} nfapi_lbt_drs_req_pdu;
+
+typedef struct {
+	uint8_t pdu_type;
+	uint8_t pdu_size;
+	union {
+		nfapi_lbt_pdsch_req_pdu		lbt_pdsch_req_pdu;
+		nfapi_lbt_drs_req_pdu		lbt_drs_req_pdu;
+	};
+} nfapi_lbt_dl_config_request_pdu_t;
+
+#define NFAPI_LBT_DL_CONFIG_REQ_MAX_PDU 16
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_pdus;
+	nfapi_lbt_dl_config_request_pdu_t*		lbt_dl_config_req_pdu_list;
+} nfapi_lbt_dl_config_request_body_t;
+#define NFAPI_LBT_DL_CONFIG_REQUEST_BODY_TAG 0x2055
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint32_t result;
+	uint32_t lte_txop_symbols;
+	uint32_t initial_partial_sf;
+} nfapi_lbt_pdsch_rsp_pdu_rel13_t;
+#define NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG 0x2059
+
+typedef struct {
+	nfapi_lbt_pdsch_rsp_pdu_rel13_t lbt_pdsch_rsp_pdu_rel13;
+} nfapi_lbt_pdsch_rsp_pdu;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t handle;
+	uint32_t result;
+} nfapi_lbt_drs_rsp_pdu_rel13_t;
+#define NFAPI_LBT_DRS_RSP_PDU_REL13_TAG 0x205A
+
+typedef struct {
+	nfapi_lbt_drs_rsp_pdu_rel13_t lbt_drs_rsp_pdu_rel13;
+} nfapi_lbt_drs_rsp_pdu;
+
+
+typedef struct {
+	uint8_t pdu_type;
+	uint8_t pdu_size;
+	union {
+		nfapi_lbt_pdsch_rsp_pdu		lbt_pdsch_rsp_pdu;
+		nfapi_lbt_drs_rsp_pdu		lbt_drs_rsp_pdu;
+	};
+} nfapi_lbt_dl_indication_pdu_t;
+
+#define NFAPI_LBT_IND_MAX_PDU 16
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_pdus;
+	nfapi_lbt_dl_indication_pdu_t* lbt_indication_pdu_list;
+} nfapi_lbt_dl_indication_body_t;
+#define NFAPI_LBT_DL_INDICATION_BODY_TAG 0x2058
+
+typedef struct {
+} nfapi_error_indication_msg_invalid_state;
+
+typedef struct {
+} nfapi_error_indication_msg_bch_missing;
+
+typedef struct {
+	uint16_t recieved_sfn_sf;
+	uint16_t expected_sfn_sf;
+} nfapi_error_indication_sfn_out_of_sync;
+
+typedef struct {
+	uint8_t sub_error_code;
+	uint8_t direction;
+	uint16_t rnti;
+	uint8_t pdu_type;
+} nfapi_error_indication_msg_pdu_err;
+
+typedef struct {
+	uint16_t recieved_sfn_sf;
+	uint16_t expected_sfn_sf;
+} nfapi_error_indication_msg_invalid_sfn;
+
+typedef struct {
+	uint8_t sub_error_code;
+	uint8_t phich_lowest_ul_rb_index;
+} nfapi_error_indication_msg_hi_err;
+
+typedef struct {
+	uint8_t sub_error_code;
+	uint16_t pdu_index;
+} nfapi_error_indication_msg_tx_err;
+
+// 
+// P4 Message Structures
+//
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t frequency_band_indicator;
+	uint16_t measurement_period;
+	uint8_t bandwidth;
+	uint32_t timeout;
+	uint8_t number_of_earfcns;
+	uint16_t earfcn[NFAPI_MAX_CARRIER_LIST];
+} nfapi_lte_rssi_request_t;
+
+#define NFAPI_LTE_RSSI_REQUEST_TAG 0x3000
+
+#define NFAPI_P4_START_TAG NFAPI_LTE_RSSI_REQUEST_TAG
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t frequency_band_indicator;
+	uint16_t measurement_period;
+	uint32_t timeout;
+	uint8_t number_of_uarfcns;
+	uint16_t uarfcn[NFAPI_MAX_CARRIER_LIST];
+} nfapi_utran_rssi_request_t;
+
+#define NFAPI_UTRAN_RSSI_REQUEST_TAG 0x3001
+
+typedef struct {
+	uint16_t arfcn;
+	uint8_t direction;
+} nfapi_arfcn_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t frequency_band_indicator;
+	uint16_t measurement_period;
+	uint32_t timeout;
+	uint8_t number_of_arfcns;
+	nfapi_arfcn_t arfcn[NFAPI_MAX_CARRIER_LIST];
+} nfapi_geran_rssi_request_t;
+
+#define NFAPI_GERAN_RSSI_REQUEST_TAG 0x3002
+
+
+
+typedef struct {
+	uint16_t earfcn;
+	uint8_t number_of_ro_dl;
+	uint8_t ro_dl[NFAPI_MAX_RO_DL];
+} nfapi_earfcn_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t frequency_band_indicator;
+	uint16_t measurement_period;
+	uint32_t timeout;
+	uint8_t number_of_earfcns;
+	nfapi_earfcn_t earfcn[NFAPI_MAX_CARRIER_LIST];
+} nfapi_nb_iot_rssi_request_t;
+
+#define NFAPI_NB_IOT_RSSI_REQUEST_TAG 0x3020
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_rssi;
+	int16_t rssi[NFAPI_MAX_RSSI];
+} nfapi_rssi_indication_body_t;
+
+#define NFAPI_RSSI_INDICATION_TAG 0x3003
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint8_t measurement_bandwidth;
+	uint8_t exhaustive_search;
+	uint32_t timeout;
+	uint8_t number_of_pci;
+	uint16_t pci[NFAPI_MAX_PCI_LIST];
+} nfapi_lte_cell_search_request_t;
+
+#define NFAPI_LTE_CELL_SEARCH_REQUEST_TAG 0x3004
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t uarfcn;
+	uint8_t exhaustive_search;
+	uint32_t timeout;
+	uint8_t number_of_psc;
+	uint16_t psc[NFAPI_MAX_PSC_LIST];
+} nfapi_utran_cell_search_request_t;
+
+#define NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG 0x3005
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint32_t timeout;
+	uint8_t number_of_arfcn;
+	uint16_t arfcn[NFAPI_MAX_ARFCN_LIST];
+} nfapi_geran_cell_search_request_t;
+
+#define NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG 0x3006
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint8_t ro_dl;
+	uint8_t exhaustive_search;
+	uint32_t timeout;
+	uint8_t number_of_pci;
+	uint16_t pci[NFAPI_MAX_PCI_LIST];
+} nfapi_nb_iot_cell_search_request_t;
+
+#define NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG 0x3021
+
+typedef struct {
+	uint16_t pci;
+	uint8_t rsrp;
+	uint8_t rsrq;
+	int16_t frequency_offset;
+} nfapi_lte_found_cell_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_lte_cells_found;
+	nfapi_lte_found_cell_t lte_found_cells[NFAPI_MAX_LTE_CELLS_FOUND];
+} nfapi_lte_cell_search_indication_t;
+
+#define NFAPI_LTE_CELL_SEARCH_INDICATION_TAG 0x3007
+
+typedef struct {
+	uint16_t psc;
+	uint8_t rscp;
+	uint8_t ecno;
+	int16_t frequency_offset;
+} nfapi_utran_found_cell_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_utran_cells_found;
+	nfapi_utran_found_cell_t utran_found_cells[NFAPI_MAX_UTRAN_CELLS_FOUND];
+} nfapi_utran_cell_search_indication_t;
+
+#define NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG 0x3008
+
+typedef struct {
+	uint16_t arfcn;
+	uint8_t bsic;
+	uint8_t rxlev;
+	uint8_t rxqual;
+	int16_t frequency_offset;
+	uint32_t sfn_offset;
+} nfapi_gsm_found_cell_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_gsm_cells_found;
+	nfapi_gsm_found_cell_t gsm_found_cells[NFAPI_MAX_GSM_CELLS_FOUND];
+} nfapi_geran_cell_search_indication_t;
+
+#define NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG 0x3009
+
+typedef struct {
+	uint16_t pci;
+	uint8_t rsrp;
+	uint8_t rsrq;
+	int16_t frequency_offset;
+} nfapi_nb_iot_found_cell_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t number_of_nb_iot_cells_found;
+	nfapi_nb_iot_found_cell_t nb_iot_found_cells[NFAPI_MAX_NB_IOT_CELLS_FOUND];
+} nfapi_nb_iot_cell_search_indication_t;
+
+#define NFAPI_NB_IOT_CELL_SEARCH_INDICATION_TAG 0x3022
+
+typedef nfapi_opaqaue_data_t nfapi_pnf_cell_search_state_t;
+
+#define NFAPI_PNF_CELL_SEARCH_STATE_TAG 0x300A
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint16_t pci;
+	uint32_t timeout;
+} nfapi_lte_broadcast_detect_request_t;
+
+#define NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG 0x300B
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t uarfcn;
+	uint16_t psc;
+	uint32_t timeout;
+} nfapi_utran_broadcast_detect_request_t;
+
+#define NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG 0x300C
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint8_t ro_dl;
+	uint16_t pci;
+	uint32_t timeout;
+} nfapi_nb_iot_broadcast_detect_request_t;
+
+#define NFAPI_NB_IOT_BROADCAST_DETECT_REQUEST_TAG 0x3023
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_of_tx_antenna;
+	uint16_t mib_length;
+	uint8_t mib[NFAPI_MAX_MIB_LENGTH];
+	uint32_t sfn_offset;
+} nfapi_lte_broadcast_detect_indication_t;
+
+#define NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG 0x300E
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t mib_length;
+	uint8_t mib[NFAPI_MAX_MIB_LENGTH];
+	uint32_t sfn_offset;
+} nfapi_utran_broadcast_detect_indication_t;
+
+#define NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG 0x300F
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t number_of_tx_antenna;
+	uint16_t mib_length;
+	uint8_t mib[NFAPI_MAX_MIB_LENGTH];
+	uint32_t sfn_offset;
+} nfapi_nb_iot_broadcast_detect_indication_t;
+
+#define NFAPI_NB_IOT_BROADCAST_DETECT_INDICATION_TAG 0x3024
+
+#define NFAPI_PNF_CELL_BROADCAST_STATE_TAG 0x3010
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint16_t pci;
+	uint16_t downlink_channel_bandwidth;
+	uint8_t phich_configuration;
+	uint8_t number_of_tx_antenna;
+	uint8_t retry_count;
+	uint32_t timeout;
+} nfapi_lte_system_information_schedule_request_t;
+
+#define NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3011
+
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint8_t ro_dl;
+	uint16_t pci;
+	uint8_t scheduling_info_sib1_nb;
+	uint32_t timeout;
+} nfapi_nb_iot_system_information_schedule_request_t;
+
+#define NFAPI_NB_IOT_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3025
+
+typedef nfapi_opaqaue_data_t nfapi_pnf_cell_broadcast_state_t;
+
+typedef struct {
+	uint8_t si_periodicity;
+	uint8_t si_index;
+} nfapi_lte_system_information_si_periodicity_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint16_t pci;
+	uint16_t downlink_channel_bandwidth;
+	uint8_t phich_configuration;
+	uint8_t number_of_tx_antenna;
+	uint8_t number_of_si_periodicity;
+	nfapi_lte_system_information_si_periodicity_t si_periodicity[NFAPI_MAX_SI_PERIODICITY];
+	uint8_t si_window_length;
+	uint32_t timeout;
+} nfapi_lte_system_information_request_t;
+
+#define NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG 0x3014
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t uarfcn;
+	uint16_t psc;
+	uint32_t timeout;
+} nfapi_utran_system_information_request_t;
+
+#define NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3015
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t arfcn;
+	uint8_t bsic;
+	uint32_t timeout;
+} nfapi_geran_system_information_request_t;
+
+#define NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3016
+
+typedef struct {
+	uint8_t si_periodicity;
+	uint8_t si_repetition_pattern;
+	uint8_t si_tb_size;
+	uint8_t number_of_si_index;
+	uint8_t si_index[NFAPI_MAX_SI_INDEX];
+} nfapi_nb_iot_system_information_si_periodicity_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t earfcn;
+	uint8_t ro_dl;
+	uint16_t pci;
+	uint8_t number_of_si_periodicity;
+	nfapi_nb_iot_system_information_si_periodicity_t si_periodicity[NFAPI_MAX_SI_PERIODICITY];
+	uint8_t si_window_length;
+	uint32_t timeout;
+} nfapi_nb_iot_system_information_request_t;
+
+#define NFAPI_NB_IOT_SYSTEM_INFORMATION_REQUEST_TAG 0x3027
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t sib_type;
+	uint16_t sib_length;
+	uint8_t sib[NFAPI_MAX_SIB_LENGTH];
+} nfapi_lte_system_information_indication_t;
+
+#define NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG 0x3018
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t sib_length;
+	uint8_t sib[NFAPI_MAX_SIB_LENGTH];
+} nfapi_utran_system_information_indication_t;
+
+#define NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG 0x3019
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint16_t si_length;
+	uint8_t si[NFAPI_MAX_SI_LENGTH];
+} nfapi_geran_system_information_indication_t;
+
+#define NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG 0x301a
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint8_t sib_type;
+	uint16_t sib_length;
+	uint8_t sib[NFAPI_MAX_SIB_LENGTH];
+} nfapi_nb_iot_system_information_indication_t;
+
+#define NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG 0x3026
+
+
+//
+// Top level NFAP messages
+//
+
+//
+// P7
+//
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_dl_config_request_body_t dl_config_request_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_dl_config_request_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_ul_config_request_body_t ul_config_request_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_ul_config_request_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_hi_dci0_request_body_t hi_dci0_request_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_hi_dci0_request_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_tx_request_body_t tx_request_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_tx_request_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+} nfapi_subframe_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_harq_indication_body_t harq_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_harq_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_crc_indication_body_t crc_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_crc_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_sr_indication_body_t sr_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_sr_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_cqi_indication_body_t cqi_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_cqi_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_rach_indication_body_t rach_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_rach_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_srs_indication_body_t srs_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_srs_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_rx_indication_body_t rx_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_rx_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_nb_harq_indication_body_t nb_harq_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_nb_harq_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_nrach_indication_body_t nrach_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_nrach_indication_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_lbt_dl_config_request_body_t lbt_dl_config_request_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_lbt_dl_config_request_t;
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint16_t sfn_sf;
+	nfapi_lbt_dl_indication_body_t lbt_dl_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_lbt_dl_indication_t;
+
+
+typedef struct {
+	nfapi_p7_message_header_t header;
+	uint8_t message_id;
+	uint8_t error_code;
+	union {
+		nfapi_error_indication_msg_invalid_state	msg_invalid_state;
+		nfapi_error_indication_msg_bch_missing		msg_bch_missing;
+		nfapi_error_indication_sfn_out_of_sync		sfn_out_of_sync;
+		nfapi_error_indication_msg_pdu_err			msg_pdu_err;
+		nfapi_error_indication_msg_invalid_sfn		msg_invalid_sfn;
+		nfapi_error_indication_msg_hi_err			msg_hi_err;
+		nfapi_error_indication_msg_tx_err			msg_tx_err;
+	};
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_error_indication_t;
+
+// 
+// P4 Messages
+// 
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint8_t rat_type;
+	union {
+		nfapi_lte_rssi_request_t					lte_rssi_request;
+		nfapi_utran_rssi_request_t					utran_rssi_request;
+		nfapi_geran_rssi_request_t					geran_rssi_request;
+		nfapi_nb_iot_rssi_request_t					nb_iot_rssi_request;
+	};
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_rssi_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_rssi_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_rssi_indication_body_t rssi_indication_body;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_rssi_indication_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint8_t rat_type;
+	union {
+		nfapi_lte_cell_search_request_t				lte_cell_search_request;
+		nfapi_utran_cell_search_request_t			utran_cell_search_request;
+		nfapi_geran_cell_search_request_t			geran_cell_search_request;
+		nfapi_nb_iot_cell_search_request_t			nb_iot_cell_search_request;
+	};
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_cell_search_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_cell_search_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_lte_cell_search_indication_t lte_cell_search_indication;
+	nfapi_utran_cell_search_indication_t utran_cell_search_indication;
+	nfapi_geran_cell_search_indication_t geran_cell_search_indication;
+	nfapi_pnf_cell_search_state_t pnf_cell_search_state;
+	nfapi_nb_iot_cell_search_indication_t nb_iot_cell_search_indication;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_cell_search_indication_t;
+
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint8_t rat_type;
+	union {
+		nfapi_lte_broadcast_detect_request_t		lte_broadcast_detect_request;
+		nfapi_utran_broadcast_detect_request_t		utran_broadcast_detect_request;
+		nfapi_nb_iot_broadcast_detect_request_t		nb_iot_broadcast_detect_request;
+	};
+	nfapi_pnf_cell_search_state_t pnf_cell_search_state;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_broadcast_detect_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_broadcast_detect_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_lte_broadcast_detect_indication_t lte_broadcast_detect_indication;
+	nfapi_utran_broadcast_detect_indication_t utran_broadcast_detect_indication;
+	nfapi_nb_iot_broadcast_detect_indication_t nb_iot_broadcast_detect_indication;
+	nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_broadcast_detect_indication_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint8_t rat_type;
+	union {
+		nfapi_lte_system_information_schedule_request_t lte_system_information_schedule_request;
+		nfapi_nb_iot_system_information_schedule_request_t nb_iot_system_information_schedule_request;
+	};
+	nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_system_information_schedule_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_system_information_schedule_response_t;
+
+typedef struct { 
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_lte_system_information_indication_t lte_system_information_indication;
+	nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_system_information_schedule_indication_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint8_t rat_type;
+	union {
+		nfapi_lte_system_information_request_t lte_system_information_request;
+		nfapi_utran_system_information_request_t utran_system_information_request;
+		nfapi_geran_system_information_request_t geran_system_information_request;
+		nfapi_nb_iot_system_information_request_t nb_iot_system_information_request;
+	};
+	nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_system_information_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_system_information_response_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_lte_system_information_indication_t lte_system_information_indication;
+	nfapi_utran_system_information_indication_t utran_system_information_indication;
+	nfapi_geran_system_information_indication_t geran_system_information_indication;
+	nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_system_information_indication_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_nmm_stop_request_t;
+
+typedef struct {
+	nfapi_p4_p5_message_header_t header;
+	uint32_t error_code;
+	nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_nmm_stop_response_t;
+
+//
+// Configuration options for the encode decode functions
+//
+
+/*! Configuration options for the p7 pack unpack functions
+ *
+ */
+typedef struct nfapi_p7_codec_config {
+
+	/*! Optional call back to allow the user to define the memory allocator. 
+	 *  \param size The size of the memory to allocate
+	 *  \return a pointer to a valid memory block or 0 if it has failed.
+	 *
+	 * If not set the nfapi unpack functions will use malloc
+	 */
+	void* (*allocate)(size_t size);
+
+	/*! Optional call back to allow the user to define the memory deallocator. 
+	 *  \param ptr A poiner to a memory block allocated by the allocate callback
+	 * 
+	 *	If not set the client should use free
+	 */
+	void (*deallocate)(void* ptr);
+
+	/*! Optional call back function to handle unpacking vendor extension tlv.
+	 *  \param tl A pointer to a decoded tag length structure
+	 *  \param ppReadPackedMsg A handle to the read buffer. 
+	 *  \param end The end of the read buffer
+	 *  \param ve A handle to a vendor extention structure that the call back should allocate if the structure can be decoded
+	 *  \param config A pointer to the p7 codec configuration
+	 *  \return return 0 if packed successfully, -1 if failed.
+	 *
+	 *  If not set the tlv will be skipped
+	 *
+	 *  Client should use the help methods in nfapi.h to decode the vendor extention.
+	 * 
+	 *  \todo Add code example
+	 */
+	int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p7_codec_config* config);
+
+	/*! Optional call back function to handle packing vendor extension tlv. 
+	 *  \param ve A pointer to a vendor extention structure.
+	 *  \param ppWritePackedMsg A handle to the write buffer
+	 *  \param end The end of the write buffer. The callee should make sure not to write beyond the end
+	 *  \param config A pointer to the p7 codec configuration
+	 *  \return return 0 if packed successfully, -1 if failed.
+	 * 
+	 *  If not set the the tlv will be skipped
+	 * 
+	 *  Client should use the help methods in nfapi.h to encode the vendor extention
+	 * 
+	 *  \todo Add code example
+	 */
+	int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config);
+
+	/*! Optional call back function to handle unpacking vendor extension messages. 
+	 *  \param header A pointer to a decode P7 message header for the vendor extention message
+	 *  \param ppReadPackedMsg A handle to the encoded data buffer
+	 *  \param end A pointer to the end of the encoded data buffer
+	 *  \param config  A pointer to the p7 codec configuration
+	 *  \return 0 if unpacked successfully, -1 if failed
+	 *
+	 *  If not set the message will be ignored
+	 *
+	 *  If the message if is unknown the function should return -1
+	 */
+	int (*unpack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config);
+
+	/*! Optional call back function to handle packing vendor extension messages. 
+	 *  \param header A poiner to a P7 message structure for the venfor extention message
+	 *  \param ppWritePackedmsg A handle to the buffer to write the encoded message into
+	 *  \param end A pointer to the end of the buffer
+	 *  \param cofig A pointer to the p7 codec configuration
+	 *  \return 0 if packed successfully, -1 if failed
+	 * 
+	 * If not set the the message will be ingored
+	 *	 
+	 *  If the message if is unknown the function should return -1
+	 */
+	int (*pack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppWritePackedmsg, uint8_t *end, struct nfapi_p7_codec_config* config);
+
+	/*! Optional user data that will be passed back with callbacks
+	 */
+	void* user_data;
+
+} nfapi_p7_codec_config_t;
+
+/*! Configuration options for the p4 & p5 pack unpack functions
+ *
+ */
+typedef struct nfapi_p4_p5_codec_config {
+
+	/*! Optional call back to allow the user to define the memory allocator.
+     *  \param size The size of the memory to allocate
+	 *  \return a pointer to a valid memory block or 0 if it has failed.
+	 *
+	 *  If not set the nfapi unpack functions will use malloc
+	 */
+	void* (*allocate)(size_t size);
+
+	/*! Optional call back to allow the user to define the memory deallocator. 
+	 *  \param ptr A poiner to a memory block allocated by the allocate callback
+	 *
+	 *  If not set free will be used
+	 */
+	void (*deallocate)(void* ptr);
+
+	/*! Optional call back function to handle unpacking vendor extension tlv.
+	 *  \param tl A pointer to a decoded tag length structure
+	 *  \param ppReadPackedMsg A handle to the data buffer to decode
+	 *  \param end A pointer to the end of the buffer
+	 *  \param ve A handle to a vendor extention structure that will be allocated by this callback
+	 *  \param config A pointer to the P4/P5 codec configuration
+	 *  \return 0 if unpacked successfully, -1 if failed
+	 *  
+	 *  If not set the tlv will be skipped
+	 */
+	int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p4_p5_codec_config* config);
+
+	/*! Optional call back function to handle packing vendor extension tlv. 
+	 *  \param ve
+	 *  \param ppWritePackedMsg A handle to the data buffer pack the tlv into
+	 *  \param end A pointer to the end of the buffer
+	 *  \param config A pointer to the P4/P5 codec configuration
+	 *  \return 0 if packed successfully, -1 if failed
+	 *
+	 *  If not set the the tlv will be skipped
+	 */
+	int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
+
+	/*! Optional call back function to handle unpacking vendor extension messages. 
+	 *  \param header A pointer to a decode P4/P5 message header
+	 *  \param ppReadPackgedMsg A handle to the data buffer to decode
+	 *  \param end A pointer to the end of the buffer
+	 *  \param config A pointer to the P4/P5 codec configuration
+	 *  \return 0 if packed successfully, -1 if failed
+	 *
+	 * If not set the message will be ignored
+	 */
+	int (*unpack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
+
+	/*! Optional call back function to handle packing vendor extension messages.
+	 *  \param header A pointer to the P4/P5 message header to be encoded
+	 *  \param ppWritePackedMsg A handle to the data buffer pack the message into
+	 *  \param end A pointer to the end of the buffer
+	 *  \param config A pointer to the P4/P5 codec configuration
+	 *  \return 0 if packed successfully, -1 if failed
+	 *  
+	 *  If not set the the message will be ingored
+	 */
+	int (*pack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppwritepackedmsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
+
+	/*! Optional user data that will be passed back with callbacks
+	 */
+	void* user_data;
+
+} nfapi_p4_p5_codec_config_t;
+
+//
+// Functions
+// 
+
+/*! \brief Encodes an NFAPI P4 message to a buffer
+ *  \param pMessageBuf A pointer to a nfapi p4 message structure
+ *  \param messageBufLen The size of the p4 message structure
+ *  \param pPackedBuf A pointer to the buffer that the p4 message will be packed into
+ *  \param packedBufLen The size of the buffer 
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will encode a nFAPI P4 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
+ * 
+ */
+int nfapi_p4_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
+
+/*! \brief Decodes a NFAPI P4 message header
+ *  \param pMessageBuf A pointer to an encoded P4 message header
+ *  \param messageBufLen The size of the encoded P4 message header
+ *  \param pUnpackedBuf A pointer to the nfapi_message_header
+ *  \param unpackedBufLen The size of nfapi_message_header structure.
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf
+ */
+int nfapi_p4_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
+
+/*! \brief Decodes a NFAPI P4 message
+ *  \param pMessageBuf A pointer to an encoded P4 message
+ *  \param messageBufLen The size of the encoded P4 message
+ *  \param pUnpackedBuf A pointer to the nfapi_message_header
+ *  \param unpackedBufLen The size of nfapi_message_header structure.
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p4 message structure pointer to by pUnpackedBuf 
+ */
+int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
+
+/*! \brief Encodes an NFAPI P5 message to a buffer
+ *  \param pMessageBuf A pointer to a nfapi p5 message structure
+ *  \param messageBufLen The size of the p5 message structure
+ *  \param pPackedBuf A pointer to the buffer that the p5 message will be packed into
+ *  \param packedBufLen The size of the buffer 
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will encode a nFAPI P5 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
+ * 
+ */
+int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
+
+/*! \brief Decodes an NFAPI P5 message header
+ *  \param pMessageBuf A pointer to an encoded P5 message header
+ *  \param messageBufLen The size of the encoded P5 message header
+ *  \param pUnpackedBuf A pointer to the nfapi_message_header
+ *  \param unpackedBufLen The size of nfapi_message_header structure.
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf
+ */
+int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
+
+/*! \brief Decodes a NFAPI P5 message
+ *  \param pMessageBuf A pointer to an encoded P5 message
+ *  \param messageBufLen The size of the encoded P5 message
+ *  \param pUnpackedBuf A pointer to the nfapi_message_header
+ *  \param unpackedBufLen The size of nfapi_message_header structure.
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf 
+ */
+int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
+
+/*! \brief Encodes an NFAPI P7 message to a buffer
+ *  \param pMessageBuf A pointer to a nfapi p7 message structure
+ *  \param pPackedBuf A pointer to the buffer that the p7 message will be packed into
+ *  \param packedBufLen The size of the buffer 
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will encode a nFAPI P7 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
+ * 
+ */
+int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config);
+
+/*! \brief Decodes an NFAPI P7 message header
+ *  \param pMessageBuf A pointer to an encoded P7 message header
+ *  \param messageBufLen The size of the encoded P7 message header
+ *  \param pUnpackedBuf A pointer to the nfapi_message_header
+ *  \param unpackedBufLen The size of nfapi_message_header structure.
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p7_message_header structure pointer to by pUnpackedBuf
+
+ */
+int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
+
+/*! \brief Decodes a NFAPI P7 message
+ *  \param pMessageBuf A pointer to an encoded P7 message
+ *  \param messageBufLen The size of the encoded P7 message
+ *  \param pUnpackedBuf A pointer to the nfapi_message_header
+ *  \param unpackedBufLen The size of nfapi_message_header structure.
+ *  \param config A pointer to the nfapi configuration structure
+ *  \return 0 means success, -1 means failure.
+ *
+ * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p7 message structure pointer to by pUnpackedBuf 
+ */
+int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
+
+/*! \brief Calculates the checksum of a  message
+ *
+ *  \param buffer Pointer to the packed message
+ *  \param len The length of the message
+ *  \return The checksum. If there is an error the function with return -1
+ */
+uint32_t nfapi_p7_calculate_checksum(uint8_t* buffer, uint32_t len);
+
+/*! \brief Calculates & updates the checksum in the message
+ *
+ *  \param buffer Pointer to the packed message
+ *  \param len The length of the message
+  *  \return 0 means success, -1 means failure.
+ */
+int nfapi_p7_update_checksum(uint8_t* buffer, uint32_t len);
+
+/*! \brief Updates the transmition time stamp in the p7 message header
+ *
+ *  \param buffer Pointer to the packed message
+ *  \param timestamp The time stamp value
+  *  \return 0 means success, -1 means failure.
+ */
+int nfapi_p7_update_transmit_timestamp(uint8_t* buffer, uint32_t timestamp);
+
+#endif /* _NFAPI_INTERFACE_H_ */
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c
new file mode 100644
index 0000000000000000000000000000000000000000..4020056e6f68043a591f4792c287202e49a76ab0
--- /dev/null
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c
@@ -0,0 +1,748 @@
+/*
+ * 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/dlsch_decoding.c
+* \brief Top-level routines for decoding  Turbo-coded (DLSCH) transport channels from 36-212, V8.6 2009-03
+* \author R. Knopp
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: knopp@eurecom.fr
+* \note
+* \warning
+*/
+
+//#include "defs.h"
+#include "PHY/defs.h"
+#include "PHY/extern.h"
+#include "PHY/CODING/extern.h"
+#include "SCHED/extern.h"
+#include "SIMULATION/TOOLS/defs.h"
+//#define DEBUG_DLSCH_DECODING
+//#define UE_DEBUG_TRACE 1
+
+
+void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch)
+{
+
+  int i,r;
+
+  if (dlsch) {
+    for (i=0; i<dlsch->Mdlharq; i++) {
+      if (dlsch->harq_processes[i]) {
+        if (dlsch->harq_processes[i]->b) {
+          free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES);
+          dlsch->harq_processes[i]->b = NULL;
+        }
+
+        for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) {
+          free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
+          dlsch->harq_processes[i]->c[r] = NULL;
+        }
+
+        for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++)
+          if (dlsch->harq_processes[i]->d[r]) {
+            free16(dlsch->harq_processes[i]->d[r],((3*8*6144)+12+96)*sizeof(short));
+            dlsch->harq_processes[i]->d[r] = NULL;
+          }
+
+        free16(dlsch->harq_processes[i],sizeof(LTE_DL_UE_HARQ_t));
+        dlsch->harq_processes[i] = NULL;
+      }
+    }
+
+    free16(dlsch,sizeof(LTE_UE_DLSCH_t));
+    dlsch = NULL;
+  }
+}
+
+LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag)
+{
+
+  LTE_UE_DLSCH_t *dlsch;
+  uint8_t exit_flag = 0,i,r;
+
+  unsigned char bw_scaling =1;
+
+  switch (N_RB_DL) {
+  case 6:
+    bw_scaling =16;
+    break;
+
+  case 25:
+    bw_scaling =4;
+    break;
+
+  case 50:
+    bw_scaling =2;
+    break;
+
+  default:
+    bw_scaling =1;
+    break;
+  }
+
+  dlsch = (LTE_UE_DLSCH_t *)malloc16(sizeof(LTE_UE_DLSCH_t));
+
+  if (dlsch) {
+    memset(dlsch,0,sizeof(LTE_UE_DLSCH_t));
+    dlsch->Kmimo = Kmimo;
+    dlsch->Mdlharq = Mdlharq;
+    dlsch->Nsoft = Nsoft;
+    dlsch->max_turbo_iterations = max_turbo_iterations;
+
+    for (i=0; i<Mdlharq; i++) {
+      //      printf("new_ue_dlsch: Harq process %d\n",i);
+      dlsch->harq_processes[i] = (LTE_DL_UE_HARQ_t *)malloc16(sizeof(LTE_DL_UE_HARQ_t));
+
+      if (dlsch->harq_processes[i]) {
+        memset(dlsch->harq_processes[i],0,sizeof(LTE_DL_UE_HARQ_t));
+        dlsch->harq_processes[i]->first_tx=1;
+        dlsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
+
+        if (dlsch->harq_processes[i]->b)
+          memset(dlsch->harq_processes[i]->b,0,MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
+        else
+          exit_flag=3;
+
+        if (abstraction_flag == 0) {
+          for (r=0; r<MAX_NUM_DLSCH_SEGMENTS/bw_scaling; r++) {
+            dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(((r==0)?8:0) + 3+ 768);
+
+            if (dlsch->harq_processes[i]->c[r])
+              memset(dlsch->harq_processes[i]->c[r],0,((r==0)?8:0) + 3+ 768);
+            else
+              exit_flag=2;
+
+            dlsch->harq_processes[i]->d[r] = (short*)malloc16(((3*8*6144)+12+96)*sizeof(short));
+
+            if (dlsch->harq_processes[i]->d[r])
+              memset(dlsch->harq_processes[i]->d[r],0,((3*8*6144)+12+96)*sizeof(short));
+            else
+              exit_flag=2;
+          }
+        }
+      } else {
+        exit_flag=1;
+      }
+    }
+
+    if (exit_flag==0)
+      return(dlsch);
+  }
+
+  printf("new_ue_dlsch with size %zu: exit_flag = %u\n",sizeof(LTE_DL_UE_HARQ_t), exit_flag);
+  free_ue_dlsch(dlsch);
+
+  return(NULL);
+}
+
+uint32_t  dlsch_decoding(PHY_VARS_UE *phy_vars_ue,
+                         short *dlsch_llr,
+                         LTE_DL_FRAME_PARMS *frame_parms,
+                         LTE_UE_DLSCH_t *dlsch,
+                         LTE_DL_UE_HARQ_t *harq_process,
+                         uint32_t frame,
+                         uint8_t subframe,
+                         uint8_t harq_pid,
+                         uint8_t is_crnti,
+                         uint8_t llr8_flag)
+{
+
+#if UE_TIMING_TRACE
+  time_stats_t *dlsch_rate_unmatching_stats=&phy_vars_ue->dlsch_rate_unmatching_stats;
+  time_stats_t *dlsch_turbo_decoding_stats=&phy_vars_ue->dlsch_turbo_decoding_stats;
+  time_stats_t *dlsch_deinterleaving_stats=&phy_vars_ue->dlsch_deinterleaving_stats;
+#endif
+  uint32_t A,E;
+  uint32_t G;
+  uint32_t ret,offset;
+  uint16_t iind;
+  //  uint8_t dummy_channel_output[(3*8*block_length)+12];
+  short dummy_w[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
+  uint32_t r,r_offset=0,Kr,Kr_bytes,err_flag=0;
+  uint8_t crc_type;
+#ifdef DEBUG_DLSCH_DECODING
+  uint16_t i;
+#endif
+  //#ifdef __AVX2__
+#if 0
+  int Kr_last,skipped_last=0;
+  uint8_t (*tc_2cw)(int16_t *y,
+		    int16_t *y2,
+		    uint8_t *,
+		    uint8_t *,
+		    uint16_t,
+		    uint16_t,
+		    uint16_t,
+		    uint8_t,
+		    uint8_t,
+		    uint8_t,
+		    time_stats_t *,
+		    time_stats_t *,
+		    time_stats_t *,
+		    time_stats_t *,
+		    time_stats_t *,
+		    time_stats_t *,
+		    time_stats_t *);
+
+#endif
+decoder_if_t tc;
+
+
+
+
+  if (!dlsch_llr) {
+    printf("dlsch_decoding.c: NULL dlsch_llr pointer\n");
+    return(dlsch->max_turbo_iterations);
+  }
+
+  if (!harq_process) {
+    printf("dlsch_decoding.c: NULL harq_process pointer\n");
+    return(dlsch->max_turbo_iterations);
+  }
+
+  if (!frame_parms) {
+    printf("dlsch_decoding.c: NULL frame_parms pointer\n");
+    return(dlsch->max_turbo_iterations);
+  }
+
+  if (subframe>9) {
+    printf("dlsch_decoding.c: Illegal subframe index %d\n",subframe);
+    return(dlsch->max_turbo_iterations);
+  }
+
+  if (dlsch->harq_ack[subframe].ack != 2) {
+    LOG_D(PHY, "[UE %d] DLSCH @ SF%d : ACK bit is %d instead of DTX even before PDSCH is decoded!\n",
+        phy_vars_ue->Mod_id, subframe, dlsch->harq_ack[subframe].ack);
+  }
+
+  if (llr8_flag == 0) {
+    //#ifdef __AVX2__
+#if 0
+    tc_2cw = phy_threegpplte_turbo_decoder16avx2;
+#endif
+    tc = decoder16;
+  }
+  else
+  {
+	  AssertFatal (harq_process->TBS >= 256 , "Mismatch flag nbRB=%d TBS=%d mcs=%d Qm=%d RIV=%d round=%d \n",
+			  harq_process->nb_rb, harq_process->TBS,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round);
+	    tc = decoder8;
+  }
+
+
+  //  nb_rb = dlsch->nb_rb;
+
+  /*
+  if (nb_rb > frame_parms->N_RB_DL) {
+    printf("dlsch_decoding.c: Illegal nb_rb %d\n",nb_rb);
+    return(max_turbo_iterations);
+    }*/
+
+  /*harq_pid = dlsch->current_harq_pid[phy_vars_ue->current_thread_id[subframe]];
+  if (harq_pid >= 8) {
+    printf("dlsch_decoding.c: Illegal harq_pid %d\n",harq_pid);
+    return(max_turbo_iterations);
+  }
+  */
+
+  harq_process->trials[harq_process->round]++;
+
+  A = harq_process->TBS; //2072 for QPSK 1/3
+
+  ret = dlsch->max_turbo_iterations;
+
+
+  G = harq_process->G;
+  //get_G(frame_parms,nb_rb,dlsch->rb_alloc,mod_order,num_pdcch_symbols,phy_vars_ue->frame,subframe);
+
+  //  printf("DLSCH Decoding, harq_pid %d Ndi %d\n",harq_pid,harq_process->Ndi);
+
+  if (harq_process->round == 0) {
+    // This is a new packet, so compute quantities regarding segmentation
+    harq_process->B = A+24;
+    lte_segmentation(NULL,
+                     NULL,
+                     harq_process->B,
+                     &harq_process->C,
+                     &harq_process->Cplus,
+                     &harq_process->Cminus,
+                     &harq_process->Kplus,
+                     &harq_process->Kminus,
+                     &harq_process->F);
+    //  CLEAR LLR's HERE for first packet in process
+  }
+
+  /*
+  else {
+    printf("dlsch_decoding.c: Ndi>0 not checked yet!!\n");
+    return(max_turbo_iterations);
+  }
+  */
+  err_flag = 0;
+  r_offset = 0;
+
+  unsigned char bw_scaling =1;
+
+  switch (frame_parms->N_RB_DL) {
+  case 6:
+    bw_scaling =16;
+    break;
+
+  case 25:
+    bw_scaling =4;
+    break;
+
+  case 50:
+    bw_scaling =2;
+    break;
+
+  default:
+    bw_scaling =1;
+    break;
+  }
+
+  if (harq_process->C > MAX_NUM_DLSCH_SEGMENTS/bw_scaling) {
+    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_DLSCH_SEGMENTS/bw_scaling);
+    return((1+dlsch->max_turbo_iterations));
+  }
+#ifdef DEBUG_DLSCH_DECODING
+  printf("Segmentation: C %d, Cminus %d, Kminus %d, Kplus %d\n",harq_process->C,harq_process->Cminus,harq_process->Kminus,harq_process->Kplus);
+#endif
+
+  opp_enabled=1;
+
+  for (r=0; r<harq_process->C; r++) {
+
+
+    // Get Turbo interleaver parameters
+    if (r<harq_process->Cminus)
+      Kr = harq_process->Kminus;
+    else
+      Kr = harq_process->Kplus;
+
+    Kr_bytes = Kr>>3;
+
+    if (Kr_bytes<=64)
+      iind = (Kr_bytes-5);
+    else if (Kr_bytes <=128)
+      iind = 59 + ((Kr_bytes-64)>>1);
+    else if (Kr_bytes <= 256)
+      iind = 91 + ((Kr_bytes-128)>>2);
+    else if (Kr_bytes <= 768)
+      iind = 123 + ((Kr_bytes-256)>>3);
+    else {
+      printf("dlsch_decoding: Illegal codeword size %d!!!\n",Kr_bytes);
+      return(dlsch->max_turbo_iterations);
+    }
+
+#ifdef DEBUG_DLSCH_DECODING
+    printf("f1 %d, f2 %d, F %d\n",f1f2mat_old[2*iind],f1f2mat_old[1+(2*iind)],(r==0) ? harq_process->F : 0);
+#endif
+
+#if UE_TIMING_TRACE
+    start_meas(dlsch_rate_unmatching_stats);
+#endif
+    memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
+    harq_process->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
+                                            (uint8_t*) &dummy_w[r][0],
+                                            (r==0) ? harq_process->F : 0);
+
+#ifdef DEBUG_DLSCH_DECODING
+    LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n",
+          harq_pid,r, G,
+          Kr*3,
+          harq_process->TBS,
+          harq_process->Qm,
+          harq_process->nb_rb,
+          harq_process->Nl,
+          harq_process->rvidx,
+          harq_process->round);
+#endif
+
+#ifdef DEBUG_DLSCH_DECODING
+    printf(" in decoding dlsch->harq_processes[harq_pid]->rvidx = %d\n", dlsch->harq_processes[harq_pid]->rvidx);
+#endif
+    if (lte_rate_matching_turbo_rx(harq_process->RTC[r],
+                                   G,
+                                   harq_process->w[r],
+                                   (uint8_t*)&dummy_w[r][0],
+                                   dlsch_llr+r_offset,
+                                   harq_process->C,
+                                   dlsch->Nsoft,
+                                   dlsch->Mdlharq,
+                                   dlsch->Kmimo,
+                                   harq_process->rvidx,
+                                   (harq_process->round==0)?1:0,
+                                   harq_process->Qm,
+                                   harq_process->Nl,
+                                   r,
+                                   &E)==-1) {
+#if UE_TIMING_TRACE
+      stop_meas(dlsch_rate_unmatching_stats);
+#endif
+      LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n");
+      return(dlsch->max_turbo_iterations);
+    } else
+    {
+#if UE_TIMING_TRACE
+      stop_meas(dlsch_rate_unmatching_stats);
+#endif
+    }
+    r_offset += E;
+
+    /*
+    printf("Subblock deinterleaving, d %p w %p\n",
+     harq_process->d[r],
+     harq_process->w);
+    */
+#if UE_TIMING_TRACE
+    start_meas(dlsch_deinterleaving_stats);
+#endif
+    sub_block_deinterleaving_turbo(4+Kr,
+                                   &harq_process->d[r][96],
+
+                                   harq_process->w[r]);
+#if UE_TIMING_TRACE
+    stop_meas(dlsch_deinterleaving_stats);
+#endif
+#ifdef DEBUG_DLSCH_DECODING
+    /*
+    if (r==0) {
+              write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0);
+              write_output("decoder_in.m","dec",&harq_process->d[0][96],(3*8*Kr_bytes)+12,1,0);
+    }
+
+    printf("decoder input(segment %d) :",r);
+    int i; for (i=0;i<(3*8*Kr_bytes)+12;i++)
+      printf("%d : %d\n",i,harq_process->d[r][96+i]);
+      printf("\n");*/
+#endif
+
+
+    //    printf("Clearing c, %p\n",harq_process->c[r]);
+    memset(harq_process->c[r],0,Kr_bytes);
+
+    //    printf("done\n");
+    if (harq_process->C == 1)
+      crc_type = CRC24_A;
+    else
+      crc_type = CRC24_B;
+
+    /*
+    printf("decoder input(segment %d)\n",r);
+    for (i=0;i<(3*8*Kr_bytes)+12;i++)
+      if ((harq_process->d[r][96+i]>7) ||
+    (harq_process->d[r][96+i] < -8))
+    printf("%d : %d\n",i,harq_process->d[r][96+i]);
+    printf("\n");
+    */
+
+    //#ifndef __AVX2__
+#if 1
+    if (err_flag == 0) {
+/*
+        LOG_I(PHY, "turbo algo Kr=%d cb_cnt=%d C=%d nbRB=%d crc_type %d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d maxIter %d\n",
+                            Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS,
+                            harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_turbo_iterations);
+*/
+    	if (llr8_flag) {
+    		AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n",
+    				Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round);
+    	}
+#if UE_TIMING_TRACE
+        start_meas(dlsch_turbo_decoding_stats);
+#endif
+      LOG_D(PHY,"AbsSubframe %d.%d Start turbo segment %d/%d \n",frame%1024,subframe,r,harq_process->C-1);
+      ret = tc
+            (&harq_process->d[r][96],
+             NULL,
+             harq_process->c[r],
+             NULL,
+             Kr,
+             f1f2mat_old[iind*2],
+             f1f2mat_old[(iind*2)+1],
+             dlsch->max_turbo_iterations,
+             crc_type,
+             (r==0) ? harq_process->F : 0,
+             &phy_vars_ue->dlsch_tc_init_stats,
+             &phy_vars_ue->dlsch_tc_alpha_stats,
+             &phy_vars_ue->dlsch_tc_beta_stats,
+             &phy_vars_ue->dlsch_tc_gamma_stats,
+             &phy_vars_ue->dlsch_tc_ext_stats,
+             &phy_vars_ue->dlsch_tc_intl1_stats,
+             &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+
+#if UE_TIMING_TRACE
+      stop_meas(dlsch_turbo_decoding_stats);
+#endif
+    }
+#else
+    if ((harq_process->C == 1) ||
+	((r==harq_process->C-1) && (skipped_last==0))) { // last segment with odd number of segments
+
+#if UE_TIMING_TRACE
+        start_meas(dlsch_turbo_decoding_stats);
+#endif
+      ret = tc
+            (&harq_process->d[r][96],
+             harq_process->c[r],
+             Kr,
+             f1f2mat_old[iind*2],
+             f1f2mat_old[(iind*2)+1],
+             dlsch->max_turbo_iterations,
+             crc_type,
+             (r==0) ? harq_process->F : 0,
+             &phy_vars_ue->dlsch_tc_init_stats,
+             &phy_vars_ue->dlsch_tc_alpha_stats,
+             &phy_vars_ue->dlsch_tc_beta_stats,
+             &phy_vars_ue->dlsch_tc_gamma_stats,
+             &phy_vars_ue->dlsch_tc_ext_stats,
+             &phy_vars_ue->dlsch_tc_intl1_stats,
+             &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+ #if UE_TIMING_TRACE
+      stop_meas(dlsch_turbo_decoding_stats);
+#endif
+      //      printf("single decode, exit\n");
+      //      exit(-1);
+    }
+    else {
+    // we can merge code segments
+      if ((skipped_last == 0) && (r<harq_process->C-1)) {
+	skipped_last = 1;
+	Kr_last = Kr;
+      }
+      else {
+	skipped_last=0;
+
+	if (Kr_last == Kr) { // decode 2 code segments with AVX2 version
+#ifdef DEBUG_DLSCH_DECODING
+	  printf("single decoding segment %d (%p)\n",r-1,&harq_process->d[r-1][96]);
+#endif
+#if UE_TIMING_TRACE
+	  start_meas(dlsch_turbo_decoding_stats);
+#endif
+#ifdef DEBUG_DLSCH_DECODING
+	  printf("double decoding segments %d,%d (%p,%p)\n",r-1,r,&harq_process->d[r-1][96],&harq_process->d[r][96]);
+#endif
+	  ret = tc_2cw
+            (&harq_process->d[r-1][96],
+	     &harq_process->d[r][96],
+             harq_process->c[r-1],
+             harq_process->c[r],
+             Kr,
+             f1f2mat_old[iind*2],
+             f1f2mat_old[(iind*2)+1],
+             dlsch->max_turbo_iterations,
+             crc_type,
+             (r==0) ? harq_process->F : 0,
+             &phy_vars_ue->dlsch_tc_init_stats,
+             &phy_vars_ue->dlsch_tc_alpha_stats,
+             &phy_vars_ue->dlsch_tc_beta_stats,
+             &phy_vars_ue->dlsch_tc_gamma_stats,
+             &phy_vars_ue->dlsch_tc_ext_stats,
+             &phy_vars_ue->dlsch_tc_intl1_stats,
+             &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+	  /*
+	  ret = tc
+            (&harq_process->d[r-1][96],
+             harq_process->c[r-1],
+             Kr_last,
+             f1f2mat_old[iind*2],
+             f1f2mat_old[(iind*2)+1],
+             dlsch->max_turbo_iterations,
+             crc_type,
+             (r==0) ? harq_process->F : 0,
+             &phy_vars_ue->dlsch_tc_init_stats,
+             &phy_vars_ue->dlsch_tc_alpha_stats,
+             &phy_vars_ue->dlsch_tc_beta_stats,
+             &phy_vars_ue->dlsch_tc_gamma_stats,
+             &phy_vars_ue->dlsch_tc_ext_stats,
+             &phy_vars_ue->dlsch_tc_intl1_stats,
+             &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+
+	     exit(-1);*/
+#if UE_TIMING_TRACE
+      stop_meas(dlsch_turbo_decoding_stats);
+#endif
+	}
+	else { // Kr_last != Kr
+#if UE_TIMING_TRACE
+	  start_meas(dlsch_turbo_decoding_stats);
+#endif
+	  ret = tc
+            (&harq_process->d[r-1][96],
+             harq_process->c[r-1],
+             Kr_last,
+             f1f2mat_old[iind*2],
+             f1f2mat_old[(iind*2)+1],
+             dlsch->max_turbo_iterations,
+             crc_type,
+             (r==0) ? harq_process->F : 0,
+             &phy_vars_ue->dlsch_tc_init_stats,
+             &phy_vars_ue->dlsch_tc_alpha_stats,
+             &phy_vars_ue->dlsch_tc_beta_stats,
+             &phy_vars_ue->dlsch_tc_gamma_stats,
+             &phy_vars_ue->dlsch_tc_ext_stats,
+             &phy_vars_ue->dlsch_tc_intl1_stats,
+             &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+#if UE_TIMING_TRACE
+      stop_meas(dlsch_turbo_decoding_stats);
+
+	  start_meas(dlsch_turbo_decoding_stats);
+#endif
+
+	  ret = tc
+            (&harq_process->d[r][96],
+             harq_process->c[r],
+             Kr,
+             f1f2mat_old[iind*2],
+             f1f2mat_old[(iind*2)+1],
+             dlsch->max_turbo_iterations,
+             crc_type,
+             (r==0) ? harq_process->F : 0,
+             &phy_vars_ue->dlsch_tc_init_stats,
+             &phy_vars_ue->dlsch_tc_alpha_stats,
+             &phy_vars_ue->dlsch_tc_beta_stats,
+             &phy_vars_ue->dlsch_tc_gamma_stats,
+             &phy_vars_ue->dlsch_tc_ext_stats,
+             &phy_vars_ue->dlsch_tc_intl1_stats,
+             &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+
+#if UE_TIMING_TRACE
+
+	  stop_meas(dlsch_turbo_decoding_stats);
+
+	  /*printf("Segmentation: C %d r %d, dlsch_rate_unmatching_stats %5.3f dlsch_deinterleaving_stats %5.3f  dlsch_turbo_decoding_stats %5.3f \n",
+              harq_process->C,
+              r,
+              dlsch_rate_unmatching_stats->p_time/(cpuf*1000.0),
+              dlsch_deinterleaving_stats->p_time/(cpuf*1000.0),
+              dlsch_turbo_decoding_stats->p_time/(cpuf*1000.0));*/
+#endif
+	}
+      }
+    }
+#endif
+
+
+    if ((err_flag == 0) && (ret>=(1+dlsch->max_turbo_iterations))) {// a Code segment is in error so break;
+      LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,subframe,r,harq_process->C-1);
+      err_flag = 1;
+    }
+  }
+
+  int32_t frame_rx_prev = frame;
+  int32_t subframe_rx_prev = subframe - 1;
+  if (subframe_rx_prev < 0) {
+    frame_rx_prev--;
+    subframe_rx_prev += 10;
+  }
+  frame_rx_prev = frame_rx_prev%1024;
+
+  if (err_flag == 1) {
+#if UE_DEBUG_TRACE
+    LOG_I(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n",
+        phy_vars_ue->Mod_id, frame, subframe, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round);
+#endif
+    dlsch->harq_ack[subframe].ack = 0;
+    dlsch->harq_ack[subframe].harq_id = harq_pid;
+    dlsch->harq_ack[subframe].send_harq_status = 1;
+    harq_process->errors[harq_process->round]++;
+    harq_process->round++;
+
+
+    //    printf("Rate: [UE %d] DLSCH: Setting NACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round);
+    if (harq_process->round >= dlsch->Mdlharq) {
+      harq_process->status = SCH_IDLE;
+      harq_process->round  = 0;
+    }
+    if(is_crnti)
+    {
+    LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for subframe %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
+               phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS);
+    }
+
+    return((1+dlsch->max_turbo_iterations));
+  } else {
+#if UE_DEBUG_TRACE
+      LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d TBS %d mcs %d nb_rb %d\n",
+           phy_vars_ue->Mod_id,subframe,harq_process->TBS,harq_process->mcs,harq_process->nb_rb);
+#endif
+
+    harq_process->status = SCH_IDLE;
+    harq_process->round  = 0;
+    dlsch->harq_ack[subframe].ack = 1;
+    dlsch->harq_ack[subframe].harq_id = harq_pid;
+    dlsch->harq_ack[subframe].send_harq_status = 1;
+    //LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n",
+      //  phy_vars_ue->Mod_id, frame, subframe, harq_pid, harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs);
+
+    if(is_crnti)
+    {
+    LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round,harq_process->TBS);
+    }
+    //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round);
+
+  }
+
+  // Reassembly of Transport block here
+  offset = 0;
+
+  /*
+  printf("harq_pid %d\n",harq_pid);
+  printf("F %d, Fbytes %d\n",harq_process->F,harq_process->F>>3);
+  printf("C %d\n",harq_process->C);
+  */
+  for (r=0; r<harq_process->C; r++) {
+    if (r<harq_process->Cminus)
+      Kr = harq_process->Kminus;
+    else
+      Kr = harq_process->Kplus;
+
+    Kr_bytes = Kr>>3;
+
+    //    printf("Segment %d : Kr= %d bytes\n",r,Kr_bytes);
+    if (r==0) {
+      memcpy(harq_process->b,
+             &harq_process->c[0][(harq_process->F>>3)],
+             Kr_bytes - (harq_process->F>>3)- ((harq_process->C>1)?3:0));
+      offset = Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0);
+      //            printf("copied %d bytes to b sequence (harq_pid %d)\n",
+      //          Kr_bytes - (harq_process->F>>3),harq_pid);
+      //          printf("b[0] = %x,c[%d] = %x\n",
+      //      harq_process->b[0],
+      //      harq_process->F>>3,
+      //      harq_process->c[0][(harq_process->F>>3)]);
+    } else {
+      memcpy(harq_process->b+offset,
+             harq_process->c[r],
+             Kr_bytes- ((harq_process->C>1)?3:0));
+      offset += (Kr_bytes - ((harq_process->C>1)?3:0));
+    }
+  }
+
+  dlsch->last_iteration_cnt = ret;
+
+  return(ret);
+}
+
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
new file mode 100644
index 0000000000000000000000000000000000000000..6284f279d895d04590cf44ca3d792c1fcda40f47
--- /dev/null
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
@@ -0,0 +1,6155 @@
+/*
+ * 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/dlsch_demodulation.c
+ * \brief Top-level routines for demodulating the PDSCH physical channel from 36-211, V8.6 2009-03
+ * \author R. Knopp, F. Kaltenberger,A. Bhamri, S. Aubert, X. Xiang
+ * \date 2011
+ * \version 0.1
+ * \company Eurecom
+ * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,ankit.bhamri@eurecom.fr,sebastien.aubert@eurecom.fr
+ * \note
+ * \warning
+ */
+//#include "PHY/defs.h"
+#include "PHY/extern.h"
+#include "SCHED/defs.h"
+#include "defs.h"
+#include "extern.h"
+#include "PHY/sse_intrin.h"
+#include "T.h"
+
+#define NOCYGWIN_STATIC
+
+/* dynamic shift for LLR computation for TM3/4
+ * set as command line argument, see lte-softmodem.c
+ * default value: 0
+ */
+int16_t dlsch_demod_shift = 0;
+int16_t interf_unaw_shift = 13;
+
+//#define DEBUG_HARQ
+
+#define DEBUG_PHY 1
+//#define DEBUG_DLSCH_DEMOD 1
+
+//#define DISABLE_LOG_X
+
+// [MCS][i_mod (0,1,2) = (2,4,6)]
+unsigned char offset_mumimo_llr_drange_fix=0;
+//inferference-free case
+unsigned char interf_unaw_shift_tm4_mcs[29]={5, 3, 4, 3, 3, 2, 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
+                                             1, 1, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 0} ;
+unsigned char interf_unaw_shift_tm1_mcs[29]={5, 5, 4, 3, 3, 3, 2, 2, 4, 4, 2, 3, 3, 3, 1, 1,
+                                             0, 1, 1, 2, 5, 4, 4, 6, 5, 1, 0, 5, 6} ; // mcs 21, 26, 28 seem to be errorneous
+
+/*
+//original values from sebastion + same hand tuning
+unsigned char offset_mumimo_llr_drange[29][3]={{8,8,8},{7,7,7},{7,7,7},{7,7,7},{6,6,6},{6,6,6},{6,6,6},{5,5,5},{4,4,4},{1,2,4}, // QPSK
+{5,5,4},{5,5,5},{5,5,5},{3,3,3},{2,2,2},{2,2,2},{2,2,2}, // 16-QAM
+{2,2,1},{3,3,3},{3,3,3},{3,3,1},{2,2,2},{2,2,2},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; //64-QAM
+*/
+ /*
+ //first optimization try
+ unsigned char offset_mumimo_llr_drange[29][3]={{7, 8, 7},{6, 6, 7},{6, 6, 7},{6, 6, 6},{5, 6, 6},{5, 5, 6},{5, 5, 6},{4, 5, 4},{4, 3, 4},{3, 2, 2},{6, 5, 5},{5, 4, 4},{5, 5, 4},{3, 3, 2},{2, 2, 1},{2, 1, 1},{2, 2, 2},{3, 3, 3},{3, 3, 2},{3, 3, 2},{3, 2, 1},{2, 2, 2},{2, 2, 2},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};
+ */
+ //second optimization try
+ /*
+   unsigned char offset_mumimo_llr_drange[29][3]={{5, 8, 7},{4, 6, 8},{3, 6, 7},{7, 7, 6},{4, 7, 8},{4, 7, 4},{6, 6, 6},{3, 6, 6},{3, 6, 6},{1, 3, 4},{1, 1, 0},{3, 3, 2},{3, 4, 1},{4, 0, 1},{4, 2, 2},{3, 1, 2},{2, 1, 0},{2, 1, 1},{1, 0, 1},{1, 0, 1},{0, 0, 0},{1, 0, 0},{0, 0, 0},{0, 1, 0},{1, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};  w
+ */
+unsigned char offset_mumimo_llr_drange[29][3]= {{0, 6, 5},{0, 4, 5},{0, 4, 5},{0, 5, 4},{0, 5, 6},{0, 5, 3},{0, 4, 4},{0, 4, 4},{0, 3, 3},{0, 1, 2},{1, 1, 0},{1, 3, 2},{3, 4, 1},{2, 0, 0},{2, 2, 2},{1, 1, 1},{2, 1, 0},{2, 1, 1},{1, 0, 1},{1, 0, 1},{0, 0, 0},{1, 0, 0},{0, 0, 0},{0, 1, 0},{1, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};
+
+
+extern void print_shorts(char *s,int16_t *x);
+
+
+int rx_pdsch(PHY_VARS_UE *ue,
+             PDSCH_t type,
+             unsigned char eNB_id,
+             unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference
+             uint32_t frame,
+             uint8_t subframe,
+             unsigned char symbol,
+             unsigned char first_symbol_flag,
+             RX_type_t rx_type,
+             unsigned char i_mod,
+             unsigned char harq_pid)
+{
+
+  LTE_UE_COMMON *common_vars  = &ue->common_vars;
+  LTE_UE_PDSCH **pdsch_vars;
+  LTE_DL_FRAME_PARMS *frame_parms    = &ue->frame_parms;
+  PHY_MEASUREMENTS *measurements = &ue->measurements;
+  LTE_UE_DLSCH_t   **dlsch;
+
+  int avg[4];
+  int avg_0[2];
+  int avg_1[2];
+
+#if UE_TIMING_TRACE
+  uint8_t slot = 0;
+#endif
+
+  unsigned char aatx,aarx;
+
+  unsigned short nb_rb = 0, round;
+  int avgs = 0, rb;
+  LTE_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0;
+
+  uint8_t beamforming_mode;
+  uint32_t *rballoc;
+
+  int32_t **rxdataF_comp_ptr;
+  int32_t **dl_ch_mag_ptr;
+  int32_t codeword_TB0 = -1;
+  int32_t codeword_TB1 = -1;
+
+
+
+  switch (type) {
+  case SI_PDSCH:
+    pdsch_vars = &ue->pdsch_vars_SI[eNB_id];
+    dlsch = &ue->dlsch_SI[eNB_id];
+    dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
+    beamforming_mode  = 0;
+    break;
+
+  case RA_PDSCH:
+    pdsch_vars = &ue->pdsch_vars_ra[eNB_id];
+    dlsch = &ue->dlsch_ra[eNB_id];
+    dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
+    beamforming_mode  = 0;
+    break;
+
+  case PDSCH:
+    pdsch_vars = ue->pdsch_vars[ue->current_thread_id[subframe]];
+    dlsch = ue->dlsch[ue->current_thread_id[subframe]][eNB_id];
+    //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status);
+    LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d,  harq status %d.%d \n",
+                   frame,subframe,symbol,harq_pid,
+                   dlsch[0]->harq_processes[harq_pid]->status,
+                   dlsch[1]->harq_processes[harq_pid]->status);
+
+    if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
+        (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE)){
+      codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
+      codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
+      dlsch0_harq = dlsch[codeword_TB0]->harq_processes[harq_pid];
+      dlsch1_harq = dlsch[codeword_TB1]->harq_processes[harq_pid];
+#ifdef DEBUG_HARQ
+      printf("[DEMOD] I am assuming both TBs are active\n");
+#endif
+    }
+     else if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
+              (dlsch[1]->harq_processes[harq_pid]->status != ACTIVE) ) {
+      codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
+      dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
+      dlsch1_harq = NULL;
+      codeword_TB1 = -1;
+#ifdef DEBUG_HARQ
+      printf("[DEMOD] I am assuming only TB0 is active\n");
+#endif
+    }
+     else if ((dlsch[0]->harq_processes[harq_pid]->status != ACTIVE) &&
+              (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE) ){
+      codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
+      dlsch0_harq  = dlsch[1]->harq_processes[harq_pid];
+      dlsch1_harq  = NULL;
+      codeword_TB0 = -1;
+#ifdef DEBUG_HARQ
+      printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", dlsch0_harq->codeword);
+#endif
+    }
+    else {
+      LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: no active DLSCH\n",ue->proc.proc_rxtx[0].frame_rx,subframe);
+      return(-1);
+    }
+    beamforming_mode  = ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id];
+    break;
+
+  default:
+    LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: Unknown PDSCH format %d\n",ue->proc.proc_rxtx[0].frame_rx,subframe,type);
+    return(-1);
+    break;
+  }
+#ifdef DEBUG_HARQ
+  printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode);
+  printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1);
+#endif
+
+  DevAssert(dlsch0_harq);
+  round = dlsch0_harq->round;
+  //printf("round = %d\n", round);
+
+  if (eNB_id > 2) {
+    LOG_W(PHY,"dlsch_demodulation.c: Illegal eNB_id %d\n",eNB_id);
+    return(-1);
+  }
+
+  if (!common_vars) {
+    LOG_W(PHY,"dlsch_demodulation.c: Null common_vars\n");
+    return(-1);
+  }
+
+  if (!dlsch[0]) {
+    LOG_W(PHY,"dlsch_demodulation.c: Null dlsch_ue pointer\n");
+    return(-1);
+  }
+
+  if (!pdsch_vars) {
+    LOG_W(PHY,"dlsch_demodulation.c: Null pdsch_vars pointer\n");
+    return(-1);
+  }
+
+  if (!frame_parms) {
+    LOG_W(PHY,"dlsch_demodulation.c: Null frame_parms\n");
+    return(-1);
+  }
+
+  if (((frame_parms->Ncp == NORMAL) && (symbol>=7)) ||
+      ((frame_parms->Ncp == EXTENDED) && (symbol>=6)))
+    rballoc = dlsch0_harq->rb_alloc_odd;
+  else
+    rballoc = dlsch0_harq->rb_alloc_even;
+
+
+  if (dlsch0_harq->mimo_mode>DUALSTREAM_PUSCH_PRECODING) {
+    LOG_E(PHY,"This transmission mode is not yet supported!\n");
+    return(-1);
+  }
+
+
+  if ((dlsch0_harq->mimo_mode==LARGE_CDD) || ((dlsch0_harq->mimo_mode>=DUALSTREAM_UNIFORM_PRECODING1) && (dlsch0_harq->mimo_mode<=DUALSTREAM_PUSCH_PRECODING)))  {
+    DevAssert(dlsch1_harq);
+    if (eNB_id!=eNB_id_i) {
+      LOG_E(PHY,"TM3/TM4 requires to set eNB_id==eNB_id_i!\n");
+      return(-1);
+    }
+  }
+
+#if UE_TIMING_TRACE
+  if(symbol > ue->frame_parms.symbols_per_tti>>1)
+  {
+      slot = 1;
+  }
+#endif
+
+#ifdef DEBUG_HARQ
+  printf("Demod  dlsch0_harq->pmi_alloc %d\n",  dlsch0_harq->pmi_alloc);
+#endif
+
+  if (frame_parms->nb_antenna_ports_eNB>1 && beamforming_mode==0) {
+#ifdef DEBUG_DLSCH_MOD
+    LOG_I(PHY,"dlsch: using pmi %x (%p), rb_alloc %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),dlsch[0],dlsch0_harq->rb_alloc_even[0]);
+#endif
+
+#if UE_TIMING_TRACE
+    start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#endif
+    nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+                                   common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+                                   pdsch_vars[eNB_id]->rxdataF_ext,
+                                   pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                   dlsch0_harq->pmi_alloc,
+                                   pdsch_vars[eNB_id]->pmi_ext,
+                                   rballoc,
+                                   symbol,
+                                   subframe,
+                                   ue->high_speed_flag,
+                                   frame_parms,
+                                   dlsch0_harq->mimo_mode);
+#ifdef DEBUG_DLSCH_MOD
+      printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc);
+       for (rb=0;rb<nb_rb;rb++)
+          printf("%d",pdsch_vars[eNB_id]->pmi_ext[rb]);
+       printf("\n");
+#endif
+
+   if (rx_type >= rx_IC_single_stream) {
+      if (eNB_id_i<ue->n_connected_eNB) // we are in TM5
+      nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+                                       common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id_i],
+                                       pdsch_vars[eNB_id_i]->rxdataF_ext,
+                                       pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                       dlsch0_harq->pmi_alloc,
+                                       pdsch_vars[eNB_id_i]->pmi_ext,
+                                       rballoc,
+                                       symbol,
+                                       subframe,
+                                       ue->high_speed_flag,
+                                       frame_parms,
+                                       dlsch0_harq->mimo_mode);
+      else
+        nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+                                       common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+                                       pdsch_vars[eNB_id_i]->rxdataF_ext,
+                                       pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                       dlsch0_harq->pmi_alloc,
+                                       pdsch_vars[eNB_id_i]->pmi_ext,
+                                       rballoc,
+                                       symbol,
+                                       subframe,
+                                       ue->high_speed_flag,
+                                       frame_parms,
+                                       dlsch0_harq->mimo_mode);
+    }
+  } else if (beamforming_mode==0) { //else if nb_antennas_ports_eNB==1 && beamforming_mode == 0
+    nb_rb = dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+                                     common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+                                     pdsch_vars[eNB_id]->rxdataF_ext,
+                                     pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                     dlsch0_harq->pmi_alloc,
+                                     pdsch_vars[eNB_id]->pmi_ext,
+                                     rballoc,
+                                     symbol,
+                                     subframe,
+                                     ue->high_speed_flag,
+                                     frame_parms);
+
+   if (rx_type==rx_IC_single_stream) {
+     if (eNB_id_i<ue->n_connected_eNB)
+        nb_rb = dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+                                         common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id_i],
+                                         pdsch_vars[eNB_id_i]->rxdataF_ext,
+                                         pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                         dlsch0_harq->pmi_alloc,
+                                         pdsch_vars[eNB_id_i]->pmi_ext,
+                                         rballoc,
+                                         symbol,
+                                         subframe,
+                                         ue->high_speed_flag,
+                                         frame_parms);
+      else
+        nb_rb = dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+                                         common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+                                         pdsch_vars[eNB_id_i]->rxdataF_ext,
+                                         pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                         dlsch0_harq->pmi_alloc,
+                                         pdsch_vars[eNB_id_i]->pmi_ext,
+                                         rballoc,
+                                         symbol,
+                                         subframe,
+                                         ue->high_speed_flag,
+                                         frame_parms);
+    }
+  } else if (beamforming_mode==7) { //else if beamforming_mode == 7
+    nb_rb = dlsch_extract_rbs_TM7(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+                                  pdsch_vars[eNB_id]->dl_bf_ch_estimates,
+                                  pdsch_vars[eNB_id]->rxdataF_ext,
+                                  pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
+                                  rballoc,
+                                  symbol,
+                                  subframe,
+                                  ue->high_speed_flag,
+                                  frame_parms);
+
+  } else if(beamforming_mode>7) {
+    LOG_W(PHY,"dlsch_demodulation: beamforming mode not supported yet.\n");
+  }
+
+  //printf("nb_rb = %d, eNB_id %d\n",nb_rb,eNB_id);
+  if (nb_rb==0) {
+    //    LOG_D(PHY,"dlsch_demodulation.c: nb_rb=0\n");
+    return(-1);
+  }
+
+
+#if UE_TIMING_TRACE
+    stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#if DISABLE_LOG_X
+    printf("[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,
+            symbol,ue->high_speed_flag,type,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#else
+    LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction  %5.2f \n",frame,subframe,slot,symbol,
+            ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#endif
+#endif
+
+
+#if UE_TIMING_TRACE
+    start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#endif
+  aatx = frame_parms->nb_antenna_ports_eNB;
+  aarx = frame_parms->nb_antennas_rx;
+
+  dlsch_scale_channel(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                      frame_parms,
+                      dlsch,
+                      symbol,
+                      nb_rb);
+
+  if ((dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) &&
+      (rx_type==rx_IC_single_stream) &&
+      (eNB_id_i==ue->n_connected_eNB) &&
+      (dlsch0_harq->dl_power_off==0)
+     )  // TM5 two-user
+  {
+    dlsch_scale_channel(pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                        frame_parms,
+                        dlsch,
+                        symbol,
+                        nb_rb);
+  }
+
+#if UE_TIMING_TRACE
+    stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#if DISABLE_LOG_X
+    printf("[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#else
+    LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale  %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#endif
+#endif
+
+#if UE_TIMING_TRACE
+    start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#endif
+  if (first_symbol_flag==1) {
+    if (beamforming_mode==0){
+      if (dlsch0_harq->mimo_mode<LARGE_CDD) {
+        dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                           frame_parms,
+                           avg,
+                           symbol,
+                           nb_rb);
+        avgs = 0;
+        for (aatx=0;aatx<frame_parms->nb_antenna_ports_eNB;aatx++)
+          for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
+            avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
+
+        pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2)+1;
+     }
+     else if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
+           ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
+            (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING)))
+     {
+      dlsch_channel_level_TM34(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                 frame_parms,
+                                 pdsch_vars[eNB_id]->pmi_ext,
+                                 avg_0,
+                                 avg_1,
+                                 symbol,
+                                 nb_rb,
+                                 dlsch0_harq->mimo_mode);
+
+      LOG_D(PHY,"Channel Level TM34  avg_0 %d, avg_1 %d, rx_type %d, rx_standard %d, dlsch_demod_shift %d \n", avg_0[0],
+              avg_1[0], rx_type, rx_standard, dlsch_demod_shift);
+        if (rx_type>rx_standard) {
+          avg_0[0] = (log2_approx(avg_0[0])/2) + dlsch_demod_shift;// + 2 ;//+ 4;
+          avg_1[0] = (log2_approx(avg_1[0])/2) + dlsch_demod_shift;// + 2 ;//+ 4;
+          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
+          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
+         // printf("dlsch_demod_shift  %d\n", dlsch_demod_shift);
+         }
+          else {
+          avg_0[0] = (log2_approx(avg_0[0])/2) - 13 + interf_unaw_shift;
+          avg_1[0] = (log2_approx(avg_1[0])/2) - 13 + interf_unaw_shift;
+          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
+          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
+        }
+      }
+      else if (dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) {// single-layer precoding (TM5, TM6)
+        if ((rx_type==rx_IC_single_stream) && (eNB_id_i==ue->n_connected_eNB) && (dlsch0_harq->dl_power_off==0)) {
+            dlsch_channel_level_TM56(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                frame_parms,
+                                pdsch_vars[eNB_id]->pmi_ext,
+                                avg,
+                                symbol,
+                                nb_rb);
+            avg[0] = log2_approx(avg[0]) - 13 + offset_mumimo_llr_drange[dlsch0_harq->mcs][(i_mod>>1)-1];
+            pdsch_vars[eNB_id]->log2_maxh = cmax(avg[0],0);
+
+        }
+        else if (dlsch0_harq->dl_power_off==1) { //TM6
+
+          dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                   frame_parms,
+                                   avg,
+                                   symbol,
+                                   nb_rb);
+
+          avgs = 0;
+          for (aatx=0;aatx<frame_parms->nb_antenna_ports_eNB;aatx++)
+            for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
+              avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
+
+          pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1;
+          pdsch_vars[eNB_id]->log2_maxh++;
+
+        }
+      }
+
+    }
+    else if (beamforming_mode==7)
+       dlsch_channel_level_TM7(pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
+                              frame_parms,
+                              avg,
+                              symbol,
+                              nb_rb);
+#ifdef UE_DEBUG_TRACE
+    LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n",
+            frame%1024,subframe, pdsch_vars[eNB_id]->log2_maxh,
+                                                 pdsch_vars[eNB_id]->log2_maxh0,
+                                                 pdsch_vars[eNB_id]->log2_maxh1,
+                                                 avg[0],avgs);
+    //LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
+#endif
+
+    //wait until pdcch is decoded
+    //proc->channel_level = 1;
+  }
+
+  /*
+  uint32_t wait = 0;
+  while(proc->channel_level == 0)
+  {
+      usleep(1);
+      wait++;
+  }
+  */
+
+#if T_TRACER
+    if (type == PDSCH)
+    {
+      T(T_UE_PHY_PDSCH_ENERGY, T_INT(eNB_id), T_INT(frame%1024), T_INT(subframe),
+                               T_INT(avg[0]), T_INT(avg[1]),     T_INT(avg[2]),   T_INT(avg[3]));
+    }
+#endif
+
+#if UE_TIMING_TRACE
+    stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#if DISABLE_LOG_X
+    printf("[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#else
+    LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level  %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#endif
+#endif
+
+
+#if UE_TIMING_TRACE
+    start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#endif
+// Now channel compensation
+  if (dlsch0_harq->mimo_mode<LARGE_CDD) {
+    dlsch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext,
+                               pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                               pdsch_vars[eNB_id]->dl_ch_mag0,
+                               pdsch_vars[eNB_id]->dl_ch_magb0,
+                               pdsch_vars[eNB_id]->rxdataF_comp0,
+                               (aatx>1) ? pdsch_vars[eNB_id]->rho : NULL,
+                               frame_parms,
+                               symbol,
+                               first_symbol_flag,
+                               dlsch0_harq->Qm,
+                               nb_rb,
+                               pdsch_vars[eNB_id]->log2_maxh,
+                               measurements); // log2_maxh+I0_shift
+ /*if (symbol == 5) {
+     write_output("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+ } */
+    if ((rx_type==rx_IC_single_stream) &&
+        (eNB_id_i<ue->n_connected_eNB)) {
+         dlsch_channel_compensation(pdsch_vars[eNB_id_i]->rxdataF_ext,
+                                 pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                 pdsch_vars[eNB_id_i]->dl_ch_mag0,
+                                 pdsch_vars[eNB_id_i]->dl_ch_magb0,
+                                 pdsch_vars[eNB_id_i]->rxdataF_comp0,
+                                 (aatx>1) ? pdsch_vars[eNB_id_i]->rho : NULL,
+                                 frame_parms,
+                                 symbol,
+                                 first_symbol_flag,
+                                 i_mod,
+                                 nb_rb,
+                                 pdsch_vars[eNB_id]->log2_maxh,
+                                 measurements); // log2_maxh+I0_shift
+#ifdef DEBUG_PHY
+      if (symbol == 5) {
+        write_output("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+        write_output("rxF_comp_i.m","rxF_c_i",&pdsch_vars[eNB_id_i]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+      }
+#endif
+
+      dlsch_dual_stream_correlation(frame_parms,
+                                    symbol,
+                                    nb_rb,
+                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                    pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                    pdsch_vars[eNB_id]->log2_maxh);
+    }
+  } else if ((dlsch0_harq->mimo_mode == LARGE_CDD) || ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
+            (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){
+      dlsch_channel_compensation_TM34(frame_parms,
+                                     pdsch_vars[eNB_id],
+                                     measurements,
+                                     eNB_id,
+                                     symbol,
+                                     dlsch0_harq->Qm,
+                                     dlsch1_harq->Qm,
+                                     harq_pid,
+                                     dlsch0_harq->round,
+                                     dlsch0_harq->mimo_mode,
+                                     nb_rb,
+                                     pdsch_vars[eNB_id]->log2_maxh0,
+                                     pdsch_vars[eNB_id]->log2_maxh1);
+  /*   if (symbol == 5) {
+     write_output("rxF_comp_d00.m","rxF_c_d00",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
+     write_output("rxF_comp_d01.m","rxF_c_d01",&pdsch_vars[eNB_id]->rxdataF_comp0[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+     write_output("rxF_comp_d10.m","rxF_c_d10",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+     write_output("rxF_comp_d11.m","rxF_c_d11",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
+        } */
+      // compute correlation between signal and interference channels (rho12 and rho21)
+        dlsch_dual_stream_correlation(frame_parms, // this is doing h11'*h12 and h21'*h22
+                                    symbol,
+                                    nb_rb,
+                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                    &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
+                                    pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                                    pdsch_vars[eNB_id]->log2_maxh0);
+        //printf("rho stream1 =%d\n", &pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round] );
+      //to be optimized (just take complex conjugate)
+      dlsch_dual_stream_correlation(frame_parms, // this is doing h12'*h11 and h22'*h21
+                                    symbol,
+                                    nb_rb,
+                                    &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
+                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                    pdsch_vars[eNB_id]->log2_maxh1);
+    //  printf("rho stream2 =%d\n",&pdsch_vars[eNB_id]->dl_ch_rho2_ext );
+      //printf("TM3 log2_maxh : %d\n",pdsch_vars[eNB_id]->log2_maxh);
+  /*     if (symbol == 5) {
+     write_output("rho0_0.m","rho0_0",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
+     write_output("rho2_0.m","rho2_0",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+     write_output("rho0_1.m.m","rho0_1",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+     write_output("rho2_1.m","rho2_1",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
+        } */
+
+    } else if (dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) {// single-layer precoding (TM5, TM6)
+        if ((rx_type==rx_IC_single_stream) && (eNB_id_i==ue->n_connected_eNB) && (dlsch0_harq->dl_power_off==0)) {
+          dlsch_channel_compensation_TM56(pdsch_vars[eNB_id]->rxdataF_ext,
+                                      pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                                      pdsch_vars[eNB_id]->dl_ch_magb0,
+                                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                                      pdsch_vars[eNB_id]->pmi_ext,
+                                      frame_parms,
+                                      measurements,
+                                      eNB_id,
+                                      symbol,
+                                      dlsch0_harq->Qm,
+                                      nb_rb,
+                                      pdsch_vars[eNB_id]->log2_maxh,
+                                      dlsch0_harq->dl_power_off);
+
+        for (rb=0; rb<nb_rb; rb++) {
+          switch(pdsch_vars[eNB_id]->pmi_ext[rb]) {
+          case 0:
+            pdsch_vars[eNB_id_i]->pmi_ext[rb]=1;
+            break;
+         case 1:
+            pdsch_vars[eNB_id_i]->pmi_ext[rb]=0;
+            break;
+         case 2:
+            pdsch_vars[eNB_id_i]->pmi_ext[rb]=3;
+            break;
+          case 3:
+            pdsch_vars[eNB_id_i]->pmi_ext[rb]=2;
+            break;
+          }
+       //  if (rb==0)
+        //    printf("pmi %d, pmi_i %d\n",pdsch_vars[eNB_id]->pmi_ext[rb],pdsch_vars[eNB_id_i]->pmi_ext[rb]);
+      }
+      dlsch_channel_compensation_TM56(pdsch_vars[eNB_id_i]->rxdataF_ext,
+                                      pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                      pdsch_vars[eNB_id_i]->dl_ch_mag0,
+                                      pdsch_vars[eNB_id_i]->dl_ch_magb0,
+                                      pdsch_vars[eNB_id_i]->rxdataF_comp0,
+                                      pdsch_vars[eNB_id_i]->pmi_ext,
+                                      frame_parms,
+                                      measurements,
+                                      eNB_id_i,
+                                      symbol,
+                                      i_mod,
+                                      nb_rb,
+                                      pdsch_vars[eNB_id]->log2_maxh,
+                                      dlsch0_harq->dl_power_off);
+#ifdef DEBUG_PHY
+      if (symbol==5) {
+        write_output("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+       write_output("rxF_comp_i.m","rxF_c_i",&pdsch_vars[eNB_id_i]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+      }
+#endif
+      dlsch_dual_stream_correlation(frame_parms,
+                                    symbol,
+                                    nb_rb,
+                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                    pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
+                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                    pdsch_vars[eNB_id]->log2_maxh);
+    }  else if (dlsch0_harq->dl_power_off==1)  {
+      dlsch_channel_compensation_TM56(pdsch_vars[eNB_id]->rxdataF_ext,
+                                      pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+                                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                                      pdsch_vars[eNB_id]->dl_ch_magb0,
+                                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                                      pdsch_vars[eNB_id]->pmi_ext,
+                                      frame_parms,
+                                      measurements,
+                                      eNB_id,
+                                      symbol,
+                                      dlsch0_harq->Qm,
+                                      nb_rb,
+                                      pdsch_vars[eNB_id]->log2_maxh,
+                                      1);
+
+      }
+
+
+    } else if (dlsch0_harq->mimo_mode==TM7) { //TM7
+
+      dlsch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext,
+                                 pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
+                                 pdsch_vars[eNB_id]->dl_ch_mag0,
+                                 pdsch_vars[eNB_id]->dl_ch_magb0,
+                                 pdsch_vars[eNB_id]->rxdataF_comp0,
+                                 (aatx>1) ? pdsch_vars[eNB_id]->rho : NULL,
+                                 frame_parms,
+                                 symbol,
+                                 first_symbol_flag,
+                                 get_Qm(dlsch0_harq->mcs),
+                                 nb_rb,
+                                 //9,
+                                 pdsch_vars[eNB_id]->log2_maxh,
+                                 measurements); // log2_maxh+I0_shift
+  }
+
+#if UE_TIMING_TRACE
+    stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#if DISABLE_LOG_X
+    printf("[AbsSFN %d.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n",frame,subframe,slot,symbol,pdsch_vars[eNB_id]->log2_maxh,proc->channel_level,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#else
+    LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp  %5.2f \n",frame,subframe,slot,symbol,pdsch_vars[eNB_id]->log2_maxh,proc->channel_level,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#endif
+#endif
+// MRC
+#if UE_TIMING_TRACE
+    start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#endif
+
+   if (frame_parms->nb_antennas_rx > 1) {
+    if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
+        ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
+         (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){  // TM3 or TM4
+      if (frame_parms->nb_antenna_ports_eNB == 2) {
+        dlsch_detection_mrc_TM34(frame_parms,
+                                 pdsch_vars[eNB_id],
+                                 harq_pid,
+                                 dlsch0_harq->round,
+                                 symbol,
+                                 nb_rb,
+                                 1);
+    /*   if (symbol == 5) {
+     write_output("rho0_mrc.m","rho0_0",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
+     write_output("rho2_mrc.m","rho2_0",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+        } */
+      }
+    } else {
+      dlsch_detection_mrc(frame_parms,
+                          pdsch_vars[eNB_id]->rxdataF_comp0,
+                          pdsch_vars[eNB_id_i]->rxdataF_comp0,
+                          pdsch_vars[eNB_id]->rho,
+                          pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                          pdsch_vars[eNB_id]->dl_ch_mag0,
+                          pdsch_vars[eNB_id]->dl_ch_magb0,
+                          pdsch_vars[eNB_id_i]->dl_ch_mag0,
+                          pdsch_vars[eNB_id_i]->dl_ch_magb0,
+                          symbol,
+                          nb_rb,
+                          rx_type==rx_IC_single_stream);
+    }
+  }
+  //  printf("Combining");
+  if ((dlsch0_harq->mimo_mode == SISO) ||
+      ((dlsch0_harq->mimo_mode >= UNIFORM_PRECODING11) &&
+       (dlsch0_harq->mimo_mode <= PUSCH_PRECODING0)) ||
+       (dlsch0_harq->mimo_mode == TM7)) {
+    /*
+      dlsch_siso(frame_parms,
+      pdsch_vars[eNB_id]->rxdataF_comp,
+      pdsch_vars[eNB_id_i]->rxdataF_comp,
+      symbol,
+      nb_rb);
+    */
+  } else if (dlsch0_harq->mimo_mode == ALAMOUTI) {
+    dlsch_alamouti(frame_parms,
+                   pdsch_vars[eNB_id]->rxdataF_comp0,
+                   pdsch_vars[eNB_id]->dl_ch_mag0,
+                   pdsch_vars[eNB_id]->dl_ch_magb0,
+                   symbol,
+                   nb_rb);
+  }
+
+  //    printf("LLR");
+  if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
+      ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
+       (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING)))  {
+    rxdataF_comp_ptr = pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round];
+    dl_ch_mag_ptr = pdsch_vars[eNB_id]->dl_ch_mag1[harq_pid][round];
+  }
+  else {
+    rxdataF_comp_ptr = pdsch_vars[eNB_id_i]->rxdataF_comp0;
+    dl_ch_mag_ptr = pdsch_vars[eNB_id_i]->dl_ch_mag0;
+    //i_mod should have been passed as a parameter
+  }
+
+#if UE_TIMING_TRACE
+    stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#if DISABLE_LOG_X
+    printf("[AbsSFN %d.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#else
+    LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Combine  %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#endif
+#endif
+
+#if UE_TIMING_TRACE
+    start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#endif
+  //printf("LLR dlsch0_harq->Qm %d rx_type %d cw0 %d cw1 %d symbol %d \n",dlsch0_harq->Qm,rx_type,codeword_TB0,codeword_TB1,symbol);
+  // compute LLRs
+  // -> // compute @pointer where llrs should filled for this ofdm-symbol
+  int8_t  *pllr_symbol_cw0;
+  int8_t  *pllr_symbol_cw1;
+  uint32_t llr_offset_symbol;
+  llr_offset_symbol = pdsch_vars[eNB_id]->llr_offset[symbol];
+  pllr_symbol_cw0  = (int8_t*)pdsch_vars[eNB_id]->llr[0];
+  pllr_symbol_cw1  = (int8_t*)pdsch_vars[eNB_id]->llr[1];
+  pllr_symbol_cw0 += llr_offset_symbol;
+  pllr_symbol_cw1 += llr_offset_symbol;
+
+  LOG_I(PHY,"compute LLRs [AbsSubframe %d.%d-%d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %p @LLR Buff(symb) %p\n",
+             frame, subframe,symbol,
+             nb_rb,dlsch0_harq->Qm,
+             pdsch_vars[eNB_id]->llr_length[symbol],
+             pdsch_vars[eNB_id]->llr_offset[symbol],
+             (int16_t*)pdsch_vars[eNB_id]->llr[0],
+             pllr_symbol_cw0);
+
+  switch (dlsch0_harq->Qm) {
+  case 2 :
+    if ((rx_type==rx_standard) || (codeword_TB1 == -1)) {
+
+
+        dlsch_qpsk_llr(frame_parms,
+                       pdsch_vars[eNB_id]->rxdataF_comp0,
+                       (int16_t*)pllr_symbol_cw0,
+                       symbol,
+                       first_symbol_flag,
+                       nb_rb,
+                       adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
+                       beamforming_mode);
+
+    } else if (codeword_TB0 == -1){
+
+        dlsch_qpsk_llr(frame_parms,
+                       pdsch_vars[eNB_id]->rxdataF_comp0,
+                       (int16_t*)pllr_symbol_cw1,
+                       symbol,
+                       first_symbol_flag,
+                       nb_rb,
+                       adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
+                       beamforming_mode);
+    }
+      else if (rx_type >= rx_IC_single_stream) {
+        if (dlsch1_harq->Qm == 2) {
+          dlsch_qpsk_qpsk_llr(frame_parms,
+                              pdsch_vars[eNB_id]->rxdataF_comp0,
+                              rxdataF_comp_ptr,
+                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                              pdsch_vars[eNB_id]->llr[0],
+                              symbol,first_symbol_flag,nb_rb,
+                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
+                              pdsch_vars[eNB_id]->llr128);
+          if (rx_type==rx_IC_dual_stream) {
+            dlsch_qpsk_qpsk_llr(frame_parms,
+                                rxdataF_comp_ptr,
+                                pdsch_vars[eNB_id]->rxdataF_comp0,
+                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                pdsch_vars[eNB_id]->llr[1],
+                                symbol,first_symbol_flag,nb_rb,
+                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
+                                pdsch_vars[eNB_id]->llr128_2ndstream);
+          }
+        }
+        else if (dlsch1_harq->Qm == 4) {
+          dlsch_qpsk_16qam_llr(frame_parms,
+                               pdsch_vars[eNB_id]->rxdataF_comp0,
+                               rxdataF_comp_ptr,//i
+                               dl_ch_mag_ptr,//i
+                               pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                               pdsch_vars[eNB_id]->llr[0],
+                               symbol,first_symbol_flag,nb_rb,
+                               adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
+                               pdsch_vars[eNB_id]->llr128);
+          if (rx_type==rx_IC_dual_stream) {
+            dlsch_16qam_qpsk_llr(frame_parms,
+                                 rxdataF_comp_ptr,
+                                 pdsch_vars[eNB_id]->rxdataF_comp0,//i
+                                 dl_ch_mag_ptr,
+                                 pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                 pdsch_vars[eNB_id]->llr[1],
+                                 symbol,first_symbol_flag,nb_rb,
+                                 adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
+                                 pdsch_vars[eNB_id]->llr128_2ndstream);
+          }
+        }
+        else {
+          dlsch_qpsk_64qam_llr(frame_parms,
+                               pdsch_vars[eNB_id]->rxdataF_comp0,
+                               rxdataF_comp_ptr,//i
+                               dl_ch_mag_ptr,//i
+                               pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                               pdsch_vars[eNB_id]->llr[0],
+                               symbol,first_symbol_flag,nb_rb,
+                               adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
+                               pdsch_vars[eNB_id]->llr128);
+          if (rx_type==rx_IC_dual_stream) {
+            dlsch_64qam_qpsk_llr(frame_parms,
+                                 rxdataF_comp_ptr,
+                                 pdsch_vars[eNB_id]->rxdataF_comp0,//i
+                                 dl_ch_mag_ptr,
+                                 pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                 pdsch_vars[eNB_id]->llr[1],
+                                 symbol,first_symbol_flag,nb_rb,
+                                 adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
+                                 pdsch_vars[eNB_id]->llr128_2ndstream);
+          }
+        }
+      }
+    break;
+  case 4 :
+    if ((rx_type==rx_standard ) || (codeword_TB1 == -1)) {
+      dlsch_16qam_llr(frame_parms,
+                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                      pdsch_vars[eNB_id]->llr[0],
+                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                      symbol,first_symbol_flag,nb_rb,
+                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
+                      pdsch_vars[eNB_id]->llr128,
+                      beamforming_mode);
+    } else if (codeword_TB0 == -1){
+      dlsch_16qam_llr(frame_parms,
+                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                      pdsch_vars[eNB_id]->llr[1],
+                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                      symbol,first_symbol_flag,nb_rb,
+                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
+                      pdsch_vars[eNB_id]->llr128_2ndstream,
+                      beamforming_mode);
+    }
+    else if (rx_type >= rx_IC_single_stream) {
+      if (dlsch1_harq->Qm == 2) {
+        dlsch_16qam_qpsk_llr(frame_parms,
+                             pdsch_vars[eNB_id]->rxdataF_comp0,
+                             rxdataF_comp_ptr,//i
+                             pdsch_vars[eNB_id]->dl_ch_mag0,
+                             pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                             pdsch_vars[eNB_id]->llr[0],
+                             symbol,first_symbol_flag,nb_rb,
+                             adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
+                             pdsch_vars[eNB_id]->llr128);
+        if (rx_type==rx_IC_dual_stream) {
+          dlsch_qpsk_16qam_llr(frame_parms,
+                               rxdataF_comp_ptr,
+                               pdsch_vars[eNB_id]->rxdataF_comp0,//i
+                               pdsch_vars[eNB_id]->dl_ch_mag0,//i
+                               pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                               pdsch_vars[eNB_id]->llr[1],
+                               symbol,first_symbol_flag,nb_rb,
+                               adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
+                               pdsch_vars[eNB_id]->llr128_2ndstream);
+        }
+      }
+      else if (dlsch1_harq->Qm == 4) {
+        dlsch_16qam_16qam_llr(frame_parms,
+                              pdsch_vars[eNB_id]->rxdataF_comp0,
+                              rxdataF_comp_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_mag0,
+                              dl_ch_mag_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                              pdsch_vars[eNB_id]->llr[0],
+                              symbol,first_symbol_flag,nb_rb,
+                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
+                              pdsch_vars[eNB_id]->llr128);
+        if (rx_type==rx_IC_dual_stream) {
+          dlsch_16qam_16qam_llr(frame_parms,
+                                rxdataF_comp_ptr,
+                                pdsch_vars[eNB_id]->rxdataF_comp0,//i
+                                dl_ch_mag_ptr,
+                                pdsch_vars[eNB_id]->dl_ch_mag0,//i
+                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                pdsch_vars[eNB_id]->llr[1],
+                                symbol,first_symbol_flag,nb_rb,
+                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
+                                pdsch_vars[eNB_id]->llr128_2ndstream);
+        }
+      }
+      else {
+        dlsch_16qam_64qam_llr(frame_parms,
+                              pdsch_vars[eNB_id]->rxdataF_comp0,
+                              rxdataF_comp_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_mag0,
+                              dl_ch_mag_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                              pdsch_vars[eNB_id]->llr[0],
+                              symbol,first_symbol_flag,nb_rb,
+                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
+                              pdsch_vars[eNB_id]->llr128);
+        if (rx_type==rx_IC_dual_stream) {
+          dlsch_64qam_16qam_llr(frame_parms,
+                                rxdataF_comp_ptr,
+                                pdsch_vars[eNB_id]->rxdataF_comp0,
+                                dl_ch_mag_ptr,
+                                pdsch_vars[eNB_id]->dl_ch_mag0,
+                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                pdsch_vars[eNB_id]->llr[1],
+                                symbol,first_symbol_flag,nb_rb,
+                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
+                                pdsch_vars[eNB_id]->llr128_2ndstream);
+        }
+      }
+    }
+    break;
+  case 6 :
+    if ((rx_type==rx_standard) || (codeword_TB1 == -1))  {
+      dlsch_64qam_llr(frame_parms,
+                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                      (int16_t*)pllr_symbol_cw0,
+                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                      pdsch_vars[eNB_id]->dl_ch_magb0,
+                      symbol,first_symbol_flag,nb_rb,
+                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
+                      pdsch_vars[eNB_id]->llr_offset[symbol],
+                      beamforming_mode);
+    } else if (codeword_TB0 == -1){
+      dlsch_64qam_llr(frame_parms,
+                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                      (int16_t*)pllr_symbol_cw1,
+                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                      pdsch_vars[eNB_id]->dl_ch_magb0,
+                      symbol,first_symbol_flag,nb_rb,
+                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
+                      pdsch_vars[eNB_id]->llr_offset[symbol],
+                      beamforming_mode);
+    }
+    else if (rx_type >= rx_IC_single_stream) {
+      if (dlsch1_harq->Qm == 2) {
+        dlsch_64qam_qpsk_llr(frame_parms,
+                             pdsch_vars[eNB_id]->rxdataF_comp0,
+                             rxdataF_comp_ptr,//i
+                             pdsch_vars[eNB_id]->dl_ch_mag0,
+                             pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                             pdsch_vars[eNB_id]->llr[0],
+                             symbol,first_symbol_flag,nb_rb,
+                             adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
+                             pdsch_vars[eNB_id]->llr128);
+        if (rx_type==rx_IC_dual_stream) {
+          dlsch_qpsk_64qam_llr(frame_parms,
+                               rxdataF_comp_ptr,
+                               pdsch_vars[eNB_id]->rxdataF_comp0,//i
+                               pdsch_vars[eNB_id]->dl_ch_mag0,
+                               pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                               pdsch_vars[eNB_id]->llr[1],
+                               symbol,first_symbol_flag,nb_rb,
+                               adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
+                               pdsch_vars[eNB_id]->llr128_2ndstream);
+        }
+      }
+      else if (dlsch1_harq->Qm == 4) {
+        dlsch_64qam_16qam_llr(frame_parms,
+                              pdsch_vars[eNB_id]->rxdataF_comp0,
+                              rxdataF_comp_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_mag0,
+                              dl_ch_mag_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                              pdsch_vars[eNB_id]->llr[0],
+                              symbol,first_symbol_flag,nb_rb,
+                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
+                              pdsch_vars[eNB_id]->llr128);
+        if (rx_type==rx_IC_dual_stream) {
+          dlsch_16qam_64qam_llr(frame_parms,
+                                rxdataF_comp_ptr,
+                                pdsch_vars[eNB_id]->rxdataF_comp0,//i
+                                dl_ch_mag_ptr,
+                                pdsch_vars[eNB_id]->dl_ch_mag0,//i
+                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                pdsch_vars[eNB_id]->llr[1],
+                                symbol,first_symbol_flag,nb_rb,
+                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
+                                pdsch_vars[eNB_id]->llr128_2ndstream);
+        }
+      }
+      else {
+        dlsch_64qam_64qam_llr(frame_parms,
+                              pdsch_vars[eNB_id]->rxdataF_comp0,
+                              rxdataF_comp_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_mag0,
+                              dl_ch_mag_ptr,//i
+                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+                              (int16_t*)pllr_symbol_cw0,
+                              symbol,first_symbol_flag,nb_rb,
+                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
+                              pdsch_vars[eNB_id]->llr_offset[symbol]);
+        if (rx_type==rx_IC_dual_stream) {
+          dlsch_64qam_64qam_llr(frame_parms,
+                                rxdataF_comp_ptr,
+                                pdsch_vars[eNB_id]->rxdataF_comp0,//i
+                                dl_ch_mag_ptr,
+                                pdsch_vars[eNB_id]->dl_ch_mag0,//i
+                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+                                (int16_t*)pllr_symbol_cw1,
+                                symbol,first_symbol_flag,nb_rb,
+                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
+                                pdsch_vars[eNB_id]->llr_offset[symbol]);
+        }
+      }
+    }
+    break;
+  default:
+    LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n");
+    return(-1);
+    break;
+  }
+  if (dlsch1_harq) {
+  switch (get_Qm(dlsch1_harq->mcs)) {
+  case 2 :
+    if (rx_type==rx_standard) {
+        dlsch_qpsk_llr(frame_parms,
+                       pdsch_vars[eNB_id]->rxdataF_comp0,
+                       (int16_t*)pllr_symbol_cw0,
+                       symbol,first_symbol_flag,nb_rb,
+                       adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
+                       beamforming_mode);
+    }
+    break;
+  case 4:
+    if (rx_type==rx_standard) {
+      dlsch_16qam_llr(frame_parms,
+                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                      pdsch_vars[eNB_id]->llr[0],
+                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                      symbol,first_symbol_flag,nb_rb,
+                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
+                      pdsch_vars[eNB_id]->llr128,
+                      beamforming_mode);
+    }
+    break;
+  case 6 :
+    if (rx_type==rx_standard) {
+      dlsch_64qam_llr(frame_parms,
+                      pdsch_vars[eNB_id]->rxdataF_comp0,
+                      (int16_t*)pllr_symbol_cw0,
+                      pdsch_vars[eNB_id]->dl_ch_mag0,
+                      pdsch_vars[eNB_id]->dl_ch_magb0,
+                      symbol,first_symbol_flag,nb_rb,
+                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
+                      pdsch_vars[eNB_id]->llr_offset[symbol],
+                      beamforming_mode);
+  }
+    break;
+  default:
+    LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n");
+    return(-1);
+    break;
+  }
+  }
+
+#if UE_TIMING_TRACE
+    stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+#if DISABLE_LOG_X
+    printf("[AbsSFN %d.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#else
+    LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: LLR Computation  %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+#endif
+#endif
+// Please keep it: useful for debugging
+#if 0
+  if( (symbol == 13) && (subframe==0) && (dlsch0_harq->Qm == 6) /*&& (nb_rb==25)*/)
+  {
+      LOG_E(PHY,"Dump Phy Chan Est \n");
+      if(1)
+      {
+#if 1
+      write_output("rxdataF0.m"    , "rxdataF0",             &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[0][0],14*frame_parms->ofdm_symbol_size,1,1);
+      //write_output("rxdataF1.m"    , "rxdataF1",             &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[0][0],14*frame_parms->ofdm_symbol_size,1,1);
+      write_output("dl_ch_estimates00.m", "dl_ch_estimates00",   &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][0][0],14*frame_parms->ofdm_symbol_size,1,1);
+      //write_output("dl_ch_estimates01.m", "dl_ch_estimates01",   &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][1][0],14*frame_parms->ofdm_symbol_size,1,1);
+      //write_output("dl_ch_estimates10.m", "dl_ch_estimates10",   &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2][0],14*frame_parms->ofdm_symbol_size,1,1);
+      //write_output("dl_ch_estimates11.m", "dl_ch_estimates11",   &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][3][0],14*frame_parms->ofdm_symbol_size,1,1);
+
+
+      //write_output("rxdataF_ext00.m"    , "rxdataF_ext00",       &pdsch_vars[eNB_id]->rxdataF_ext[0][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("rxdataF_ext01.m"    , "rxdataF_ext01",       &pdsch_vars[eNB_id]->rxdataF_ext[1][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("rxdataF_ext10.m"    , "rxdataF_ext10",       &pdsch_vars[eNB_id]->rxdataF_ext[2][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("rxdataF_ext11.m"    , "rxdataF_ext11",       &pdsch_vars[eNB_id]->rxdataF_ext[3][0],14*frame_parms->N_RB_DL*12,1,1);
+      write_output("dl_ch_estimates_ext00.m", "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[0][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("dl_ch_estimates_ext01.m", "dl_ch_estimates_ext01", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[1][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("dl_ch_estimates_ext10.m", "dl_ch_estimates_ext10", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[2][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("dl_ch_estimates_ext11.m", "dl_ch_estimates_ext11", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[3][0],14*frame_parms->N_RB_DL*12,1,1);
+      write_output("rxdataF_comp00.m","rxdataF_comp00",              &pdsch_vars[eNB_id]->rxdataF_comp0[0][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("rxdataF_comp01.m","rxdataF_comp01",              &pdsch_vars[eNB_id]->rxdataF_comp0[1][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("rxdataF_comp10.m","rxdataF_comp10",              &pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][0][0],14*frame_parms->N_RB_DL*12,1,1);
+      //write_output("rxdataF_comp11.m","rxdataF_comp11",              &pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][1][0],14*frame_parms->N_RB_DL*12,1,1);
+#endif
+      write_output("llr0.m","llr0",  &pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0);
+      //write_output("llr1.m","llr1",  &pdsch_vars[eNB_id]->llr[1][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0);
+
+
+      AssertFatal(0," ");
+      }
+
+  }
+#endif
+
+  T(T_UE_PHY_PDSCH_IQ, T_INT(eNB_id), T_INT(frame%1024),
+    T_INT(subframe), T_INT(nb_rb),
+    T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_tti),
+    T_BUFFER(&pdsch_vars[eNB_id]->rxdataF_comp0[eNB_id][0],
+             2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_tti*2));
+
+  return 0;
+}
+
+//==============================================================================================
+// Pre-processing for LLR computation
+//==============================================================================================
+
+void dlsch_channel_compensation(int **rxdataF_ext,
+                                int **dl_ch_estimates_ext,
+                                int **dl_ch_mag,
+                                int **dl_ch_magb,
+                                int **rxdataF_comp,
+                                int **rho,
+                                LTE_DL_FRAME_PARMS *frame_parms,
+                                unsigned char symbol,
+                                uint8_t first_symbol_flag,
+                                unsigned char mod_order,
+                                unsigned short nb_rb,
+                                unsigned char output_shift,
+                                PHY_MEASUREMENTS *measurements)
+{
+
+#if defined(__i386) || defined(__x86_64)
+
+  unsigned short rb;
+  unsigned char aatx,aarx,symbol_mod,pilots=0;
+  __m128i *dl_ch128,*dl_ch128_2,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128;
+  __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
+
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
+      nb_rb=1+(5*nb_rb/6);
+    else
+      pilots=1;
+  }
+
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+    if (mod_order == 4) {
+      QAM_amp128 = _mm_set1_epi16(QAM16_n1);  // 2/sqrt(10)
+      QAM_amp128b = _mm_setzero_si128();
+    } else if (mod_order == 6) {
+      QAM_amp128  = _mm_set1_epi16(QAM64_n1); //
+      QAM_amp128b = _mm_set1_epi16(QAM64_n2);
+    }
+
+    //    printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol);
+
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+      dl_ch128          = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128      = (__m128i *)&dl_ch_mag[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128b     = (__m128i *)&dl_ch_magb[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+      rxdataF128        = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128   = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+
+
+      for (rb=0; rb<nb_rb; rb++) {
+        if (mod_order>2) {
+          // get channel amplitude if not QPSK
+
+          mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128[0]);
+          mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+
+          mmtmpD1 = _mm_madd_epi16(dl_ch128[1],dl_ch128[1]);
+          mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+
+          mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1);
+
+          // store channel magnitude here in a new field of dlsch
+
+          dl_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0);
+          dl_ch_mag128b[0] = dl_ch_mag128[0];
+          dl_ch_mag128[0] = _mm_mulhi_epi16(dl_ch_mag128[0],QAM_amp128);
+          dl_ch_mag128[0] = _mm_slli_epi16(dl_ch_mag128[0],1);
+    //print_ints("Re(ch):",(int16_t*)&mmtmpD0);
+    //print_shorts("QAM_amp:",(int16_t*)&QAM_amp128);
+    //print_shorts("mag:",(int16_t*)&dl_ch_mag128[0]);
+          dl_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0);
+          dl_ch_mag128b[1] = dl_ch_mag128[1];
+          dl_ch_mag128[1] = _mm_mulhi_epi16(dl_ch_mag128[1],QAM_amp128);
+          dl_ch_mag128[1] = _mm_slli_epi16(dl_ch_mag128[1],1);
+
+          if (pilots==0) {
+            mmtmpD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128[2]);
+            mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+            mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0);
+
+            dl_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1);
+            dl_ch_mag128b[2] = dl_ch_mag128[2];
+
+            dl_ch_mag128[2] = _mm_mulhi_epi16(dl_ch_mag128[2],QAM_amp128);
+            dl_ch_mag128[2] = _mm_slli_epi16(dl_ch_mag128[2],1);
+          }
+
+          dl_ch_mag128b[0] = _mm_mulhi_epi16(dl_ch_mag128b[0],QAM_amp128b);
+          dl_ch_mag128b[0] = _mm_slli_epi16(dl_ch_mag128b[0],1);
+
+
+          dl_ch_mag128b[1] = _mm_mulhi_epi16(dl_ch_mag128b[1],QAM_amp128b);
+          dl_ch_mag128b[1] = _mm_slli_epi16(dl_ch_mag128b[1],1);
+
+          if (pilots==0) {
+            dl_ch_mag128b[2] = _mm_mulhi_epi16(dl_ch_mag128b[2],QAM_amp128b);
+            dl_ch_mag128b[2] = _mm_slli_epi16(dl_ch_mag128b[2],1);
+          }
+        }
+
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]);
+        //  print_ints("re",&mmtmpD0);
+
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
+        //  print_ints("im",&mmtmpD1);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        //  print_ints("re(shift)",&mmtmpD0);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        //  print_ints("im(shift)",&mmtmpD1);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+        //        print_ints("c0",&mmtmpD2);
+        //  print_ints("c1",&mmtmpD3);
+        rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+        //  print_shorts("rx:",rxdataF128);
+        //  print_shorts("ch:",dl_ch128);
+        //  print_shorts("pack:",rxdataF_comp128);
+
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+        rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+        //  print_shorts("rx:",rxdataF128+1);
+        //  print_shorts("ch:",dl_ch128+1);
+        //  print_shorts("pack:",rxdataF_comp128+1);
+
+        if (pilots==0) {
+          // multiply by conjugated channel
+          mmtmpD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]);
+          // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+          mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1));
+          mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+          mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+          mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]);
+          // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+          mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+          mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+          mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+          mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+          rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+          //  print_shorts("rx:",rxdataF128+2);
+          //  print_shorts("ch:",dl_ch128+2);
+          //        print_shorts("pack:",rxdataF_comp128+2);
+
+          dl_ch128+=3;
+          dl_ch_mag128+=3;
+          dl_ch_mag128b+=3;
+          rxdataF128+=3;
+          rxdataF_comp128+=3;
+        } else { // we have a smaller PDSCH in symbols with pilots so skip last group of 4 REs and increment less
+          dl_ch128+=2;
+          dl_ch_mag128+=2;
+          dl_ch_mag128b+=2;
+          rxdataF128+=2;
+          rxdataF_comp128+=2;
+        }
+
+      }
+    }
+  }
+
+  if (rho) {
+
+
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      rho128        = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch128      = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch128_2    = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+
+      for (rb=0; rb<nb_rb; rb++) {
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128_2[0]);
+        //  print_ints("re",&mmtmpD0);
+
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
+        //  print_ints("im",&mmtmpD1);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128_2[0]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        //  print_ints("re(shift)",&mmtmpD0);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        //  print_ints("im(shift)",&mmtmpD1);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+        //        print_ints("c0",&mmtmpD2);
+        //  print_ints("c1",&mmtmpD3);
+        rho128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+
+        //print_shorts("rx:",dl_ch128_2);
+        //print_shorts("ch:",dl_ch128);
+        //print_shorts("pack:",rho128);
+
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128_2[1]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128_2[1]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+
+        rho128[1] =_mm_packs_epi32(mmtmpD2,mmtmpD3);
+        //print_shorts("rx:",dl_ch128_2+1);
+        //print_shorts("ch:",dl_ch128+1);
+        //print_shorts("pack:",rho128+1);
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128_2[2]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128_2[2]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+        rho128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+        //print_shorts("rx:",dl_ch128_2+2);
+        //print_shorts("ch:",dl_ch128+2);
+        //print_shorts("pack:",rho128+2);
+
+        dl_ch128+=3;
+        dl_ch128_2+=3;
+        rho128+=3;
+
+      }
+
+      if (first_symbol_flag==1) {
+        measurements->rx_correlation[0][aarx] = signal_energy(&rho[aarx][symbol*frame_parms->N_RB_DL*12],rb*12);
+      }
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+
+  unsigned short rb;
+  unsigned char aatx,aarx,symbol_mod,pilots=0;
+
+  int16x4_t *dl_ch128,*dl_ch128_2,*rxdataF128;
+  int32x4_t mmtmpD0,mmtmpD1,mmtmpD0b,mmtmpD1b;
+  int16x8_t *dl_ch_mag128,*dl_ch_mag128b,mmtmpD2,mmtmpD3,mmtmpD4;
+  int16x8_t QAM_amp128,QAM_amp128b;
+  int16x4x2_t *rxdataF_comp128,*rho128;
+
+  int16_t conj[4]__attribute__((aligned(16))) = {1,-1,1,-1};
+  int32x4_t output_shift128 = vmovq_n_s32(-(int32_t)output_shift);
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
+    if (frame_parms->nb_antenna_ports_eNB==1) { // 10 out of 12 so don't reduce size
+      nb_rb=1+(5*nb_rb/6);
+    }
+    else {
+      pilots=1;
+    }
+  }
+
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+    if (mod_order == 4) {
+      QAM_amp128  = vmovq_n_s16(QAM16_n1);  // 2/sqrt(10)
+      QAM_amp128b = vmovq_n_s16(0);
+    } else if (mod_order == 6) {
+      QAM_amp128  = vmovq_n_s16(QAM64_n1); //
+      QAM_amp128b = vmovq_n_s16(QAM64_n2);
+    }
+    //    printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol);
+
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      dl_ch128          = (int16x4_t*)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128      = (int16x8_t*)&dl_ch_mag[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128b     = (int16x8_t*)&dl_ch_magb[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+      rxdataF128        = (int16x4_t*)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128   = (int16x4x2_t*)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+
+      for (rb=0; rb<nb_rb; rb++) {
+  if (mod_order>2) {
+    // get channel amplitude if not QPSK
+    mmtmpD0 = vmull_s16(dl_ch128[0], dl_ch128[0]);
+    // mmtmpD0 = [ch0*ch0,ch1*ch1,ch2*ch2,ch3*ch3];
+    mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+    // mmtmpD0 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3]>>output_shift128 on 32-bits
+    mmtmpD1 = vmull_s16(dl_ch128[1], dl_ch128[1]);
+    mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+    mmtmpD2 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+    // mmtmpD2 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3,ch4*ch4 + ch5*ch5,ch4*ch4 + ch5*ch5,ch6*ch6 + ch7*ch7,ch6*ch6 + ch7*ch7]>>output_shift128 on 16-bits
+    mmtmpD0 = vmull_s16(dl_ch128[2], dl_ch128[2]);
+    mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+    mmtmpD1 = vmull_s16(dl_ch128[3], dl_ch128[3]);
+    mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+    mmtmpD3 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+    if (pilots==0) {
+      mmtmpD0 = vmull_s16(dl_ch128[4], dl_ch128[4]);
+      mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+      mmtmpD1 = vmull_s16(dl_ch128[5], dl_ch128[5]);
+      mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+      mmtmpD4 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+    }
+
+    dl_ch_mag128b[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128b);
+    dl_ch_mag128b[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128b);
+    dl_ch_mag128[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128);
+    dl_ch_mag128[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128);
+
+    if (pilots==0) {
+      dl_ch_mag128b[2] = vqdmulhq_s16(mmtmpD4,QAM_amp128b);
+      dl_ch_mag128[2]  = vqdmulhq_s16(mmtmpD4,QAM_amp128);
+    }
+  }
+
+  mmtmpD0 = vmull_s16(dl_ch128[0], rxdataF128[0]);
+  //mmtmpD0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])]
+  mmtmpD1 = vmull_s16(dl_ch128[1], rxdataF128[1]);
+  //mmtmpD1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])]
+  mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+  //mmtmpD0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])]
+
+  mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[0],*(int16x4_t*)conj)), rxdataF128[0]);
+  //mmtmpD0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])]
+  mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[1],*(int16x4_t*)conj)), rxdataF128[1]);
+  //mmtmpD0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])]
+  mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+  //mmtmpD1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])]
+
+  mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+  mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+  rxdataF_comp128[0] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+  mmtmpD0 = vmull_s16(dl_ch128[2], rxdataF128[2]);
+  mmtmpD1 = vmull_s16(dl_ch128[3], rxdataF128[3]);
+  mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+  mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[2],*(int16x4_t*)conj)), rxdataF128[2]);
+  mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[3],*(int16x4_t*)conj)), rxdataF128[3]);
+  mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+  mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+  mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+  rxdataF_comp128[1] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+  if (pilots==0) {
+    mmtmpD0 = vmull_s16(dl_ch128[4], rxdataF128[4]);
+    mmtmpD1 = vmull_s16(dl_ch128[5], rxdataF128[5]);
+    mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+         vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+
+    mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[4],*(int16x4_t*)conj)), rxdataF128[4]);
+    mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[5],*(int16x4_t*)conj)), rxdataF128[5]);
+    mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+         vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+
+    mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+    mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+    rxdataF_comp128[2] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+
+    dl_ch128+=6;
+    dl_ch_mag128+=3;
+    dl_ch_mag128b+=3;
+    rxdataF128+=6;
+    rxdataF_comp128+=3;
+
+  } else { // we have a smaller PDSCH in symbols with pilots so skip last group of 4 REs and increment less
+    dl_ch128+=4;
+    dl_ch_mag128+=2;
+    dl_ch_mag128b+=2;
+    rxdataF128+=4;
+    rxdataF_comp128+=2;
+  }
+      }
+    }
+  }
+
+  if (rho) {
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      rho128        = (int16x4x2_t*)&rho[aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch128      = (int16x4_t*)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+      dl_ch128_2    = (int16x4_t*)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+      for (rb=0; rb<nb_rb; rb++) {
+  mmtmpD0 = vmull_s16(dl_ch128[0], dl_ch128_2[0]);
+  mmtmpD1 = vmull_s16(dl_ch128[1], dl_ch128_2[1]);
+  mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+  mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[0],*(int16x4_t*)conj)), dl_ch128_2[0]);
+  mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[1],*(int16x4_t*)conj)), dl_ch128_2[1]);
+  mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+  mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+  mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+  rho128[0] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+  mmtmpD0 = vmull_s16(dl_ch128[2], dl_ch128_2[2]);
+  mmtmpD1 = vmull_s16(dl_ch128[3], dl_ch128_2[3]);
+  mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+  mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[2],*(int16x4_t*)conj)), dl_ch128_2[2]);
+  mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[3],*(int16x4_t*)conj)), dl_ch128_2[3]);
+  mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+  mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+  mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+  rho128[1] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+  mmtmpD0 = vmull_s16(dl_ch128[0], dl_ch128_2[0]);
+  mmtmpD1 = vmull_s16(dl_ch128[1], dl_ch128_2[1]);
+  mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+  mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[4],*(int16x4_t*)conj)), dl_ch128_2[4]);
+  mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch128[5],*(int16x4_t*)conj)), dl_ch128_2[5]);
+  mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+  mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+  mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+  rho128[2] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+
+  dl_ch128+=6;
+  dl_ch128_2+=6;
+  rho128+=3;
+      }
+
+      if (first_symbol_flag==1) {
+  measurements->rx_correlation[0][aarx] = signal_energy(&rho[aarx][symbol*frame_parms->N_RB_DL*12],rb*12);
+      }
+    }
+  }
+#endif
+}
+
+#if defined(__x86_64__) || defined(__i386__)
+
+void prec2A_TM56_128(unsigned char pmi,__m128i *ch0,__m128i *ch1)
+{
+
+  __m128i amp;
+  amp = _mm_set1_epi16(ONE_OVER_SQRT2_Q15);
+
+  switch (pmi) {
+
+  case 0 :   // +1 +1
+    //    print_shorts("phase 0 :ch0",ch0);
+    //    print_shorts("phase 0 :ch1",ch1);
+    ch0[0] = _mm_adds_epi16(ch0[0],ch1[0]);
+    break;
+
+  case 1 :   // +1 -1
+    //    print_shorts("phase 1 :ch0",ch0);
+    //    print_shorts("phase 1 :ch1",ch1);
+    ch0[0] = _mm_subs_epi16(ch0[0],ch1[0]);
+    //    print_shorts("phase 1 :ch0-ch1",ch0);
+    break;
+
+  case 2 :   // +1 +j
+    ch1[0] = _mm_sign_epi16(ch1[0],*(__m128i*)&conjugate[0]);
+    ch1[0] = _mm_shufflelo_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch1[0] = _mm_shufflehi_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch0[0] = _mm_subs_epi16(ch0[0],ch1[0]);
+
+    break;   // +1 -j
+
+  case 3 :
+    ch1[0] = _mm_sign_epi16(ch1[0],*(__m128i*)&conjugate[0]);
+    ch1[0] = _mm_shufflelo_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch1[0] = _mm_shufflehi_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch0[0] = _mm_adds_epi16(ch0[0],ch1[0]);
+    break;
+  }
+
+  ch0[0] = _mm_mulhi_epi16(ch0[0],amp);
+  ch0[0] = _mm_slli_epi16(ch0[0],1);
+
+  _mm_empty();
+  _m_empty();
+}
+#elif defined(__arm__)
+void prec2A_TM56_128(unsigned char pmi,__m128i *ch0,__m128i *ch1) {
+
+  // sqrt(2) is already taken into account in computation sqrt_rho_a, sqrt_rho_b,
+  //so removed it
+
+  //__m128i amp;
+  //amp = _mm_set1_epi16(ONE_OVER_SQRT2_Q15);
+
+  switch (pmi) {
+
+  case 0 :   // +1 +1
+    //    print_shorts("phase 0 :ch0",ch0);
+    //    print_shorts("phase 0 :ch1",ch1);
+    ch0[0] = _mm_adds_epi16(ch0[0],ch1[0]);
+    break;
+  case 1 :   // +1 -1
+    //    print_shorts("phase 1 :ch0",ch0);
+    //    print_shorts("phase 1 :ch1",ch1);
+    ch0[0] = _mm_subs_epi16(ch0[0],ch1[0]);
+    //    print_shorts("phase 1 :ch0-ch1",ch0);
+    break;
+  case 2 :   // +1 +j
+    ch1[0] = _mm_sign_epi16(ch1[0],*(__m128i*)&conjugate[0]);
+    ch1[0] = _mm_shufflelo_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch1[0] = _mm_shufflehi_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch0[0] = _mm_subs_epi16(ch0[0],ch1[0]);
+
+    break;   // +1 -j
+  case 3 :
+    ch1[0] = _mm_sign_epi16(ch1[0],*(__m128i*)&conjugate[0]);
+    ch1[0] = _mm_shufflelo_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch1[0] = _mm_shufflehi_epi16(ch1[0],_MM_SHUFFLE(2,3,0,1));
+    ch0[0] = _mm_adds_epi16(ch0[0],ch1[0]);
+    break;
+  }
+
+  //ch0[0] = _mm_mulhi_epi16(ch0[0],amp);
+  //ch0[0] = _mm_slli_epi16(ch0[0],1);
+
+  _mm_empty();
+  _m_empty();
+}
+#endif
+// precoding is stream 0 .5(1,1)  .5(1,-1) .5(1,1)  .5(1,-1)
+//              stream 1 .5(1,-1) .5(1,1)  .5(1,-1) .5(1,1)
+// store "precoded" channel for stream 0 in ch0, stream 1 in ch1
+
+short TM3_prec[8]__attribute__((aligned(16))) = {1,1,-1,-1,1,1,-1,-1} ;
+
+void prec2A_TM3_128(__m128i *ch0,__m128i *ch1) {
+
+  __m128i amp = _mm_set1_epi16(ONE_OVER_SQRT2_Q15);
+
+  __m128i tmp0,tmp1;
+
+  //_mm_mulhi_epi16
+  //  print_shorts("prec2A_TM3 ch0 (before):",ch0);
+  //  print_shorts("prec2A_TM3 ch1 (before):",ch1);
+
+  tmp0 = ch0[0];
+  tmp1  = _mm_sign_epi16(ch1[0],((__m128i*)&TM3_prec)[0]);
+  //  print_shorts("prec2A_TM3 ch1*s (mid):",(__m128i*)TM3_prec);
+
+  ch0[0] = _mm_adds_epi16(ch0[0],tmp1);
+  ch1[0] = _mm_subs_epi16(tmp0,tmp1);
+
+  ch0[0] = _mm_mulhi_epi16(ch0[0],amp);
+  ch0[0] = _mm_slli_epi16(ch0[0],1);
+
+  ch1[0] = _mm_mulhi_epi16(ch1[0],amp);
+  ch1[0] = _mm_slli_epi16(ch1[0],1);
+
+  //  print_shorts("prec2A_TM3 ch0 (mid):",&tmp0);
+  //  print_shorts("prec2A_TM3 ch1 (mid):",ch1);
+
+  //ch0[0] = _mm_mulhi_epi16(ch0[0],amp);
+  //ch0[0] = _mm_slli_epi16(ch0[0],1);
+  //ch1[0] = _mm_mulhi_epi16(ch1[0],amp);
+  //ch1[0] = _mm_slli_epi16(ch1[0],1);
+
+  //ch0[0] = _mm_srai_epi16(ch0[0],1);
+  //ch1[0] = _mm_srai_epi16(ch1[0],1);
+
+  //  print_shorts("prec2A_TM3 ch0 (after):",ch0);
+  //  print_shorts("prec2A_TM3 ch1 (after):",ch1);
+
+  _mm_empty();
+  _m_empty();
+}
+
+// pmi = 0 => stream 0 (1,1), stream 1 (1,-1)
+// pmi = 1 => stream 0 (1,j), stream 2 (1,-j)
+
+void prec2A_TM4_128(int pmi,__m128i *ch0,__m128i *ch1) {
+
+// sqrt(2) is already taken into account in computation sqrt_rho_a, sqrt_rho_b,
+//so divide by 2 is replaced by divide by sqrt(2).
+
+ // printf ("demod pmi=%d\n", pmi);
+ __m128i amp;
+ amp = _mm_set1_epi16(ONE_OVER_SQRT2_Q15);
+  __m128i tmp0,tmp1;
+
+ // print_shorts("prec2A_TM4 ch0 (before):",ch0);
+ // print_shorts("prec2A_TM4 ch1 (before):",ch1);
+
+  if (pmi == 0) { //[1 1;1 -1]
+    tmp0 = ch0[0];
+    tmp1 = ch1[0];
+    ch0[0] = _mm_adds_epi16(tmp0,tmp1);
+    ch1[0] = _mm_subs_epi16(tmp0,tmp1);
+  }
+  else { //ch0+j*ch1 ch0-j*ch1
+    tmp0 = ch0[0];
+    tmp1   = _mm_sign_epi16(ch1[0],*(__m128i*)&conjugate[0]);
+    tmp1   = _mm_shufflelo_epi16(tmp1,_MM_SHUFFLE(2,3,0,1));
+    tmp1   = _mm_shufflehi_epi16(tmp1,_MM_SHUFFLE(2,3,0,1));
+    ch0[0] = _mm_subs_epi16(tmp0,tmp1);
+    ch1[0] = _mm_add_epi16(tmp0,tmp1);
+  }
+
+  //print_shorts("prec2A_TM4 ch0 (middle):",ch0);
+  //print_shorts("prec2A_TM4 ch1 (middle):",ch1);
+
+  ch0[0] = _mm_mulhi_epi16(ch0[0],amp);
+  ch0[0] = _mm_slli_epi16(ch0[0],1);
+  ch1[0] = _mm_mulhi_epi16(ch1[0],amp);
+  ch1[0] = _mm_slli_epi16(ch1[0],1);
+
+
+ // ch0[0] = _mm_srai_epi16(ch0[0],1); //divide by 2
+ // ch1[0] = _mm_srai_epi16(ch1[0],1); //divide by 2
+  //print_shorts("prec2A_TM4 ch0 (end):",ch0);
+  //print_shorts("prec2A_TM4 ch1 (end):",ch1);
+  _mm_empty();
+  _m_empty();
+ // print_shorts("prec2A_TM4 ch0 (end):",ch0);
+  //print_shorts("prec2A_TM4 ch1 (end):",ch1);
+}
+
+void dlsch_channel_compensation_TM56(int **rxdataF_ext,
+                                     int **dl_ch_estimates_ext,
+                                     int **dl_ch_mag,
+                                     int **dl_ch_magb,
+                                     int **rxdataF_comp,
+                                     unsigned char *pmi_ext,
+                                     LTE_DL_FRAME_PARMS *frame_parms,
+                                     PHY_MEASUREMENTS *measurements,
+                                     int eNB_id,
+                                     unsigned char symbol,
+                                     unsigned char mod_order,
+                                     unsigned short nb_rb,
+                                     unsigned char output_shift,
+                                     unsigned char dl_power_off)
+{
+
+#if defined(__x86_64__) || defined(__i386__)
+
+  unsigned short rb,Nre;
+  __m128i *dl_ch0_128,*dl_ch1_128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128;
+  unsigned char aarx=0,symbol_mod,pilots=0;
+  int precoded_signal_strength=0;
+  __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp)))
+    pilots=1;
+
+
+  //printf("comp prec: symbol %d, pilots %d\n",symbol, pilots);
+
+  if (mod_order == 4) {
+    QAM_amp128 = _mm_set1_epi16(QAM16_n1);
+    QAM_amp128b = _mm_setzero_si128();
+  } else if (mod_order == 6) {
+    QAM_amp128  = _mm_set1_epi16(QAM64_n1);
+    QAM_amp128b = _mm_set1_epi16(QAM64_n2);
+  }
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+    dl_ch0_128          = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128          = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+
+
+    dl_ch_mag128      = (__m128i *)&dl_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch_mag128b     = (__m128i *)&dl_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12];
+    rxdataF128        = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    rxdataF_comp128   = (__m128i *)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12];
+
+
+    for (rb=0; rb<nb_rb; rb++) {
+      // combine TX channels using precoder from pmi
+#ifdef DEBUG_DLSCH_DEMOD
+      printf("mode 6 prec: rb %d, pmi->%d\n",rb,pmi_ext[rb]);
+#endif
+      prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128[0],&dl_ch1_128[0]);
+      prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128[1],&dl_ch1_128[1]);
+
+      if (pilots==0) {
+
+        prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128[2],&dl_ch1_128[2]);
+      }
+
+      if (mod_order>2) {
+        // get channel amplitude if not QPSK
+
+        mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch0_128[0]);
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+
+        mmtmpD1 = _mm_madd_epi16(dl_ch0_128[1],dl_ch0_128[1]);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+
+        mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1);
+
+        dl_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0);
+        dl_ch_mag128b[0] = dl_ch_mag128[0];
+        dl_ch_mag128[0] = _mm_mulhi_epi16(dl_ch_mag128[0],QAM_amp128);
+        dl_ch_mag128[0] = _mm_slli_epi16(dl_ch_mag128[0],1);
+
+
+        //print_shorts("dl_ch_mag128[0]=",&dl_ch_mag128[0]);
+
+        //print_shorts("dl_ch_mag128[0]=",&dl_ch_mag128[0]);
+
+        dl_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0);
+        dl_ch_mag128b[1] = dl_ch_mag128[1];
+        dl_ch_mag128[1] = _mm_mulhi_epi16(dl_ch_mag128[1],QAM_amp128);
+        dl_ch_mag128[1] = _mm_slli_epi16(dl_ch_mag128[1],1);
+
+        if (pilots==0) {
+          mmtmpD0 = _mm_madd_epi16(dl_ch0_128[2],dl_ch0_128[2]);
+          mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+
+          mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0);
+
+          dl_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1);
+          dl_ch_mag128b[2] = dl_ch_mag128[2];
+
+          dl_ch_mag128[2] = _mm_mulhi_epi16(dl_ch_mag128[2],QAM_amp128);
+          dl_ch_mag128[2] = _mm_slli_epi16(dl_ch_mag128[2],1);
+        }
+
+        dl_ch_mag128b[0] = _mm_mulhi_epi16(dl_ch_mag128b[0],QAM_amp128b);
+        dl_ch_mag128b[0] = _mm_slli_epi16(dl_ch_mag128b[0],1);
+
+        //print_shorts("dl_ch_mag128b[0]=",&dl_ch_mag128b[0]);
+
+        dl_ch_mag128b[1] = _mm_mulhi_epi16(dl_ch_mag128b[1],QAM_amp128b);
+        dl_ch_mag128b[1] = _mm_slli_epi16(dl_ch_mag128b[1],1);
+
+        if (pilots==0) {
+          dl_ch_mag128b[2] = _mm_mulhi_epi16(dl_ch_mag128b[2],QAM_amp128b);
+          dl_ch_mag128b[2] = _mm_slli_epi16(dl_ch_mag128b[2],1);
+
+        }
+      }
+
+      // MF multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],rxdataF128[0]);
+      //        print_ints("re",&mmtmpD0);
+
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[0],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
+
+      //        print_ints("im",&mmtmpD1);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+      //        print_ints("re(shift)",&mmtmpD0);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+      //        print_ints("im(shift)",&mmtmpD1);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+      //        print_ints("c0",&mmtmpD2);
+      //        print_ints("c1",&mmtmpD3);
+      rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+      //        print_shorts("rx:",rxdataF128);
+      //        print_shorts("ch:",dl_ch128);
+      //        print_shorts("pack:",rxdataF_comp128);
+
+      // multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch0_128[1],rxdataF128[1]);
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[1],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+      rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+      //  print_shorts("rx:",rxdataF128+1);
+      //  print_shorts("ch:",dl_ch128+1);
+      //  print_shorts("pack:",rxdataF_comp128+1);
+
+      if (pilots==0) {
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch0_128[2],rxdataF128[2]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[2],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+        rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+        //  print_shorts("rx:",rxdataF128+2);
+        //  print_shorts("ch:",dl_ch128+2);
+        //        print_shorts("pack:",rxdataF_comp128+2);
+
+        dl_ch0_128+=3;
+        dl_ch1_128+=3;
+        dl_ch_mag128+=3;
+        dl_ch_mag128b+=3;
+        rxdataF128+=3;
+        rxdataF_comp128+=3;
+      } else {
+        dl_ch0_128+=2;
+        dl_ch1_128+=2;
+        dl_ch_mag128+=2;
+        dl_ch_mag128b+=2;
+        rxdataF128+=2;
+        rxdataF_comp128+=2;
+      }
+    }
+
+    Nre = (pilots==0) ? 12 : 8;
+
+    precoded_signal_strength += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre],
+                                                     (nb_rb*Nre))) - (measurements->n0_power[aarx]));
+  } // rx_antennas
+
+  measurements->precoded_cqi_dB[eNB_id][0] = dB_fixed2(precoded_signal_strength,measurements->n0_power_tot);
+
+  //printf("eNB_id %d, symbol %d: precoded CQI %d dB\n",eNB_id,symbol,
+  //   measurements->precoded_cqi_dB[eNB_id][0]);
+
+#elif defined(__arm__)
+
+  uint32_t rb,Nre;
+  uint32_t aarx,symbol_mod,pilots=0;
+
+  int16x4_t *dl_ch0_128,*dl_ch1_128,*rxdataF128;
+  int16x8_t *dl_ch0_128b,*dl_ch1_128b;
+  int32x4_t mmtmpD0,mmtmpD1,mmtmpD0b,mmtmpD1b;
+  int16x8_t *dl_ch_mag128,*dl_ch_mag128b,mmtmpD2,mmtmpD3,mmtmpD4,*rxdataF_comp128;
+  int16x8_t QAM_amp128,QAM_amp128b;
+
+  int16_t conj[4]__attribute__((aligned(16))) = {1,-1,1,-1};
+  int32x4_t output_shift128 = vmovq_n_s32(-(int32_t)output_shift);
+  int32_t precoded_signal_strength=0;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
+      { nb_rb=1+(5*nb_rb/6); }
+
+    else
+      { pilots=1; }
+  }
+
+
+  if (mod_order == 4) {
+    QAM_amp128  = vmovq_n_s16(QAM16_n1);  // 2/sqrt(10)
+    QAM_amp128b = vmovq_n_s16(0);
+
+  } else if (mod_order == 6) {
+    QAM_amp128  = vmovq_n_s16(QAM64_n1); //
+    QAM_amp128b = vmovq_n_s16(QAM64_n2);
+  }
+
+  //    printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol);
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+
+
+    dl_ch0_128          = (int16x4_t*)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128          = (int16x4_t*)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch0_128b         = (int16x8_t*)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128b         = (int16x8_t*)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch_mag128        = (int16x8_t*)&dl_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch_mag128b       = (int16x8_t*)&dl_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12];
+    rxdataF128          = (int16x4_t*)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    rxdataF_comp128     = (int16x8_t*)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12];
+
+    for (rb=0; rb<nb_rb; rb++) {
+#ifdef DEBUG_DLSCH_DEMOD
+      printf("mode 6 prec: rb %d, pmi->%d\n",rb,pmi_ext[rb]);
+#endif
+      prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128b[0],&dl_ch1_128b[0]);
+      prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128b[1],&dl_ch1_128b[1]);
+
+      if (pilots==0) {
+        prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128b[2],&dl_ch1_128b[2]);
+      }
+
+      if (mod_order>2) {
+        // get channel amplitude if not QPSK
+        mmtmpD0 = vmull_s16(dl_ch0_128[0], dl_ch0_128[0]);
+        // mmtmpD0 = [ch0*ch0,ch1*ch1,ch2*ch2,ch3*ch3];
+        mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+        // mmtmpD0 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3]>>output_shift128 on 32-bits
+        mmtmpD1 = vmull_s16(dl_ch0_128[1], dl_ch0_128[1]);
+        mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+        mmtmpD2 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+        // mmtmpD2 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3,ch4*ch4 + ch5*ch5,ch4*ch4 + ch5*ch5,ch6*ch6 + ch7*ch7,ch6*ch6 + ch7*ch7]>>output_shift128 on 16-bits
+        mmtmpD0 = vmull_s16(dl_ch0_128[2], dl_ch0_128[2]);
+        mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+        mmtmpD1 = vmull_s16(dl_ch0_128[3], dl_ch0_128[3]);
+        mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+        mmtmpD3 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+        if (pilots==0) {
+          mmtmpD0 = vmull_s16(dl_ch0_128[4], dl_ch0_128[4]);
+          mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+          mmtmpD1 = vmull_s16(dl_ch0_128[5], dl_ch0_128[5]);
+          mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+          mmtmpD4 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+
+        }
+
+        dl_ch_mag128b[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128b);
+        dl_ch_mag128b[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128b);
+        dl_ch_mag128[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128);
+        dl_ch_mag128[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128);
+
+
+        if (pilots==0) {
+          dl_ch_mag128b[2] = vqdmulhq_s16(mmtmpD4,QAM_amp128b);
+          dl_ch_mag128[2]  = vqdmulhq_s16(mmtmpD4,QAM_amp128);
+        }
+      }
+      mmtmpD0 = vmull_s16(dl_ch0_128[0], rxdataF128[0]);
+      //mmtmpD0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])]
+      mmtmpD1 = vmull_s16(dl_ch0_128[1], rxdataF128[1]);
+      //mmtmpD1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])]
+      mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+      //mmtmpD0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])]
+
+      mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[0],*(int16x4_t*)conj)), rxdataF128[0]);
+      //mmtmpD0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])]
+      mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[1],*(int16x4_t*)conj)), rxdataF128[1]);
+      //mmtmpD0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])]
+      mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+      //mmtmpD1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])]
+
+      mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+      mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+      rxdataF_comp128[0] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+      mmtmpD0 = vmull_s16(dl_ch0_128[2], rxdataF128[2]);
+      mmtmpD1 = vmull_s16(dl_ch0_128[3], rxdataF128[3]);
+      mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+
+      mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[2],*(int16x4_t*)conj)), rxdataF128[2]);
+      mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[3],*(int16x4_t*)conj)), rxdataF128[3]);
+      mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+      mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+      mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+      rxdataF_comp128[1] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+      if (pilots==0) {
+        mmtmpD0 = vmull_s16(dl_ch0_128[4], rxdataF128[4]);
+        mmtmpD1 = vmull_s16(dl_ch0_128[5], rxdataF128[5]);
+        mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                               vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+
+        mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[4],*(int16x4_t*)conj)), rxdataF128[4]);
+        mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[5],*(int16x4_t*)conj)), rxdataF128[5]);
+        mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                               vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+
+        mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+        mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+        rxdataF_comp128[2] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+
+        dl_ch0_128+=6;
+        dl_ch1_128+=6;
+        dl_ch_mag128+=3;
+        dl_ch_mag128b+=3;
+        rxdataF128+=6;
+        rxdataF_comp128+=3;
+
+      } else { // we have a smaller PDSCH in symbols with pilots so skip last group of 4 REs and increment less
+        dl_ch0_128+=4;
+        dl_ch1_128+=4;
+        dl_ch_mag128+=2;
+        dl_ch_mag128b+=2;
+        rxdataF128+=4;
+        rxdataF_comp128+=2;
+      }
+    }
+
+    Nre = (pilots==0) ? 12 : 8;
+
+
+    precoded_signal_strength += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre],
+
+                                                     (nb_rb*Nre))) - (measurements->n0_power[aarx]));
+    // rx_antennas
+  }
+  measurements->precoded_cqi_dB[eNB_id][0] = dB_fixed2(precoded_signal_strength,measurements->n0_power_tot);
+
+  //printf("eNB_id %d, symbol %d: precoded CQI %d dB\n",eNB_id,symbol,
+  //     measurements->precoded_cqi_dB[eNB_id][0]);
+
+#endif
+  _mm_empty();
+  _m_empty();
+}
+
+void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms,
+                                    LTE_UE_PDSCH *pdsch_vars,
+                                    PHY_MEASUREMENTS *measurements,
+                                    int eNB_id,
+                                    unsigned char symbol,
+                                    unsigned char mod_order0,
+                                    unsigned char mod_order1,
+                                    int harq_pid,
+                                    int round,
+                                    MIMO_mode_t mimo_mode,
+                                    unsigned short nb_rb,
+                                    unsigned char output_shift0,
+                                    unsigned char output_shift1) {
+
+#if defined(__x86_64__) || defined(__i386__)
+
+  unsigned short rb,Nre;
+  __m128i *dl_ch0_128,*dl_ch1_128,*dl_ch_mag0_128,*dl_ch_mag1_128,*dl_ch_mag0_128b,*dl_ch_mag1_128b,*rxdataF128,*rxdataF_comp0_128,*rxdataF_comp1_128;
+  unsigned char aarx=0,symbol_mod,pilots=0;
+  int precoded_signal_strength0=0,precoded_signal_strength1=0;
+  int rx_power_correction;
+
+  int **rxdataF_ext           = pdsch_vars->rxdataF_ext;
+  int **dl_ch_estimates_ext   = pdsch_vars->dl_ch_estimates_ext;
+  int **dl_ch_mag0            = pdsch_vars->dl_ch_mag0;
+  int **dl_ch_mag1            = pdsch_vars->dl_ch_mag1[harq_pid][round];
+  int **dl_ch_magb0           = pdsch_vars->dl_ch_magb0;
+  int **dl_ch_magb1           = pdsch_vars->dl_ch_magb1[harq_pid][round];
+  int **rxdataF_comp0         = pdsch_vars->rxdataF_comp0;
+  int **rxdataF_comp1         = pdsch_vars->rxdataF_comp1[harq_pid][round];
+  unsigned char *pmi_ext      = pdsch_vars->pmi_ext;
+  __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp0_128,QAM_amp0_128b,QAM_amp1_128,QAM_amp1_128b;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp)))
+    pilots=1;
+
+  rx_power_correction = 1;
+
+ // printf("comp prec: symbol %d, pilots %d\n",symbol, pilots);
+
+  if (mod_order0 == 4) {
+    QAM_amp0_128  = _mm_set1_epi16(QAM16_n1);
+    QAM_amp0_128b = _mm_setzero_si128();
+  } else if (mod_order0 == 6) {
+    QAM_amp0_128  = _mm_set1_epi16(QAM64_n1);
+    QAM_amp0_128b = _mm_set1_epi16(QAM64_n2);
+  }
+
+  if (mod_order1 == 4) {
+    QAM_amp1_128  = _mm_set1_epi16(QAM16_n1);
+    QAM_amp1_128b = _mm_setzero_si128();
+  } else if (mod_order1 == 6) {
+    QAM_amp1_128  = _mm_set1_epi16(QAM64_n1);
+    QAM_amp1_128b = _mm_set1_epi16(QAM64_n2);
+  }
+
+  for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
+
+   /* if (aarx==0) {
+      output_shift=output_shift0;
+    }
+      else {
+        output_shift=output_shift1;
+      } */
+
+     // printf("antenna %d\n", aarx);
+   // printf("symbol %d, rx antenna %d\n", symbol, aarx);
+
+    dl_ch0_128          = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; // this is h11
+    dl_ch1_128          = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12]; // this is h12
+
+
+    dl_ch_mag0_128      = (__m128i *)&dl_ch_mag0[aarx][symbol*frame_parms->N_RB_DL*12]; //responsible for x1
+    dl_ch_mag0_128b     = (__m128i *)&dl_ch_magb0[aarx][symbol*frame_parms->N_RB_DL*12];//responsible for x1
+    dl_ch_mag1_128      = (__m128i *)&dl_ch_mag1[aarx][symbol*frame_parms->N_RB_DL*12];   //responsible for x2. always coming from tx2
+    dl_ch_mag1_128b     = (__m128i *)&dl_ch_magb1[aarx][symbol*frame_parms->N_RB_DL*12];  //responsible for x2. always coming from tx2
+    rxdataF128          = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; //received signal on antenna of interest h11*x1+h12*x2
+    rxdataF_comp0_128   = (__m128i *)&rxdataF_comp0[aarx][symbol*frame_parms->N_RB_DL*12]; //result of multipl with MF x1 on antenna of interest
+    rxdataF_comp1_128   = (__m128i *)&rxdataF_comp1[aarx][symbol*frame_parms->N_RB_DL*12]; //result of multipl with MF x2 on antenna of interest
+
+    for (rb=0; rb<nb_rb; rb++) {
+
+      // combine TX channels using precoder from pmi
+      if (mimo_mode==LARGE_CDD) {
+        prec2A_TM3_128(&dl_ch0_128[0],&dl_ch1_128[0]);
+        prec2A_TM3_128(&dl_ch0_128[1],&dl_ch1_128[1]);
+
+
+        if (pilots==0) {
+          prec2A_TM3_128(&dl_ch0_128[2],&dl_ch1_128[2]);
+        }
+      }
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1) {
+        prec2A_TM4_128(0,&dl_ch0_128[0],&dl_ch1_128[0]);
+        prec2A_TM4_128(0,&dl_ch0_128[1],&dl_ch1_128[1]);
+
+        if (pilots==0) {
+          prec2A_TM4_128(0,&dl_ch0_128[2],&dl_ch1_128[2]);
+        }
+      }
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj) {
+        prec2A_TM4_128(1,&dl_ch0_128[0],&dl_ch1_128[0]);
+        prec2A_TM4_128(1,&dl_ch0_128[1],&dl_ch1_128[1]);
+
+        if (pilots==0) {
+          prec2A_TM4_128(1,&dl_ch0_128[2],&dl_ch1_128[2]);
+        }
+      }
+
+        else if (mimo_mode==DUALSTREAM_PUSCH_PRECODING) {
+        prec2A_TM4_128(pmi_ext[rb],&dl_ch0_128[0],&dl_ch1_128[0]);
+        prec2A_TM4_128(pmi_ext[rb],&dl_ch0_128[1],&dl_ch1_128[1]);
+
+        if (pilots==0) {
+          prec2A_TM4_128(pmi_ext[rb],&dl_ch0_128[2],&dl_ch1_128[2]);
+        }
+      }
+
+
+      else {
+        LOG_E(PHY,"Unknown MIMO mode\n");
+        return;
+      }
+
+
+      if (mod_order0>2) {
+        // get channel amplitude if not QPSK
+
+        mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch0_128[0]);
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0);
+
+        mmtmpD1 = _mm_madd_epi16(dl_ch0_128[1],dl_ch0_128[1]);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0);
+
+        mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1);
+
+        dl_ch_mag0_128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0);
+        dl_ch_mag0_128b[0] = dl_ch_mag0_128[0];
+        dl_ch_mag0_128[0] = _mm_mulhi_epi16(dl_ch_mag0_128[0],QAM_amp0_128);
+        dl_ch_mag0_128[0] = _mm_slli_epi16(dl_ch_mag0_128[0],1);
+
+        //  print_shorts("dl_ch_mag0_128[0]=",&dl_ch_mag0_128[0]);
+
+
+        dl_ch_mag0_128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0);
+        dl_ch_mag0_128b[1] = dl_ch_mag0_128[1];
+        dl_ch_mag0_128[1] = _mm_mulhi_epi16(dl_ch_mag0_128[1],QAM_amp0_128);
+        dl_ch_mag0_128[1] = _mm_slli_epi16(dl_ch_mag0_128[1],1);
+
+        if (pilots==0) {
+          mmtmpD0 = _mm_madd_epi16(dl_ch0_128[2],dl_ch0_128[2]);
+          mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0);
+
+          mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0);
+
+          dl_ch_mag0_128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1);
+          dl_ch_mag0_128b[2] = dl_ch_mag0_128[2];
+
+          dl_ch_mag0_128[2] = _mm_mulhi_epi16(dl_ch_mag0_128[2],QAM_amp0_128);
+          dl_ch_mag0_128[2] = _mm_slli_epi16(dl_ch_mag0_128[2],1);
+        }
+
+        dl_ch_mag0_128b[0] = _mm_mulhi_epi16(dl_ch_mag0_128b[0],QAM_amp0_128b);
+        dl_ch_mag0_128b[0] = _mm_slli_epi16(dl_ch_mag0_128b[0],1);
+
+       // print_shorts("dl_ch_mag0_128b[0]=",&dl_ch_mag0_128b[0]);
+
+        dl_ch_mag0_128b[1] = _mm_mulhi_epi16(dl_ch_mag0_128b[1],QAM_amp0_128b);
+        dl_ch_mag0_128b[1] = _mm_slli_epi16(dl_ch_mag0_128b[1],1);
+
+        if (pilots==0) {
+          dl_ch_mag0_128b[2] = _mm_mulhi_epi16(dl_ch_mag0_128b[2],QAM_amp0_128b);
+          dl_ch_mag0_128b[2] = _mm_slli_epi16(dl_ch_mag0_128b[2],1);
+        }
+      }
+
+      if (mod_order1>2) {
+        // get channel amplitude if not QPSK
+
+        mmtmpD0 = _mm_madd_epi16(dl_ch1_128[0],dl_ch1_128[0]);
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift1);
+
+        mmtmpD1 = _mm_madd_epi16(dl_ch1_128[1],dl_ch1_128[1]);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift1);
+
+        mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1);
+
+        dl_ch_mag1_128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0);
+        dl_ch_mag1_128b[0] = dl_ch_mag1_128[0];
+        dl_ch_mag1_128[0] = _mm_mulhi_epi16(dl_ch_mag1_128[0],QAM_amp1_128);
+        dl_ch_mag1_128[0] = _mm_slli_epi16(dl_ch_mag1_128[0],1);
+
+       // print_shorts("dl_ch_mag1_128[0]=",&dl_ch_mag1_128[0]);
+
+        dl_ch_mag1_128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0);
+        dl_ch_mag1_128b[1] = dl_ch_mag1_128[1];
+        dl_ch_mag1_128[1] = _mm_mulhi_epi16(dl_ch_mag1_128[1],QAM_amp1_128);
+        dl_ch_mag1_128[1] = _mm_slli_epi16(dl_ch_mag1_128[1],1);
+
+        if (pilots==0) {
+          mmtmpD0 = _mm_madd_epi16(dl_ch1_128[2],dl_ch1_128[2]);
+          mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift1);
+
+          mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0);
+
+          dl_ch_mag1_128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1);
+          dl_ch_mag1_128b[2] = dl_ch_mag1_128[2];
+
+          dl_ch_mag1_128[2] = _mm_mulhi_epi16(dl_ch_mag1_128[2],QAM_amp1_128);
+          dl_ch_mag1_128[2] = _mm_slli_epi16(dl_ch_mag1_128[2],1);
+        }
+
+        dl_ch_mag1_128b[0] = _mm_mulhi_epi16(dl_ch_mag1_128b[0],QAM_amp1_128b);
+        dl_ch_mag1_128b[0] = _mm_slli_epi16(dl_ch_mag1_128b[0],1);
+
+       // print_shorts("dl_ch_mag1_128b[0]=",&dl_ch_mag1_128b[0]);
+
+        dl_ch_mag1_128b[1] = _mm_mulhi_epi16(dl_ch_mag1_128b[1],QAM_amp1_128b);
+        dl_ch_mag1_128b[1] = _mm_slli_epi16(dl_ch_mag1_128b[1],1);
+
+        if (pilots==0) {
+          dl_ch_mag1_128b[2] = _mm_mulhi_epi16(dl_ch_mag1_128b[2],QAM_amp1_128b);
+          dl_ch_mag1_128b[2] = _mm_slli_epi16(dl_ch_mag1_128b[2],1);
+        }
+      }
+
+      // layer 0
+      // MF multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],rxdataF128[0]);
+    //  print_ints("re",&mmtmpD0);
+
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[0],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]);
+           // print_ints("im",&mmtmpD1);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0);
+           // printf("Shift: %d\n",output_shift);
+          // print_ints("re(shift)",&mmtmpD0);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0);
+           // print_ints("im(shift)",&mmtmpD1);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+          //  print_ints("c0",&mmtmpD2);
+          // print_ints("c1",&mmtmpD3);
+      rxdataF_comp0_128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+
+           // print_shorts("rx:",rxdataF128);
+           // print_shorts("ch:",dl_ch0_128);
+        // print_shorts("pack:",rxdataF_comp0_128);
+
+      // multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch0_128[1],rxdataF128[1]);
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[1],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+      rxdataF_comp0_128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+           //  print_shorts("rx:",rxdataF128+1);
+            //  print_shorts("ch:",dl_ch0_128+1);
+            // print_shorts("pack:",rxdataF_comp0_128+1);
+
+      if (pilots==0) {
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch0_128[2],rxdataF128[2]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[2],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+        rxdataF_comp0_128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+           //   print_shorts("rx:",rxdataF128+2);
+           //   print_shorts("ch:",dl_ch0_128+2);
+            //  print_shorts("pack:",rxdataF_comp0_128+2);
+
+      }
+
+
+      // layer 1
+      // MF multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch1_128[0],rxdataF128[0]);
+           //  print_ints("re",&mmtmpD0);
+
+     // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch1_128[0],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
+            //  print_ints("im",&mmtmpD1);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift1);
+             // print_ints("re(shift)",&mmtmpD0);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift1);
+             // print_ints("im(shift)",&mmtmpD1);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+             // print_ints("c0",&mmtmpD2);
+             // print_ints("c1",&mmtmpD3);
+      rxdataF_comp1_128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+            // print_shorts("rx:",rxdataF128);
+            //  print_shorts("ch:",dl_ch1_128);
+            // print_shorts("pack:",rxdataF_comp1_128);
+
+     // multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch1_128[1],rxdataF128[1]);
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch1_128[1],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift1);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift1);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+      rxdataF_comp1_128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+            //  print_shorts("rx:",rxdataF128+1);
+           // print_shorts("ch:",dl_ch1_128+1);
+            // print_shorts("pack:",rxdataF_comp1_128+1);
+
+      if (pilots==0) {
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch1_128[2],rxdataF128[2]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch1_128[2],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift1);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift1);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+
+        rxdataF_comp1_128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+          //   print_shorts("rx:",rxdataF128+2);
+           //  print_shorts("ch:",dl_ch1_128+2);
+             //         print_shorts("pack:",rxdataF_comp1_128+2);
+
+        dl_ch0_128+=3;
+        dl_ch1_128+=3;
+        dl_ch_mag0_128+=3;
+        dl_ch_mag1_128+=3;
+        dl_ch_mag0_128b+=3;
+        dl_ch_mag1_128b+=3;
+        rxdataF128+=3;
+        rxdataF_comp0_128+=3;
+        rxdataF_comp1_128+=3;
+      }
+      else {
+        dl_ch0_128+=2;
+        dl_ch1_128+=2;
+        dl_ch_mag0_128+=2;
+        dl_ch_mag1_128+=2;
+        dl_ch_mag0_128b+=2;
+        dl_ch_mag1_128b+=2;
+        rxdataF128+=2;
+        rxdataF_comp0_128+=2;
+        rxdataF_comp1_128+=2;
+      }
+
+    } // rb loop
+    Nre = (pilots==0) ? 12 : 8;
+
+    precoded_signal_strength0 += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre],
+                                                        (nb_rb*Nre))*rx_power_correction) - (measurements->n0_power[aarx]));
+
+    precoded_signal_strength1 += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx+2][symbol*frame_parms->N_RB_DL*Nre],
+                                                        (nb_rb*Nre))*rx_power_correction) - (measurements->n0_power[aarx]));
+  } // rx_antennas
+
+  measurements->precoded_cqi_dB[eNB_id][0] = dB_fixed2(precoded_signal_strength0,measurements->n0_power_tot);
+  measurements->precoded_cqi_dB[eNB_id][1] = dB_fixed2(precoded_signal_strength1,measurements->n0_power_tot);
+
+ // printf("eNB_id %d, symbol %d: precoded CQI %d dB\n",eNB_id,symbol,
+     //  measurements->precoded_cqi_dB[eNB_id][0]);
+
+  _mm_empty();
+  _m_empty();
+
+  #elif defined(__arm__)
+
+  unsigned short rb,Nre;
+  unsigned char aarx,symbol_mod,pilots=0;
+  int precoded_signal_strength0=0,precoded_signal_strength1=0, rx_power_correction;
+  int16x4_t *dl_ch0_128,*rxdataF128;
+  int16x4_t *dl_ch1_128;
+  int16x8_t *dl_ch0_128b,*dl_ch1_128b;
+
+  int32x4_t mmtmpD0,mmtmpD1,mmtmpD0b,mmtmpD1b;
+  int16x8_t *dl_ch_mag0_128,*dl_ch_mag0_128b,*dl_ch_mag1_128,*dl_ch_mag1_128b,mmtmpD2,mmtmpD3,mmtmpD4,*rxdataF_comp0_128,*rxdataF_comp1_128;
+  int16x8_t QAM_amp0_128,QAM_amp0_128b,QAM_amp1_128,QAM_amp1_128b;
+  int32x4_t output_shift128 = vmovq_n_s32(-(int32_t)output_shift);
+
+  int **rxdataF_ext           = pdsch_vars->rxdataF_ext;
+  int **dl_ch_estimates_ext   = pdsch_vars->dl_ch_estimates_ext;
+  int **dl_ch_mag0            = pdsch_vars->dl_ch_mag0;
+  int **dl_ch_mag1            = pdsch_vars->dl_ch_mag1[harq_pid][round];
+  int **dl_ch_magb0           = pdsch_vars->dl_ch_magb0;
+  int **dl_ch_magb1           = pdsch_vars->dl_ch_magb1[harq_pid][round];
+  int **rxdataF_comp0         = pdsch_vars->rxdataF_comp0;
+  int **rxdataF_comp1         = pdsch_vars->rxdataF_comp1[harq_pid][round];
+
+  int16_t conj[4]__attribute__((aligned(16))) = {1,-1,1,-1};
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
+      { nb_rb=1+(5*nb_rb/6); }
+
+    else
+      { pilots=1; }
+  }
+
+  rx_power_correction=1;
+
+  if (mod_order0 == 4) {
+    QAM_amp0_128  = vmovq_n_s16(QAM16_n1);  // 2/sqrt(10)
+    QAM_amp0_128b = vmovq_n_s16(0);
+
+  } else if (mod_order0 == 6) {
+    QAM_amp0_128  = vmovq_n_s16(QAM64_n1); //
+    QAM_amp0_128b = vmovq_n_s16(QAM64_n2);
+  }
+
+  if (mod_order1 == 4) {
+    QAM_amp1_128  = vmovq_n_s16(QAM16_n1);  // 2/sqrt(10)
+    QAM_amp1_128b = vmovq_n_s16(0);
+
+  } else if (mod_order1 == 6) {
+    QAM_amp1_128  = vmovq_n_s16(QAM64_n1); //
+    QAM_amp1_128b = vmovq_n_s16(QAM64_n2);
+  }
+
+  //    printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol);
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+
+
+    dl_ch0_128          = (int16x4_t*)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128          = (int16x4_t*)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch0_128b          = (int16x8_t*)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128b          = (int16x8_t*)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch_mag0_128      = (int16x8_t*)&dl_ch_mag0[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch_mag0_128b     = (int16x8_t*)&dl_ch_magb0[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch_mag1_128      = (int16x8_t*)&dl_ch_mag1[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch_mag1_128b     = (int16x8_t*)&dl_ch_magb1[aarx][symbol*frame_parms->N_RB_DL*12];
+    rxdataF128          = (int16x4_t*)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    rxdataF_comp0_128   = (int16x8_t*)&rxdataF_comp0[aarx][symbol*frame_parms->N_RB_DL*12];
+    rxdataF_comp1_128   = (int16x8_t*)&rxdataF_comp1[aarx][symbol*frame_parms->N_RB_DL*12];
+
+    for (rb=0; rb<nb_rb; rb++) {
+      // combine TX channels using precoder from pmi
+      if (mimo_mode==LARGE_CDD) {
+        prec2A_TM3_128(&dl_ch0_128[0],&dl_ch1_128[0]);
+        prec2A_TM3_128(&dl_ch0_128[1],&dl_ch1_128[1]);
+
+
+        if (pilots==0) {
+          prec2A_TM3_128(&dl_ch0_128[2],&dl_ch1_128[2]);
+        }
+      }
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1) {
+        prec2A_TM4_128(0,&dl_ch0_128[0],&dl_ch1_128[0]);
+        prec2A_TM4_128(0,&dl_ch0_128[1],&dl_ch1_128[1]);
+
+        if (pilots==0) {
+          prec2A_TM4_128(0,&dl_ch0_128[2],&dl_ch1_128[2]);
+        }
+      }
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj) {
+        prec2A_TM4_128(1,&dl_ch0_128[0],&dl_ch1_128[0]);
+        prec2A_TM4_128(1,&dl_ch0_128[1],&dl_ch1_128[1]);
+
+        if (pilots==0) {
+          prec2A_TM4_128(1,&dl_ch0_128[2],&dl_ch1_128[2]);
+        }
+      }
+      else {
+        LOG_E(PHY,"Unknown MIMO mode\n");
+        return;
+      }
+
+
+      if (mod_order0>2) {
+        // get channel amplitude if not QPSK
+        mmtmpD0 = vmull_s16(dl_ch0_128[0], dl_ch0_128[0]);
+        // mmtmpD0 = [ch0*ch0,ch1*ch1,ch2*ch2,ch3*ch3];
+        mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+        // mmtmpD0 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3]>>output_shift128 on 32-bits
+        mmtmpD1 = vmull_s16(dl_ch0_128[1], dl_ch0_128[1]);
+        mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+        mmtmpD2 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+        // mmtmpD2 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3,ch4*ch4 + ch5*ch5,ch4*ch4 + ch5*ch5,ch6*ch6 + ch7*ch7,ch6*ch6 + ch7*ch7]>>output_shift128 on 16-bits
+        mmtmpD0 = vmull_s16(dl_ch0_128[2], dl_ch0_128[2]);
+        mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+        mmtmpD1 = vmull_s16(dl_ch0_128[3], dl_ch0_128[3]);
+        mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+        mmtmpD3 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+        if (pilots==0) {
+          mmtmpD0 = vmull_s16(dl_ch0_128[4], dl_ch0_128[4]);
+          mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+          mmtmpD1 = vmull_s16(dl_ch0_128[5], dl_ch0_128[5]);
+          mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+          mmtmpD4 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+
+        }
+
+        dl_ch_mag0_128b[0] = vqdmulhq_s16(mmtmpD2,QAM_amp0_128b);
+        dl_ch_mag0_128b[1] = vqdmulhq_s16(mmtmpD3,QAM_amp0_128b);
+        dl_ch_mag0_128[0] = vqdmulhq_s16(mmtmpD2,QAM_amp0_128);
+        dl_ch_mag0_128[1] = vqdmulhq_s16(mmtmpD3,QAM_amp0_128);
+
+
+        if (pilots==0) {
+          dl_ch_mag0_128b[2] = vqdmulhq_s16(mmtmpD4,QAM_amp0_128b);
+          dl_ch_mag0_128[2]  = vqdmulhq_s16(mmtmpD4,QAM_amp0_128);
+        }
+      }
+
+      if (mod_order1>2) {
+        // get channel amplitude if not QPSK
+        mmtmpD0 = vmull_s16(dl_ch1_128[0], dl_ch1_128[0]);
+        // mmtmpD0 = [ch0*ch0,ch1*ch1,ch2*ch2,ch3*ch3];
+        mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+        // mmtmpD0 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3]>>output_shift128 on 32-bits
+        mmtmpD1 = vmull_s16(dl_ch1_128[1], dl_ch1_128[1]);
+        mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+        mmtmpD2 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+        // mmtmpD2 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3,ch4*ch4 + ch5*ch5,ch4*ch4 + ch5*ch5,ch6*ch6 + ch7*ch7,ch6*ch6 + ch7*ch7]>>output_shift128 on 16-bits
+        mmtmpD0 = vmull_s16(dl_ch1_128[2], dl_ch1_128[2]);
+        mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+        mmtmpD1 = vmull_s16(dl_ch1_128[3], dl_ch1_128[3]);
+        mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+        mmtmpD3 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+        if (pilots==0) {
+          mmtmpD0 = vmull_s16(dl_ch1_128[4], dl_ch1_128[4]);
+          mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128);
+          mmtmpD1 = vmull_s16(dl_ch1_128[5], dl_ch1_128[5]);
+          mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128);
+          mmtmpD4 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+
+        }
+
+        dl_ch_mag1_128b[0] = vqdmulhq_s16(mmtmpD2,QAM_amp1_128b);
+        dl_ch_mag1_128b[1] = vqdmulhq_s16(mmtmpD3,QAM_amp1_128b);
+        dl_ch_mag1_128[0] = vqdmulhq_s16(mmtmpD2,QAM_amp1_128);
+        dl_ch_mag1_128[1] = vqdmulhq_s16(mmtmpD3,QAM_amp1_128);
+
+
+        if (pilots==0) {
+          dl_ch_mag1_128b[2] = vqdmulhq_s16(mmtmpD4,QAM_amp1_128b);
+          dl_ch_mag1_128[2]  = vqdmulhq_s16(mmtmpD4,QAM_amp1_128);
+        }
+      }
+
+      mmtmpD0 = vmull_s16(dl_ch0_128[0], rxdataF128[0]);
+      //mmtmpD0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])]
+      mmtmpD1 = vmull_s16(dl_ch0_128[1], rxdataF128[1]);
+      //mmtmpD1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])]
+      mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+      //mmtmpD0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])]
+
+      mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[0],*(int16x4_t*)conj)), rxdataF128[0]);
+      //mmtmpD0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])]
+      mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[1],*(int16x4_t*)conj)), rxdataF128[1]);
+      //mmtmpD0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])]
+      mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+      //mmtmpD1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])]
+
+      mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+      mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+      rxdataF_comp0_128[0] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+      mmtmpD0 = vmull_s16(dl_ch0_128[2], rxdataF128[2]);
+      mmtmpD1 = vmull_s16(dl_ch0_128[3], rxdataF128[3]);
+      mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+
+      mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[2],*(int16x4_t*)conj)), rxdataF128[2]);
+      mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[3],*(int16x4_t*)conj)), rxdataF128[3]);
+      mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+      mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+      mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+      rxdataF_comp0_128[1] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+      // second stream
+      mmtmpD0 = vmull_s16(dl_ch1_128[0], rxdataF128[0]);
+      mmtmpD1 = vmull_s16(dl_ch1_128[1], rxdataF128[1]);
+      mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+      mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[0],*(int16x4_t*)conj)), rxdataF128[0]);
+
+      mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[1],*(int16x4_t*)conj)), rxdataF128[1]);
+      //mmtmpD0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])]
+      mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+      //mmtmpD1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])]
+
+      mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+      mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+      rxdataF_comp1_128[0] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+      mmtmpD0 = vmull_s16(dl_ch1_128[2], rxdataF128[2]);
+      mmtmpD1 = vmull_s16(dl_ch1_128[3], rxdataF128[3]);
+      mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                             vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+
+      mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[2],*(int16x4_t*)conj)), rxdataF128[2]);
+      mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[3],*(int16x4_t*)conj)), rxdataF128[3]);
+      mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                             vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+      mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+      mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+      rxdataF_comp1_128[1] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+
+      if (pilots==0) {
+        mmtmpD0 = vmull_s16(dl_ch0_128[4], rxdataF128[4]);
+        mmtmpD1 = vmull_s16(dl_ch0_128[5], rxdataF128[5]);
+        mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                               vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+
+        mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[4],*(int16x4_t*)conj)), rxdataF128[4]);
+        mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch0_128[5],*(int16x4_t*)conj)), rxdataF128[5]);
+        mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                               vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+
+        mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+        mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+        rxdataF_comp0_128[2] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+        mmtmpD0 = vmull_s16(dl_ch1_128[4], rxdataF128[4]);
+        mmtmpD1 = vmull_s16(dl_ch1_128[5], rxdataF128[5]);
+        mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)),
+                               vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1)));
+
+        mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(dl_ch1_128[4],*(int16x4_t*)conj)), rxdataF128[4]);
+        mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(dl_ch1_128[5],*(int16x4_t*)conj)), rxdataF128[5]);
+        mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)),
+                               vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b)));
+
+
+        mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128);
+        mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128);
+        rxdataF_comp1_128[2] = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1));
+      }
+    }
+
+
+
+    Nre = (pilots==0) ? 12 : 8;
+
+    // rx_antennas
+  }
+
+
+  Nre = (pilots==0) ? 12 : 8;
+
+  precoded_signal_strength0 += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre],
+                                                        (nb_rb*Nre))*rx_power_correction) - (measurements->n0_power[aarx]));
+  precoded_signal_strength1 += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx+2][symbol*frame_parms->N_RB_DL*Nre],
+                                                        (nb_rb*Nre))*rx_power_correction) - (measurements->n0_power[aarx]));
+
+  measurements->precoded_cqi_dB[eNB_id][0] = dB_fixed2(precoded_signal_strength0,measurements->n0_power_tot);
+  measurements->precoded_cqi_dB[eNB_id][1] = dB_fixed2(precoded_signal_strength1,measurements->n0_power_tot);
+
+#endif
+}
+
+
+void dlsch_dual_stream_correlation(LTE_DL_FRAME_PARMS *frame_parms,
+                                   unsigned char symbol,
+                                   unsigned short nb_rb,
+                                   int **dl_ch_estimates_ext,
+                                   int **dl_ch_estimates_ext_i,
+                                   int **dl_ch_rho_ext,
+                                   unsigned char output_shift)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  unsigned short rb;
+  __m128i *dl_ch128,*dl_ch128i,*dl_ch_rho128,mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3;
+  unsigned char aarx,symbol_mod,pilots=0;
+
+  //    printf("dlsch_dual_stream_correlation: symbol %d\n",symbol);
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
+    pilots=1;
+  }
+
+  //  printf("Dual stream correlation (%p)\n",dl_ch_estimates_ext_i);
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+
+
+ //printf ("antenna %d", aarx);
+    dl_ch128          = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+
+    if (dl_ch_estimates_ext_i == NULL) // TM3/4
+      dl_ch128i         = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+    else
+      dl_ch128i         = (__m128i *)&dl_ch_estimates_ext_i[aarx][symbol*frame_parms->N_RB_DL*12];
+
+    dl_ch_rho128      = (__m128i *)&dl_ch_rho_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+
+
+    for (rb=0; rb<nb_rb; rb++) {
+      // multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128i[0]);
+      //      print_ints("re",&mmtmpD0);
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128i[0]);
+      //      print_ints("im",&mmtmpD1);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+      //      print_ints("re(shift)",&mmtmpD0);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+      //      print_ints("im(shift)",&mmtmpD1);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+      //      print_ints("c0",&mmtmpD2);
+      //      print_ints("c1",&mmtmpD3);
+      dl_ch_rho128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+    // print_shorts("rho 0:",dl_ch_rho128);
+      // multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128i[1]);
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128i[1]);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+      dl_ch_rho128[1] =_mm_packs_epi32(mmtmpD2,mmtmpD3);
+
+
+      if (pilots==0) {
+
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128i[2]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128i[2]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+        dl_ch_rho128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+
+       dl_ch128+=3;
+        dl_ch128i+=3;
+        dl_ch_rho128+=3;
+      } else {
+
+        dl_ch128+=2;
+        dl_ch128i+=2;
+        dl_ch_rho128+=2;
+      }
+    }
+
+  }
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+#endif
+}
+
+
+/*void dlsch_dual_stream_correlationTM34(LTE_DL_FRAME_PARMS *frame_parms,
+                                   unsigned char symbol,
+                                   unsigned short nb_rb,
+                                   int **dl_ch_estimates_ext,
+                                   int **dl_ch_estimates_ext_i,
+                                   int **dl_ch_rho_ext,
+                                   unsigned char output_shift0,
+                                   unsigned char output_shift1)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  unsigned short rb;
+  __m128i *dl_ch128,*dl_ch128i,*dl_ch_rho128,mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3;
+  unsigned char aarx,symbol_mod,pilots=0;
+  int output_shift;
+
+  //    printf("dlsch_dual_stream_correlation: symbol %d\n",symbol);
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
+    pilots=1;
+  }
+
+  //  printf("Dual stream correlation (%p)\n",dl_ch_estimates_ext_i);
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+       if (aarx==0) {
+      output_shift=output_shift0;
+    }
+      else {
+        output_shift=output_shift1;
+      }
+
+ //printf ("antenna %d", aarx);
+    dl_ch128          = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+
+    if (dl_ch_estimates_ext_i == NULL) // TM3/4
+      dl_ch128i         = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+    else
+      dl_ch128i         = (__m128i *)&dl_ch_estimates_ext_i[aarx][symbol*frame_parms->N_RB_DL*12];
+
+    dl_ch_rho128      = (__m128i *)&dl_ch_rho_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+
+
+    for (rb=0; rb<nb_rb; rb++) {
+      // multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128i[0]);
+      //      print_ints("re",&mmtmpD0);
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128i[0]);
+      //      print_ints("im",&mmtmpD1);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+      //      print_ints("re(shift)",&mmtmpD0);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+      //      print_ints("im(shift)",&mmtmpD1);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+      //      print_ints("c0",&mmtmpD2);
+      //      print_ints("c1",&mmtmpD3);
+      dl_ch_rho128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+    // print_shorts("rho 0:",dl_ch_rho128);
+      // multiply by conjugated channel
+      mmtmpD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128i[1]);
+      // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+      mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+      mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+      mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128i[1]);
+      // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+      mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+      mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+      mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+      mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+      dl_ch_rho128[1] =_mm_packs_epi32(mmtmpD2,mmtmpD3);
+
+
+      if (pilots==0) {
+
+        // multiply by conjugated channel
+        mmtmpD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128i[2]);
+        // mmtmpD0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate);
+        mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch128i[2]);
+        // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift);
+        mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift);
+        mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
+        mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
+        dl_ch_rho128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
+
+       dl_ch128+=3;
+        dl_ch128i+=3;
+        dl_ch_rho128+=3;
+      } else {
+
+        dl_ch128+=2;
+        dl_ch128i+=2;
+        dl_ch_rho128+=2;
+      }
+    }
+
+  }
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+#endif
+}
+*/
+
+void dlsch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms,
+                         int **rxdataF_comp,
+                         int **rxdataF_comp_i,
+                         int **rho,
+                         int **rho_i,
+                         int **dl_ch_mag,
+                         int **dl_ch_magb,
+                         int **dl_ch_mag_i,
+                         int **dl_ch_magb_i,
+                         unsigned char symbol,
+                         unsigned short nb_rb,
+                         unsigned char dual_stream_UE)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  unsigned char aatx;
+  int i;
+  __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1,
+    *dl_ch_mag128_i0,*dl_ch_mag128_i1,*dl_ch_mag128_i0b,*dl_ch_mag128_i1b;
+
+  if (frame_parms->nb_antennas_rx>1) {
+
+    for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+
+      rxdataF_comp128_0   = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_1   = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_0      = (__m128i *)&dl_ch_mag[(aatx<<1)][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_1      = (__m128i *)&dl_ch_mag[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_0b     = (__m128i *)&dl_ch_magb[(aatx<<1)][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_1b     = (__m128i *)&dl_ch_magb[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
+
+      // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation)
+      for (i=0;i<nb_rb*3;i++) {
+        rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
+        dl_ch_mag128_0[i]    = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1));
+        dl_ch_mag128_0b[i]   = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1));
+          //       print_shorts("mrc comp0:",&rxdataF_comp128_0[i]);
+        //       print_shorts("mrc mag0:",&dl_ch_mag128_0[i]);
+        //       print_shorts("mrc mag0b:",&dl_ch_mag128_0b[i]);
+        //      print_shorts("mrc rho1:",&rho128_1[i]);
+
+      }
+    }
+
+    if (rho) {
+      rho128_0 = (__m128i *) &rho[0][symbol*frame_parms->N_RB_DL*12];
+      rho128_1 = (__m128i *) &rho[1][symbol*frame_parms->N_RB_DL*12];
+      for (i=0;i<nb_rb*3;i++) {
+        //      print_shorts("mrc rho0:",&rho128_0[i]);
+        //      print_shorts("mrc rho1:",&rho128_1[i]);
+        rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1));
+      }
+    }
+
+
+    if (dual_stream_UE == 1) {
+      rho128_i0 = (__m128i *) &rho_i[0][symbol*frame_parms->N_RB_DL*12];
+      rho128_i1 = (__m128i *) &rho_i[1][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_i0   = (__m128i *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_i1   = (__m128i *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i0      = (__m128i *)&dl_ch_mag_i[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i1      = (__m128i *)&dl_ch_mag_i[1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i0b     = (__m128i *)&dl_ch_magb_i[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i1b     = (__m128i *)&dl_ch_magb_i[1][symbol*frame_parms->N_RB_DL*12];
+
+      for (i=0; i<nb_rb*3; i++) {
+        rxdataF_comp128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_i0[i],1),_mm_srai_epi16(rxdataF_comp128_i1[i],1));
+        rho128_i0[i]           = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1));
+
+        dl_ch_mag128_i0[i]    = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_i0[i],1),_mm_srai_epi16(dl_ch_mag128_i1[i],1));
+        dl_ch_mag128_i0b[i]    = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_i0b[i],1),_mm_srai_epi16(dl_ch_mag128_i1b[i],1));
+      }
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+  unsigned char aatx;
+  int i;
+  int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1,*dl_ch_mag128_i0,*dl_ch_mag128_i1,*dl_ch_mag128_i0b,*dl_ch_mag128_i1b;
+
+  if (frame_parms->nb_antennas_rx>1) {
+
+    for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+
+      rxdataF_comp128_0   = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_1   = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_0      = (int16x8_t *)&dl_ch_mag[(aatx<<1)][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_1      = (int16x8_t *)&dl_ch_mag[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_0b     = (int16x8_t *)&dl_ch_magb[(aatx<<1)][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_1b     = (int16x8_t *)&dl_ch_magb[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
+
+      // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation)
+      for (i=0; i<nb_rb*3; i++) {
+        rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]);
+        dl_ch_mag128_0[i]    = vhaddq_s16(dl_ch_mag128_0[i],dl_ch_mag128_1[i]);
+        dl_ch_mag128_0b[i]   = vhaddq_s16(dl_ch_mag128_0b[i],dl_ch_mag128_1b[i]);
+      }
+    }
+
+    if (rho) {
+      rho128_0 = (int16x8_t *) &rho[0][symbol*frame_parms->N_RB_DL*12];
+      rho128_1 = (int16x8_t *) &rho[1][symbol*frame_parms->N_RB_DL*12];
+
+      for (i=0; i<nb_rb*3; i++) {
+        //  print_shorts("mrc rho0:",&rho128_0[i]);
+        //  print_shorts("mrc rho1:",&rho128_1[i]);
+        rho128_0[i] = vhaddq_s16(rho128_0[i],rho128_1[i]);
+      }
+    }
+
+
+    if (dual_stream_UE == 1) {
+      rho128_i0 = (int16x8_t *) &rho_i[0][symbol*frame_parms->N_RB_DL*12];
+      rho128_i1 = (int16x8_t *) &rho_i[1][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_i0   = (int16x8_t *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_i1   = (int16x8_t *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12];
+
+      dl_ch_mag128_i0      = (int16x8_t *)&dl_ch_mag_i[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i1      = (int16x8_t *)&dl_ch_mag_i[1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i0b     = (int16x8_t *)&dl_ch_magb_i[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i1b     = (int16x8_t *)&dl_ch_magb_i[1][symbol*frame_parms->N_RB_DL*12];
+
+      for (i=0; i<nb_rb*3; i++) {
+        rxdataF_comp128_i0[i] = vhaddq_s16(rxdataF_comp128_i0[i],rxdataF_comp128_i1[i]);
+        rho128_i0[i]          = vhaddq_s16(rho128_i0[i],rho128_i1[i]);
+
+        dl_ch_mag128_i0[i]    = vhaddq_s16(dl_ch_mag128_i0[i],dl_ch_mag128_i1[i]);
+        dl_ch_mag128_i0b[i]   = vhaddq_s16(dl_ch_mag128_i0b[i],dl_ch_mag128_i1b[i]);
+      }
+    }
+  }
+
+#endif
+}
+
+
+void dlsch_detection_mrc_TM34(LTE_DL_FRAME_PARMS *frame_parms,
+                              LTE_UE_PDSCH *pdsch_vars,
+                              int harq_pid,
+                              int round,
+                              unsigned char symbol,
+                              unsigned short nb_rb,
+                              unsigned char dual_stream_UE) {
+
+  int i;
+  __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1,*dl_ch_mag128_i0,*dl_ch_mag128_i1,*dl_ch_mag128_i0b,*dl_ch_mag128_i1b;
+
+  int **rxdataF_comp0           = pdsch_vars->rxdataF_comp0;
+  int **rxdataF_comp1           = pdsch_vars->rxdataF_comp1[harq_pid][round];
+  int **dl_ch_rho_ext           = pdsch_vars->dl_ch_rho_ext[harq_pid][round]; //for second stream
+  int **dl_ch_rho2_ext          = pdsch_vars->dl_ch_rho2_ext;
+  int **dl_ch_mag0              = pdsch_vars->dl_ch_mag0;
+  int **dl_ch_mag1              = pdsch_vars->dl_ch_mag1[harq_pid][round];
+  int **dl_ch_magb0             = pdsch_vars->dl_ch_magb0;
+  int **dl_ch_magb1             = pdsch_vars->dl_ch_magb1[harq_pid][round];
+
+  if (frame_parms->nb_antennas_rx>1) {
+
+      rxdataF_comp128_0   = (__m128i *)&rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_1   = (__m128i *)&rxdataF_comp0[1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_0      = (__m128i *)&dl_ch_mag0[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_1      = (__m128i *)&dl_ch_mag0[1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_0b     = (__m128i *)&dl_ch_magb0[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_1b     = (__m128i *)&dl_ch_magb0[1][symbol*frame_parms->N_RB_DL*12];
+
+      // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation)
+      for (i=0;i<nb_rb*3;i++) {
+        rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
+        dl_ch_mag128_0[i]    = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1));
+        dl_ch_mag128_0b[i]   = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1));
+
+        // print_shorts("mrc compens0:",&rxdataF_comp128_0[i]);
+        // print_shorts("mrc mag128_0:",&dl_ch_mag128_0[i]);
+        // print_shorts("mrc mag128_0b:",&dl_ch_mag128_0b[i]);
+      }    }
+
+   // if (rho) {
+      rho128_0 = (__m128i *) &dl_ch_rho2_ext[0][symbol*frame_parms->N_RB_DL*12];
+      rho128_1 = (__m128i *) &dl_ch_rho2_ext[1][symbol*frame_parms->N_RB_DL*12];
+      for (i=0;i<nb_rb*3;i++) {
+           //  print_shorts("mrc rho0:",&rho128_0[i]);
+            //  print_shorts("mrc rho1:",&rho128_1[i]);
+        rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1));
+      }
+   //}
+
+
+    if (dual_stream_UE == 1) {
+      rho128_i0 = (__m128i *) &dl_ch_rho_ext[0][symbol*frame_parms->N_RB_DL*12];
+      rho128_i1 = (__m128i *) &dl_ch_rho_ext[1][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_i0   = (__m128i *)&rxdataF_comp1[0][symbol*frame_parms->N_RB_DL*12];
+      rxdataF_comp128_i1   = (__m128i *)&rxdataF_comp1[1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i0      = (__m128i *)&dl_ch_mag1[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i1      = (__m128i *)&dl_ch_mag1[1][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i0b     = (__m128i *)&dl_ch_magb1[0][symbol*frame_parms->N_RB_DL*12];
+      dl_ch_mag128_i1b     = (__m128i *)&dl_ch_magb1[1][symbol*frame_parms->N_RB_DL*12];
+      for (i=0;i<nb_rb*3;i++) {
+        rxdataF_comp128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_i0[i],1),_mm_srai_epi16(rxdataF_comp128_i1[i],1));
+        rho128_i0[i]           = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1));
+
+        dl_ch_mag128_i0[i]    = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_i0[i],1),_mm_srai_epi16(dl_ch_mag128_i1[i],1));
+        dl_ch_mag128_i0b[i]    = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_i0b[i],1),_mm_srai_epi16(dl_ch_mag128_i1b[i],1));
+
+        //print_shorts("mrc compens1:",&rxdataF_comp128_i0[i]);
+        //print_shorts("mrc mag128_i0:",&dl_ch_mag128_i0[i]);
+        //print_shorts("mrc mag128_i0b:",&dl_ch_mag128_i0b[i]);
+      }
+    }
+
+
+  _mm_empty();
+  _m_empty();
+}
+
+
+
+void dlsch_scale_channel(int **dl_ch_estimates_ext,
+                         LTE_DL_FRAME_PARMS *frame_parms,
+                         LTE_UE_DLSCH_t **dlsch_ue,
+                         uint8_t symbol,
+                         unsigned short nb_rb)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  short rb, ch_amp;
+  unsigned char aatx,aarx,pilots=0,symbol_mod;
+  __m128i *dl_ch128, ch_amp128;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
+      nb_rb=1+(5*nb_rb/6);
+    else
+      pilots=1;
+  }
+
+  // Determine scaling amplitude based the symbol
+
+  ch_amp = ((pilots) ? (dlsch_ue[0]->sqrt_rho_b) : (dlsch_ue[0]->sqrt_rho_a));
+  
+  LOG_D(PHY,"Scaling PDSCH Chest in OFDM symbol %d by %d, pilots %d nb_rb %d NCP %d symbol %d\n",symbol_mod,ch_amp,pilots,nb_rb,frame_parms->Ncp,symbol);
+   // printf("Scaling PDSCH Chest in OFDM symbol %d by %d\n",symbol_mod,ch_amp);
+
+  ch_amp128 = _mm_set1_epi16(ch_amp); // Q3.13
+
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+      dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+
+      for (rb=0;rb<nb_rb;rb++) {
+
+        dl_ch128[0] = _mm_mulhi_epi16(dl_ch128[0],ch_amp128);
+        dl_ch128[0] = _mm_slli_epi16(dl_ch128[0],3);
+
+        dl_ch128[1] = _mm_mulhi_epi16(dl_ch128[1],ch_amp128);
+        dl_ch128[1] = _mm_slli_epi16(dl_ch128[1],3);
+
+        if (pilots) {
+          dl_ch128+=2;
+        } else {
+          dl_ch128[2] = _mm_mulhi_epi16(dl_ch128[2],ch_amp128);
+          dl_ch128[2] = _mm_slli_epi16(dl_ch128[2],3);
+          dl_ch128+=3;
+
+        }
+      }
+    }
+  }
+
+#elif defined(__arm__)
+
+#endif
+}
+
+
+//compute average channel_level on each (TX,RX) antenna pair
+void dlsch_channel_level(int **dl_ch_estimates_ext,
+                         LTE_DL_FRAME_PARMS *frame_parms,
+                         int32_t *avg,
+                         uint8_t symbol,
+                         unsigned short nb_rb)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  short rb;
+  unsigned char aatx,aarx,nre=12,symbol_mod;
+  __m128i *dl_ch128, avg128D;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
+    nre=8;
+  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
+    nre=10;
+  else
+    nre=12;
+
+  //nb_rb*nre = y * 2^x
+  int16_t x = factor2(nb_rb*nre);
+  int16_t y = (nb_rb*nre)>>x;
+  //printf("nb_rb*nre = %d = %d * 2^(%d)\n",nb_rb*nre,y,x);
+
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      //clear average level
+      avg128D = _mm_setzero_si128();
+      // 5 is always a symbol with no pilots for both normal and extended prefix
+
+      dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+
+      for (rb=0;rb<nb_rb;rb++) {
+        //      printf("rb %d : ",rb);
+        //      print_shorts("ch",&dl_ch128[0]);
+	avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[0],dl_ch128[0]),x));
+	avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[1],dl_ch128[1]),x));
+
+        //avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[0],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[0], coeff128),15)));
+        //avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[1],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[1], coeff128),15)));
+
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+          dl_ch128+=2;
+        }
+        else {
+	  avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[2],dl_ch128[2]),x));
+          //avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[2], coeff128),15)));
+          dl_ch128+=3;
+        }
+        /*
+          if (rb==0) {
+          print_shorts("dl_ch128",&dl_ch128[0]);
+          print_shorts("dl_ch128",&dl_ch128[1]);
+          print_shorts("dl_ch128",&dl_ch128[2]);
+          }
+        */
+      }
+
+      avg[(aatx<<1)+aarx] =(((int32_t*)&avg128D)[0] +
+                            ((int32_t*)&avg128D)[1] +
+                            ((int32_t*)&avg128D)[2] +
+			      ((int32_t*)&avg128D)[3])/y;
+                //  printf("Channel level : %d\n",avg[(aatx<<1)+aarx]);
+    }
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+  short rb;
+  unsigned char aatx,aarx,nre=12,symbol_mod;
+  int32x4_t avg128D;
+  int16x4_t *dl_ch128;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      //clear average level
+      avg128D = vdupq_n_s32(0);
+      // 5 is always a symbol with no pilots for both normal and extended prefix
+
+      dl_ch128=(int16x4_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+
+      for (rb=0; rb<nb_rb; rb++) {
+        //  printf("rb %d : ",rb);
+        //  print_shorts("ch",&dl_ch128[0]);
+        avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[0],dl_ch128[0]));
+        avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[1],dl_ch128[1]));
+        avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[2],dl_ch128[2]));
+        avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[3],dl_ch128[3]));
+
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+          dl_ch128+=4;
+        } else {
+          avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[4],dl_ch128[4]));
+          avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[5],dl_ch128[5]));
+          dl_ch128+=6;
+        }
+
+        /*
+          if (rb==0) {
+          print_shorts("dl_ch128",&dl_ch128[0]);
+          print_shorts("dl_ch128",&dl_ch128[1]);
+          print_shorts("dl_ch128",&dl_ch128[2]);
+          }
+        */
+      }
+
+
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
+        nre=8;
+      else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
+        nre=10;
+      else
+        nre=12;
+
+      avg[(aatx<<1)+aarx] = (((int32_t*)&avg128D)[0] +
+                             ((int32_t*)&avg128D)[1] +
+                             ((int32_t*)&avg128D)[2] +
+                             ((int32_t*)&avg128D)[3])/(nb_rb*nre);
+
+      //            printf("Channel level : %d\n",avg[(aatx<<1)+aarx]);
+    }
+
+
+#endif
+}
+
+//compute average channel_level of effective (precoded) channel
+
+//compute average channel_level of effective (precoded) channel
+void dlsch_channel_level_TM34(int **dl_ch_estimates_ext,
+                              LTE_DL_FRAME_PARMS *frame_parms,
+                              unsigned char *pmi_ext,
+                              int *avg_0,
+                              int *avg_1,
+                              uint8_t symbol,
+                              unsigned short nb_rb,
+                              MIMO_mode_t mimo_mode){
+
+#if defined(__x86_64__)||defined(__i386__)
+
+
+  short rb;
+  unsigned char aarx,nre=12,symbol_mod;
+  __m128i *dl_ch0_128,*dl_ch1_128, dl_ch0_128_tmp, dl_ch1_128_tmp, avg_0_128D, avg_1_128D;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  //clear average level
+ // avg_0_128D = _mm_setzero_si128();
+ // avg_1_128D = _mm_setzero_si128();
+  avg_0[0] = 0;
+  avg_0[1] = 0;
+  avg_1[0] = 0;
+  avg_1[1] = 0;
+  // 5 is always a symbol with no pilots for both normal and extended prefix
+
+  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
+    nre=8;
+  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
+    nre=10;
+  else
+    nre=12;
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+    dl_ch0_128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+
+    avg_0_128D = _mm_setzero_si128();
+    avg_1_128D = _mm_setzero_si128();
+    for (rb=0; rb<nb_rb; rb++) {
+              // printf("rb %d : \n",rb);
+              // print_shorts("ch0\n",&dl_ch0_128[0]);
+               //print_shorts("ch1\n",&dl_ch1_128[0]);
+      dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[0]);
+      dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[0]);
+
+      if (mimo_mode==LARGE_CDD)
+        prec2A_TM3_128(&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1)
+        prec2A_TM4_128(0,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj)
+        prec2A_TM4_128(1,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_PUSCH_PRECODING)
+        prec2A_TM4_128(pmi_ext[rb],&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+
+      //      mmtmpD0 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+      avg_0_128D = _mm_add_epi32(avg_0_128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+      avg_1_128D = _mm_add_epi32(avg_1_128D,_mm_madd_epi16(dl_ch1_128_tmp,dl_ch1_128_tmp));
+
+      dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[1]);
+      dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[1]);
+
+      if (mimo_mode==LARGE_CDD)
+        prec2A_TM3_128(&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1)
+        prec2A_TM4_128(0,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj)
+        prec2A_TM4_128(1,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_PUSCH_PRECODING)
+        prec2A_TM4_128(pmi_ext[rb],&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+
+      //      mmtmpD1 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+      avg_0_128D = _mm_add_epi32(avg_0_128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+      avg_1_128D = _mm_add_epi32(avg_1_128D,_mm_madd_epi16(dl_ch1_128_tmp,dl_ch1_128_tmp));
+
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+        dl_ch0_128+=2;
+        dl_ch1_128+=2;
+      }
+      else {
+        dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[2]);
+        dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[2]);
+
+        if (mimo_mode==LARGE_CDD)
+          prec2A_TM3_128(&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+        else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1)
+          prec2A_TM4_128(0,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+        else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj)
+          prec2A_TM4_128(1,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+        else if (mimo_mode==DUALSTREAM_PUSCH_PRECODING)
+          prec2A_TM4_128(pmi_ext[rb],&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+        //      mmtmpD2 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+
+        avg_1_128D = _mm_add_epi32(avg_1_128D,_mm_madd_epi16(dl_ch1_128_tmp,dl_ch1_128_tmp));
+        avg_0_128D = _mm_add_epi32(avg_0_128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+        dl_ch0_128+=3;
+        dl_ch1_128+=3;
+      }
+    }
+
+
+    avg_0[aarx] = (((int*)&avg_0_128D)[0])/(nb_rb*nre) +
+      (((int*)&avg_0_128D)[1])/(nb_rb*nre) +
+      (((int*)&avg_0_128D)[2])/(nb_rb*nre) +
+      (((int*)&avg_0_128D)[3])/(nb_rb*nre);
+    //  printf("From Chan_level aver stream 0 %d =%d\n", aarx, avg_0[aarx]);
+
+    avg_1[aarx] = (((int*)&avg_1_128D)[0])/(nb_rb*nre) +
+      (((int*)&avg_1_128D)[1])/(nb_rb*nre) +
+      (((int*)&avg_1_128D)[2])/(nb_rb*nre) +
+      (((int*)&avg_1_128D)[3])/(nb_rb*nre);
+  //    printf("From Chan_level aver stream 1 %d =%d\n", aarx, avg_1[aarx]);
+  }
+//avg_0[0] = max(avg_0[0],avg_0[1]);
+//avg_1[0] = max(avg_1[0],avg_1[1]);
+//avg_0[0]= max(avg_0[0], avg_1[0]);
+
+  avg_0[0] = avg_0[0] + avg_0[1];
+ // printf("From Chan_level aver stream 0 final =%d\n", avg_0[0]);
+  avg_1[0] = avg_1[0] + avg_1[1];
+ // printf("From Chan_level aver stream 1 final =%d\n", avg_1[0]);
+ avg_0[0] = min (avg_0[0], avg_1[0]);
+ avg_1[0] = avg_0[0];
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+#endif
+}
+
+
+
+/*void dlsch_channel_level_TM34(int **dl_ch_estimates_ext,
+                              LTE_DL_FRAME_PARMS *frame_parms,
+                              int *avg,
+                              uint8_t symbol,
+                              unsigned short nb_rb,
+                              MIMO_mode_t mimo_mode){
+
+#if defined(__x86_64__)||defined(__i386__)
+
+
+  short rb;
+  unsigned char aarx,nre=12,symbol_mod;
+  __m128i *dl_ch0_128,*dl_ch1_128, dl_ch0_128_tmp, dl_ch1_128_tmp,avg128D;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  //clear average level
+  avg128D = _mm_setzero_si128();
+  avg[0] = 0;
+  avg[1] = 0;
+  // 5 is always a symbol with no pilots for both normal and extended prefix
+
+  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
+    nre=8;
+  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
+    nre=10;
+  else
+    nre=12;
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+    dl_ch0_128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+
+    for (rb=0; rb<nb_rb; rb++) {
+
+      dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[0]);
+      dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[0]);
+
+      if (mimo_mode==LARGE_CDD)
+        prec2A_TM3_128(&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1)
+        prec2A_TM4_128(0,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj)
+        prec2A_TM4_128(1,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+
+      //      mmtmpD0 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+      avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+      dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[1]);
+      dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[1]);
+
+      if (mimo_mode==LARGE_CDD)
+        prec2A_TM3_128(&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1)
+        prec2A_TM4_128(0,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj)
+        prec2A_TM4_128(1,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+
+      //      mmtmpD1 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+      avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+        dl_ch0_128+=2;
+        dl_ch1_128+=2;
+      }
+      else {
+        dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[2]);
+        dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[2]);
+
+        if (mimo_mode==LARGE_CDD)
+          prec2A_TM3_128(&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+        else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODING1)
+          prec2A_TM4_128(0,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+        else if (mimo_mode==DUALSTREAM_UNIFORM_PRECODINGj)
+          prec2A_TM4_128(1,&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+
+        //      mmtmpD2 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+        avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+        dl_ch0_128+=3;
+        dl_ch1_128+=3;
+      }
+    }
+
+    avg[aarx] = (((int*)&avg128D)[0])/(nb_rb*nre) +
+      (((int*)&avg128D)[1])/(nb_rb*nre) +
+      (((int*)&avg128D)[2])/(nb_rb*nre) +
+      (((int*)&avg128D)[3])/(nb_rb*nre);
+  }
+
+  // choose maximum of the 2 effective channels
+  avg[0] = cmax(avg[0],avg[1]);
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+#endif
+}*/
+
+//compute average channel_level of effective (precoded) channel
+void dlsch_channel_level_TM56(int **dl_ch_estimates_ext,
+                              LTE_DL_FRAME_PARMS *frame_parms,
+                              unsigned char *pmi_ext,
+                              int *avg,
+                              uint8_t symbol,
+                              unsigned short nb_rb)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  short rb;
+  unsigned char aarx,nre=12,symbol_mod;
+  __m128i *dl_ch0_128,*dl_ch1_128, dl_ch0_128_tmp, dl_ch1_128_tmp,avg128D;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  //clear average level
+  avg128D = _mm_setzero_si128();
+  avg[0] = 0;
+  avg[1] = 0;
+  // 5 is always a symbol with no pilots for both normal and extended prefix
+
+  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
+    nre=8;
+  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
+    nre=10;
+  else
+    nre=12;
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+    dl_ch0_128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
+    dl_ch1_128 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12];
+
+    for (rb=0; rb<nb_rb; rb++) {
+
+      dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[0]);
+      dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[0]);
+
+      prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      //      mmtmpD0 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+      avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+      dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[1]);
+      dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[1]);
+
+      prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+      //      mmtmpD1 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+      avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+        dl_ch0_128+=2;
+        dl_ch1_128+=2;
+      }
+      else {
+        dl_ch0_128_tmp = _mm_load_si128(&dl_ch0_128[2]);
+        dl_ch1_128_tmp = _mm_load_si128(&dl_ch1_128[2]);
+
+        prec2A_TM56_128(pmi_ext[rb],&dl_ch0_128_tmp,&dl_ch1_128_tmp);
+        //      mmtmpD2 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
+        avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
+
+        dl_ch0_128+=3;
+        dl_ch1_128+=3;
+      }
+    }
+
+    avg[aarx] = (((int*)&avg128D)[0])/(nb_rb*nre) +
+      (((int*)&avg128D)[1])/(nb_rb*nre) +
+      (((int*)&avg128D)[2])/(nb_rb*nre) +
+      (((int*)&avg128D)[3])/(nb_rb*nre);
+  }
+
+  // choose maximum of the 2 effective channels
+  avg[0] = cmax(avg[0],avg[1]);
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+
+#endif
+}
+
+//compute average channel_level for TM7
+void dlsch_channel_level_TM7(int **dl_bf_ch_estimates_ext,
+                         LTE_DL_FRAME_PARMS *frame_parms,
+                         int *avg,
+                         uint8_t symbol,
+                         unsigned short nb_rb)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  short rb;
+  unsigned char aatx,aarx,nre=12,symbol_mod;
+  __m128i *dl_ch128,avg128D;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      //clear average level
+      avg128D = _mm_setzero_si128();
+      // 5 is always a symbol with no pilots for both normal and extended prefix
+
+      dl_ch128=(__m128i *)&dl_bf_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12];
+
+      for (rb=0; rb<nb_rb; rb++) {
+        //  printf("rb %d : ",rb);
+        //  print_shorts("ch",&dl_ch128[0]);
+        avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[0],dl_ch128[0]));
+        avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[1],dl_ch128[1]));
+
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+          dl_ch128+=2;
+        } else {
+          avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],dl_ch128[2]));
+          dl_ch128+=3;
+        }
+
+        /*
+          if (rb==0) {
+          print_shorts("dl_ch128",&dl_ch128[0]);
+          print_shorts("dl_ch128",&dl_ch128[1]);
+          print_shorts("dl_ch128",&dl_ch128[2]);
+          }
+        */
+      }
+
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1))))
+        nre=10;
+      else if ((frame_parms->Ncp==0) && (symbol==3 || symbol==6 || symbol==9 || symbol==12))
+        nre=9;
+      else if ((frame_parms->Ncp==1) && (symbol==4 || symbol==7 || symbol==9))
+        nre=8;
+      else
+        nre=12;
+
+      avg[(aatx<<1)+aarx] = (((int*)&avg128D)[0] +
+                             ((int*)&avg128D)[1] +
+                             ((int*)&avg128D)[2] +
+                             ((int*)&avg128D)[3])/(nb_rb*nre);
+
+      //            printf("Channel level : %d\n",avg[(aatx<<1)+aarx]);
+    }
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+#endif
+}
+//#define ONE_OVER_2_Q15 16384
+void dlsch_alamouti(LTE_DL_FRAME_PARMS *frame_parms,
+                    int **rxdataF_comp,
+                    int **dl_ch_mag,
+                    int **dl_ch_magb,
+                    unsigned char symbol,
+                    unsigned short nb_rb)
+{
+
+#if defined(__x86_64__)||defined(__i386__)
+
+  short *rxF0,*rxF1;
+  __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b, *rxF0_128;
+  unsigned char rb,re;
+  int jj = (symbol*frame_parms->N_RB_DL*12);
+  uint8_t symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+  uint8_t pilots = ((symbol_mod==0)||(symbol_mod==(4-frame_parms->Ncp))) ? 1 : 0;
+  rxF0_128 = (__m128i*) &rxdataF_comp[0][jj];
+
+  //amp = _mm_set1_epi16(ONE_OVER_2_Q15);
+
+
+  //    printf("Doing alamouti!\n");
+  rxF0     = (short*)&rxdataF_comp[0][jj];  //tx antenna 0  h0*y
+  rxF1     = (short*)&rxdataF_comp[2][jj];  //tx antenna 1  h1*y
+  ch_mag0 = (__m128i *)&dl_ch_mag[0][jj];
+  ch_mag1 = (__m128i *)&dl_ch_mag[2][jj];
+  ch_mag0b = (__m128i *)&dl_ch_magb[0][jj];
+  ch_mag1b = (__m128i *)&dl_ch_magb[2][jj];
+
+  for (rb=0; rb<nb_rb; rb++) {
+
+    for (re=0; re<((pilots==0)?12:8); re+=2) {
+
+      // Alamouti RX combining
+
+      //      printf("Alamouti: symbol %d, rb %d, re %d: rxF0 (%d,%d,%d,%d), rxF1 (%d,%d,%d,%d)\n",symbol,rb,re,rxF0[0],rxF0[1],rxF0[2],rxF0[3],rxF1[0],rxF1[1],rxF1[2],rxF1[3]);
+      rxF0[0] = rxF0[0] + rxF1[2];
+      rxF0[1] = rxF0[1] - rxF1[3];
+
+      rxF0[2] = rxF0[2] - rxF1[0];
+      rxF0[3] = rxF0[3] + rxF1[1];
+
+      //      printf("Alamouti: rxF0 after (%d,%d,%d,%d)\n",rxF0[0],rxF0[1],rxF0[2],rxF0[3]);
+      rxF0+=4;
+      rxF1+=4;
+
+    }
+
+    // compute levels for 16QAM or 64 QAM llr unit
+    ch_mag0[0] = _mm_adds_epi16(ch_mag0[0],ch_mag1[0]);
+    ch_mag0[1] = _mm_adds_epi16(ch_mag0[1],ch_mag1[1]);
+
+    ch_mag0b[0] = _mm_adds_epi16(ch_mag0b[0],ch_mag1b[0]);
+    ch_mag0b[1] = _mm_adds_epi16(ch_mag0b[1],ch_mag1b[1]);
+
+    // account for 1/sqrt(2) scaling at transmission
+    //ch_mag0[0] = _mm_srai_epi16(ch_mag0[0],1);
+    //ch_mag0[1] = _mm_srai_epi16(ch_mag0[1],1);
+    //ch_mag0b[0] = _mm_srai_epi16(ch_mag0b[0],1);
+    //ch_mag0b[1] = _mm_srai_epi16(ch_mag0b[1],1);
+
+    //rxF0_128[0] = _mm_mulhi_epi16(rxF0_128[0],amp);
+    //rxF0_128[0] = _mm_slli_epi16(rxF0_128[0],1);
+    //rxF0_128[1] = _mm_mulhi_epi16(rxF0_128[1],amp);
+    //rxF0_128[1] = _mm_slli_epi16(rxF0_128[1],1);
+
+    //rxF0_128[0] = _mm_srai_epi16(rxF0_128[0],1);
+    //rxF0_128[1] = _mm_srai_epi16(rxF0_128[1],1);
+
+
+
+    if (pilots==0) {
+      ch_mag0[2] = _mm_adds_epi16(ch_mag0[2],ch_mag1[2]);
+      ch_mag0b[2] = _mm_adds_epi16(ch_mag0b[2],ch_mag1b[2]);
+
+      //ch_mag0[2] = _mm_srai_epi16(ch_mag0[2],1);
+      //ch_mag0b[2] = _mm_srai_epi16(ch_mag0b[2],1);
+
+      //rxF0_128[2] = _mm_mulhi_epi16(rxF0_128[2],amp);
+      //rxF0_128[2] = _mm_slli_epi16(rxF0_128[2],1);
+
+      //rxF0_128[2] = _mm_srai_epi16(rxF0_128[2],1);
+
+
+      ch_mag0+=3;
+      ch_mag1+=3;
+      ch_mag0b+=3;
+      ch_mag1b+=3;
+      rxF0_128+=3;
+    } else {
+      ch_mag0+=2;
+      ch_mag1+=2;
+      ch_mag0b+=2;
+      ch_mag1b+=2;
+      rxF0_128+=2;
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+#elif defined(__arm__)
+
+#endif
+}
+
+
+//==============================================================================================
+// Extraction functions
+//==============================================================================================
+
+unsigned short dlsch_extract_rbs_single(int **rxdataF,
+                                        int **dl_ch_estimates,
+                                        int **rxdataF_ext,
+                                        int **dl_ch_estimates_ext,
+                                        unsigned short pmi,
+                                        unsigned char *pmi_ext,
+                                        unsigned int *rb_alloc,
+                                        unsigned char symbol,
+                                        unsigned char subframe,
+                                        uint32_t high_speed_flag,
+                                        LTE_DL_FRAME_PARMS *frame_parms) {
+
+
+
+  unsigned short rb,nb_rb=0;
+  unsigned char rb_alloc_ind;
+  unsigned char i,aarx,l,nsymb,skip_half=0,sss_symb,pss_symb=0;
+  int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
+
+
+
+  unsigned char symbol_mod,pilots=0,j=0,poffset=0;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+  pilots = ((symbol_mod==0)||(symbol_mod==(4-frame_parms->Ncp))) ? 1 : 0;
+  l=symbol;
+  nsymb = (frame_parms->Ncp==NORMAL) ? 14:12;
+
+  if (frame_parms->frame_type == TDD) {  // TDD
+    sss_symb = nsymb-1;
+    pss_symb = 2;
+  } else {
+    sss_symb = (nsymb>>1)-2;
+    pss_symb = (nsymb>>1)-1;
+  }
+
+  if (symbol_mod==(4-frame_parms->Ncp))
+    poffset=3;
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+    if (high_speed_flag == 1)
+      dl_ch0     = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))];
+    else
+      dl_ch0     = &dl_ch_estimates[aarx][5];
+
+    dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)];
+
+    rxF_ext   = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)];
+    rxF       = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))];
+
+    if ((frame_parms->N_RB_DL&1) == 0)  // even number of RBs
+
+      for (rb=0;rb<frame_parms->N_RB_DL;rb++) {
+
+        if (rb < 32)
+          rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+        else if (rb < 64)
+          rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+        else if (rb < 96)
+          rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+        else if (rb < 100)
+          rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+        else
+          rb_alloc_ind = 0;
+
+        if (rb_alloc_ind == 1)
+          nb_rb++;
+
+        // For second half of RBs skip DC carrier
+        if (rb==(frame_parms->N_RB_DL>>1)) {
+          rxF       = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))];
+          //dl_ch0++;
+        }
+
+        // PBCH
+        if ((subframe==0) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l>=nsymb>>1) && (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+        }
+
+        //SSS
+        if (((subframe==0)||(subframe==5)) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+
+
+        if (frame_parms->frame_type == FDD) {
+          //PSS
+          if (((subframe==0)||(subframe==5)) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+        }
+
+        if ((frame_parms->frame_type == TDD) &&
+            (subframe==6)) { //TDD Subframe 6
+          if ((rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+        }
+
+        if (rb_alloc_ind==1) {
+          *pmi_ext = (pmi>>((rb>>2)<<1))&3;
+          memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
+
+          /*
+            printf("rb %d\n",rb);
+            for (i=0;i<12;i++)
+            printf("(%d %d)",((short *)dl_ch0)[i<<1],((short*)dl_ch0)[1+(i<<1)]);
+            printf("\n");
+          */
+          if (pilots==0) {
+            for (i=0; i<12; i++) {
+              rxF_ext[i]=rxF[i];
+              /*
+                printf("%d : (%d,%d)\n",(rxF+i-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))]),
+                ((short*)&rxF[i])[0],((short*)&rxF[i])[1]);*/
+            }
+
+            dl_ch0_ext+=12;
+            rxF_ext+=12;
+          } else {
+            j=0;
+
+            for (i=0; i<12; i++) {
+              if ((i!=(frame_parms->nushift+poffset)) &&
+                  (i!=((frame_parms->nushift+poffset+6)%12))) {
+                rxF_ext[j]=rxF[i];
+                //            printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+                dl_ch0_ext[j++]=dl_ch0[i];
+
+              }
+            }
+
+            dl_ch0_ext+=10;
+            rxF_ext+=10;
+          }
+
+
+        }
+
+        dl_ch0+=12;
+        rxF+=12;
+
+      }
+    else {  // Odd number of RBs
+      for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) {
+#ifdef DEBUG_DLSCH_DEMOD
+        printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]);
+#endif
+        skip_half=0;
+
+        if (rb < 32)
+          rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+        else if (rb < 64)
+          rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+        else if (rb < 96)
+          rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+        else if (rb < 100)
+          rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+        else
+          rb_alloc_ind = 0;
+
+        if (rb_alloc_ind == 1)
+          nb_rb++;
+
+
+        // PBCH
+        if ((subframe==0) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+        }
+
+        //PBCH subframe 0, symbols nsymb>>1 ... nsymb>>1 + 3
+        if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=1;
+        else if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=2;
+
+        //SSS
+
+        if (((subframe==0)||(subframe==5)) &&
+            (rb>((frame_parms->N_RB_DL>>1)-3)) &&
+            (rb<((frame_parms->N_RB_DL>>1)+3)) &&
+            (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+        //SSS
+        if (((subframe==0)||(subframe==5)) &&
+            (rb==((frame_parms->N_RB_DL>>1)-3)) &&
+            (l==sss_symb))
+          skip_half=1;
+        else if (((subframe==0)||(subframe==5)) &&
+                 (rb==((frame_parms->N_RB_DL>>1)+3)) &&
+                 (l==sss_symb))
+          skip_half=2;
+
+        //PSS in subframe 0/5 if FDD
+        if (frame_parms->frame_type == FDD) {  //FDD
+
+          if (((subframe==0)||(subframe==5)) &&
+              (rb>((frame_parms->N_RB_DL>>1)-3)) &&
+              (rb<((frame_parms->N_RB_DL>>1)+3)) &&
+              (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+
+          if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+        if ((frame_parms->frame_type == TDD) &&
+            (subframe==6)){  //TDD Subframe 6
+          if ((rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+          if ((rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if ((rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+
+        if (rb_alloc_ind==1) {
+
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("rb %d/symbol %d (skip_half %d)\n",rb,l,skip_half);
+#endif
+          if (pilots==0) {
+            //      printf("Extracting w/o pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            if (skip_half==1) {
+              memcpy(dl_ch0_ext,dl_ch0,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+            } else if (skip_half==2) {
+              memcpy(dl_ch0_ext,dl_ch0+6,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[(i+6)];
+#ifdef DEBUG_DLSCH_DEMOD
+                printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+            } else {
+              memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
+
+              for (i=0; i<12; i++) {
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+              dl_ch0_ext+=12;
+              rxF_ext+=12;
+            }
+          } else {
+            //      printf("Extracting with pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            j=0;
+
+            if (skip_half==1) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i];
+                }
+              }
+              rxF_ext+=5;
+              dl_ch0_ext+=5;
+            } else if (skip_half==2) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[(i+6)];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i+6];
+                }
+              }
+
+              dl_ch0_ext+=5;
+              rxF_ext+=5;
+            } else {
+              for (i=0; i<12; i++) {
+                if ((i!=(frame_parms->nushift+poffset)) &&
+                    (i!=((frame_parms->nushift+poffset+6)%12))) {
+                  rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i];
+
+                }
+              }
+
+              dl_ch0_ext+=10;
+              rxF_ext+=10;
+            }
+          }
+        }
+        dl_ch0+=12;
+        rxF+=12;
+      } // first half loop
+
+
+      // Do middle RB (around DC)
+      if (rb < 32)
+        rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+      else if (rb < 64)
+        rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+      else if (rb < 96)
+        rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+      else if (rb < 100)
+        rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+      else
+        rb_alloc_ind = 0;
+
+
+      if (rb_alloc_ind == 1)
+        nb_rb++;
+
+      // PBCH
+
+      if ((subframe==0) &&
+          (l>=(nsymb>>1)) &&
+          (l<((nsymb>>1) + 4))) {
+        rb_alloc_ind = 0;
+      }
+
+      //SSS
+      if (((subframe==0)||(subframe==5)) && (l==sss_symb) ) {
+        rb_alloc_ind = 0;
+      }
+
+      if (frame_parms->frame_type == FDD) {
+        //PSS
+        if (((subframe==0)||(subframe==5)) && (l==pss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+      }
+
+      //PSS
+      if ((frame_parms->frame_type == TDD) &&
+          (subframe==6) &&
+          (l==pss_symb) ) {
+        rb_alloc_ind = 0;
+      }
+
+
+      //  printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]);
+      //      printf("DC rb %d (%p)\n",rb,rxF);
+      if (rb_alloc_ind==1) {
+#ifdef DEBUG_DLSCH_DEMOD
+        printf("rb %d/symbol %d (skip_half %d)\n",rb,l,skip_half);
+#endif
+        if (pilots==0) {
+          for (i=0; i<6; i++) {
+            dl_ch0_ext[i]=dl_ch0[i];
+            rxF_ext[i]=rxF[i];
+          }
+
+          rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+
+          for (; i<12; i++) {
+            dl_ch0_ext[i]=dl_ch0[i];
+            rxF_ext[i]=rxF[(1+i-6)];
+          }
+
+          dl_ch0_ext+=12;
+          rxF_ext+=12;
+        } else { // pilots==1
+          j=0;
+
+          for (i=0; i<6; i++) {
+            if (i!=((frame_parms->nushift+poffset)%6)) {
+              dl_ch0_ext[j]=dl_ch0[i];
+              rxF_ext[j++]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1]));
+#endif
+            }
+          }
+
+          rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+
+          for (; i<12; i++) {
+            if (i!=((frame_parms->nushift+6+poffset)%12)) {
+              dl_ch0_ext[j]=dl_ch0[i];
+              rxF_ext[j++]=rxF[(1+i-6)];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1]));
+#endif
+            }
+          }
+
+          dl_ch0_ext+=10;
+          rxF_ext+=10;
+        } // symbol_mod==0
+      } // rballoc==1
+      else {
+        rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+      }
+
+      dl_ch0+=12;
+      rxF+=7;
+      rb++;
+
+      for (;rb<frame_parms->N_RB_DL;rb++) {
+        //      printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]);
+        //      printf("rb %d (%p)\n",rb,rxF);
+        skip_half=0;
+
+        if (rb < 32)
+          rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+        else if (rb < 64)
+          rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+        else if (rb < 96)
+          rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+        else if (rb < 100)
+          rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+        else
+          rb_alloc_ind = 0;
+
+        if (rb_alloc_ind == 1)
+          nb_rb++;
+
+        // PBCH
+        if ((subframe==0) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l>=nsymb>>1) && (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+        }
+        //PBCH subframe 0, symbols nsymb>>1 ... nsymb>>1 + 3
+        if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=1;
+        else if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=2;
+
+        //SSS
+        if (((subframe==0)||(subframe==5)) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+        //SSS
+        if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l==sss_symb))
+          skip_half=1;
+        else if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l==sss_symb))
+          skip_half=2;
+        if (frame_parms->frame_type == FDD) {
+          //PSS
+          if (((subframe==0)||(subframe==5)) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+
+          //PSS
+
+          if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+        if ((frame_parms->frame_type == TDD) &&
+
+            (subframe==6)) { //TDD Subframe 6
+          if ((rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+
+          if ((rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if ((rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+        if (rb_alloc_ind==1) {
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("rb %d/symbol %d (skip_half %d)\n",rb,l,skip_half);
+#endif
+          /*
+            printf("rb %d\n",rb);
+            for (i=0;i<12;i++)
+            printf("(%d %d)",((short *)dl_ch0)[i<<1],((short*)dl_ch0)[1+(i<<1)]);
+            printf("\n");
+          */
+          if (pilots==0) {
+            //      printf("Extracting w/o pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            if (skip_half==1) {
+              memcpy(dl_ch0_ext,dl_ch0,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+
+            } else if (skip_half==2) {
+              memcpy(dl_ch0_ext,dl_ch0+6,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[(i+6)];
+#ifdef DEBUG_DLSCH_DEMOD
+                printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+
+            } else {
+              memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
+
+              for (i=0; i<12; i++) {
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+              dl_ch0_ext+=12;
+              rxF_ext+=12;
+            }
+          } else {
+            //      printf("Extracting with pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            j=0;
+
+            if (skip_half==1) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i];
+                }
+              }
+
+              dl_ch0_ext+=5;
+              rxF_ext+=5;
+            } else if (skip_half==2) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[(i+6)];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i+6];
+                }
+              }
+
+              dl_ch0_ext+=5;
+              rxF_ext+=5;
+            } else {
+              for (i=0; i<12; i++) {
+                if ((i!=(frame_parms->nushift+poffset)) &&
+                    (i!=((frame_parms->nushift+poffset+6)%12))) {
+                  rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i];
+                }
+              }
+              dl_ch0_ext+=10;
+              rxF_ext+=10;
+            }
+          } // pilots=0
+        }
+
+        dl_ch0+=12;
+        rxF+=12;
+      }
+    }
+  }
+
+
+  return(nb_rb/frame_parms->nb_antennas_rx);
+}
+
+unsigned short dlsch_extract_rbs_dual(int **rxdataF,
+                                      int **dl_ch_estimates,
+                                      int **rxdataF_ext,
+                                      int **dl_ch_estimates_ext,
+                                      unsigned short pmi,
+                                      unsigned char *pmi_ext,
+                                      unsigned int *rb_alloc,
+                                      unsigned char symbol,
+                                      unsigned char subframe,
+                                      uint32_t high_speed_flag,
+                                      LTE_DL_FRAME_PARMS *frame_parms,
+                                      MIMO_mode_t mimo_mode) {
+
+  int prb,nb_rb=0;
+  int prb_off,prb_off2;
+  int rb_alloc_ind,skip_half=0,sss_symb,pss_symb=0,nsymb,l;
+  int i,aarx;
+  int32_t *dl_ch0,*dl_ch0p,*dl_ch0_ext,*dl_ch1,*dl_ch1p,*dl_ch1_ext,*rxF,*rxF_ext;
+  int symbol_mod,pilots=0,j=0;
+  unsigned char *pmi_loc;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+  //  printf("extract_rbs: symbol_mod %d\n",symbol_mod);
+
+  if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp)))
+    pilots=1;
+
+  nsymb = (frame_parms->Ncp==NORMAL) ? 14:12;
+  l=symbol;
+
+  if (frame_parms->frame_type == TDD) {  // TDD
+    sss_symb = nsymb-1;
+    pss_symb = 2;
+  } else {
+    sss_symb = (nsymb>>1)-2;
+    pss_symb = (nsymb>>1)-1;
+  }
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+    if (high_speed_flag==1) {
+      dl_ch0     = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))];
+      dl_ch1     = &dl_ch_estimates[2+aarx][5+(symbol*(frame_parms->ofdm_symbol_size))];
+    } else {
+      dl_ch0     = &dl_ch_estimates[aarx][5];
+      dl_ch1     = &dl_ch_estimates[2+aarx][5];
+    }
+
+    pmi_loc = pmi_ext;
+
+    // pointers to extracted RX signals and channel estimates
+    rxF_ext    = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)];
+    dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)];
+    dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(frame_parms->N_RB_DL*12)];
+
+    for (prb=0; prb<frame_parms->N_RB_DL; prb++) {
+      skip_half=0;
+
+      if (prb < 32)
+        rb_alloc_ind = (rb_alloc[0]>>prb) & 1;
+      else if (prb < 64)
+        rb_alloc_ind = (rb_alloc[1]>>(prb-32)) & 1;
+      else if (prb < 96)
+        rb_alloc_ind = (rb_alloc[2]>>(prb-64)) & 1;
+      else if (prb < 100)
+        rb_alloc_ind = (rb_alloc[3]>>(prb-96)) & 1;
+      else
+        rb_alloc_ind = 0;
+
+      if (rb_alloc_ind == 1)
+          nb_rb++;
+
+
+      if ((frame_parms->N_RB_DL&1) == 0) {  // even number of RBs
+
+        // PBCH
+        if ((subframe==0) &&
+            (prb>=((frame_parms->N_RB_DL>>1)-3)) &&
+            (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+            (l>=(nsymb>>1)) &&
+            (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+          //    printf("symbol %d / rb %d: skipping PBCH REs\n",symbol,prb);
+        }
+
+        //SSS
+
+        if (((subframe==0)||(subframe==5)) &&
+            (prb>=((frame_parms->N_RB_DL>>1)-3)) &&
+            (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+            (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+          //    printf("symbol %d / rb %d: skipping SSS REs\n",symbol,prb);
+        }
+
+
+
+        //PSS in subframe 0/5 if FDD
+        if (frame_parms->frame_type == FDD) {  //FDD
+          if (((subframe==0)||(subframe==5)) &&
+              (prb>=((frame_parms->N_RB_DL>>1)-3)) &&
+              (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+              (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+            //    printf("symbol %d / rb %d: skipping PSS REs\n",symbol,prb);
+          }
+        }
+
+        if ((frame_parms->frame_type == TDD) &&
+            (subframe==6)) { //TDD Subframe 6
+          if ((prb>=((frame_parms->N_RB_DL>>1)-3)) &&
+              (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+              (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+        }
+
+        if (rb_alloc_ind==1) {              // PRB is allocated
+
+
+
+          prb_off      = 12*prb;
+          prb_off2     = 1+(12*(prb-(frame_parms->N_RB_DL>>1)));
+          dl_ch0p    = dl_ch0+(12*prb);
+          dl_ch1p    = dl_ch1+(12*prb);
+          if (prb<(frame_parms->N_RB_DL>>1)){
+            rxF      = &rxdataF[aarx][prb_off+
+                                      frame_parms->first_carrier_offset +
+                                      (symbol*(frame_parms->ofdm_symbol_size))];
+          }
+          else {
+            rxF      = &rxdataF[aarx][prb_off2+
+                                      (symbol*(frame_parms->ofdm_symbol_size))];
+          }
+
+         /*
+         if (mimo_mode <= PUSCH_PRECODING1)
+          *pmi_loc = (pmi>>((prb>>2)<<1))&3;
+         else
+          *pmi_loc=(pmi>>prb)&1;*/
+
+         *pmi_loc = get_pmi(frame_parms->N_RB_DL,mimo_mode,pmi,prb);
+          pmi_loc++;
+
+
+          if (pilots == 0) {
+
+            memcpy(dl_ch0_ext,dl_ch0p,12*sizeof(int));
+            memcpy(dl_ch1_ext,dl_ch1p,12*sizeof(int));
+            memcpy(rxF_ext,rxF,12*sizeof(int));
+            dl_ch0_ext +=12;
+            dl_ch1_ext +=12;
+            rxF_ext    +=12;
+          } else { // pilots==1
+            j=0;
+            for (i=0; i<12; i++) {
+              if ((i!=frame_parms->nushift) &&
+                  (i!=frame_parms->nushift+3) &&
+                  (i!=frame_parms->nushift+6) &&
+                  (i!=((frame_parms->nushift+9)%12))) {
+                rxF_ext[j]=rxF[i];
+                //        printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+                dl_ch0_ext[j]=dl_ch0p[i];
+                dl_ch1_ext[j++]=dl_ch1p[i];
+              }
+            }
+            dl_ch0_ext+=8;
+            dl_ch1_ext+=8;
+            rxF_ext+=8;
+          } // pilots==1
+
+        }
+      } else {  // Odd number of RBs
+
+
+      // PBCH
+        if ((subframe==0) &&
+            (prb>((frame_parms->N_RB_DL>>1)-3)) &&
+            (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+            (l>=(nsymb>>1)) &&
+            (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+          //    printf("symbol %d / rb %d: skipping PBCH REs\n",symbol,prb);
+        }
+
+        //SSS
+
+        if (((subframe==0)||(subframe==5)) &&
+            (prb>((frame_parms->N_RB_DL>>1)-3)) &&
+            (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+            (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+          //    printf("symbol %d / rb %d: skipping SSS REs\n",symbol,prb);
+        }
+
+
+
+        //PSS in subframe 0/5 if FDD
+        if (frame_parms->frame_type == FDD) {  //FDD
+          if (((subframe==0)||(subframe==5)) &&
+              (prb>((frame_parms->N_RB_DL>>1)-3)) &&
+              (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+              (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+            //    printf("symbol %d / rb %d: skipping PSS REs\n",symbol,prb);
+          }
+        }
+
+        if ((frame_parms->frame_type == TDD) &&
+            ((subframe==1) || (subframe==6))) { //TDD Subframe 1-6
+          if ((prb>((frame_parms->N_RB_DL>>1)-3)) &&
+              (prb<((frame_parms->N_RB_DL>>1)+3)) &&
+              (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+        }
+
+        if (rb_alloc_ind == 1) {
+          skip_half=0;
+
+          //Check if we have to drop half a PRB due to PSS/SSS/PBCH
+          // skip_half == 0 means full PRB
+          // skip_half == 1 means first half is used (leftmost half-PRB from PSS/SSS/PBCH)
+          // skip_half == 2 means second half is used (rightmost half-PRB from PSS/SSS/PBCH)
+          //PBCH subframe 0, symbols nsymb>>1 ... nsymb>>1 + 3
+          if ((subframe==0) &&
+              (prb==((frame_parms->N_RB_DL>>1)-3)) &&
+              (l>=(nsymb>>1)) &&
+              (l<((nsymb>>1) + 4)))
+            skip_half=1;
+          else if ((subframe==0) &&
+                   (prb==((frame_parms->N_RB_DL>>1)+3)) &&
+                   (l>=(nsymb>>1)) &&
+                   (l<((nsymb>>1) + 4)))
+            skip_half=2;
+
+          //SSS
+          if (((subframe==0)||(subframe==5)) &&
+              (prb==((frame_parms->N_RB_DL>>1)-3)) &&
+              (l==sss_symb))
+            skip_half=1;
+          else if (((subframe==0)||(subframe==5)) &&
+                   (prb==((frame_parms->N_RB_DL>>1)+3)) &&
+                   (l==sss_symb))
+            skip_half=2;
+
+          //PSS Subframe 0,5
+          if (((frame_parms->frame_type == FDD) &&
+               (((subframe==0)||(subframe==5)))) ||  //FDD Subframes 0,5
+              ((frame_parms->frame_type == TDD) &&
+               (((subframe==1) || (subframe==6))))) { //TDD Subframes 1,6
+
+            if ((prb==((frame_parms->N_RB_DL>>1)-3)) &&
+                (l==pss_symb))
+              skip_half=1;
+            else if ((prb==((frame_parms->N_RB_DL>>1)+3)) &&
+                     (l==pss_symb))
+              skip_half=2;
+          }
+
+
+          prb_off      = 12*prb;
+          prb_off2     = 7+(12*(prb-(frame_parms->N_RB_DL>>1)-1));
+          dl_ch0p      = dl_ch0+(12*prb);
+          dl_ch1p      = dl_ch1+(12*prb);
+
+          if (prb<=(frame_parms->N_RB_DL>>1)){
+            rxF      = &rxdataF[aarx][prb_off+
+                                      frame_parms->first_carrier_offset +
+                                      (symbol*(frame_parms->ofdm_symbol_size))];
+          }
+          else {
+            rxF      = &rxdataF[aarx][prb_off2+
+                                      (symbol*(frame_parms->ofdm_symbol_size))];
+          }
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("symbol %d / rb %d: alloc %d skip_half %d (rxF %p, rxF_ext %p) prb_off (%d,%d)\n",symbol,prb,rb_alloc_ind,skip_half,rxF,rxF_ext,prb_off,prb_off2);
+#endif
+         /* if (mimo_mode <= PUSCH_PRECODING1)
+           *pmi_loc = (pmi>>((prb>>2)<<1))&3;
+          else
+           *pmi_loc=(pmi>>prb)&1;
+         // printf("symbol_mod %d (pilots %d) rb %d, sb %d, pmi %d (pmi_loc %p,rxF %p, ch00 %p, ch01 %p, rxF_ext %p dl_ch0_ext %p dl_ch1_ext %p)\n",symbol_mod,pilots,prb,prb>>2,*pmi_loc,pmi_loc,rxF,dl_ch0, dl_ch1, rxF_ext,dl_ch0_ext,dl_ch1_ext);
+*/
+         *pmi_loc = get_pmi(frame_parms->N_RB_DL,mimo_mode,pmi,prb);
+          pmi_loc++;
+
+          if (prb != (frame_parms->N_RB_DL>>1)) { // This PRB is not around DC
+            if (pilots==0) {
+              if (skip_half==1) {
+                memcpy(dl_ch0_ext,dl_ch0p,6*sizeof(int32_t));
+                memcpy(dl_ch1_ext,dl_ch1p,6*sizeof(int32_t));
+                memcpy(rxF_ext,rxF,6*sizeof(int32_t));
+#ifdef DEBUG_DLSCH_DEMOD
+                for (i=0;i<6;i++)
+                  printf("extract rb %d, re %d => (%d,%d)\n",prb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                dl_ch0_ext+=6;
+                dl_ch1_ext+=6;
+                rxF_ext+=6;
+              } else if (skip_half==2) {
+                memcpy(dl_ch0_ext,dl_ch0p+6,6*sizeof(int32_t));
+                memcpy(dl_ch1_ext,dl_ch1p+6,6*sizeof(int32_t));
+                memcpy(rxF_ext,rxF+6,6*sizeof(int32_t));
+#ifdef DEBUG_DLSCH_DEMOD
+                for (i=0;i<6;i++)
+                  printf("extract rb %d, re %d => (%d,%d)\n",prb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                dl_ch0_ext+=6;
+                dl_ch1_ext+=6;
+                rxF_ext+=6;
+              } else {  // skip_half==0
+                memcpy(dl_ch0_ext,dl_ch0p,12*sizeof(int32_t));
+                memcpy(dl_ch1_ext,dl_ch1p,12*sizeof(int32_t));
+                memcpy(rxF_ext,rxF,12*sizeof(int32_t));
+#ifdef DEBUG_DLSCH_DEMOD
+                for (i=0;i<12;i++)
+                  printf("extract rb %d, re %d => (%d,%d)\n",prb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                dl_ch0_ext+=12;
+                dl_ch1_ext+=12;
+                rxF_ext+=12;
+              }
+            } else { // pilots=1
+              j=0;
+
+              if (skip_half==1) {
+                for (i=0; i<6; i++) {
+                  if ((i!=frame_parms->nushift) &&
+                      (i!=((frame_parms->nushift+3)%6))) {
+                    rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                    printf("(pilots,skip1)extract rb %d, re %d (%d)=> (%d,%d)\n",prb,i,j,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                    dl_ch0_ext[j]=dl_ch0p[i];
+                    dl_ch1_ext[j++]=dl_ch1p[i];
+                  }
+                }
+                dl_ch0_ext+=4;
+                dl_ch1_ext+=4;
+                rxF_ext+=4;
+              } else if (skip_half==2) {
+                for (i=0; i<6; i++) {
+                  if ((i!=frame_parms->nushift) &&
+                      (i!=((frame_parms->nushift+3)%6))) {
+                    rxF_ext[j]=rxF[(i+6)];
+#ifdef DEBUG_DLSCH_DEMOD
+                    printf("(pilots,skip2)extract rb %d, re %d (%d) => (%d,%d)\n",prb,i,j,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                    dl_ch0_ext[j]=dl_ch0p[i+6];
+                    dl_ch1_ext[j++]=dl_ch1p[i+6];
+                  }
+                }
+                dl_ch0_ext+=4;
+                dl_ch1_ext+=4;
+                rxF_ext+=4;
+
+              } else { //skip_half==0
+                for (i=0; i<12; i++) {
+                  if ((i!=frame_parms->nushift) &&
+                      (i!=frame_parms->nushift+3) &&
+                      (i!=frame_parms->nushift+6) &&
+                      (i!=((frame_parms->nushift+9)%12))) {
+                    rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                    printf("(pilots)extract rb %d, re %d => (%d,%d)\n",prb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                    dl_ch0_ext[j]  =dl_ch0p[i];
+                    dl_ch1_ext[j++]=dl_ch1p[i];
+                  }
+                }
+                dl_ch0_ext+=8;
+                dl_ch1_ext+=8;
+                rxF_ext+=8;
+              } //skip_half==0
+            } //pilots==1
+          } else {       // Do middle RB (around DC)
+
+            if (pilots==0) {
+              memcpy(dl_ch0_ext,dl_ch0p,6*sizeof(int32_t));
+              memcpy(dl_ch1_ext,dl_ch1p,6*sizeof(int32_t));
+              memcpy(rxF_ext,rxF,6*sizeof(int32_t));
+#ifdef DEBUG_DLSCH_DEMOD
+              for (i=0; i<6; i++) {
+                printf("extract rb %d, re %d => (%d,%d)\n",prb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+              }
+#endif
+              rxF_ext+=6;
+              dl_ch0_ext+=6;
+              dl_ch1_ext+=6;
+              dl_ch0p+=6;
+              dl_ch1p+=6;
+
+              rxF       = &rxdataF[aarx][1+((symbol*(frame_parms->ofdm_symbol_size)))];
+
+              memcpy(dl_ch0_ext,dl_ch0p,6*sizeof(int32_t));
+              memcpy(dl_ch1_ext,dl_ch1p,6*sizeof(int32_t));
+              memcpy(rxF_ext,rxF,6*sizeof(int32_t));
+#ifdef DEBUG_DLSCH_DEMOD
+              for (i=0; i<6; i++) {
+                printf("extract rb %d, re %d => (%d,%d)\n",prb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+              }
+#endif
+              rxF_ext+=6;
+              dl_ch0_ext+=6;
+              dl_ch1_ext+=6;
+            } else { // pilots==1
+              j=0;
+
+              for (i=0; i<6; i++) {
+                if ((i!=frame_parms->nushift) &&
+                    (i!=((frame_parms->nushift+3)%6))) {
+                  dl_ch0_ext[j]=dl_ch0p[i];
+                  dl_ch1_ext[j]=dl_ch1p[i];
+                  rxF_ext[j++]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("(pilots)extract rb %d, re %d (%d) => (%d,%d)\n",prb,i,j,*(short *)&rxF[i],*(1+(short*)&rxF[i]));
+#endif
+                }
+              }
+              rxF       = &rxdataF[aarx][1+symbol*(frame_parms->ofdm_symbol_size)];
+
+              for (; i<12; i++) {
+                if ((i!=((frame_parms->nushift+6)%12)) &&
+                    (i!=((frame_parms->nushift+9)%12))) {
+                  dl_ch0_ext[j]=dl_ch0p[i];
+                  dl_ch1_ext[j]=dl_ch1p[i];
+                  rxF_ext[j++]=rxF[i-6];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("(pilots)extract rb %d, re %d (%d) => (%d,%d)\n",prb,i,j,*(short *)&rxF[1+i-6],*(1+(short*)&rxF[1+i-6]));
+#endif
+                }
+              }
+
+              dl_ch0_ext+=8;
+              dl_ch1_ext+=8;
+              rxF_ext+=8;
+            } //pilots==1
+          }  // if Middle PRB
+        } // if odd PRB
+      } // if rballoc==1
+    } // for prb
+  } // for aarx
+  return(nb_rb/frame_parms->nb_antennas_rx);
+}
+
+unsigned short dlsch_extract_rbs_TM7(int **rxdataF,
+                                     int **dl_bf_ch_estimates,
+                                     int **rxdataF_ext,
+                                     int **dl_bf_ch_estimates_ext,
+                                     unsigned int *rb_alloc,
+                                     unsigned char symbol,
+                                     unsigned char subframe,
+                                     uint32_t high_speed_flag,
+                                     LTE_DL_FRAME_PARMS *frame_parms)
+{
+
+  unsigned short rb,nb_rb=0;
+  unsigned char rb_alloc_ind;
+  unsigned char i,aarx,l,nsymb,skip_half=0,sss_symb,pss_symb=0;
+  int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
+
+  unsigned char symbol_mod,pilots=0,uespec_pilots=0,j=0,poffset=0,uespec_poffset=0;
+  int8_t uespec_nushift = frame_parms->Nid_cell%3;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+  pilots = ((symbol_mod==0)||(symbol_mod==(4-frame_parms->Ncp))) ? 1 : 0;
+  l=symbol;
+  nsymb = (frame_parms->Ncp==NORMAL) ? 14:12;
+
+  if (frame_parms->Ncp==0){
+    if (symbol==3 || symbol==6 || symbol==9 || symbol==12)
+      uespec_pilots = 1;
+  } else{
+    if (symbol==4 || symbol==7 || symbol==10)
+      uespec_pilots = 1;
+  }
+
+  if (frame_parms->frame_type == TDD) {// TDD
+    sss_symb = nsymb-1;
+    pss_symb = 2;
+  } else {
+    sss_symb = (nsymb>>1)-2;
+    pss_symb = (nsymb>>1)-1;
+  }
+
+  if (symbol_mod==(4-frame_parms->Ncp))
+    poffset=3;
+
+  if ((frame_parms->Ncp==0 && (symbol==6 ||symbol ==12)) || (frame_parms->Ncp==1 && symbol==7))
+    uespec_poffset=2;
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+    if (high_speed_flag == 1)
+      dl_ch0     = &dl_bf_ch_estimates[aarx][symbol*(frame_parms->ofdm_symbol_size)];
+    else
+      dl_ch0     = &dl_bf_ch_estimates[aarx][0];
+
+    dl_ch0_ext = &dl_bf_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)];
+
+    rxF_ext    = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)];
+    rxF        = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))];
+
+    if ((frame_parms->N_RB_DL&1) == 0)  // even number of RBs
+      for (rb=0; rb<frame_parms->N_RB_DL; rb++) {
+
+        if (rb < 32)
+          rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+        else if (rb < 64)
+          rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+        else if (rb < 96)
+          rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+        else if (rb < 100)
+          rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+        else
+          rb_alloc_ind = 0;
+
+  if (rb_alloc_ind == 1)
+          nb_rb++;
+
+        // For second half of RBs skip DC carrier
+        if (rb==(frame_parms->N_RB_DL>>1)) {
+          rxF       = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))];
+          //dl_ch0++;
+        }
+
+        // PBCH
+        if ((subframe==0) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l>=nsymb>>1) && (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+        }
+
+        //SSS
+        if (((subframe==0)||(subframe==5)) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+
+
+        if (frame_parms->frame_type == FDD) {
+          //PSS
+          if (((subframe==0)||(subframe==5)) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+        }
+
+        if ((frame_parms->frame_type == TDD) &&
+            (subframe==6)) { //TDD Subframe 6
+          if ((rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+        }
+
+        if (rb_alloc_ind==1) {
+
+          /*
+              printf("rb %d\n",rb);
+              for (i=0;i<12;i++)
+              printf("(%d %d)",((short *)dl_ch0)[i<<1],((short*)dl_ch0)[1+(i<<1)]);
+              printf("\n");
+          */
+          if (pilots==0 && uespec_pilots==0) {
+            memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
+
+            for (i=0; i<12; i++) {
+              rxF_ext[i]=rxF[i];
+            }
+
+            dl_ch0_ext+=12;
+            rxF_ext+=12;
+          } else if(pilots==1 && uespec_pilots==0) {
+            j=0;
+
+            for (i=0; i<12; i++) {
+              if ((i!=(frame_parms->nushift+poffset)) &&
+                  (i!=((frame_parms->nushift+poffset+6)%12))) {
+                rxF_ext[j]=rxF[i];
+                dl_ch0_ext[j++]=dl_ch0[i];
+              }
+            }
+
+            dl_ch0_ext+=10;
+            rxF_ext+=10;
+
+          } else if (pilots==0 && uespec_pilots==1) {
+            j=0;
+
+
+      for (i=0; i<12; i++){
+              if (frame_parms->Ncp==0){
+                if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+      rxF_ext[j] = rxF[i];
+                  dl_ch0_ext[j++]=dl_ch0[i];
+                }
+              } else{
+                if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+      rxF_ext[j] = rxF[i];
+                  dl_ch0_ext[j++]=dl_ch0[i];
+                }
+              }
+
+      }
+
+            dl_ch0_ext+=9-frame_parms->Ncp;
+            rxF_ext+=9-frame_parms->Ncp;
+
+          } else {
+            LOG_E(PHY,"dlsch_extract_rbs_TM7(dl_demodulation.c):pilot or ue spec pilot detection error\n");
+            exit(-1);
+          }
+
+        }
+
+        dl_ch0+=12;
+        rxF+=12;
+
+      }
+    else {  // Odd number of RBs
+      for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) {
+        skip_half=0;
+
+        if (rb < 32)
+          rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+        else if (rb < 64)
+          rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+        else if (rb < 96)
+          rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+        else if (rb < 100)
+          rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+        else
+          rb_alloc_ind = 0;
+
+        if (rb_alloc_ind == 1)
+          nb_rb++;
+
+        // PBCH
+        if ((subframe==0) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+        }
+
+        //PBCH subframe 0, symbols nsymb>>1 ... nsymb>>1 + 3
+        if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=1;
+        else if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=2;
+
+        //SSS
+
+        if (((subframe==0)||(subframe==5)) &&
+            (rb>((frame_parms->N_RB_DL>>1)-3)) &&
+            (rb<((frame_parms->N_RB_DL>>1)+3)) &&
+            (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+
+        //SSS
+        if (((subframe==0)||(subframe==5)) &&
+            (rb==((frame_parms->N_RB_DL>>1)-3)) &&
+            (l==sss_symb))
+          skip_half=1;
+        else if (((subframe==0)||(subframe==5)) &&
+                 (rb==((frame_parms->N_RB_DL>>1)+3)) &&
+                 (l==sss_symb))
+          skip_half=2;
+
+        //PSS in subframe 0/5 if FDD
+        if (frame_parms->frame_type == FDD) {  //FDD
+          if (((subframe==0)||(subframe==5)) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+
+          if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+        if ((frame_parms->frame_type == TDD) && ((subframe==1)||(subframe==6))) { //TDD Subframe 1 and 6
+          if ((rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+
+          if ((rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if ((rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+
+        if (rb_alloc_ind==1) {
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("rb %d/symbol %d pilots %d, uespec_pilots %d, (skip_half %d)\n",rb,l,pilots,uespec_pilots,skip_half);
+#endif
+
+          if (pilots==0 && uespec_pilots==0) {
+            //printf("Extracting w/o pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+
+            if (skip_half==1) {
+              memcpy(dl_ch0_ext,dl_ch0,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+    printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+            } else if (skip_half==2) {
+              memcpy(dl_ch0_ext,dl_ch0+6,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[(i+6)];
+#ifdef DEBUG_DLSCH_DEMOD
+    printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+            } else {
+              memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
+
+              for (i=0; i<12; i++){
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                printf("extract rb %d, re %d => (%d,%d)\n",symbol,rb,i,*(short *)&rxF[i],*(1+(short*)&rxF[i]));
+#endif
+              }
+              dl_ch0_ext+=12;
+              rxF_ext+=12;
+            }
+          } else if (pilots==1 && uespec_pilots==0) {
+            // printf("Extracting with pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            j=0;
+
+            if (skip_half==1) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[i];
+                  dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+    printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                }
+              }
+
+              dl_ch0_ext+=5;
+              rxF_ext+=5;
+            } else if (skip_half==2) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[(i+6)];
+                  dl_ch0_ext[j++]=dl_ch0[i+6];
+#ifdef DEBUG_DLSCH_DEMOD
+    printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                }
+              }
+
+              dl_ch0_ext+=5;
+              rxF_ext+=5;
+            } else {
+              for (i=0; i<12; i++) {
+                if ((i!=(frame_parms->nushift+poffset)) &&
+                    (i!=((frame_parms->nushift+poffset+6)%12))) {
+                  rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i];
+
+                }
+              }
+
+              dl_ch0_ext+=10;
+              rxF_ext+=10;
+            }
+          } else if(pilots==0 && uespec_pilots==1){
+            //printf("Extracting with uespec pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            j=0;
+
+            if (skip_half==1) {
+              if (frame_parms->Ncp==0){
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+                    rxF_ext[j]=rxF[i];
+                    dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=6-(uespec_nushift+uespec_poffset<6)-(uespec_nushift+uespec_poffset+4<6)-((uespec_nushift+uespec_poffset+8)%12<6);
+                rxF_ext+=6-(uespec_nushift+uespec_poffset<6)-(uespec_nushift+uespec_poffset+4<6)-((uespec_nushift+uespec_poffset+8)%12<6);
+
+              } else{
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+                    rxF_ext[j]=rxF[i];
+                    dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+        printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=4;
+                rxF_ext+=4;
+              }
+
+            } else if (skip_half==2) {
+              if(frame_parms->Ncp==0){
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+                    rxF_ext[j]=rxF[(i+6)];
+                    dl_ch0_ext[j++]=dl_ch0[i+6];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=6-(uespec_nushift+uespec_poffset>6)-(uespec_nushift+uespec_poffset+4>6)-((uespec_nushift+uespec_poffset+8)%12>6);
+                rxF_ext+=6-(uespec_nushift+uespec_poffset>6)-(uespec_nushift+uespec_poffset+4>6)-((uespec_nushift+uespec_poffset+8)%12>6);
+
+              } else {
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+                    rxF_ext[j]=rxF[(i+6)];
+                    dl_ch0_ext[j++]=dl_ch0[i+6];
+#ifdef DEBUG_DLSCH_DEMOD
+        printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=4;
+                rxF_ext+=4;
+              }
+
+            } else {
+
+        for (i=0; i<12; i++){
+                if (frame_parms->Ncp==0){
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+              rxF_ext[j] = rxF[i];
+                    dl_ch0_ext[j++] = dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                    printf("extract rb %d, re %d, j %d => (%d,%d)\n",symbol,rb,i,j-1,*(short *)&dl_ch0[j],*(1+(short*)&dl_ch0[i]));
+#endif
+                  }
+                } else{
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+              rxF_ext[j] = rxF[i];
+                    dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+        printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+
+        }
+
+              dl_ch0_ext+=9-frame_parms->Ncp;
+              rxF_ext+=9-frame_parms->Ncp;
+      }
+
+          } else {
+            LOG_E(PHY,"dlsch_extract_rbs_TM7(dl_demodulation.c):pilot or ue spec pilot detection error\n");
+            exit(-1);
+
+          }
+        }
+
+        dl_ch0+=12;
+        rxF+=12;
+      } // first half loop
+
+
+      // Do middle RB (around DC)
+      if (rb < 32)
+        rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+      else if (rb < 64)
+        rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+      else if (rb < 96)
+        rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+      else if (rb < 100)
+        rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+      else
+        rb_alloc_ind = 0;
+
+      if (rb_alloc_ind == 1)
+        nb_rb++;
+
+      // PBCH
+      if ((subframe==0) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4))) {
+        rb_alloc_ind = 0;
+      }
+
+      //SSS
+      if (((subframe==0)||(subframe==5)) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==sss_symb) ) {
+        rb_alloc_ind = 0;
+      }
+
+      if (frame_parms->frame_type == FDD) {
+        //PSS
+        if (((subframe==0)||(subframe==5)) && (rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+      }
+
+      if ((frame_parms->frame_type == TDD) && ((subframe==1)||(subframe==6))) {
+        //PSS
+        if ((rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+      }
+
+      //printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]);
+      //printf("DC rb %d (%p)\n",rb,rxF);
+      if (rb_alloc_ind==1) {
+        //printf("rb %d/symbol %d (skip_half %d)\n",rb,l,skip_half);
+        if (pilots==0 && uespec_pilots==0) {
+          for (i=0; i<6; i++) {
+            dl_ch0_ext[i]=dl_ch0[i];
+            rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+      printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+          }
+
+          rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+
+          for (; i<12; i++) {
+            dl_ch0_ext[i]=dl_ch0[i];
+            rxF_ext[i]=rxF[(1+i-6)];
+#ifdef DEBUG_DLSCH_DEMOD
+      printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+          }
+
+          dl_ch0_ext+=12;
+          rxF_ext+=12;
+        } else if(pilots==1 && uespec_pilots==0){ // pilots==1
+          j=0;
+
+          for (i=0; i<6; i++) {
+            if (i!=((frame_parms->nushift+poffset)%6)) {
+              dl_ch0_ext[j]=dl_ch0[i];
+              rxF_ext[j++]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+        printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+            }
+          }
+
+          rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+
+          for (; i<12; i++) {
+            if (i!=((frame_parms->nushift+6+poffset)%12)) {
+              dl_ch0_ext[j]=dl_ch0[i];
+              rxF_ext[j++]=rxF[(1+i-6)];
+#ifdef DEBUG_DLSCH_DEMOD
+        printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+            }
+          }
+
+          dl_ch0_ext+=10;
+          rxF_ext+=10;
+        } else if(pilots==0 && uespec_pilots==1) {
+          j=0;
+
+    for (i=0; i<6; i++) {
+            if (frame_parms->Ncp==0){
+              if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+                dl_ch0_ext[j]=dl_ch0[i];
+          rxF_ext[j++] = rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+            } else {
+              if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+                dl_ch0_ext[j]=dl_ch0[i];
+          rxF_ext[j++] = rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+            }
+    }
+
+          rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+
+          for (; i<12; i++) {
+            if (frame_parms->Ncp==0){
+              if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+                dl_ch0_ext[j]=dl_ch0[i];
+                rxF_ext[j++]=rxF[(1+i-6)];
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+            } else {
+              if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+                dl_ch0_ext[j]=dl_ch0[i];
+          rxF_ext[j++] = rxF[(1+i-6)];
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+            }
+          }
+
+          dl_ch0_ext+=9-frame_parms->Ncp;
+          rxF_ext+=9-frame_parms->Ncp;
+
+  }// symbol_mod==0
+
+      } // rballoc==1
+      else {
+        rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+      }
+
+      dl_ch0+=12;
+      rxF+=7;
+      rb++;
+
+      for (; rb<frame_parms->N_RB_DL; rb++) {
+        //  printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]);
+        //  printf("rb %d (%p)\n",rb,rxF);
+        skip_half=0;
+
+        if (rb < 32)
+          rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
+        else if (rb < 64)
+          rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
+        else if (rb < 96)
+          rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
+        else if (rb < 100)
+          rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
+        else
+          rb_alloc_ind = 0;
+
+        if (rb_alloc_ind==1)
+          nb_rb++;
+
+        // PBCH
+        if ((subframe==0) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l>=nsymb>>1) && (l<((nsymb>>1) + 4))) {
+          rb_alloc_ind = 0;
+        }
+
+        //PBCH subframe 0, symbols nsymb>>1 ... nsymb>>1 + 3
+        if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=1;
+        else if ((subframe==0) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l>=(nsymb>>1)) && (l<((nsymb>>1) + 4)))
+          skip_half=2;
+
+        //SSS
+        if (((subframe==0)||(subframe==5)) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==sss_symb) ) {
+          rb_alloc_ind = 0;
+        }
+
+        //SSS
+        if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l==sss_symb))
+          skip_half=1;
+        else if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l==sss_symb))
+          skip_half=2;
+
+        //PSS
+        if (frame_parms->frame_type == FDD) {
+          if (((subframe==0)||(subframe==5)) && (rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+
+          if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if (((subframe==0)||(subframe==5)) && (rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+        if ((frame_parms->frame_type == TDD) && ((subframe==1)||(subframe==6))) { //TDD Subframe 1 and 6
+          if ((rb>((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
+            rb_alloc_ind = 0;
+          }
+
+          if ((rb==((frame_parms->N_RB_DL>>1)-3)) && (l==pss_symb))
+            skip_half=1;
+          else if ((rb==((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb))
+            skip_half=2;
+        }
+
+        if (rb_alloc_ind==1) {
+#ifdef DEBUG_DLSCH_DEMOD
+           printf("rb %d/symbol %d (skip_half %d)\n",rb,l,skip_half);
+#endif
+          /*
+              printf("rb %d\n",rb);
+            for (i=0;i<12;i++)
+            printf("(%d %d)",((short *)dl_ch0)[i<<1],((short*)dl_ch0)[1+(i<<1)]);
+            printf("\n");
+          */
+          if (pilots==0 && uespec_pilots==0) {
+            //printf("Extracting w/o pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            if (skip_half==1) {
+              memcpy(dl_ch0_ext,dl_ch0,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+
+            } else if (skip_half==2) {
+              memcpy(dl_ch0_ext,dl_ch0+6,6*sizeof(int));
+
+              for (i=0; i<6; i++) {
+                rxF_ext[i]=rxF[i+6];
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+
+              dl_ch0_ext+=6;
+              rxF_ext+=6;
+
+            } else {
+              memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
+              //printf("symbol %d, extract rb %d, => (%d,%d)\n",symbol,rb,*(short *)&dl_ch0[j],*(1+(short*)&dl_ch0[i]));
+
+              for (i=0; i<12; i++) {
+                rxF_ext[i]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+          printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+              }
+
+              dl_ch0_ext+=12;
+              rxF_ext+=12;
+            }
+          } else if (pilots==1 && uespec_pilots==0){
+            //printf("Extracting with pilots (symbol %d, rb %d, skip_half %d)\n",l,rb,skip_half);
+            j=0;
+
+            if (skip_half==1) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[i];
+                  dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+            printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                }
+              }
+
+              dl_ch0_ext+=5;
+              rxF_ext+=5;
+            } else if (skip_half==2) {
+              for (i=0; i<6; i++) {
+                if (i!=((frame_parms->nushift+poffset)%6)) {
+                  rxF_ext[j]=rxF[(i+6)];
+                  dl_ch0_ext[j++]=dl_ch0[i+6];
+#ifdef DEBUG_DLSCH_DEMOD
+            printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                }
+              }
+
+              dl_ch0_ext+=5;
+              rxF_ext+=5;
+            } else {
+              for (i=0; i<12; i++) {
+                if ((i!=(frame_parms->nushift+poffset)) &&
+                    (i!=((frame_parms->nushift+poffset+6)%12))) {
+                  rxF_ext[j]=rxF[i];
+#ifdef DEBUG_DLSCH_DEMOD
+                  printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+#endif
+                  dl_ch0_ext[j++]=dl_ch0[i];
+                }
+              }
+
+              dl_ch0_ext+=10;
+              rxF_ext+=10;
+            }
+          } else if(pilots==0 && uespec_pilots==1) {
+            j=0;
+
+            if (skip_half==1) {
+              if (frame_parms->Ncp==0){
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+                    rxF_ext[j]=rxF[i];
+                    dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=6-(uespec_nushift+uespec_poffset<6)-(uespec_nushift+uespec_poffset+4<6)-((uespec_nushift+uespec_poffset+8)%12<6);
+                rxF_ext+=6-(uespec_nushift+uespec_poffset<6)-(uespec_nushift+uespec_poffset+4<6)-((uespec_nushift+uespec_poffset+8)%12<6);
+
+              } else{
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+                    rxF_ext[j]=rxF[i];
+                    dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=4;
+                rxF_ext+=4;
+              }
+
+            } else if (skip_half==2) {
+              if(frame_parms->Ncp==0){
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+                    rxF_ext[j]=rxF[i+6];
+                    dl_ch0_ext[j++]=dl_ch0[i+6];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=6-(uespec_nushift+uespec_poffset>6)-(uespec_nushift+uespec_poffset+4>6)-((uespec_nushift+uespec_poffset+8)%12>6);
+                rxF_ext+=6-(uespec_nushift+uespec_poffset>6)-(uespec_nushift+uespec_poffset+4>6)-((uespec_nushift+uespec_poffset+8)%12>6);
+
+              } else {
+                for (i=0; i<6; i++) {
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+                    rxF_ext[j]=rxF[(i+6)];
+                    dl_ch0_ext[j++]=dl_ch0[i+6];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+                dl_ch0_ext+=4;
+                rxF_ext+=4;
+              }
+
+            } else {
+        for (i=0; i<12; i++){
+                if (frame_parms->Ncp==0){
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+4 && i!=(uespec_nushift+uespec_poffset+8)%12){
+              rxF_ext[j] = rxF[i];
+                    dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                } else{
+                  if (i!=uespec_nushift+uespec_poffset && i!=uespec_nushift+uespec_poffset+3 && i!=uespec_nushift+uespec_poffset+6 && i!=(uespec_nushift+uespec_poffset+9)%12){
+              rxF_ext[j] = rxF[i];
+                    dl_ch0_ext[j++]=dl_ch0[i];
+#ifdef DEBUG_DLSCH_DEMOD
+              printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[i],*(1+(short*)&rxF_ext[i]));
+#endif
+                  }
+                }
+        }
+
+              dl_ch0_ext+=9-frame_parms->Ncp;
+              rxF_ext+=9-frame_parms->Ncp;
+
+            }
+
+          }// pilots=0
+        }
+
+        dl_ch0+=12;
+        rxF+=12;
+      }
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+  return(nb_rb/frame_parms->nb_antennas_rx);
+}
+
+//==============================================================================================
+
+void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t subframe,unsigned int *coded_bits_per_codeword,int round,  unsigned char harq_pid)
+{
+  unsigned int nsymb = (ue->frame_parms.Ncp == 0) ? 14 : 12;
+  char fname[32],vname[32];
+  int N_RB_DL=ue->frame_parms.N_RB_DL;
+
+  sprintf(fname,"dlsch%d_rxF_r%d_ext0.m",eNB_id,round);
+  sprintf(vname,"dl%d_rxF_r%d_ext0",eNB_id,round);
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb,1,1);
+
+  if (ue->frame_parms.nb_antennas_rx >1) {
+    sprintf(fname,"dlsch%d_rxF_r%d_ext1.m",eNB_id,round);
+    sprintf(vname,"dl%d_rxF_r%d_ext1",eNB_id,round);
+    write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->rxdataF_ext[1],12*N_RB_DL*nsymb,1,1);
+  }
+
+  sprintf(fname,"dlsch%d_ch_r%d_ext00.m",eNB_id,round);
+  sprintf(vname,"dl%d_ch_r%d_ext00",eNB_id,round);
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1);
+
+  if (ue->transmission_mode[eNB_id]==7){
+    sprintf(fname,"dlsch%d_bf_ch_r%d.m",eNB_id,round);
+    sprintf(vname,"dl%d_bf_ch_r%d",eNB_id,round);
+    write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_bf_ch_estimates[0],512*nsymb,1,1);
+    //write_output(fname,vname,phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_bf_ch_estimates[0],512,1,1);
+
+    sprintf(fname,"dlsch%d_bf_ch_r%d_ext00.m",eNB_id,round);
+    sprintf(vname,"dl%d_bf_ch_r%d_ext00",eNB_id,round);
+    write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_bf_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1);
+  }
+
+  if (ue->frame_parms.nb_antennas_rx == 2) {
+    sprintf(fname,"dlsch%d_ch_r%d_ext01.m",eNB_id,round);
+    sprintf(vname,"dl%d_ch_r%d_ext01",eNB_id,round);
+    write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb,1,1);
+  }
+
+  if (ue->frame_parms.nb_antenna_ports_eNB == 2) {
+    sprintf(fname,"dlsch%d_ch_r%d_ext10.m",eNB_id,round);
+    sprintf(vname,"dl%d_ch_r%d_ext10",eNB_id,round);
+    write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1);
+
+    if (ue->frame_parms.nb_antennas_rx == 2) {
+      sprintf(fname,"dlsch%d_ch_r%d_ext11.m",eNB_id,round);
+      sprintf(vname,"dl%d_ch_r%d_ext11",eNB_id,round);
+      write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1);
+    }
+  }
+
+  sprintf(fname,"dlsch%d_rxF_r%d_uespec0.m",eNB_id,round);
+  sprintf(vname,"dl%d_rxF_r%d_uespec0",eNB_id,round);
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->rxdataF_uespec_pilots[0],12*N_RB_DL,1,1);
+
+  /*
+    write_output("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb,1,1);
+    write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1);
+    write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1);
+  */
+  sprintf(fname,"dlsch%d_r%d_rho.m",eNB_id,round);
+  sprintf(vname,"dl_rho_r%d_%d",eNB_id,round);
+
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_rho_ext[harq_pid][round][0],12*N_RB_DL*nsymb,1,1);
+
+  sprintf(fname,"dlsch%d_r%d_rho2.m",eNB_id,round);
+  sprintf(vname,"dl_rho2_r%d_%d",eNB_id,round);
+
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_rho2_ext[0],12*N_RB_DL*nsymb,1,1);
+
+  sprintf(fname,"dlsch%d_rxF_r%d_comp0.m",eNB_id,round);
+  sprintf(vname,"dl%d_rxF_r%d_comp0",eNB_id,round);
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb,1,1);
+  if (ue->frame_parms.nb_antenna_ports_eNB == 2) {
+    sprintf(fname,"dlsch%d_rxF_r%d_comp1.m",eNB_id,round);
+    sprintf(vname,"dl%d_rxF_r%d_comp1",eNB_id,round);
+    write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp1[harq_pid][round][0],12*N_RB_DL*nsymb,1,1);
+  }
+
+  sprintf(fname,"dlsch%d_rxF_r%d_llr.m",eNB_id,round);
+  sprintf(vname,"dl%d_r%d_llr",eNB_id,round);
+  write_output(fname,vname, ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->llr[0],coded_bits_per_codeword[0],1,0);
+  sprintf(fname,"dlsch%d_r%d_mag1.m",eNB_id,round);
+  sprintf(vname,"dl%d_r%d_mag1",eNB_id,round);
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_mag0[0],12*N_RB_DL*nsymb,1,1);
+  sprintf(fname,"dlsch%d_r%d_mag2.m",eNB_id,round);
+  sprintf(vname,"dl%d_r%d_mag2",eNB_id,round);
+  write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_magb0[0],12*N_RB_DL*nsymb,1,1);
+
+  //  printf("log2_maxh = %d\n",ue->pdsch_vars[eNB_id]->log2_maxh);
+}
+
+#ifdef DEBUG_DLSCH_DEMOD
+/*
+void print_bytes(char *s,__m128i *x)
+{
+
+  char *tempb = (char *)x;
+
+  printf("%s  : %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",s,
+         tempb[0],tempb[1],tempb[2],tempb[3],tempb[4],tempb[5],tempb[6],tempb[7],
+         tempb[8],tempb[9],tempb[10],tempb[11],tempb[12],tempb[13],tempb[14],tempb[15]
+         );
+
+}
+
+void print_shorts(char *s,__m128i *x)
+{
+
+  short *tempb = (short *)x;
+  printf("%s  : %d,%d,%d,%d,%d,%d,%d,%d\n",s,
+         tempb[0],tempb[1],tempb[2],tempb[3],tempb[4],tempb[5],tempb[6],tempb[7]);
+
+}
+
+void print_shorts2(char *s,__m64 *x)
+{
+
+  short *tempb = (short *)x;
+  printf("%s  : %d,%d,%d,%d\n",s,
+         tempb[0],tempb[1],tempb[2],tempb[3]);
+
+}
+
+void print_ints(char *s,__m128i *x)
+{
+
+  int *tempb = (int *)x;
+  printf("%s  : %d,%d,%d,%d\n",s,
+         tempb[0],tempb[1],tempb[2],tempb[3]);
+
+}*/
+#endif
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c
new file mode 100644
index 0000000000000000000000000000000000000000..7682045ae1307ca6a10ee83ef071091f7e28528d
--- /dev/null
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c
@@ -0,0 +1,8899 @@
+/*
+ * 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/dlsch_llr_computation.c
+ * \brief Top-level routines for LLR computation of the PDSCH physical channel from 36-211, V8.6 2009-03
+ * \author R. Knopp, F. Kaltenberger,A. Bhamri, S. Aubert, S. Wagner, X Jiang
+ * \date 2011
+ * \version 0.1
+ * \company Eurecom
+ * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,ankit.bhamri@eurecom.fr,sebastien.aubert@eurecom.fr, sebastian.wagner@eurecom.fr
+ * \note
+ * \warning
+ */
+
+#include "PHY/defs.h"
+#include "PHY/TOOLS/defs.h"
+#include "PHY/extern.h"
+#include "defs.h"
+#include "extern.h"
+#include "PHY/sse_intrin.h"
+
+//#define DEBUG_LLR_SIC
+
+
+int16_t zeros[8] __attribute__ ((aligned(16))) = {0,0,0,0,0,0,0,0};
+int16_t ones[8] __attribute__ ((aligned(16))) = {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
+#if defined(__x86_64__) || defined(__i386__)
+__m128i rho_rpi __attribute__ ((aligned(16)));
+__m128i rho_rmi __attribute__ ((aligned(16)));
+__m128i rho_rpi_1_1 __attribute__ ((aligned(16)));
+__m128i rho_rpi_1_3 __attribute__ ((aligned(16)));
+__m128i rho_rpi_1_5 __attribute__ ((aligned(16)));
+__m128i rho_rpi_1_7 __attribute__ ((aligned(16)));
+__m128i rho_rpi_3_1 __attribute__ ((aligned(16)));
+__m128i rho_rpi_3_3 __attribute__ ((aligned(16)));
+__m128i rho_rpi_3_5 __attribute__ ((aligned(16)));
+__m128i rho_rpi_3_7 __attribute__ ((aligned(16)));
+__m128i rho_rpi_5_1 __attribute__ ((aligned(16)));
+__m128i rho_rpi_5_3 __attribute__ ((aligned(16)));
+__m128i rho_rpi_5_5 __attribute__ ((aligned(16)));
+__m128i rho_rpi_5_7 __attribute__ ((aligned(16)));
+__m128i rho_rpi_7_1 __attribute__ ((aligned(16)));
+__m128i rho_rpi_7_3 __attribute__ ((aligned(16)));
+__m128i rho_rpi_7_5 __attribute__ ((aligned(16)));
+__m128i rho_rpi_7_7 __attribute__ ((aligned(16)));
+__m128i rho_rmi_1_1 __attribute__ ((aligned(16)));
+__m128i rho_rmi_1_3 __attribute__ ((aligned(16)));
+__m128i rho_rmi_1_5 __attribute__ ((aligned(16)));
+__m128i rho_rmi_1_7 __attribute__ ((aligned(16)));
+__m128i rho_rmi_3_1 __attribute__ ((aligned(16)));
+__m128i rho_rmi_3_3 __attribute__ ((aligned(16)));
+__m128i rho_rmi_3_5 __attribute__ ((aligned(16)));
+__m128i rho_rmi_3_7 __attribute__ ((aligned(16)));
+__m128i rho_rmi_5_1 __attribute__ ((aligned(16)));
+__m128i rho_rmi_5_3 __attribute__ ((aligned(16)));
+__m128i rho_rmi_5_5 __attribute__ ((aligned(16)));
+__m128i rho_rmi_5_7 __attribute__ ((aligned(16)));
+__m128i rho_rmi_7_1 __attribute__ ((aligned(16)));
+__m128i rho_rmi_7_3 __attribute__ ((aligned(16)));
+__m128i rho_rmi_7_5 __attribute__ ((aligned(16)));
+__m128i rho_rmi_7_7 __attribute__ ((aligned(16)));
+
+__m128i psi_r_m7_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_m7_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_m7_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_m7_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_m7_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_m7_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_m7_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_m7_p7 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_m5_p7 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_m3_p7 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_m1_p7 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_p1_p7 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_p3_p7 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_p5_p7 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_m7 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_m5 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_m3 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_m1 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_p1 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_p3 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_p5 __attribute__ ((aligned(16)));
+__m128i psi_r_p7_p7 __attribute__ ((aligned(16)));
+
+__m128i psi_i_m7_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_m7_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_m7_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_m7_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_m7_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_m7_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_m7_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_m7_p7 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_m5_p7 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_m3_p7 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_m1_p7 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_p1_p7 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_p3_p7 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_p5_p7 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_m7 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_m5 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_m3 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_m1 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_p1 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_p3 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_p5 __attribute__ ((aligned(16)));
+__m128i psi_i_p7_p7 __attribute__ ((aligned(16)));
+
+__m128i a_r_m7_m7 __attribute__ ((aligned(16)));
+__m128i a_r_m7_m5 __attribute__ ((aligned(16)));
+__m128i a_r_m7_m3 __attribute__ ((aligned(16)));
+__m128i a_r_m7_m1 __attribute__ ((aligned(16)));
+__m128i a_r_m7_p1 __attribute__ ((aligned(16)));
+__m128i a_r_m7_p3 __attribute__ ((aligned(16)));
+__m128i a_r_m7_p5 __attribute__ ((aligned(16)));
+__m128i a_r_m7_p7 __attribute__ ((aligned(16)));
+__m128i a_r_m5_m7 __attribute__ ((aligned(16)));
+__m128i a_r_m5_m5 __attribute__ ((aligned(16)));
+__m128i a_r_m5_m3 __attribute__ ((aligned(16)));
+__m128i a_r_m5_m1 __attribute__ ((aligned(16)));
+__m128i a_r_m5_p1 __attribute__ ((aligned(16)));
+__m128i a_r_m5_p3 __attribute__ ((aligned(16)));
+__m128i a_r_m5_p5 __attribute__ ((aligned(16)));
+__m128i a_r_m5_p7 __attribute__ ((aligned(16)));
+__m128i a_r_m3_m7 __attribute__ ((aligned(16)));
+__m128i a_r_m3_m5 __attribute__ ((aligned(16)));
+__m128i a_r_m3_m3 __attribute__ ((aligned(16)));
+__m128i a_r_m3_m1 __attribute__ ((aligned(16)));
+__m128i a_r_m3_p1 __attribute__ ((aligned(16)));
+__m128i a_r_m3_p3 __attribute__ ((aligned(16)));
+__m128i a_r_m3_p5 __attribute__ ((aligned(16)));
+__m128i a_r_m3_p7 __attribute__ ((aligned(16)));
+__m128i a_r_m1_m7 __attribute__ ((aligned(16)));
+__m128i a_r_m1_m5 __attribute__ ((aligned(16)));
+__m128i a_r_m1_m3 __attribute__ ((aligned(16)));
+__m128i a_r_m1_m1 __attribute__ ((aligned(16)));
+__m128i a_r_m1_p1 __attribute__ ((aligned(16)));
+__m128i a_r_m1_p3 __attribute__ ((aligned(16)));
+__m128i a_r_m1_p5 __attribute__ ((aligned(16)));
+__m128i a_r_m1_p7 __attribute__ ((aligned(16)));
+__m128i a_r_p1_m7 __attribute__ ((aligned(16)));
+__m128i a_r_p1_m5 __attribute__ ((aligned(16)));
+__m128i a_r_p1_m3 __attribute__ ((aligned(16)));
+__m128i a_r_p1_m1 __attribute__ ((aligned(16)));
+__m128i a_r_p1_p1 __attribute__ ((aligned(16)));
+__m128i a_r_p1_p3 __attribute__ ((aligned(16)));
+__m128i a_r_p1_p5 __attribute__ ((aligned(16)));
+__m128i a_r_p1_p7 __attribute__ ((aligned(16)));
+__m128i a_r_p3_m7 __attribute__ ((aligned(16)));
+__m128i a_r_p3_m5 __attribute__ ((aligned(16)));
+__m128i a_r_p3_m3 __attribute__ ((aligned(16)));
+__m128i a_r_p3_m1 __attribute__ ((aligned(16)));
+__m128i a_r_p3_p1 __attribute__ ((aligned(16)));
+__m128i a_r_p3_p3 __attribute__ ((aligned(16)));
+__m128i a_r_p3_p5 __attribute__ ((aligned(16)));
+__m128i a_r_p3_p7 __attribute__ ((aligned(16)));
+__m128i a_r_p5_m7 __attribute__ ((aligned(16)));
+__m128i a_r_p5_m5 __attribute__ ((aligned(16)));
+__m128i a_r_p5_m3 __attribute__ ((aligned(16)));
+__m128i a_r_p5_m1 __attribute__ ((aligned(16)));
+__m128i a_r_p5_p1 __attribute__ ((aligned(16)));
+__m128i a_r_p5_p3 __attribute__ ((aligned(16)));
+__m128i a_r_p5_p5 __attribute__ ((aligned(16)));
+__m128i a_r_p5_p7 __attribute__ ((aligned(16)));
+__m128i a_r_p7_m7 __attribute__ ((aligned(16)));
+__m128i a_r_p7_m5 __attribute__ ((aligned(16)));
+__m128i a_r_p7_m3 __attribute__ ((aligned(16)));
+__m128i a_r_p7_m1 __attribute__ ((aligned(16)));
+__m128i a_r_p7_p1 __attribute__ ((aligned(16)));
+__m128i a_r_p7_p3 __attribute__ ((aligned(16)));
+__m128i a_r_p7_p5 __attribute__ ((aligned(16)));
+__m128i a_r_p7_p7 __attribute__ ((aligned(16)));
+
+__m128i a_i_m7_m7 __attribute__ ((aligned(16)));
+__m128i a_i_m7_m5 __attribute__ ((aligned(16)));
+__m128i a_i_m7_m3 __attribute__ ((aligned(16)));
+__m128i a_i_m7_m1 __attribute__ ((aligned(16)));
+__m128i a_i_m7_p1 __attribute__ ((aligned(16)));
+__m128i a_i_m7_p3 __attribute__ ((aligned(16)));
+__m128i a_i_m7_p5 __attribute__ ((aligned(16)));
+__m128i a_i_m7_p7 __attribute__ ((aligned(16)));
+__m128i a_i_m5_m7 __attribute__ ((aligned(16)));
+__m128i a_i_m5_m5 __attribute__ ((aligned(16)));
+__m128i a_i_m5_m3 __attribute__ ((aligned(16)));
+__m128i a_i_m5_m1 __attribute__ ((aligned(16)));
+__m128i a_i_m5_p1 __attribute__ ((aligned(16)));
+__m128i a_i_m5_p3 __attribute__ ((aligned(16)));
+__m128i a_i_m5_p5 __attribute__ ((aligned(16)));
+__m128i a_i_m5_p7 __attribute__ ((aligned(16)));
+__m128i a_i_m3_m7 __attribute__ ((aligned(16)));
+__m128i a_i_m3_m5 __attribute__ ((aligned(16)));
+__m128i a_i_m3_m3 __attribute__ ((aligned(16)));
+__m128i a_i_m3_m1 __attribute__ ((aligned(16)));
+__m128i a_i_m3_p1 __attribute__ ((aligned(16)));
+__m128i a_i_m3_p3 __attribute__ ((aligned(16)));
+__m128i a_i_m3_p5 __attribute__ ((aligned(16)));
+__m128i a_i_m3_p7 __attribute__ ((aligned(16)));
+__m128i a_i_m1_m7 __attribute__ ((aligned(16)));
+__m128i a_i_m1_m5 __attribute__ ((aligned(16)));
+__m128i a_i_m1_m3 __attribute__ ((aligned(16)));
+__m128i a_i_m1_m1 __attribute__ ((aligned(16)));
+__m128i a_i_m1_p1 __attribute__ ((aligned(16)));
+__m128i a_i_m1_p3 __attribute__ ((aligned(16)));
+__m128i a_i_m1_p5 __attribute__ ((aligned(16)));
+__m128i a_i_m1_p7 __attribute__ ((aligned(16)));
+__m128i a_i_p1_m7 __attribute__ ((aligned(16)));
+__m128i a_i_p1_m5 __attribute__ ((aligned(16)));
+__m128i a_i_p1_m3 __attribute__ ((aligned(16)));
+__m128i a_i_p1_m1 __attribute__ ((aligned(16)));
+__m128i a_i_p1_p1 __attribute__ ((aligned(16)));
+__m128i a_i_p1_p3 __attribute__ ((aligned(16)));
+__m128i a_i_p1_p5 __attribute__ ((aligned(16)));
+__m128i a_i_p1_p7 __attribute__ ((aligned(16)));
+__m128i a_i_p3_m7 __attribute__ ((aligned(16)));
+__m128i a_i_p3_m5 __attribute__ ((aligned(16)));
+__m128i a_i_p3_m3 __attribute__ ((aligned(16)));
+__m128i a_i_p3_m1 __attribute__ ((aligned(16)));
+__m128i a_i_p3_p1 __attribute__ ((aligned(16)));
+__m128i a_i_p3_p3 __attribute__ ((aligned(16)));
+__m128i a_i_p3_p5 __attribute__ ((aligned(16)));
+__m128i a_i_p3_p7 __attribute__ ((aligned(16)));
+__m128i a_i_p5_m7 __attribute__ ((aligned(16)));
+__m128i a_i_p5_m5 __attribute__ ((aligned(16)));
+__m128i a_i_p5_m3 __attribute__ ((aligned(16)));
+__m128i a_i_p5_m1 __attribute__ ((aligned(16)));
+__m128i a_i_p5_p1 __attribute__ ((aligned(16)));
+__m128i a_i_p5_p3 __attribute__ ((aligned(16)));
+__m128i a_i_p5_p5 __attribute__ ((aligned(16)));
+__m128i a_i_p5_p7 __attribute__ ((aligned(16)));
+__m128i a_i_p7_m7 __attribute__ ((aligned(16)));
+__m128i a_i_p7_m5 __attribute__ ((aligned(16)));
+__m128i a_i_p7_m3 __attribute__ ((aligned(16)));
+__m128i a_i_p7_m1 __attribute__ ((aligned(16)));
+__m128i a_i_p7_p1 __attribute__ ((aligned(16)));
+__m128i a_i_p7_p3 __attribute__ ((aligned(16)));
+__m128i a_i_p7_p5 __attribute__ ((aligned(16)));
+__m128i a_i_p7_p7 __attribute__ ((aligned(16)));
+
+__m128i psi_a_m7_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_m7_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_m7_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_m7_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_m7_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_m7_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_m7_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_m7_p7 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_m5_p7 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_m3_p7 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_m1_p7 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_p1_p7 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_p3_p7 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_p5_p7 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_m7 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_m5 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_m3 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_m1 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_p1 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_p3 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_p5 __attribute__ ((aligned(16)));
+__m128i psi_a_p7_p7 __attribute__ ((aligned(16)));
+
+__m128i a_sq_m7_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_m7_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_m7_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_m7_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_m7_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_m7_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_m7_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_m7_p7 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_m5_p7 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_m3_p7 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_m1_p7 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_p1_p7 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_p3_p7 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_p5_p7 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_m7 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_m5 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_m3 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_m1 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_p1 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_p3 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_p5 __attribute__ ((aligned(16)));
+__m128i a_sq_p7_p7 __attribute__ ((aligned(16)));
+
+__m128i bit_met_m7_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_m7_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_m7_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_m7_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_m7_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_m7_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_m7_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_m7_p7 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_m5_p7 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_m3_p7 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_m1_p7 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_p1_p7 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_p3_p7 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_p5_p7 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_m7 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_m5 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_m3 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_m1 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_p1 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_p3 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_p5 __attribute__ ((aligned(16)));
+__m128i bit_met_p7_p7 __attribute__ ((aligned(16)));
+
+__m128i  y0_p_1_1 __attribute__ ((aligned(16)));
+__m128i  y0_p_1_3 __attribute__ ((aligned(16)));
+__m128i  y0_p_1_5 __attribute__ ((aligned(16)));
+__m128i  y0_p_1_7 __attribute__ ((aligned(16)));
+__m128i  y0_p_3_1 __attribute__ ((aligned(16)));
+__m128i  y0_p_3_3 __attribute__ ((aligned(16)));
+__m128i  y0_p_3_5 __attribute__ ((aligned(16)));
+__m128i  y0_p_3_7 __attribute__ ((aligned(16)));
+__m128i  y0_p_5_1 __attribute__ ((aligned(16)));
+__m128i  y0_p_5_3 __attribute__ ((aligned(16)));
+__m128i  y0_p_5_5 __attribute__ ((aligned(16)));
+__m128i  y0_p_5_7 __attribute__ ((aligned(16)));
+__m128i  y0_p_7_1 __attribute__ ((aligned(16)));
+__m128i  y0_p_7_3 __attribute__ ((aligned(16)));
+__m128i  y0_p_7_5 __attribute__ ((aligned(16)));
+__m128i  y0_p_7_7 __attribute__ ((aligned(16)));
+__m128i  y0_m_1_1 __attribute__ ((aligned(16)));
+__m128i  y0_m_1_3 __attribute__ ((aligned(16)));
+__m128i  y0_m_1_5 __attribute__ ((aligned(16)));
+__m128i  y0_m_1_7 __attribute__ ((aligned(16)));
+__m128i  y0_m_3_1 __attribute__ ((aligned(16)));
+__m128i  y0_m_3_3 __attribute__ ((aligned(16)));
+__m128i  y0_m_3_5 __attribute__ ((aligned(16)));
+__m128i  y0_m_3_7 __attribute__ ((aligned(16)));
+__m128i  y0_m_5_1 __attribute__ ((aligned(16)));
+__m128i  y0_m_5_3 __attribute__ ((aligned(16)));
+__m128i  y0_m_5_5 __attribute__ ((aligned(16)));
+__m128i  y0_m_5_7 __attribute__ ((aligned(16)));
+__m128i  y0_m_7_1 __attribute__ ((aligned(16)));
+__m128i  y0_m_7_3 __attribute__ ((aligned(16)));
+__m128i  y0_m_7_5 __attribute__ ((aligned(16)));
+__m128i  y0_m_7_7 __attribute__ ((aligned(16)));
+
+__m128i  xmm0 __attribute__ ((aligned(16)));
+__m128i  xmm1 __attribute__ ((aligned(16)));
+__m128i  xmm2 __attribute__ ((aligned(16)));
+__m128i  xmm3 __attribute__ ((aligned(16)));
+__m128i  xmm4 __attribute__ ((aligned(16)));
+__m128i  xmm5 __attribute__ ((aligned(16)));
+__m128i  xmm6 __attribute__ ((aligned(16)));
+__m128i  xmm7 __attribute__ ((aligned(16)));
+__m128i  xmm8 __attribute__ ((aligned(16)));
+
+__m128i  y0r __attribute__ ((aligned(16)));
+__m128i  y0i __attribute__ ((aligned(16)));
+__m128i  y1r __attribute__ ((aligned(16)));
+__m128i  y1i __attribute__ ((aligned(16)));
+__m128i  y2r __attribute__ ((aligned(16)));
+__m128i  y2i __attribute__ ((aligned(16)));
+
+__m128i  logmax_num_re0 __attribute__ ((aligned(16)));
+__m128i  logmax_num_im0 __attribute__ ((aligned(16)));
+__m128i  logmax_den_re0 __attribute__ ((aligned(16)));
+__m128i  logmax_den_im0 __attribute__ ((aligned(16)));
+__m128i  logmax_num_re1 __attribute__ ((aligned(16)));
+__m128i  logmax_num_im1 __attribute__ ((aligned(16)));
+__m128i  logmax_den_re1 __attribute__ ((aligned(16)));
+__m128i  logmax_den_im1 __attribute__ ((aligned(16)));
+
+__m128i tmp_result  __attribute__ ((aligned(16)));
+__m128i tmp_result2 __attribute__ ((aligned(16)));
+__m128i tmp_result3 __attribute__ ((aligned(16)));
+__m128i tmp_result4 __attribute__ ((aligned(16)));
+
+
+//==============================================================================================
+// Auxiliary Makros
+
+// calculates psi_a = psi_r*a_r + psi_i*a_i
+#define prodsum_psi_a_epi16(psi_r,a_r,psi_i,a_i,psi_a) tmp_result = _mm_mulhi_epi16(psi_r,a_r); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result2 = _mm_mulhi_epi16(psi_i,a_i); tmp_result2 = _mm_slli_epi16(tmp_result2,1); psi_a = _mm_adds_epi16(tmp_result,tmp_result2);
+
+// calculate interference magnitude
+#define interference_abs_epi16(psi,int_ch_mag,int_mag,c1,c2) tmp_result = _mm_cmplt_epi16(psi,int_ch_mag); tmp_result2 = _mm_xor_si128(tmp_result,(*(__m128i*)&ones[0])); tmp_result = _mm_and_si128(tmp_result,c1); tmp_result2 = _mm_and_si128(tmp_result2,c2); int_mag = _mm_or_si128(tmp_result,tmp_result2);
+
+// calculate interference magnitude
+// tmp_result = ones in shorts corr. to interval 2<=x<=4, tmp_result2 interval < 2, tmp_result3 interval 4<x<6 and tmp_result4 interval x>6
+#define interference_abs_64qam_epi16(psi,int_ch_mag,int_two_ch_mag,int_three_ch_mag,a,c1,c3,c5,c7) tmp_result = _mm_cmplt_epi16(psi,int_two_ch_mag); tmp_result3 = _mm_xor_si128(tmp_result,(*(__m128i*)&ones[0])); tmp_result2 = _mm_cmplt_epi16(psi,int_ch_mag); tmp_result = _mm_xor_si128(tmp_result,tmp_result2); tmp_result4 = _mm_cmpgt_epi16(psi,int_three_ch_mag); tmp_result3 = _mm_xor_si128(tmp_result3,tmp_result4); tmp_result = _mm_and_si128(tmp_result,c3); tmp_result2 = _mm_and_si128(tmp_result2,c1); tmp_result3 = _mm_and_si128(tmp_result3,c5); tmp_result4 = _mm_and_si128(tmp_result4,c7); tmp_result = _mm_or_si128(tmp_result,tmp_result2); tmp_result3 = _mm_or_si128(tmp_result3,tmp_result4); a = _mm_or_si128(tmp_result,tmp_result3);
+
+// calculates a_sq = int_ch_mag*(a_r^2 + a_i^2)*scale_factor
+#define square_a_epi16(a_r,a_i,int_ch_mag,scale_factor,a_sq) tmp_result = _mm_mulhi_epi16(a_r,a_r); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result = _mm_mulhi_epi16(tmp_result,scale_factor); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result = _mm_mulhi_epi16(tmp_result,int_ch_mag); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result2 = _mm_mulhi_epi16(a_i,a_i); tmp_result2 = _mm_slli_epi16(tmp_result2,1); tmp_result2 = _mm_mulhi_epi16(tmp_result2,scale_factor); tmp_result2 = _mm_slli_epi16(tmp_result2,1); tmp_result2 = _mm_mulhi_epi16(tmp_result2,int_ch_mag); tmp_result2 = _mm_slli_epi16(tmp_result2,1); a_sq = _mm_adds_epi16(tmp_result,tmp_result2);
+
+// calculates a_sq = int_ch_mag*(a_r^2 + a_i^2)*scale_factor for 64-QAM
+#define square_a_64qam_epi16(a_r,a_i,int_ch_mag,scale_factor,a_sq)  tmp_result = _mm_mulhi_epi16(a_r,a_r); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result = _mm_mulhi_epi16(tmp_result,scale_factor); tmp_result = _mm_slli_epi16(tmp_result,3); tmp_result = _mm_mulhi_epi16(tmp_result,int_ch_mag); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result2 = _mm_mulhi_epi16(a_i,a_i); tmp_result2 = _mm_slli_epi16(tmp_result2,1); tmp_result2 = _mm_mulhi_epi16(tmp_result2,scale_factor); tmp_result2 = _mm_slli_epi16(tmp_result2,3); tmp_result2 = _mm_mulhi_epi16(tmp_result2,int_ch_mag); tmp_result2 = _mm_slli_epi16(tmp_result2,1); a_sq = _mm_adds_epi16(tmp_result,tmp_result2);
+
+#elif defined(__arm__)
+
+#endif
+
+//==============================================================================================
+// SINGLE-STREAM
+//==============================================================================================
+
+//----------------------------------------------------------------------------------------------
+// QPSK
+//----------------------------------------------------------------------------------------------
+
+int dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                   int32_t **rxdataF_comp,
+                   int16_t *dlsch_llr,
+                   uint8_t symbol,
+                   uint8_t first_symbol_flag,
+                   uint16_t nb_rb,
+                   uint16_t pbch_pss_sss_adjust,
+                   uint8_t beamforming_mode)
+{
+
+  uint32_t *rxF = (uint32_t*)&rxdataF_comp[0][((int32_t)symbol*frame_parms->N_RB_DL*12)];
+  uint32_t *llr32;
+  int i,len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  /*
+  if (first_symbol_flag==1) {
+    llr32 = (uint32_t*)dlsch_llr;
+  } else {
+    llr32 = (uint32_t*)(*llr32p);
+  }*/
+
+  llr32 = (uint32_t*)dlsch_llr;
+  if (!llr32) {
+    LOG_E(PHY,"dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32);
+    return(-1);
+  }
+
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else if((beamforming_mode==7) && (frame_parms->Ncp==0) && (symbol==3 || symbol==6 || symbol==9 || symbol==12)){
+      len = (nb_rb*9) - (3*pbch_pss_sss_adjust/4);
+  } else if((beamforming_mode==7) && (frame_parms->Ncp==1) && (symbol==4 || symbol==7 || symbol==10)){
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+  } else {
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+
+  /*
+  LOG_I(PHY,"dlsch_qpsk_llr: [symb %d / FirstSym %d / Length %d]: @LLR Buff %x, @LLR Buff(symb) %x \n",
+             symbol,
+             first_symbol_flag,
+             len,
+             dlsch_llr,
+             llr32);
+  */
+  //printf("ll32p=%p , dlsch_llr=%p, symbol=%d, flag=%d \n", llr32, dlsch_llr, symbol, first_symbol_flag);
+  for (i=0; i<len; i++) {
+    *llr32 = *rxF;
+     //printf("llr %d : (%d,%d)\n",i,((int16_t*)llr32)[0],((int16_t*)llr32)[1]);
+    rxF++;
+    llr32++;
+  }
+
+  //*llr32p = (int16_t *)llr32;
+
+  return(0);
+}
+
+int32_t dlsch_qpsk_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
+                           int32_t **rxdataF_comp,
+                           int32_t **sic_buffer,  //Q15
+                           int32_t **rho_i,
+                           short *dlsch_llr,
+                           uint8_t num_pdcch_symbols,
+                           uint16_t nb_rb,
+                           uint8_t subframe,
+                           uint16_t mod_order_0,
+                           uint32_t rb_alloc)
+{
+
+  int16_t rho_amp_x0[2*frame_parms->N_RB_DL*12];
+  int16_t rho_rho_amp_x0[2*frame_parms->N_RB_DL*12];
+  uint16_t amp_tmp;
+  uint16_t *llr16=(uint16_t*)dlsch_llr;
+  int i, len,  nsymb;
+  uint8_t symbol, symbol_mod;
+  int len_acc=0;
+  uint16_t *sic_data;
+  uint16_t pbch_pss_sss_adjust;
+
+  nsymb = (frame_parms->Ncp==0) ? 14:12;
+
+  for (symbol=num_pdcch_symbols; symbol<nsymb; symbol++) {
+    uint16_t *rxF = (uint16_t*)(&rxdataF_comp[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    int16_t *rho_1=(int16_t*)(&rho_i[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    sic_data = (uint16_t*)&sic_buffer[0][((int16_t)len_acc)];
+
+    symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+
+
+
+    if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) //pilots=1
+      amp_tmp=0x1fff;//dlsch0->sqrt_rho_b; already taken into account
+    else //pilots=0
+      amp_tmp=0x1fff;//1.5*dlsch0->sqrt_rho_a; already taken into account
+
+    if (mod_order_0==6)
+      amp_tmp=amp_tmp<<1; // to compensate for >> 1 shift in modulation
+
+
+    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,2,subframe,symbol);
+
+    if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+      if (frame_parms->nb_antenna_ports_eNB!=1)
+        len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+      else
+        len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+    } else {
+      len = (nb_rb*12) - pbch_pss_sss_adjust;
+    }
+
+   //  printf("dlsch_qpsk_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust);
+
+    len_acc+=len; //accumulated length; this is done because in sic_buffer we have only data symbols
+
+    multadd_complex_vector_real_scalar((int16_t *)sic_data,
+                                       amp_tmp,
+                                       (int16_t *)rho_amp_x0, //this is in Q13
+                                       1,
+                                       len);
+
+    mult_cpx_vector((int16_t *)rho_1, //Q15
+                    (int16_t *)rho_amp_x0, //Q13
+                    (int16_t*)rho_rho_amp_x0,
+                    len,
+                    13);
+
+#ifdef DEBUG_LLR_SIC
+    write_output("rho_for_multipl.m","rho_for_m", rho_1,len,1,
+     symbol==num_pdcch_symbols ? 15 :
+     symbol==nsymb-1 ? 14 : 13);
+
+    write_output("rho_rho_in_llr.m","rho2", rho_rho_amp_x0,len,1,
+     symbol==num_pdcch_symbols ? 15 :
+     symbol==nsymb-1 ? 14 : 13);
+#endif
+
+    sub_cpx_vector16((int16_t *)rxF,
+                     (int16_t *)rho_rho_amp_x0,
+                     //(int16_t *)clean_x1,
+                     (int16_t *)rxF,
+                     len*2);
+
+#ifdef DEBUG_LLR_SIC
+    write_output("rxFdata_comp1_after.m","rxF_a", rxF,len,1,1);
+    write_output("rxF_comp1.m","rxF_1_comp", rxF,len,1,
+                 symbol==num_pdcch_symbols ? 15 :
+                 symbol==nsymb-1 ? 14 : 13);
+#endif
+
+    //this is for QPSK only!!!
+    for (i=0; i<len*2; i++) {
+      *llr16 =rxF[i];
+      //printf("llr %d : (%d,%d)\n",i,((int16_t*)llr32)[0],((int16_t*)llr32)[1]);
+      llr16++;
+    }
+
+  }
+
+ // printf("dlsch_qpsk_llr_SIC: acc_len=%d\n",len_acc);
+
+  return(0);
+}
+
+
+//----------------------------------------------------------------------------------------------
+// 16-QAM
+//----------------------------------------------------------------------------------------------
+
+void dlsch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                     int32_t **rxdataF_comp,
+                     int16_t *dlsch_llr,
+                     int32_t **dl_ch_mag,
+                     uint8_t symbol,
+                     uint8_t first_symbol_flag,
+                     uint16_t nb_rb,
+                     uint16_t pbch_pss_sss_adjust,
+                     int16_t **llr32p,
+                     uint8_t beamforming_mode)
+{
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  __m128i *ch_mag;
+  __m128i llr128[2];
+  uint32_t *llr32;
+#elif defined(__arm__)
+  int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16x8_t *ch_mag;
+  int16x8_t xmm0;
+  int16_t *llr16;
+#endif
+
+
+  int i,len;
+  unsigned char symbol_mod,len_mod4=0;
+
+
+#if defined(__x86_64__) || defined(__i386__)
+  if (first_symbol_flag==1) {
+    llr32 = (uint32_t*)dlsch_llr;
+  } else {
+    llr32 = (uint32_t*)*llr32p;
+  }
+#elif defined(__arm__)
+  if (first_symbol_flag==1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)*llr32p;
+  }
+#endif
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+#if defined(__x86_64__) || defined(__i386__)
+  ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+#elif defined(__arm__)
+  ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+#endif
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else if((beamforming_mode==7) && (frame_parms->Ncp==0) && (symbol==3 || symbol==6 || symbol==9 || symbol==12)){
+      len = (nb_rb*9) - (3*pbch_pss_sss_adjust/4);
+  } else if((beamforming_mode==7) && (frame_parms->Ncp==1) && (symbol==4 || symbol==7 || symbol==10)){
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+  } else {
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  // update output pointer according to number of REs in this symbol (<<2 because 4 bits per RE)
+  if (first_symbol_flag == 1)
+    *llr32p = dlsch_llr + (len<<2);
+  else
+    *llr32p += (len<<2);
+
+ // printf("len=%d\n", len);
+  len_mod4 = len&3;
+ // printf("len_mod4=%d\n", len_mod4);
+  len>>=2;  // length in quad words (4 REs)
+ // printf("len>>=2=%d\n", len);
+  len+=(len_mod4==0 ? 0 : 1);
+ // printf("len+=%d\n", len);
+  for (i=0; i<len; i++) {
+
+#if defined(__x86_64__) || defined(__i386)
+    xmm0 = _mm_abs_epi16(rxF[i]);
+    xmm0 = _mm_subs_epi16(ch_mag[i],xmm0);
+
+    // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2
+    llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0);
+    llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0);
+    llr32[0] = _mm_extract_epi32(llr128[0],0); //((uint32_t *)&llr128[0])[0];
+    llr32[1] = _mm_extract_epi32(llr128[0],1); //((uint32_t *)&llr128[0])[1];
+    llr32[2] = _mm_extract_epi32(llr128[0],2); //((uint32_t *)&llr128[0])[2];
+    llr32[3] = _mm_extract_epi32(llr128[0],3); //((uint32_t *)&llr128[0])[3];
+    llr32[4] = _mm_extract_epi32(llr128[1],0); //((uint32_t *)&llr128[1])[0];
+    llr32[5] = _mm_extract_epi32(llr128[1],1); //((uint32_t *)&llr128[1])[1];
+    llr32[6] = _mm_extract_epi32(llr128[1],2); //((uint32_t *)&llr128[1])[2];
+    llr32[7] = _mm_extract_epi32(llr128[1],3); //((uint32_t *)&llr128[1])[3];
+    llr32+=8;
+#elif defined(__arm__)
+    xmm0 = vabsq_s16(rxF[i]);
+    xmm0 = vqsubq_s16(ch_mag[i],xmm0);
+    // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2
+
+    llr16[0] = vgetq_lane_s16(rxF[i],0);
+    llr16[1] = vgetq_lane_s16(rxF[i],1);
+    llr16[2] = vgetq_lane_s16(xmm0,0);
+    llr16[3] = vgetq_lane_s16(xmm0,1);
+    llr16[4] = vgetq_lane_s16(rxF[i],2);
+    llr16[5] = vgetq_lane_s16(rxF[i],3);
+    llr16[6] = vgetq_lane_s16(xmm0,2);
+    llr16[7] = vgetq_lane_s16(xmm0,3);
+    llr16[8] = vgetq_lane_s16(rxF[i],4);
+    llr16[9] = vgetq_lane_s16(rxF[i],5);
+    llr16[10] = vgetq_lane_s16(xmm0,4);
+    llr16[11] = vgetq_lane_s16(xmm0,5);
+    llr16[12] = vgetq_lane_s16(rxF[i],6);
+    llr16[13] = vgetq_lane_s16(rxF[i],6);
+    llr16[14] = vgetq_lane_s16(xmm0,7);
+    llr16[15] = vgetq_lane_s16(xmm0,7);
+    llr16+=16;
+#endif
+
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+void dlsch_16qam_llr_SIC (LTE_DL_FRAME_PARMS *frame_parms,
+                          int32_t **rxdataF_comp,
+                          int32_t **sic_buffer,  //Q15
+                          int32_t **rho_i,
+                          int16_t *dlsch_llr,
+                          uint8_t num_pdcch_symbols,
+                          int32_t **dl_ch_mag,
+                          uint16_t nb_rb,
+                          uint8_t subframe,
+                          uint16_t mod_order_0,
+                          uint32_t rb_alloc)
+{
+  int16_t rho_amp_x0[2*frame_parms->N_RB_DL*12];
+  int16_t rho_rho_amp_x0[2*frame_parms->N_RB_DL*12];
+  uint16_t amp_tmp;
+  uint32_t *llr32=(uint32_t*)dlsch_llr;
+  int i, len,  nsymb;
+  uint8_t symbol, symbol_mod;
+  int len_acc=0;
+  uint16_t *sic_data;
+  uint16_t pbch_pss_sss_adjust;
+  unsigned char len_mod4=0;
+  __m128i llr128[2];
+  __m128i *ch_mag;
+  nsymb = (frame_parms->Ncp==0) ? 14:12;
+
+    for (symbol=num_pdcch_symbols; symbol<nsymb; symbol++) {
+    uint16_t *rxF = (uint16_t*)(&rxdataF_comp[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    int16_t *rho_1=(int16_t*)(&rho_i[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    ch_mag = (__m128i*)(&dl_ch_mag[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    sic_data = (uint16_t*)(&sic_buffer[0][((int16_t)len_acc)]);
+
+    symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,4,subframe,symbol);
+
+    if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+      amp_tmp=0x1fff;//dlsch0->sqrt_rho_b; already taken into account
+      if (frame_parms->nb_antenna_ports_eNB!=1)
+        len = nb_rb*8 - (2*pbch_pss_sss_adjust/3);
+      else
+        len = nb_rb*10 - (5*pbch_pss_sss_adjust/6);
+    } else {
+      amp_tmp=0x1fff;;//dlsch0->sqrt_rho_a; already taken into account
+      len = nb_rb*12 - pbch_pss_sss_adjust;
+    }
+
+    if (mod_order_0==6)
+      amp_tmp=amp_tmp<<1; // to compensate for >> 1 shift in modulation
+
+    len_acc+=len;
+
+    multadd_complex_vector_real_scalar((int16_t *)sic_data,
+                                       amp_tmp,
+                                       (int16_t *)rho_amp_x0, //this is in Q13
+                                       1,
+                                       len);
+
+     mult_cpx_vector((int16_t *)rho_1, //Q15
+                    (int16_t *)rho_amp_x0, //Q13
+                    (int16_t*)rho_rho_amp_x0,
+                    len,
+                    13);
+
+     sub_cpx_vector16((int16_t *)rxF,
+                      (int16_t *)rho_rho_amp_x0,
+                      //(int16_t *)clean_x1,
+                      (int16_t *)rxF,
+                      len*2);
+
+    len_mod4 = len&3;
+    len>>=2;  // length in quad words (4 REs)
+    len+=(len_mod4==0 ? 0 : 1);
+
+    for (i=0; i<len; i++) {
+
+
+    __m128i *x1 = (__m128i*)rxF;//clean_x1;
+//printf("%p %p %p\n", clean_x1, &clean_x1, &clean_x1[0]);
+//int *a = malloc(10*sizeof(int));
+//printf("%p %p\n", a, &a);
+//exit(0);
+    xmm0 = _mm_abs_epi16(x1[i]);
+    xmm0 = _mm_subs_epi16(ch_mag[i],xmm0);
+
+    // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2
+    llr128[0] = _mm_unpacklo_epi32(x1[i],xmm0);
+    llr128[1] = _mm_unpackhi_epi32(x1[i],xmm0);
+    llr32[0] = _mm_extract_epi32(llr128[0],0); //((uint32_t *)&llr128[0])[0];
+    llr32[1] = _mm_extract_epi32(llr128[0],1); //((uint32_t *)&llr128[0])[1];
+    llr32[2] = _mm_extract_epi32(llr128[0],2); //((uint32_t *)&llr128[0])[2];
+    llr32[3] = _mm_extract_epi32(llr128[0],3); //((uint32_t *)&llr128[0])[3];
+    llr32[4] = _mm_extract_epi32(llr128[1],0); //((uint32_t *)&llr128[1])[0];
+    llr32[5] = _mm_extract_epi32(llr128[1],1); //((uint32_t *)&llr128[1])[1];
+    llr32[6] = _mm_extract_epi32(llr128[1],2); //((uint32_t *)&llr128[1])[2];
+    llr32[7] = _mm_extract_epi32(llr128[1],3); //((uint32_t *)&llr128[1])[3];
+    llr32+=8;
+
+  }
+  _mm_empty();
+  _m_empty();
+}
+}
+
+//----------------------------------------------------------------------------------------------
+// 64-QAM
+//----------------------------------------------------------------------------------------------
+
+void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                     int32_t **rxdataF_comp,
+                     int16_t *dlsch_llr,
+                     int32_t **dl_ch_mag,
+                     int32_t **dl_ch_magb,
+                     uint8_t symbol,
+                     uint8_t first_symbol_flag,
+                     uint16_t nb_rb,
+                     uint16_t pbch_pss_sss_adjust,
+                     //int16_t **llr_save,
+                     uint32_t llr_offset,
+                     uint8_t beamforming_mode)
+{
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  __m128i *ch_mag,*ch_magb;
+#elif defined(__arm__)
+  int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16x8_t *ch_mag,*ch_magb,xmm1,xmm2;
+#endif
+  int i,len,len2;
+  unsigned char symbol_mod,len_mod4;
+  short *llr;
+  int16_t *llr2;
+  int8_t *pllr_symbol;
+
+  /*
+  if (first_symbol_flag==1)
+    llr = dlsch_llr;
+  else
+    llr = *llr_save;
+  */
+  llr = dlsch_llr;
+
+  pllr_symbol = (int8_t*)dlsch_llr;
+  pllr_symbol += llr_offset;
+
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+#if defined(__x86_64__) || defined(__i386__)
+  ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  ch_magb = (__m128i*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)];
+#elif defined(__arm__)
+  ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)];
+#endif
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else if((beamforming_mode==7) && (frame_parms->Ncp==0) && (symbol==3 || symbol==6 || symbol==9 || symbol==12)){
+      len = (nb_rb*9) - (3*pbch_pss_sss_adjust/4);
+  } else if((beamforming_mode==7) && (frame_parms->Ncp==1) && (symbol==4 || symbol==7 || symbol==10)){
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+  } else {
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+//  printf("dlsch_64qam_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust);
+
+/*  LOG_I(PHY,"dlsch_64qam_llr [symb %d / FirstSym %d / Length %d]: @LLR Buff %x \n",
+             symbol,
+             first_symbol_flag,
+             len,
+             dlsch_llr,
+             pllr_symbol);*/
+
+  llr2 = llr;
+  llr += (len*6);
+
+  len_mod4 =len&3;
+  len2=len>>2;  // length in quad words (4 REs)
+  len2+=((len_mod4==0)?0:1);
+
+  for (i=0; i<len2; i++) {
+
+#if defined(__x86_64__) || defined(__i386__)
+    xmm1 = _mm_abs_epi16(rxF[i]);
+    xmm1 = _mm_subs_epi16(ch_mag[i],xmm1);
+    xmm2 = _mm_abs_epi16(xmm1);
+    xmm2 = _mm_subs_epi16(ch_magb[i],xmm2);
+#elif defined(__arm__)
+    xmm1 = vabsq_s16(rxF[i]);
+    xmm1 = vsubq_s16(ch_mag[i],xmm1);
+    xmm2 = vabsq_s16(xmm1);
+    xmm2 = vsubq_s16(ch_magb[i],xmm2);
+#endif
+    // loop over all LLRs in quad word (24 coded bits)
+    /*
+      for (j=0;j<8;j+=2) {
+      llr2[0] = ((short *)&rxF[i])[j];
+      llr2[1] = ((short *)&rxF[i])[j+1];
+      llr2[2] = ((short *)&xmm1)[j];
+      llr2[3] = ((short *)&xmm1)[j+1];
+      llr2[4] = ((short *)&xmm2)[j];
+      llr2[5] = ((short *)&xmm2)[j+1];
+
+     llr2+=6;
+      }
+    */
+    llr2[0] = ((short *)&rxF[i])[0];
+    llr2[1] = ((short *)&rxF[i])[1];
+#if defined(__x86_64__) || defined(__i386__)
+    llr2[2] = _mm_extract_epi16(xmm1,0);
+    llr2[3] = _mm_extract_epi16(xmm1,1);//((short *)&xmm1)[j+1];
+    llr2[4] = _mm_extract_epi16(xmm2,0);//((short *)&xmm2)[j];
+    llr2[5] = _mm_extract_epi16(xmm2,1);//((short *)&xmm2)[j+1];
+#elif defined(__arm__)
+    llr2[2] = vgetq_lane_s16(xmm1,0);
+    llr2[3] = vgetq_lane_s16(xmm1,1);//((short *)&xmm1)[j+1];
+    llr2[4] = vgetq_lane_s16(xmm2,0);//((short *)&xmm2)[j];
+    llr2[5] = vgetq_lane_s16(xmm2,1);//((short *)&xmm2)[j+1];
+#endif
+
+    llr2+=6;
+    llr2[0] = ((short *)&rxF[i])[2];
+    llr2[1] = ((short *)&rxF[i])[3];
+#if defined(__x86_64__) || defined(__i386__)
+    llr2[2] = _mm_extract_epi16(xmm1,2);
+    llr2[3] = _mm_extract_epi16(xmm1,3);//((short *)&xmm1)[j+1];
+    llr2[4] = _mm_extract_epi16(xmm2,2);//((short *)&xmm2)[j];
+    llr2[5] = _mm_extract_epi16(xmm2,3);//((short *)&xmm2)[j+1];
+#elif defined(__arm__)
+    llr2[2] = vgetq_lane_s16(xmm1,2);
+    llr2[3] = vgetq_lane_s16(xmm1,3);//((short *)&xmm1)[j+1];
+    llr2[4] = vgetq_lane_s16(xmm2,2);//((short *)&xmm2)[j];
+    llr2[5] = vgetq_lane_s16(xmm2,3);//((short *)&xmm2)[j+1];
+#endif
+
+    llr2+=6;
+    llr2[0] = ((short *)&rxF[i])[4];
+    llr2[1] = ((short *)&rxF[i])[5];
+#if defined(__x86_64__) || defined(__i386__)
+    llr2[2] = _mm_extract_epi16(xmm1,4);
+    llr2[3] = _mm_extract_epi16(xmm1,5);//((short *)&xmm1)[j+1];
+    llr2[4] = _mm_extract_epi16(xmm2,4);//((short *)&xmm2)[j];
+    llr2[5] = _mm_extract_epi16(xmm2,5);//((short *)&xmm2)[j+1];
+#elif defined(__arm__)
+    llr2[2] = vgetq_lane_s16(xmm1,4);
+    llr2[3] = vgetq_lane_s16(xmm1,5);//((short *)&xmm1)[j+1];
+    llr2[4] = vgetq_lane_s16(xmm2,4);//((short *)&xmm2)[j];
+    llr2[5] = vgetq_lane_s16(xmm2,5);//((short *)&xmm2)[j+1];
+#endif
+    llr2+=6;
+    llr2[0] = ((short *)&rxF[i])[6];
+    llr2[1] = ((short *)&rxF[i])[7];
+#if defined(__x86_64__) || defined(__i386__)
+    llr2[2] = _mm_extract_epi16(xmm1,6);
+    llr2[3] = _mm_extract_epi16(xmm1,7);//((short *)&xmm1)[j+1];
+    llr2[4] = _mm_extract_epi16(xmm2,6);//((short *)&xmm2)[j];
+    llr2[5] = _mm_extract_epi16(xmm2,7);//((short *)&xmm2)[j+1];
+#elif defined(__arm__)
+    llr2[2] = vgetq_lane_s16(xmm1,6);
+    llr2[3] = vgetq_lane_s16(xmm1,7);//((short *)&xmm1)[j+1];
+    llr2[4] = vgetq_lane_s16(xmm2,6);//((short *)&xmm2)[j];
+    llr2[5] = vgetq_lane_s16(xmm2,7);//((short *)&xmm2)[j+1];
+#endif
+    llr2+=6;
+
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+//#if 0
+void dlsch_64qam_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
+                         int32_t **rxdataF_comp,
+                         int32_t **sic_buffer,  //Q15
+                         int32_t **rho_i,
+                         int16_t *dlsch_llr,
+                         uint8_t num_pdcch_symbols,
+                         int32_t **dl_ch_mag,
+                         int32_t **dl_ch_magb,
+                         uint16_t nb_rb,
+                         uint8_t subframe,
+                         uint16_t mod_order_0,
+                         uint32_t rb_alloc)
+{
+  int16_t rho_amp_x0[2*frame_parms->N_RB_DL*12];
+  int16_t rho_rho_amp_x0[2*frame_parms->N_RB_DL*12];
+  uint16_t amp_tmp;
+  uint16_t *llr32=(uint16_t*)dlsch_llr;
+  int i, len,  nsymb, len2;
+  uint8_t symbol, symbol_mod;
+  int len_acc=0;
+  uint16_t *sic_data;
+  uint16_t pbch_pss_sss_adjust;
+  unsigned char len_mod4=0;
+  uint16_t *llr2;
+  __m128i *ch_mag,*ch_magb;
+
+  nsymb = (frame_parms->Ncp==0) ? 14:12;
+
+  for (symbol=num_pdcch_symbols; symbol<nsymb; symbol++) {
+    uint16_t *rxF = (uint16_t*)(&rxdataF_comp[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    int16_t *rho_1=(int16_t*)(&rho_i[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    ch_mag = (__m128i*)(&dl_ch_mag[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    ch_magb = (__m128i*)(&dl_ch_magb[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
+    sic_data = (uint16_t*)(&sic_buffer[0][((int16_t)len_acc)]);
+
+    symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,6,subframe,symbol);
+
+    if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+      amp_tmp = 0x1fff;//dlsch0->sqrt_rho_b; already taken into account
+      if (frame_parms->nb_antenna_ports_eNB!=1)
+        len = nb_rb*8 - (2*pbch_pss_sss_adjust/3);
+      else
+        len = nb_rb*10 - (5*pbch_pss_sss_adjust/6);
+      } else {
+        amp_tmp = 0x1fff; //dlsch0->sqrt_rho_a; already taken into account
+        len = nb_rb*12 - pbch_pss_sss_adjust;
+      }
+
+    if (mod_order_0==6)
+      amp_tmp=amp_tmp<<1; // to compensate for >> 1 shift in modulation
+
+    len_acc+=len;
+
+    multadd_complex_vector_real_scalar((int16_t *)sic_data,
+                                        amp_tmp,
+                                        (int16_t *)rho_amp_x0, //this is in Q13
+                                        1,
+                                        len);
+
+    mult_cpx_vector((int16_t *)rho_1, //Q15
+                    (int16_t *)rho_amp_x0, //Q13
+                    (int16_t*)rho_rho_amp_x0,
+                    len,
+                    13);
+
+    sub_cpx_vector16((int16_t *)rxF,
+                      (int16_t *)rho_rho_amp_x0,
+                      //(int16_t *)clean_x1,
+                      (int16_t *)rxF,
+                      len*2);
+
+    llr2 = llr32;
+    llr32 += (len*6);
+
+    len_mod4 =len&3;
+    len2=len>>2;  // length in quad words (4 REs)
+    len2+=(len_mod4?0:1);
+
+
+
+    for (i=0; i<len2; i++) {
+
+      __m128i *x1 = (__m128i*)rxF;
+      xmm1 = _mm_abs_epi16(x1[i]);
+      xmm1 = _mm_subs_epi16(ch_mag[i],xmm1);
+      xmm2 = _mm_abs_epi16(xmm1);
+      xmm2 = _mm_subs_epi16(ch_magb[i],xmm2);
+
+      // loop over all LLRs in quad word (24 coded bits)
+      /*
+        for (j=0;j<8;j+=2) {
+        llr2[0] = ((short *)&rxF[i])[j];
+        llr2[1] = ((short *)&rxF[i])[j+1];
+        llr2[2] = ((short *)&xmm1)[j];
+        llr2[3] = ((short *)&xmm1)[j+1];
+        llr2[4] = ((short *)&xmm2)[j];
+        llr2[5] = ((short *)&xmm2)[j+1];
+
+       llr2+=6;
+        }
+      */
+      llr2[0] = ((short *)&x1[i])[0];
+      llr2[1] = ((short *)&x1[i])[1];
+      llr2[2] = _mm_extract_epi16(xmm1,0);
+      llr2[3] = _mm_extract_epi16(xmm1,1);//((short *)&xmm1)[j+1];
+      llr2[4] = _mm_extract_epi16(xmm2,0);//((short *)&xmm2)[j];
+      llr2[5] = _mm_extract_epi16(xmm2,1);//((short *)&xmm2)[j+1];
+
+
+      llr2+=6;
+      llr2[0] = ((short *)&x1[i])[2];
+      llr2[1] = ((short *)&x1[i])[3];
+
+      llr2[2] = _mm_extract_epi16(xmm1,2);
+      llr2[3] = _mm_extract_epi16(xmm1,3);//((short *)&xmm1)[j+1];
+      llr2[4] = _mm_extract_epi16(xmm2,2);//((short *)&xmm2)[j];
+      llr2[5] = _mm_extract_epi16(xmm2,3);//((short *)&xmm2)[j+1];
+
+      llr2+=6;
+      llr2[0] = ((short *)&x1[i])[4];
+      llr2[1] = ((short *)&x1[i])[5];
+
+      llr2[2] = _mm_extract_epi16(xmm1,4);
+      llr2[3] = _mm_extract_epi16(xmm1,5);//((short *)&xmm1)[j+1];
+      llr2[4] = _mm_extract_epi16(xmm2,4);//((short *)&xmm2)[j];
+      llr2[5] = _mm_extract_epi16(xmm2,5);//((short *)&xmm2)[j+1];
+
+      llr2+=6;
+      llr2[0] = ((short *)&x1[i])[6];
+      llr2[1] = ((short *)&x1[i])[7];
+
+      llr2[2] = _mm_extract_epi16(xmm1,6);
+      llr2[3] = _mm_extract_epi16(xmm1,7);//((short *)&xmm1)[j+1];
+      llr2[4] = _mm_extract_epi16(xmm2,6);//((short *)&xmm2)[j];
+      llr2[5] = _mm_extract_epi16(xmm2,7);//((short *)&xmm2)[j+1];
+
+      llr2+=6;
+
+    }
+
+ // *llr_save = llr;
+
+  _mm_empty();
+  _m_empty();
+
+  }
+}
+//#endif
+//==============================================================================================
+// DUAL-STREAM
+//==============================================================================================
+
+//----------------------------------------------------------------------------------------------
+// QPSK
+//----------------------------------------------------------------------------------------------
+
+#if defined(__x86_64__) || defined(__i386)
+__m128i  y0r_over2 __attribute__ ((aligned(16)));
+__m128i  y0i_over2 __attribute__ ((aligned(16)));
+__m128i  y1r_over2 __attribute__ ((aligned(16)));
+__m128i  y1i_over2 __attribute__ ((aligned(16)));
+
+__m128i  A __attribute__ ((aligned(16)));
+__m128i  B __attribute__ ((aligned(16)));
+__m128i  C __attribute__ ((aligned(16)));
+__m128i  D __attribute__ ((aligned(16)));
+__m128i  E __attribute__ ((aligned(16)));
+__m128i  F __attribute__ ((aligned(16)));
+__m128i  G __attribute__ ((aligned(16)));
+__m128i  H __attribute__ ((aligned(16)));
+
+#endif
+
+int dlsch_qpsk_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                        int **rxdataF_comp,
+                        int **rxdataF_comp_i,
+                        int **rho_i,
+                        short *dlsch_llr,
+                        unsigned char symbol,
+                        unsigned char first_symbol_flag,
+                        unsigned short nb_rb,
+                        uint16_t pbch_pss_sss_adjust,
+                        short **llr16p)
+{
+
+  int16_t *rxF=(int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i=(int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho=(int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+  AssertFatal(llr16!=NULL,"dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol);
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  // printf("dlsch_qpsk_qpsk_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust);
+  //    printf("qpsk_qpsk: len %d, llr16 %p\n",len,llr16);
+  qpsk_qpsk((short *)rxF,
+            (short *)rxF_i,
+            (short *)llr16,
+            (short *)rho,
+            len);
+
+  llr16 += (len<<1);
+  *llr16p = (short *)llr16;
+
+  return(0);
+}
+
+//__m128i ONE_OVER_SQRT_8 __attribute__((aligned(16)));
+
+void qpsk_qpsk(short *stream0_in,
+               short *stream1_in,
+               short *stream0_out,
+               short *rho01,
+               int length
+         )
+{
+
+  /*
+    This function computes the LLRs of stream 0 (s_0) in presence of the interfering stream 1 (s_1) assuming that both symbols are QPSK. It can be used for both MU-MIMO interference-aware receiver or for SU-MIMO receivers.
+
+    Parameters:
+    stream0_in = Matched filter output y0' = (h0*g0)*y0
+    stream1_in = Matched filter output y1' = (h0*g1)*y0
+    stream0_out = LLRs
+    rho01 = Correlation between the two effective channels \rho_{10} = (h1*g1)*(h0*g0)
+    length = number of resource elements
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rho01_128i = (__m128i *)rho01;
+  __m128i *stream0_128i_in = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in = (__m128i *)stream1_in;
+  __m128i *stream0_128i_out = (__m128i *)stream0_out;
+  __m128i ONE_OVER_SQRT_8 = _mm_set1_epi16(23170); //round(2^16/sqrt(8))
+#elif defined(__arm__)
+  int16x8_t *rho01_128i = (int16x8_t *)rho01;
+  int16x8_t *stream0_128i_in = (int16x8_t *)stream0_in;
+  int16x8_t *stream1_128i_in = (int16x8_t *)stream1_in;
+  int16x8_t *stream0_128i_out = (int16x8_t *)stream0_out;
+  int16x8_t ONE_OVER_SQRT_8 = vdupq_n_s16(23170); //round(2^16/sqrt(8))
+#endif
+
+  int i;
+
+
+  for (i=0; i<length>>2; i+=2) {
+    // in each iteration, we take 8 complex samples
+#if defined(__x86_64__) || defined(__i386__)
+    xmm0 = rho01_128i[i]; // 4 symbols
+    xmm1 = rho01_128i[i+1];
+
+    // put (rho_r + rho_i)/2sqrt2 in rho_rpi
+    // put (rho_r - rho_i)/2sqrt2 in rho_rmi
+
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // divide by sqrt(8), no shift needed ONE_OVER_SQRT_8 = Q1.16
+    rho_rpi = _mm_mulhi_epi16(rho_rpi,ONE_OVER_SQRT_8);
+    rho_rmi = _mm_mulhi_epi16(rho_rmi,ONE_OVER_SQRT_8);
+#elif defined(__arm__)
+
+
+#endif
+    // Compute LLR for first bit of stream 0
+
+    // Compute real and imaginary parts of MF output for stream 0
+#if defined(__x86_64__) || defined(__i386__)
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    y0r_over2  = _mm_srai_epi16(y0r,1);   // divide by 2
+    y0i_over2  = _mm_srai_epi16(y0i,1);   // divide by 2
+#elif defined(__arm__)
+
+
+#endif
+    // Compute real and imaginary parts of MF output for stream 1
+#if defined(__x86_64__) || defined(__i386__)
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    y1r_over2  = _mm_srai_epi16(y1r,1);   // divide by 2
+    y1i_over2  = _mm_srai_epi16(y1i,1);   // divide by 2
+
+    // Compute the terms for the LLR of first bit
+
+    xmm0 = _mm_setzero_si128(); // ZERO
+
+    // 1 term for numerator of LLR
+    xmm3 = _mm_subs_epi16(y1r_over2,rho_rpi);
+    A = _mm_abs_epi16(xmm3); // A = |y1r/2 - rho/sqrt(8)|
+    xmm2 = _mm_adds_epi16(A,y0i_over2); // = |y1r/2 - rho/sqrt(8)| + y0i/2
+    xmm3 = _mm_subs_epi16(y1i_over2,rho_rmi);
+    B = _mm_abs_epi16(xmm3); // B = |y1i/2 - rho*/sqrt(8)|
+    logmax_num_re0 = _mm_adds_epi16(B,xmm2); // = |y1r/2 - rho/sqrt(8)|+|y1i/2 - rho*/sqrt(8)| + y0i/2
+
+    // 2 term for numerator of LLR
+    xmm3 = _mm_subs_epi16(y1r_over2,rho_rmi);
+    C = _mm_abs_epi16(xmm3); // C = |y1r/2 - rho*/4|
+    xmm2 = _mm_subs_epi16(C,y0i_over2); // = |y1r/2 - rho*/4| - y0i/2
+    xmm3 = _mm_adds_epi16(y1i_over2,rho_rpi);
+    D = _mm_abs_epi16(xmm3); // D = |y1i/2 + rho/4|
+    xmm2 = _mm_adds_epi16(xmm2,D); // |y1r/2 - rho*/4| + |y1i/2 + rho/4| - y0i/2
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0,xmm2); // max, numerator done
+
+    // 1 term for denominator of LLR
+    xmm3 = _mm_adds_epi16(y1r_over2,rho_rmi);
+    E = _mm_abs_epi16(xmm3); // E = |y1r/2 + rho*/4|
+    xmm2 = _mm_adds_epi16(E,y0i_over2); // = |y1r/2 + rho*/4| + y0i/2
+    xmm3 = _mm_subs_epi16(y1i_over2,rho_rpi);
+    F = _mm_abs_epi16(xmm3); // F = |y1i/2 - rho/4|
+    logmax_den_re0 = _mm_adds_epi16(F,xmm2); // = |y1r/2 + rho*/4| + |y1i/2 - rho/4| + y0i/2
+
+    // 2 term for denominator of LLR
+    xmm3 = _mm_adds_epi16(y1r_over2,rho_rpi);
+    G = _mm_abs_epi16(xmm3); // G = |y1r/2 + rho/4|
+    xmm2 = _mm_subs_epi16(G,y0i_over2); // = |y1r/2 + rho/4| - y0i/2
+    xmm3 = _mm_adds_epi16(y1i_over2,rho_rmi);
+    H = _mm_abs_epi16(xmm3); // H = |y1i/2 + rho*/4|
+    xmm2 = _mm_adds_epi16(xmm2,H); // = |y1r/2 + rho/4| + |y1i/2 + rho*/4| - y0i/2
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0,xmm2); // max, denominator done
+
+    // Compute the terms for the LLR of first bit
+
+    // 1 term for nominator of LLR
+    xmm2 = _mm_adds_epi16(A,y0r_over2);
+    logmax_num_im0 = _mm_adds_epi16(B,xmm2); // = |y1r/2 - rho/4| + |y1i/2 - rho*/4| + y0r/2
+
+    // 2 term for nominator of LLR
+    xmm2 = _mm_subs_epi16(E,y0r_over2);
+    xmm2 = _mm_adds_epi16(xmm2,F); // = |y1r/2 + rho*/4| + |y1i/2 - rho/4| - y0r/2
+
+    logmax_num_im0 = _mm_max_epi16(logmax_num_im0,xmm2); // max, nominator done
+
+    // 1 term for denominator of LLR
+    xmm2 = _mm_adds_epi16(C,y0r_over2);
+    logmax_den_im0 = _mm_adds_epi16(D,xmm2); // = |y1r/2 - rho*/4| + |y1i/2 + rho/4| - y0r/2
+
+    xmm2 = _mm_subs_epi16(G,y0r_over2);
+    xmm2 = _mm_adds_epi16(xmm2,H); // = |y1r/2 + rho/4| + |y1i/2 + rho*/4| - y0r/2
+
+    logmax_den_im0 = _mm_max_epi16(logmax_den_im0,xmm2); // max, denominator done
+
+    // LLR of first bit [L1(1), L1(2), L1(3), L1(4)]
+    y0r = _mm_adds_epi16(y0r,logmax_num_re0);
+    y0r = _mm_subs_epi16(y0r,logmax_den_re0);
+
+    // LLR of second bit [L2(1), L2(2), L2(3), L2(4)]
+    y0i = _mm_adds_epi16(y0i,logmax_num_im0);
+    y0i = _mm_subs_epi16(y0i,logmax_den_im0);
+
+    _mm_storeu_si128(&stream0_128i_out[i],_mm_unpacklo_epi16(y0r,y0i)); // = [L1(1), L2(1), L1(2), L2(2)]
+
+    if (i<((length>>1) - 1)) // false if only 2 REs remain
+      _mm_storeu_si128(&stream0_128i_out[i+1],_mm_unpackhi_epi16(y0r,y0i));
+
+#elif defined(__x86_64__)
+
+#endif
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+int dlsch_qpsk_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                         int32_t **rxdataF_comp,
+                         int32_t **rxdataF_comp_i,
+                         int32_t **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                         int32_t **rho_i,
+                         int16_t *dlsch_llr,
+                         uint8_t symbol,
+                         uint8_t first_symbol_flag,
+                         uint16_t nb_rb,
+                         uint16_t pbch_pss_sss_adjust,
+                         int16_t **llr16p)
+{
+
+  int16_t *rxF=(int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i=(int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho=(int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+  AssertFatal(llr16!=NULL,"dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol);
+
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  qpsk_qam16((short *)rxF,
+             (short *)rxF_i,
+             (short *)ch_mag_i,
+             (short *)llr16,
+             (short *)rho,
+             len);
+
+  llr16 += (len<<1);
+  *llr16p = (short *)llr16;
+
+  return(0);
+}
+
+/*
+#if defined(__x86_64__) || defined(__i386__)
+__m128i ONE_OVER_SQRT_2 __attribute__((aligned(16)));
+__m128i ONE_OVER_SQRT_10 __attribute__((aligned(16)));
+__m128i THREE_OVER_SQRT_10 __attribute__((aligned(16)));
+__m128i ONE_OVER_SQRT_10_Q15 __attribute__((aligned(16)));
+__m128i SQRT_10_OVER_FOUR __attribute__((aligned(16)));
+__m128i ch_mag_int;
+#endif
+*/
+void qpsk_qam16(int16_t *stream0_in,
+                int16_t *stream1_in,
+                int16_t *ch_mag_i,
+                int16_t *stream0_out,
+                int16_t *rho01,
+                int32_t length
+    )
+{
+  /*
+    This function computes the LLRs of stream 0 (s_0) in presence of the interfering stream 1 (s_1) assuming that both symbols are QPSK. It can be used for both MU-MIMO interference-aware receiver or for SU-MIMO receivers.
+
+    Parameters:
+    stream0_in = Matched filter output y0' = (h0*g0)*y0
+    stream1_in = Matched filter output y1' = (h0*g1)*y0
+    stream0_out = LLRs
+    rho01 = Correlation between the two effective channels \rho_{10} = (h1*g1)*(h0*g0)
+    length = number of resource elements
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rho01_128i = (__m128i *)rho01;
+  __m128i *stream0_128i_in = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in = (__m128i *)stream1_in;
+  __m128i *stream0_128i_out = (__m128i *)stream0_out;
+  __m128i *ch_mag_128i_i    = (__m128i *)ch_mag_i;
+  __m128i ONE_OVER_SQRT_2 = _mm_set1_epi16(23170); // round(1/sqrt(2)*2^15)
+  __m128i ONE_OVER_SQRT_10_Q15 = _mm_set1_epi16(10362); // round(1/sqrt(10)*2^15)
+  __m128i THREE_OVER_SQRT_10 = _mm_set1_epi16(31086); // round(3/sqrt(10)*2^15)
+  __m128i SQRT_10_OVER_FOUR = _mm_set1_epi16(25905); // round(sqrt(10)/4*2^15)
+  __m128i ch_mag_int __attribute__((aligned(16)));
+#elif defined(__arm__)
+  int16x8_t *rho01_128i = (int16x8_t *)rho01;
+  int16x8_t *stream0_128i_in = (int16x8_t *)stream0_in;
+  int16x8_t *stream1_128i_in = (int16x8_t *)stream1_in;
+  int16x8_t *stream0_128i_out = (int16x8_t *)stream0_out;
+  int16x8_t *ch_mag_128i_i    = (int16x8_t *)ch_mag_i;
+  int16x8_t ONE_OVER_SQRT_2 = vdupq_n_s16(23170); // round(1/sqrt(2)*2^15)
+  int16x8_t ONE_OVER_SQRT_10_Q15 = vdupq_n_s16(10362); // round(1/sqrt(10)*2^15)
+  int16x8_t THREE_OVER_SQRT_10 = vdupq_n_s16(31086); // round(3/sqrt(10)*2^15)
+  int16x8_t SQRT_10_OVER_FOUR = vdupq_n_s16(25905); // round(sqrt(10)/4*2^15)
+  int16x8_t ch_mag_int __attribute__((aligned(16)));
+#endif
+
+#ifdef DEBUG_LLR
+  print_shorts2("rho01_128i:\n",rho01_128i);
+#endif
+
+  int i;
+
+
+  for (i=0; i<length>>2; i+=2) {
+    // in each iteration, we take 8 complex samples
+
+#if defined(__x86_64__) || defined(__i386__)
+
+    xmm0 = rho01_128i[i]; // 4 symbols
+    xmm1 = rho01_128i[i+1];
+
+    // put (rho_r + rho_i)/2sqrt2 in rho_rpi
+    // put (rho_r - rho_i)/2sqrt2 in rho_rmi
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // divide by sqrt(2)
+    rho_rpi = _mm_mulhi_epi16(rho_rpi, ONE_OVER_SQRT_2);
+    rho_rmi = _mm_mulhi_epi16(rho_rmi, ONE_OVER_SQRT_2);
+    rho_rpi = _mm_slli_epi16(rho_rpi,1);
+    rho_rmi = _mm_slli_epi16(rho_rmi,1);
+
+    // Compute LLR for first bit of stream 0
+
+    // Compute real and imaginary parts of MF output for stream 0
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // divide by sqrt(2)
+    y0r_over2 = _mm_mulhi_epi16(y0r, ONE_OVER_SQRT_2);
+    y0i_over2 = _mm_mulhi_epi16(y0i, ONE_OVER_SQRT_2);
+    y0r_over2  = _mm_slli_epi16(y0r,1);
+    y0i_over2  = _mm_slli_epi16(y0i,1);
+
+    y0_p_1_1 = _mm_adds_epi16(y0r_over2, y0i_over2);
+    y0_m_1_1 = _mm_subs_epi16(y0r_over2, y0i_over2);
+
+    // Compute real and imaginary parts of MF output for stream 1
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    xmm0 = _mm_setzero_si128(); // ZERO
+
+    // compute psi
+    xmm3 = _mm_subs_epi16(y1r,rho_rpi);
+    psi_r_p1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_subs_epi16(y1i,rho_rmi);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_subs_epi16(y1r,rho_rmi);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1i,rho_rpi);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1r,rho_rmi);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_subs_epi16(y1i,rho_rpi);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1r,rho_rpi);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1i,rho_rmi);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm3);
+
+    // Rearrange interfering channel magnitudes
+    xmm2 = ch_mag_128i_i[i];
+    xmm3 = ch_mag_128i_i[i+1];
+
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+
+    ch_mag_int = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    // calculate optimal interference amplitudes
+    interference_abs_epi16(psi_r_p1_p1 , ch_mag_int, a_r_p1_p1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_p1 , ch_mag_int, a_i_p1_p1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_m1 , ch_mag_int, a_r_p1_m1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_m1 , ch_mag_int, a_i_p1_m1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_p1 , ch_mag_int, a_r_m1_p1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_p1 , ch_mag_int, a_i_m1_p1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_m1 , ch_mag_int, a_r_m1_m1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_m1 , ch_mag_int, a_i_m1_m1 , ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+
+    // prodsum
+    prodsum_psi_a_epi16(psi_r_p1_p1, a_r_p1_p1, psi_i_p1_p1, a_i_p1_p1, psi_a_p1_p1);
+    prodsum_psi_a_epi16(psi_r_p1_m1, a_r_p1_m1, psi_i_p1_m1, a_i_p1_m1, psi_a_p1_m1);
+    prodsum_psi_a_epi16(psi_r_m1_p1, a_r_m1_p1, psi_i_m1_p1, a_i_m1_p1, psi_a_m1_p1);
+    prodsum_psi_a_epi16(psi_r_m1_m1, a_r_m1_m1, psi_i_m1_m1, a_i_m1_m1, psi_a_m1_m1);
+
+    // squares
+    square_a_epi16(a_r_p1_p1, a_i_p1_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_p1);
+    square_a_epi16(a_r_p1_m1, a_i_p1_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_m1);
+    square_a_epi16(a_r_m1_p1, a_i_m1_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_p1);
+    square_a_epi16(a_r_m1_m1, a_i_m1_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_m1);
+
+    // Computing Metrics
+    xmm0 = _mm_subs_epi16(psi_a_p1_p1, a_sq_p1_p1);
+    bit_met_p1_p1 = _mm_adds_epi16(xmm0, y0_p_1_1);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_m1, a_sq_p1_m1);
+    bit_met_p1_m1 = _mm_adds_epi16(xmm0, y0_m_1_1);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p1, a_sq_m1_p1);
+    bit_met_m1_p1 = _mm_subs_epi16(xmm0, y0_m_1_1);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_m1, a_sq_m1_m1);
+    bit_met_m1_m1 = _mm_subs_epi16(xmm0, y0_p_1_1);
+
+    // MSB
+    logmax_num_re0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_m1); // bit=0
+    logmax_den_re0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_m1); // bit=1
+
+    y0r = _mm_subs_epi16(logmax_num_re0,logmax_den_re0);
+
+    // LSB
+    logmax_num_im0 = _mm_max_epi16(bit_met_p1_p1,bit_met_m1_p1); // bit=0
+    logmax_den_im0 = _mm_max_epi16(bit_met_p1_m1,bit_met_m1_m1); // bit=1
+
+    y0i = _mm_subs_epi16(logmax_num_im0,logmax_den_im0);
+
+    stream0_128i_out[i] = _mm_unpacklo_epi16(y0r,y0i); // = [L1(1), L2(1), L1(2), L2(2)]
+
+    if (i<((length>>1) - 1)) // false if only 2 REs remain
+      stream0_128i_out[i+1] = _mm_unpackhi_epi16(y0r,y0i);
+
+#elif defined(__arm__)
+
+#endif
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+int dlsch_qpsk_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                         int32_t **rxdataF_comp,
+                         int32_t **rxdataF_comp_i,
+                         int32_t **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                         int32_t **rho_i,
+                         int16_t *dlsch_llr,
+                         uint8_t symbol,
+                         uint8_t first_symbol_flag,
+                         uint16_t nb_rb,
+                         uint16_t pbch_pss_sss_adjust,
+                         int16_t **llr16p)
+{
+
+  int16_t *rxF=(int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i=(int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho=(int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+  AssertFatal(llr16!=NULL,"dlsch_qpsk_qam64_llr: llr is null, symbol %d\n",symbol);
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  qpsk_qam64((short *)rxF,
+             (short *)rxF_i,
+             (short *)ch_mag_i,
+             (short *)llr16,
+             (short *)rho,
+             len);
+
+  llr16 += (len<<1);
+  *llr16p = (short *)llr16;
+
+  return(0);
+}
+/*
+__m128i ONE_OVER_SQRT_2_42 __attribute__((aligned(16)));
+__m128i THREE_OVER_SQRT_2_42 __attribute__((aligned(16)));
+__m128i FIVE_OVER_SQRT_2_42 __attribute__((aligned(16)));
+__m128i SEVEN_OVER_SQRT_2_42 __attribute__((aligned(16)));
+
+__m128i ch_mag_int_with_sigma2 __attribute__((aligned(16)));
+__m128i two_ch_mag_int_with_sigma2 __attribute__((aligned(16)));
+__m128i three_ch_mag_int_with_sigma2 __attribute__((aligned(16)));
+__m128i SQRT_42_OVER_FOUR __attribute__((aligned(16)));
+*/
+void qpsk_qam64(short *stream0_in,
+                short *stream1_in,
+                short *ch_mag_i,
+                short *stream0_out,
+                short *rho01,
+                int length
+    )
+{
+
+  /*
+    This function computes the LLRs of stream 0 (s_0) in presence of the interfering stream 1 (s_1) assuming that both symbols are QPSK. It can be used for both MU-MIMO interference-aware receiver or for SU-MIMO receivers.
+
+    Parameters:
+    stream0_in = Matched filter output y0' = (h0*g0)*y0
+    stream1_in = Matched filter output y1' = (h0*g1)*y0
+    stream0_out = LLRs
+    rho01 = Correlation between the two effective channels \rho_{10} = (h1*g1)*(h0*g0)
+    length = number of resource elements
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rho01_128i = (__m128i *)rho01;
+  __m128i *stream0_128i_in = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in = (__m128i *)stream1_in;
+  __m128i *stream0_128i_out = (__m128i *)stream0_out;
+  __m128i *ch_mag_128i_i    = (__m128i *)ch_mag_i;
+  __m128i ONE_OVER_SQRT_2 = _mm_set1_epi16(23170); // round(1/sqrt(2)*2^15)
+  __m128i ONE_OVER_SQRT_2_42 = _mm_set1_epi16(3575); // round(1/sqrt(2*42)*2^15)
+  __m128i THREE_OVER_SQRT_2_42 = _mm_set1_epi16(10726); // round(3/sqrt(2*42)*2^15)
+  __m128i FIVE_OVER_SQRT_2_42 = _mm_set1_epi16(17876); // round(5/sqrt(2*42)*2^15)
+  __m128i SEVEN_OVER_SQRT_2_42 = _mm_set1_epi16(25027); // round(7/sqrt(2*42)*2^15)
+  __m128i SQRT_42_OVER_FOUR = _mm_set1_epi16(13272); // round(sqrt(42)/4*2^13), Q3.1
+  __m128i ch_mag_int;
+  __m128i ch_mag_int_with_sigma2;
+  __m128i two_ch_mag_int_with_sigma2;
+  __m128i three_ch_mag_int_with_sigma2;
+#elif defined(__arm__)
+
+#endif
+
+#ifdef DEBUG_LLR
+  print_shorts2("rho01_128i:\n",rho01_128i);
+#endif
+
+  int i;
+
+
+  for (i=0; i<length>>2; i+=2) {
+    // in each iteration, we take 8 complex samples
+
+#if defined(__x86_64__) || defined(__i386__)
+
+    xmm0 = rho01_128i[i]; // 4 symbols
+    xmm1 = rho01_128i[i+1];
+
+    // put (rho_r + rho_i)/sqrt2 in rho_rpi
+    // put (rho_r - rho_i)/sqrt2 in rho_rmi
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // divide by sqrt(2)
+    rho_rpi = _mm_mulhi_epi16(rho_rpi, ONE_OVER_SQRT_2);
+    rho_rmi = _mm_mulhi_epi16(rho_rmi, ONE_OVER_SQRT_2);
+    rho_rpi = _mm_slli_epi16(rho_rpi,1);
+    rho_rmi = _mm_slli_epi16(rho_rmi,1);
+
+    // Compute LLR for first bit of stream 0
+
+    // Compute real and imaginary parts of MF output for stream 0
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // divide by sqrt(2)
+    y0r_over2 = _mm_mulhi_epi16(y0r, ONE_OVER_SQRT_2);
+    y0i_over2 = _mm_mulhi_epi16(y0i, ONE_OVER_SQRT_2);
+    y0r_over2  = _mm_slli_epi16(y0r,1);
+    y0i_over2  = _mm_slli_epi16(y0i,1);
+
+    y0_p_1_1 = _mm_adds_epi16(y0r_over2, y0i_over2);
+    y0_m_1_1 = _mm_subs_epi16(y0r_over2, y0i_over2);
+
+    // Compute real and imaginary parts of MF output for stream 1
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    xmm0 = _mm_setzero_si128(); // ZERO
+
+    // compute psi
+    xmm3 = _mm_subs_epi16(y1r,rho_rpi);
+    psi_r_p1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_subs_epi16(y1i,rho_rmi);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_subs_epi16(y1r,rho_rmi);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1i,rho_rpi);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1r,rho_rmi);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_subs_epi16(y1i,rho_rpi);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1r,rho_rpi);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm3);
+    xmm3 = _mm_adds_epi16(y1i,rho_rmi);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm3);
+
+    // Rearrange interfering channel magnitudes
+    xmm2 = ch_mag_128i_i[i];
+    xmm3 = ch_mag_128i_i[i+1];
+
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+
+    ch_mag_int = _mm_unpacklo_epi64(xmm2,xmm3);
+    ch_mag_int_with_sigma2       = _mm_srai_epi16(ch_mag_int, 1); // *2
+    two_ch_mag_int_with_sigma2   = ch_mag_int; // *4
+    three_ch_mag_int_with_sigma2 = _mm_adds_epi16(ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2); // *6
+
+    interference_abs_64qam_epi16(psi_r_p1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+
+    // prodsum
+    prodsum_psi_a_epi16(psi_r_p1_p1, a_r_p1_p1, psi_i_p1_p1, a_i_p1_p1, psi_a_p1_p1);
+    prodsum_psi_a_epi16(psi_r_p1_m1, a_r_p1_m1, psi_i_p1_m1, a_i_p1_m1, psi_a_p1_m1);
+    prodsum_psi_a_epi16(psi_r_m1_p1, a_r_m1_p1, psi_i_m1_p1, a_i_m1_p1, psi_a_m1_p1);
+    prodsum_psi_a_epi16(psi_r_m1_m1, a_r_m1_m1, psi_i_m1_m1, a_i_m1_m1, psi_a_m1_m1);
+
+    // Multiply by sqrt(2)
+    psi_a_p1_p1 = _mm_mulhi_epi16(psi_a_p1_p1, ONE_OVER_SQRT_2);
+    psi_a_p1_p1 = _mm_slli_epi16(psi_a_p1_p1, 2);
+    psi_a_p1_m1 = _mm_mulhi_epi16(psi_a_p1_m1, ONE_OVER_SQRT_2);
+    psi_a_p1_m1 = _mm_slli_epi16(psi_a_p1_m1, 2);
+    psi_a_m1_p1 = _mm_mulhi_epi16(psi_a_m1_p1, ONE_OVER_SQRT_2);
+    psi_a_m1_p1 = _mm_slli_epi16(psi_a_m1_p1, 2);
+    psi_a_m1_m1 = _mm_mulhi_epi16(psi_a_m1_m1, ONE_OVER_SQRT_2);
+    psi_a_m1_m1 = _mm_slli_epi16(psi_a_m1_m1, 2);
+
+    square_a_64qam_epi16(a_r_p1_p1, a_i_p1_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_p1);
+    square_a_64qam_epi16(a_r_p1_m1, a_i_p1_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_m1);
+    square_a_64qam_epi16(a_r_m1_p1, a_i_m1_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_p1);
+    square_a_64qam_epi16(a_r_m1_m1, a_i_m1_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_m1);
+
+    // Computing Metrics
+    xmm0 = _mm_subs_epi16(psi_a_p1_p1, a_sq_p1_p1);
+    bit_met_p1_p1 = _mm_adds_epi16(xmm0, y0_p_1_1);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_m1, a_sq_p1_m1);
+    bit_met_p1_m1 = _mm_adds_epi16(xmm0, y0_m_1_1);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p1, a_sq_m1_p1);
+    bit_met_m1_p1 = _mm_subs_epi16(xmm0, y0_m_1_1);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_m1, a_sq_m1_m1);
+    bit_met_m1_m1 = _mm_subs_epi16(xmm0, y0_p_1_1);
+
+    // MSB
+    logmax_num_re0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_m1); // bit=0
+    logmax_den_re0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_m1); // bit=1
+
+    y0r = _mm_subs_epi16(logmax_num_re0,logmax_den_re0);
+
+    // LSB
+    logmax_num_im0 = _mm_max_epi16(bit_met_p1_p1,bit_met_m1_p1); // bit=0
+    logmax_den_im0 = _mm_max_epi16(bit_met_p1_m1,bit_met_m1_m1); // bit=1
+
+    y0i = _mm_subs_epi16(logmax_num_im0,logmax_den_im0);
+
+    stream0_128i_out[i] = _mm_unpacklo_epi16(y0r,y0i); // = [L1(1), L2(1), L1(2), L2(2)]
+
+    if (i<((length>>1) - 1)) // false if only 2 REs remain
+      stream0_128i_out[i+1] = _mm_unpackhi_epi16(y0r,y0i);
+
+#elif defined(__arm__)
+
+#endif
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+
+//----------------------------------------------------------------------------------------------
+// 16-QAM
+//----------------------------------------------------------------------------------------------
+
+/*
+__m128i ONE_OVER_TWO_SQRT_10 __attribute__((aligned(16)));
+__m128i NINE_OVER_TWO_SQRT_10 __attribute__((aligned(16)));
+
+__m128i  y0r_over_sqrt10 __attribute__ ((aligned(16)));
+__m128i  y0i_over_sqrt10 __attribute__ ((aligned(16)));
+__m128i  y0r_three_over_sqrt10 __attribute__ ((aligned(16)));
+__m128i  y0i_three_over_sqrt10 __attribute__ ((aligned(16)));
+
+__m128i ch_mag_des __attribute__((aligned(16)));
+__m128i ch_mag_over_10 __attribute__ ((aligned(16)));
+__m128i ch_mag_over_2 __attribute__ ((aligned(16)));
+__m128i ch_mag_9_over_10 __attribute__ ((aligned(16)));
+*/
+
+void qam16_qpsk(short *stream0_in,
+                short *stream1_in,
+                short *ch_mag,
+                short *stream0_out,
+                short *rho01,
+                int length
+    )
+{
+
+  /*
+    Author: Sebastian Wagner
+    Date: 2012-06-04
+
+    Input:
+    stream0_in:  MF filter for 1st stream, i.e., y0=h0'*y
+    stream!_in:  MF filter for 2nd stream, i.e., y1=h1'*y
+    ch_mag:      2*h0/sqrt(00), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    ch_mag_i:    2*h1/sqrt(00), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    rho01:       Channel cross correlation, i.e., h1'*h0
+
+    Output:
+    stream0_out: output LLRs for 1st stream
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rho01_128i       = (__m128i *)rho01;
+  __m128i *stream0_128i_in  = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in  = (__m128i *)stream1_in;
+  __m128i *stream0_128i_out = (__m128i *)stream0_out;
+  __m128i *ch_mag_128i      = (__m128i *)ch_mag;
+  __m128i ONE_OVER_SQRT_2 = _mm_set1_epi16(23170); // round(1/sqrt(2)*2^15)
+  __m128i ONE_OVER_SQRT_10 = _mm_set1_epi16(20724); // round(1/sqrt(10)*2^16)
+  __m128i THREE_OVER_SQRT_10 = _mm_set1_epi16(31086); // round(3/sqrt(10)*2^15)
+  __m128i SQRT_10_OVER_FOUR = _mm_set1_epi16(25905); // round(sqrt(10)/4*2^15)
+  __m128i ONE_OVER_TWO_SQRT_10 = _mm_set1_epi16(10362); // round(1/2/sqrt(10)*2^16)
+  __m128i NINE_OVER_TWO_SQRT_10 = _mm_set1_epi16(23315); // round(9/2/sqrt(10)*2^14)
+  __m128i  y0r_over_sqrt10;
+  __m128i  y0i_over_sqrt10;
+  __m128i  y0r_three_over_sqrt10;
+  __m128i  y0i_three_over_sqrt10;
+
+  __m128i ch_mag_des;
+  __m128i ch_mag_over_10;
+  __m128i ch_mag_over_2;
+  __m128i ch_mag_9_over_10;
+#elif defined(__arm__)
+
+#endif
+
+  int i;
+
+
+  for (i=0; i<length>>2; i+=2) {
+    // In one iteration, we deal with 8 REs
+
+#if defined(__x86_64__) || defined(__i386__)
+    // Get rho
+    xmm0 = rho01_128i[i];
+    xmm1 = rho01_128i[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // Compute the different rhos
+    rho_rpi_1_1 = _mm_mulhi_epi16(rho_rpi,ONE_OVER_SQRT_10);
+    rho_rmi_1_1 = _mm_mulhi_epi16(rho_rmi,ONE_OVER_SQRT_10);
+    rho_rpi_3_3 = _mm_mulhi_epi16(rho_rpi,THREE_OVER_SQRT_10);
+    rho_rmi_3_3 = _mm_mulhi_epi16(rho_rmi,THREE_OVER_SQRT_10);
+    rho_rpi_3_3 = _mm_slli_epi16(rho_rpi_3_3,1);
+    rho_rmi_3_3 = _mm_slli_epi16(rho_rmi_3_3,1);
+
+    xmm4 = _mm_mulhi_epi16(xmm2,ONE_OVER_SQRT_10); // Re(rho)
+    xmm5 = _mm_mulhi_epi16(xmm3,THREE_OVER_SQRT_10); // Im(rho)
+    xmm5 = _mm_slli_epi16(xmm5,1);
+
+    rho_rpi_1_3 = _mm_adds_epi16(xmm4,xmm5);
+    rho_rmi_1_3 = _mm_subs_epi16(xmm4,xmm5);
+
+    xmm6 = _mm_mulhi_epi16(xmm2,THREE_OVER_SQRT_10); // Re(rho)
+    xmm7 = _mm_mulhi_epi16(xmm3,ONE_OVER_SQRT_10); // Im(rho)
+    xmm6 = _mm_slli_epi16(xmm6,1);
+
+    rho_rpi_3_1 = _mm_adds_epi16(xmm6,xmm7);
+    rho_rmi_3_1 = _mm_subs_epi16(xmm6,xmm7);
+
+    // Rearrange interfering MF output
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    xmm0 = _mm_setzero_si128(); // ZERO
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1,y1r); // = [Re(rho)+ Im(rho)]/sqrt(10) - y1r
+    psi_r_p1_p1 = _mm_abs_epi16(xmm2); // = |[Re(rho)+ Im(rho)]/sqrt(10) - y1r|
+
+    xmm2= _mm_subs_epi16(rho_rmi_1_1,y1r);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_1,y1i);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_3,y1r);
+    psi_r_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_3,y1r);
+    psi_r_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_1,y1i);
+    psi_i_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_1,y1r);
+    psi_r_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_1,y1r);
+    psi_r_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_3,y1i);
+    psi_i_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_3,y1r);
+    psi_r_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_3,y1r);
+    psi_r_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_3,y1i);
+    psi_i_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_1,y1i);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_1,y1i);
+    psi_i_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_3,y1i);
+    psi_i_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_3,y1i);
+    psi_i_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_1,y1i);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_1,y1i);
+    psi_i_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_3,y1i);
+    psi_i_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_3,y1i);
+    psi_i_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_1,y1r);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_3,y1r);
+    psi_r_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_1,y1r);
+    psi_r_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_3,y1r);
+    psi_r_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_1_1);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_1_3);
+    psi_r_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_1_1);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_3_1);
+    psi_i_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_3_1);
+    psi_r_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_3_3);
+    psi_r_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_1_3);
+    psi_i_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_3_3);
+    psi_i_m3_m3 = _mm_abs_epi16(xmm2);
+
+    // Rearrange desired MF output
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // Rearrange desired channel magnitudes
+    xmm2 = ch_mag_128i[i]; // = [|h|^2(1),|h|^2(1),|h|^2(2),|h|^2(2)]*(2/sqrt(10))
+    xmm3 = ch_mag_128i[i+1]; // = [|h|^2(3),|h|^2(3),|h|^2(4),|h|^2(4)]*(2/sqrt(10))
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+
+    ch_mag_des = _mm_unpacklo_epi64(xmm2,xmm3); // = [|h|^2(1),|h|^2(2),|h|^2(3),|h|^2(4)]*(2/sqrt(10))
+
+    // Scale MF output of desired signal
+    y0r_over_sqrt10 = _mm_mulhi_epi16(y0r,ONE_OVER_SQRT_10);
+    y0i_over_sqrt10 = _mm_mulhi_epi16(y0i,ONE_OVER_SQRT_10);
+    y0r_three_over_sqrt10 = _mm_mulhi_epi16(y0r,THREE_OVER_SQRT_10);
+    y0i_three_over_sqrt10 = _mm_mulhi_epi16(y0i,THREE_OVER_SQRT_10);
+    y0r_three_over_sqrt10 = _mm_slli_epi16(y0r_three_over_sqrt10,1);
+    y0i_three_over_sqrt10 = _mm_slli_epi16(y0i_three_over_sqrt10,1);
+
+    // Compute necessary combination of required terms
+    y0_p_1_1 = _mm_adds_epi16(y0r_over_sqrt10,y0i_over_sqrt10);
+    y0_m_1_1 = _mm_subs_epi16(y0r_over_sqrt10,y0i_over_sqrt10);
+
+    y0_p_1_3 = _mm_adds_epi16(y0r_over_sqrt10,y0i_three_over_sqrt10);
+    y0_m_1_3 = _mm_subs_epi16(y0r_over_sqrt10,y0i_three_over_sqrt10);
+
+    y0_p_3_1 = _mm_adds_epi16(y0r_three_over_sqrt10,y0i_over_sqrt10);
+    y0_m_3_1 = _mm_subs_epi16(y0r_three_over_sqrt10,y0i_over_sqrt10);
+
+    y0_p_3_3 = _mm_adds_epi16(y0r_three_over_sqrt10,y0i_three_over_sqrt10);
+    y0_m_3_3 = _mm_subs_epi16(y0r_three_over_sqrt10,y0i_three_over_sqrt10);
+
+    // Add psi
+    psi_a_p1_p1 = _mm_adds_epi16(psi_r_p1_p1 ,psi_i_p1_p1);
+    psi_a_p1_p3 = _mm_adds_epi16(psi_r_p1_p3 ,psi_i_p1_p3);
+    psi_a_p3_p1 = _mm_adds_epi16(psi_r_p3_p1 ,psi_i_p3_p1);
+    psi_a_p3_p3 = _mm_adds_epi16(psi_r_p3_p3 ,psi_i_p3_p3);
+    psi_a_p1_m1 = _mm_adds_epi16(psi_r_p1_m1 ,psi_i_p1_m1);
+    psi_a_p1_m3 = _mm_adds_epi16(psi_r_p1_m3 ,psi_i_p1_m3);
+    psi_a_p3_m1 = _mm_adds_epi16(psi_r_p3_m1 ,psi_i_p3_m1);
+    psi_a_p3_m3 = _mm_adds_epi16(psi_r_p3_m3 ,psi_i_p3_m3);
+    psi_a_m1_p1 = _mm_adds_epi16(psi_r_m1_p1 ,psi_i_m1_p1);
+    psi_a_m1_p3 = _mm_adds_epi16(psi_r_m1_p3 ,psi_i_m1_p3);
+    psi_a_m3_p1 = _mm_adds_epi16(psi_r_m3_p1 ,psi_i_m3_p1);
+    psi_a_m3_p3 = _mm_adds_epi16(psi_r_m3_p3 ,psi_i_m3_p3);
+    psi_a_m1_m1 = _mm_adds_epi16(psi_r_m1_m1 ,psi_i_m1_m1);
+    psi_a_m1_m3 = _mm_adds_epi16(psi_r_m1_m3 ,psi_i_m1_m3);
+    psi_a_m3_m1 = _mm_adds_epi16(psi_r_m3_m1 ,psi_i_m3_m1);
+    psi_a_m3_m3 = _mm_adds_epi16(psi_r_m3_m3 ,psi_i_m3_m3);
+
+    // scale by sqrt(2)
+    psi_a_p1_p1 = _mm_mulhi_epi16(psi_a_p1_p1,ONE_OVER_SQRT_2);
+    psi_a_p1_p1 = _mm_slli_epi16(psi_a_p1_p1,1);
+    psi_a_p1_p3 = _mm_mulhi_epi16(psi_a_p1_p3,ONE_OVER_SQRT_2);
+    psi_a_p1_p3 = _mm_slli_epi16(psi_a_p1_p3,1);
+    psi_a_p3_p1 = _mm_mulhi_epi16(psi_a_p3_p1,ONE_OVER_SQRT_2);
+    psi_a_p3_p1 = _mm_slli_epi16(psi_a_p3_p1,1);
+    psi_a_p3_p3 = _mm_mulhi_epi16(psi_a_p3_p3,ONE_OVER_SQRT_2);
+    psi_a_p3_p3 = _mm_slli_epi16(psi_a_p3_p3,1);
+
+    psi_a_p1_m1 = _mm_mulhi_epi16(psi_a_p1_m1,ONE_OVER_SQRT_2);
+    psi_a_p1_m1 = _mm_slli_epi16(psi_a_p1_m1,1);
+    psi_a_p1_m3 = _mm_mulhi_epi16(psi_a_p1_m3,ONE_OVER_SQRT_2);
+    psi_a_p1_m3 = _mm_slli_epi16(psi_a_p1_m3,1);
+    psi_a_p3_m1 = _mm_mulhi_epi16(psi_a_p3_m1,ONE_OVER_SQRT_2);
+    psi_a_p3_m1 = _mm_slli_epi16(psi_a_p3_m1,1);
+    psi_a_p3_m3 = _mm_mulhi_epi16(psi_a_p3_m3,ONE_OVER_SQRT_2);
+    psi_a_p3_m3 = _mm_slli_epi16(psi_a_p3_m3,1);
+
+    psi_a_m1_p1 = _mm_mulhi_epi16(psi_a_m1_p1,ONE_OVER_SQRT_2);
+    psi_a_m1_p1 = _mm_slli_epi16(psi_a_m1_p1,1);
+    psi_a_m1_p3 = _mm_mulhi_epi16(psi_a_m1_p3,ONE_OVER_SQRT_2);
+    psi_a_m1_p3 = _mm_slli_epi16(psi_a_m1_p3,1);
+    psi_a_m3_p1 = _mm_mulhi_epi16(psi_a_m3_p1,ONE_OVER_SQRT_2);
+    psi_a_m3_p1 = _mm_slli_epi16(psi_a_m3_p1,1);
+    psi_a_m3_p3 = _mm_mulhi_epi16(psi_a_m3_p3,ONE_OVER_SQRT_2);
+    psi_a_m3_p3 = _mm_slli_epi16(psi_a_m3_p3,1);
+
+    psi_a_m1_m1 = _mm_mulhi_epi16(psi_a_m1_m1,ONE_OVER_SQRT_2);
+    psi_a_m1_m1 = _mm_slli_epi16(psi_a_m1_m1,1);
+    psi_a_m1_m3 = _mm_mulhi_epi16(psi_a_m1_m3,ONE_OVER_SQRT_2);
+    psi_a_m1_m3 = _mm_slli_epi16(psi_a_m1_m3,1);
+    psi_a_m3_m1 = _mm_mulhi_epi16(psi_a_m3_m1,ONE_OVER_SQRT_2);
+    psi_a_m3_m1 = _mm_slli_epi16(psi_a_m3_m1,1);
+    psi_a_m3_m3 = _mm_mulhi_epi16(psi_a_m3_m3,ONE_OVER_SQRT_2);
+    psi_a_m3_m3 = _mm_slli_epi16(psi_a_m3_m3,1);
+
+    // Computing different multiples of channel norms
+    ch_mag_over_10=_mm_mulhi_epi16(ch_mag_des, ONE_OVER_TWO_SQRT_10);
+    ch_mag_over_2=_mm_mulhi_epi16(ch_mag_des, SQRT_10_OVER_FOUR);
+    ch_mag_over_2=_mm_slli_epi16(ch_mag_over_2, 1);
+    ch_mag_9_over_10=_mm_mulhi_epi16(ch_mag_des, NINE_OVER_TWO_SQRT_10);
+    ch_mag_9_over_10=_mm_slli_epi16(ch_mag_9_over_10, 2);
+
+    // Computing Metrics
+    xmm1 = _mm_adds_epi16(psi_a_p1_p1, y0_p_1_1);
+    bit_met_p1_p1= _mm_subs_epi16(xmm1, ch_mag_over_10);
+
+    xmm1 = _mm_adds_epi16(psi_a_p1_p3, y0_p_1_3);
+    bit_met_p1_p3= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_adds_epi16(psi_a_p1_m1, y0_m_1_1);
+    bit_met_p1_m1= _mm_subs_epi16(xmm1, ch_mag_over_10);
+
+    xmm1 = _mm_adds_epi16(psi_a_p1_m3, y0_m_1_3);
+    bit_met_p1_m3= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_adds_epi16(psi_a_p3_p1, y0_p_3_1);
+    bit_met_p3_p1= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_adds_epi16(psi_a_p3_p3, y0_p_3_3);
+    bit_met_p3_p3= _mm_subs_epi16(xmm1, ch_mag_9_over_10);
+
+    xmm1 = _mm_adds_epi16(psi_a_p3_m1, y0_m_3_1);
+    bit_met_p3_m1= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_adds_epi16(psi_a_p3_m3, y0_m_3_3);
+    bit_met_p3_m3= _mm_subs_epi16(xmm1, ch_mag_9_over_10);
+
+    xmm1 = _mm_subs_epi16(psi_a_m1_p1, y0_m_1_1);
+    bit_met_m1_p1= _mm_subs_epi16(xmm1, ch_mag_over_10);
+
+    xmm1 = _mm_subs_epi16(psi_a_m1_p3, y0_m_1_3);
+    bit_met_m1_p3= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_subs_epi16(psi_a_m1_m1, y0_p_1_1);
+    bit_met_m1_m1= _mm_subs_epi16(xmm1, ch_mag_over_10);
+
+    xmm1 = _mm_subs_epi16(psi_a_m1_m3, y0_p_1_3);
+    bit_met_m1_m3= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_subs_epi16(psi_a_m3_p1, y0_m_3_1);
+    bit_met_m3_p1= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_subs_epi16(psi_a_m3_p3, y0_m_3_3);
+    bit_met_m3_p3= _mm_subs_epi16(xmm1, ch_mag_9_over_10);
+
+    xmm1 = _mm_subs_epi16(psi_a_m3_m1, y0_p_3_1);
+    bit_met_m3_m1= _mm_subs_epi16(xmm1, ch_mag_over_2);
+
+    xmm1 = _mm_subs_epi16(psi_a_m3_m3, y0_p_3_3);
+    bit_met_m3_m3= _mm_subs_epi16(xmm1, ch_mag_9_over_10);
+
+    // LLR of the first bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_p3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1,bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_m1,bit_met_m3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_re0= _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_p3);
+    xmm1 = _mm_max_epi16(bit_met_p1_m1,bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m1,bit_met_p3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of first bit [L1(1), L1(2), L1(3), L1(4), L1(5), L1(6), L1(7), L1(8)]
+    y0r = _mm_subs_epi16(logmax_den_re0,logmax_num_re0);
+
+    // LLR of the second bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p1_m1,bit_met_p3_m1);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_m3,bit_met_p3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m1_m3,bit_met_m3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_re1 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p3_p1);
+    xmm1 = _mm_max_epi16(bit_met_m1_p1,bit_met_m3_p1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p3,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p3,bit_met_m3_p3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_re1 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of second bit [L2(1), L2(2), L2(3), L2(4)]
+    y1r = _mm_subs_epi16(logmax_den_re1,logmax_num_re1);
+
+    // LLR of the third bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m3_p1,bit_met_m3_p3);
+    xmm1 = _mm_max_epi16(bit_met_m3_m1,bit_met_m3_m3);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m1,bit_met_p3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_im0 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_p3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m1_m3);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_m1,bit_met_p1_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_im0 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of third bit [L3(1), L3(2), L3(3), L3(4)]
+    y0i = _mm_subs_epi16(logmax_den_im0,logmax_num_im0);
+
+    // LLR of the fourth bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p1_m3,bit_met_p3_m3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3,bit_met_m3_m3);
+    xmm2 = _mm_max_epi16(bit_met_p1_p3,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p3,bit_met_m3_p3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_im1 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_m1,bit_met_p3_m1);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1,bit_met_p3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m1_p1,bit_met_m3_p1);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_im1 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of fourth bit [L4(1), L4(2), L4(3), L4(4)]
+    y1i = _mm_subs_epi16(logmax_den_im1,logmax_num_im1);
+
+    // Pack LLRs in output
+    // [L1(1), L2(1), L1(2), L2(2), L1(3), L2(3), L1(4), L2(4)]
+    xmm0 = _mm_unpacklo_epi16(y0r,y1r);
+    // [L1(5), L2(5), L1(6), L2(6), L1(7), L2(7), L1(8), L2(8)]
+    xmm1 = _mm_unpackhi_epi16(y0r,y1r);
+    // [L3(1), L4(1), L3(2), L4(2), L3(3), L4(3), L3(4), L4(4)]
+    xmm2 = _mm_unpacklo_epi16(y0i,y1i);
+    // [L3(5), L4(5), L3(6), L4(6), L3(7), L4(7), L3(8), L4(8)]
+    xmm3 = _mm_unpackhi_epi16(y0i,y1i);
+
+    stream0_128i_out[2*i+0] = _mm_unpacklo_epi32(xmm0,xmm2); // 8LLRs, 2REs
+    stream0_128i_out[2*i+1] = _mm_unpackhi_epi32(xmm0,xmm2);
+    stream0_128i_out[2*i+2] = _mm_unpacklo_epi32(xmm1,xmm3);
+    stream0_128i_out[2*i+3] = _mm_unpackhi_epi32(xmm1,xmm3);
+
+#elif defined(__arm__)
+
+#endif
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+
+}
+
+int dlsch_16qam_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                         int32_t **rxdataF_comp,
+                         int32_t **rxdataF_comp_i,
+                         int32_t **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
+                         int32_t **rho_i,
+                         int16_t *dlsch_llr,
+                         uint8_t symbol,
+                         uint8_t first_symbol_flag,
+                         uint16_t nb_rb,
+                         uint16_t pbch_pss_sss_adjust,
+                         int16_t **llr16p)
+{
+
+  int16_t *rxF      = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i    = (int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag   = (int16_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho      = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  // first symbol has different structure due to more pilots
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+  AssertFatal(llr16!=NULL,"dlsch_16qam_qpsk_llr: llr is null, symbol %d\n",symbol);
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  // printf("symbol %d: qam16_llr, len %d (llr16 %p)\n",symbol,len,llr16);
+
+  qam16_qpsk((short *)rxF,
+             (short *)rxF_i,
+             (short *)ch_mag,
+             (short *)llr16,
+             (short *)rho,
+             len);
+
+  llr16 += (len<<2);
+  *llr16p = (short *)llr16;
+
+  return(0);
+}
+
+void qam16_qam16(short *stream0_in,
+                 short *stream1_in,
+                 short *ch_mag,
+                 short *ch_mag_i,
+                 short *stream0_out,
+                 short *rho01,
+                 int length
+     )
+{
+
+  /*
+    Author: Sebastian Wagner
+    Date: 2012-06-04
+
+    Input:
+    stream0_in:  MF filter for 1st stream, i.e., y0=h0'*y
+    stream!_in:  MF filter for 2nd stream, i.e., y1=h1'*y
+    ch_mag:      2*h0/sqrt(00), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    ch_mag_i:    2*h1/sqrt(00), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    rho01:       Channel cross correlation, i.e., h1'*h0
+
+    Output:
+    stream0_out: output LLRs for 1st stream
+  */
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rho01_128i       = (__m128i *)rho01;
+  __m128i *stream0_128i_in  = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in  = (__m128i *)stream1_in;
+  __m128i *stream0_128i_out = (__m128i *)stream0_out;
+  __m128i *ch_mag_128i      = (__m128i *)ch_mag;
+  __m128i *ch_mag_128i_i    = (__m128i *)ch_mag_i;
+
+
+
+  __m128i ONE_OVER_SQRT_10 = _mm_set1_epi16(20724); // round(1/sqrt(10)*2^16)
+  __m128i ONE_OVER_SQRT_10_Q15 = _mm_set1_epi16(10362); // round(1/sqrt(10)*2^15)
+  __m128i THREE_OVER_SQRT_10 = _mm_set1_epi16(31086); // round(3/sqrt(10)*2^15)
+  __m128i SQRT_10_OVER_FOUR = _mm_set1_epi16(25905); // round(sqrt(10)/4*2^15)
+  __m128i ONE_OVER_TWO_SQRT_10 = _mm_set1_epi16(10362); // round(1/2/sqrt(10)*2^16)
+  __m128i NINE_OVER_TWO_SQRT_10 = _mm_set1_epi16(23315); // round(9/2/sqrt(10)*2^14)
+  __m128i ch_mag_des,ch_mag_int;
+  __m128i  y0r_over_sqrt10;
+  __m128i  y0i_over_sqrt10;
+  __m128i  y0r_three_over_sqrt10;
+  __m128i  y0i_three_over_sqrt10;
+  __m128i ch_mag_over_10;
+  __m128i ch_mag_over_2;
+  __m128i ch_mag_9_over_10;
+#elif defined(__arm__)
+
+#endif
+
+  int i;
+
+  for (i=0; i<length>>2; i+=2) {
+    // In one iteration, we deal with 8 REs
+
+#if defined(__x86_64__) || defined(__i386__)
+    // Get rho
+    xmm0 = rho01_128i[i];
+    xmm1 = rho01_128i[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // Compute the different rhos
+    rho_rpi_1_1 = _mm_mulhi_epi16(rho_rpi,ONE_OVER_SQRT_10);
+    rho_rmi_1_1 = _mm_mulhi_epi16(rho_rmi,ONE_OVER_SQRT_10);
+    rho_rpi_3_3 = _mm_mulhi_epi16(rho_rpi,THREE_OVER_SQRT_10);
+    rho_rmi_3_3 = _mm_mulhi_epi16(rho_rmi,THREE_OVER_SQRT_10);
+    rho_rpi_3_3 = _mm_slli_epi16(rho_rpi_3_3,1);
+    rho_rmi_3_3 = _mm_slli_epi16(rho_rmi_3_3,1);
+
+    xmm4 = _mm_mulhi_epi16(xmm2,ONE_OVER_SQRT_10); // Re(rho)
+    xmm5 = _mm_mulhi_epi16(xmm3,THREE_OVER_SQRT_10); // Im(rho)
+    xmm5 = _mm_slli_epi16(xmm5,1);
+
+    rho_rpi_1_3 = _mm_adds_epi16(xmm4,xmm5);
+    rho_rmi_1_3 = _mm_subs_epi16(xmm4,xmm5);
+
+    xmm6 = _mm_mulhi_epi16(xmm2,THREE_OVER_SQRT_10); // Re(rho)
+    xmm7 = _mm_mulhi_epi16(xmm3,ONE_OVER_SQRT_10); // Im(rho)
+    xmm6 = _mm_slli_epi16(xmm6,1);
+
+    rho_rpi_3_1 = _mm_adds_epi16(xmm6,xmm7);
+    rho_rmi_3_1 = _mm_subs_epi16(xmm6,xmm7);
+
+    // Rearrange interfering MF output
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    xmm0 = _mm_setzero_si128(); // ZERO
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1,y1r); // = [Re(rho)+ Im(rho)]/sqrt(10) - y1r
+    psi_r_p1_p1 = _mm_abs_epi16(xmm2); // = |[Re(rho)+ Im(rho)]/sqrt(10) - y1r|
+
+    xmm2= _mm_subs_epi16(rho_rmi_1_1,y1r);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_1,y1i);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_3,y1r);
+    psi_r_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_3,y1r);
+    psi_r_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_1,y1i);
+    psi_i_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_1,y1r);
+    psi_r_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_1,y1r);
+    psi_r_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_3,y1i);
+    psi_i_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_3,y1r);
+    psi_r_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_3,y1r);
+    psi_r_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_3,y1i);
+    psi_i_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_1,y1i);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_1,y1i);
+    psi_i_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_3,y1i);
+    psi_i_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_3,y1i);
+    psi_i_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_1,y1i);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_1,y1i);
+    psi_i_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_3,y1i);
+    psi_i_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_3,y1i);
+    psi_i_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_1,y1r);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_3,y1r);
+    psi_r_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_1,y1r);
+    psi_r_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_3,y1r);
+    psi_r_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_1_1);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_1_3);
+    psi_r_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_1_1);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_3_1);
+    psi_i_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_3_1);
+    psi_r_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_3_3);
+    psi_r_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_1_3);
+    psi_i_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_3_3);
+    psi_i_m3_m3 = _mm_abs_epi16(xmm2);
+
+    // Rearrange desired MF output
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // Rearrange desired channel magnitudes
+    xmm2 = ch_mag_128i[i]; // = [|h|^2(1),|h|^2(1),|h|^2(2),|h|^2(2)]*(2/sqrt(10))
+    xmm3 = ch_mag_128i[i+1]; // = [|h|^2(3),|h|^2(3),|h|^2(4),|h|^2(4)]*(2/sqrt(10))
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+
+    ch_mag_des = _mm_unpacklo_epi64(xmm2,xmm3); // = [|h|^2(1),|h|^2(2),|h|^2(3),|h|^2(4)]*(2/sqrt(10))
+
+    // Rearrange interfering channel magnitudes
+    xmm2 = ch_mag_128i_i[i];
+    xmm3 = ch_mag_128i_i[i+1];
+
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+
+    ch_mag_int  = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    // Scale MF output of desired signal
+    y0r_over_sqrt10 = _mm_mulhi_epi16(y0r,ONE_OVER_SQRT_10);
+    y0i_over_sqrt10 = _mm_mulhi_epi16(y0i,ONE_OVER_SQRT_10);
+    y0r_three_over_sqrt10 = _mm_mulhi_epi16(y0r,THREE_OVER_SQRT_10);
+    y0i_three_over_sqrt10 = _mm_mulhi_epi16(y0i,THREE_OVER_SQRT_10);
+    y0r_three_over_sqrt10 = _mm_slli_epi16(y0r_three_over_sqrt10,1);
+    y0i_three_over_sqrt10 = _mm_slli_epi16(y0i_three_over_sqrt10,1);
+
+    // Compute necessary combination of required terms
+    y0_p_1_1 = _mm_adds_epi16(y0r_over_sqrt10,y0i_over_sqrt10);
+    y0_m_1_1 = _mm_subs_epi16(y0r_over_sqrt10,y0i_over_sqrt10);
+
+    y0_p_1_3 = _mm_adds_epi16(y0r_over_sqrt10,y0i_three_over_sqrt10);
+    y0_m_1_3 = _mm_subs_epi16(y0r_over_sqrt10,y0i_three_over_sqrt10);
+
+    y0_p_3_1 = _mm_adds_epi16(y0r_three_over_sqrt10,y0i_over_sqrt10);
+    y0_m_3_1 = _mm_subs_epi16(y0r_three_over_sqrt10,y0i_over_sqrt10);
+
+    y0_p_3_3 = _mm_adds_epi16(y0r_three_over_sqrt10,y0i_three_over_sqrt10);
+    y0_m_3_3 = _mm_subs_epi16(y0r_three_over_sqrt10,y0i_three_over_sqrt10);
+
+    // Compute optimal interfering symbol magnitude
+    interference_abs_epi16(psi_r_p1_p1 ,ch_mag_int,a_r_p1_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_p1 ,ch_mag_int,a_i_p1_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_p3 ,ch_mag_int,a_r_p1_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_p3 ,ch_mag_int,a_i_p1_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_m1 ,ch_mag_int,a_r_p1_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_m1 ,ch_mag_int,a_i_p1_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_m3 ,ch_mag_int,a_r_p1_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_m3 ,ch_mag_int,a_i_p1_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_p1 ,ch_mag_int,a_r_p3_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_p1 ,ch_mag_int,a_i_p3_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_p3 ,ch_mag_int,a_r_p3_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_p3 ,ch_mag_int,a_i_p3_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_m1 ,ch_mag_int,a_r_p3_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_m1 ,ch_mag_int,a_i_p3_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_m3 ,ch_mag_int,a_r_p3_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_m3 ,ch_mag_int,a_i_p3_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_p1 ,ch_mag_int,a_r_m1_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_p1 ,ch_mag_int,a_i_m1_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_p3 ,ch_mag_int,a_r_m1_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_p3 ,ch_mag_int,a_i_m1_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_m1 ,ch_mag_int,a_r_m1_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_m1 ,ch_mag_int,a_i_m1_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_m3 ,ch_mag_int,a_r_m1_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_m3 ,ch_mag_int,a_i_m1_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_p1 ,ch_mag_int,a_r_m3_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_p1 ,ch_mag_int,a_i_m3_p1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_p3 ,ch_mag_int,a_r_m3_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_p3 ,ch_mag_int,a_i_m3_p3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_m1 ,ch_mag_int,a_r_m3_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_m1 ,ch_mag_int,a_i_m3_m1,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_m3 ,ch_mag_int,a_r_m3_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_m3 ,ch_mag_int,a_i_m3_m3,ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+
+    // Calculation of groups of two terms in the bit metric involving product of psi and interference magnitude
+    prodsum_psi_a_epi16(psi_r_p1_p1,a_r_p1_p1,psi_i_p1_p1,a_i_p1_p1,psi_a_p1_p1);
+    prodsum_psi_a_epi16(psi_r_p1_p3,a_r_p1_p3,psi_i_p1_p3,a_i_p1_p3,psi_a_p1_p3);
+    prodsum_psi_a_epi16(psi_r_p3_p1,a_r_p3_p1,psi_i_p3_p1,a_i_p3_p1,psi_a_p3_p1);
+    prodsum_psi_a_epi16(psi_r_p3_p3,a_r_p3_p3,psi_i_p3_p3,a_i_p3_p3,psi_a_p3_p3);
+    prodsum_psi_a_epi16(psi_r_p1_m1,a_r_p1_m1,psi_i_p1_m1,a_i_p1_m1,psi_a_p1_m1);
+    prodsum_psi_a_epi16(psi_r_p1_m3,a_r_p1_m3,psi_i_p1_m3,a_i_p1_m3,psi_a_p1_m3);
+    prodsum_psi_a_epi16(psi_r_p3_m1,a_r_p3_m1,psi_i_p3_m1,a_i_p3_m1,psi_a_p3_m1);
+    prodsum_psi_a_epi16(psi_r_p3_m3,a_r_p3_m3,psi_i_p3_m3,a_i_p3_m3,psi_a_p3_m3);
+    prodsum_psi_a_epi16(psi_r_m1_p1,a_r_m1_p1,psi_i_m1_p1,a_i_m1_p1,psi_a_m1_p1);
+    prodsum_psi_a_epi16(psi_r_m1_p3,a_r_m1_p3,psi_i_m1_p3,a_i_m1_p3,psi_a_m1_p3);
+    prodsum_psi_a_epi16(psi_r_m3_p1,a_r_m3_p1,psi_i_m3_p1,a_i_m3_p1,psi_a_m3_p1);
+    prodsum_psi_a_epi16(psi_r_m3_p3,a_r_m3_p3,psi_i_m3_p3,a_i_m3_p3,psi_a_m3_p3);
+    prodsum_psi_a_epi16(psi_r_m1_m1,a_r_m1_m1,psi_i_m1_m1,a_i_m1_m1,psi_a_m1_m1);
+    prodsum_psi_a_epi16(psi_r_m1_m3,a_r_m1_m3,psi_i_m1_m3,a_i_m1_m3,psi_a_m1_m3);
+    prodsum_psi_a_epi16(psi_r_m3_m1,a_r_m3_m1,psi_i_m3_m1,a_i_m3_m1,psi_a_m3_m1);
+    prodsum_psi_a_epi16(psi_r_m3_m3,a_r_m3_m3,psi_i_m3_m3,a_i_m3_m3,psi_a_m3_m3);
+
+
+    // squared interference magnitude times int. ch. power
+    square_a_epi16(a_r_p1_p1,a_i_p1_p1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p1_p1);
+    square_a_epi16(a_r_p1_p3,a_i_p1_p3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p1_p3);
+    square_a_epi16(a_r_p3_p1,a_i_p3_p1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p3_p1);
+    square_a_epi16(a_r_p3_p3,a_i_p3_p3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p3_p3);
+    square_a_epi16(a_r_p1_m1,a_i_p1_m1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p1_m1);
+    square_a_epi16(a_r_p1_m3,a_i_p1_m3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p1_m3);
+    square_a_epi16(a_r_p3_m1,a_i_p3_m1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p3_m1);
+    square_a_epi16(a_r_p3_m3,a_i_p3_m3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_p3_m3);
+    square_a_epi16(a_r_m1_p1,a_i_m1_p1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m1_p1);
+    square_a_epi16(a_r_m1_p3,a_i_m1_p3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m1_p3);
+    square_a_epi16(a_r_m3_p1,a_i_m3_p1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m3_p1);
+    square_a_epi16(a_r_m3_p3,a_i_m3_p3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m3_p3);
+    square_a_epi16(a_r_m1_m1,a_i_m1_m1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m1_m1);
+    square_a_epi16(a_r_m1_m3,a_i_m1_m3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m1_m3);
+    square_a_epi16(a_r_m3_m1,a_i_m3_m1,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m3_m1);
+    square_a_epi16(a_r_m3_m3,a_i_m3_m3,ch_mag_int,SQRT_10_OVER_FOUR,a_sq_m3_m3);
+
+    // Computing different multiples of channel norms
+    ch_mag_over_10=_mm_mulhi_epi16(ch_mag_des, ONE_OVER_TWO_SQRT_10);
+    ch_mag_over_2=_mm_mulhi_epi16(ch_mag_des, SQRT_10_OVER_FOUR);
+    ch_mag_over_2=_mm_slli_epi16(ch_mag_over_2, 1);
+    ch_mag_9_over_10=_mm_mulhi_epi16(ch_mag_des, NINE_OVER_TWO_SQRT_10);
+    ch_mag_9_over_10=_mm_slli_epi16(ch_mag_9_over_10, 2);
+
+    // Computing Metrics
+    xmm0 = _mm_subs_epi16(psi_a_p1_p1,a_sq_p1_p1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_1_1);
+    bit_met_p1_p1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_p3,a_sq_p1_p3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_1_3);
+    bit_met_p1_p3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_m1,a_sq_p1_m1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_1_1);
+    bit_met_p1_m1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_m3,a_sq_p1_m3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_1_3);
+    bit_met_p1_m3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_p1,a_sq_p3_p1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_3_1);
+    bit_met_p3_p1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_p3,a_sq_p3_p3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_3_3);
+    bit_met_p3_p3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_m1,a_sq_p3_m1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_3_1);
+    bit_met_p3_m1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_m3,a_sq_p3_m3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_3_3);
+    bit_met_p3_m3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p1,a_sq_m1_p1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_1_1);
+    bit_met_m1_p1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p3,a_sq_m1_p3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_1_3);
+    bit_met_m1_p3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_m1,a_sq_m1_m1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_1_1);
+    bit_met_m1_m1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_m3,a_sq_m1_m3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_1_3);
+    bit_met_m1_m3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_p1,a_sq_m3_p1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_3_1);
+    bit_met_m3_p1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_p3,a_sq_m3_p3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_3_3);
+    bit_met_m3_p3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_m1,a_sq_m3_m1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_3_1);
+    bit_met_m3_m1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_m3,a_sq_m3_m3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_3_3);
+    bit_met_m3_m3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    // LLR of the first bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_p3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1,bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_m1,bit_met_m3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_re0= _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_p3);
+    xmm1 = _mm_max_epi16(bit_met_p1_m1,bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m1,bit_met_p3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of first bit [L1(1), L1(2), L1(3), L1(4), L1(5), L1(6), L1(7), L1(8)]
+    y0r = _mm_subs_epi16(logmax_den_re0,logmax_num_re0);
+
+    // LLR of the second bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p1_m1,bit_met_p3_m1);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_m3,bit_met_p3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m1_m3,bit_met_m3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_re1 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p3_p1);
+    xmm1 = _mm_max_epi16(bit_met_m1_p1,bit_met_m3_p1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p3,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p3,bit_met_m3_p3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_re1 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of second bit [L2(1), L2(2), L2(3), L2(4)]
+    y1r = _mm_subs_epi16(logmax_den_re1,logmax_num_re1);
+
+    // LLR of the third bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m3_p1,bit_met_m3_p3);
+    xmm1 = _mm_max_epi16(bit_met_m3_m1,bit_met_m3_m3);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m1,bit_met_p3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_im0 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_p3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m1_m3);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_m1,bit_met_p1_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_im0 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of third bit [L3(1), L3(2), L3(3), L3(4)]
+    y0i = _mm_subs_epi16(logmax_den_im0,logmax_num_im0);
+
+    // LLR of the fourth bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p1_m3,bit_met_p3_m3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3,bit_met_m3_m3);
+    xmm2 = _mm_max_epi16(bit_met_p1_p3,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p3,bit_met_m3_p3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_im1 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_m1,bit_met_p3_m1);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1,bit_met_p3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m1_p1,bit_met_m3_p1);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_im1 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of fourth bit [L4(1), L4(2), L4(3), L4(4)]
+    y1i = _mm_subs_epi16(logmax_den_im1,logmax_num_im1);
+
+    // Pack LLRs in output
+    // [L1(1), L2(1), L1(2), L2(2), L1(3), L2(3), L1(4), L2(4)]
+    xmm0 = _mm_unpacklo_epi16(y0r,y1r);
+    // [L1(5), L2(5), L1(6), L2(6), L1(7), L2(7), L1(8), L2(8)]
+    xmm1 = _mm_unpackhi_epi16(y0r,y1r);
+    // [L3(1), L4(1), L3(2), L4(2), L3(3), L4(3), L3(4), L4(4)]
+    xmm2 = _mm_unpacklo_epi16(y0i,y1i);
+    // [L3(5), L4(5), L3(6), L4(6), L3(7), L4(7), L3(8), L4(8)]
+    xmm3 = _mm_unpackhi_epi16(y0i,y1i);
+
+    stream0_128i_out[2*i+0] = _mm_unpacklo_epi32(xmm0,xmm2); // 8LLRs, 2REs
+    stream0_128i_out[2*i+1] = _mm_unpackhi_epi32(xmm0,xmm2);
+    stream0_128i_out[2*i+2] = _mm_unpacklo_epi32(xmm1,xmm3);
+    stream0_128i_out[2*i+3] = _mm_unpackhi_epi32(xmm1,xmm3);
+#elif defined(__arm__)
+
+#endif
+
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+int dlsch_16qam_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                          int32_t **rxdataF_comp,
+                          int32_t **rxdataF_comp_i,
+                          int32_t **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
+                          int32_t **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                          int32_t **rho_i,
+                          int16_t *dlsch_llr,
+                          uint8_t symbol,
+                          uint8_t first_symbol_flag,
+                          uint16_t nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          int16_t **llr16p)
+{
+
+  int16_t *rxF      = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i    = (int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag   = (int16_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho      = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  // first symbol has different structure due to more pilots
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+
+  AssertFatal(llr16!=NULL,"dlsch_16qam_16qam_llr: llr is null, symbol %d\n",symbol);
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  // printf("symbol %d: qam16_llr, len %d (llr16 %p)\n",symbol,len,llr16);
+
+  qam16_qam16((short *)rxF,
+              (short *)rxF_i,
+              (short *)ch_mag,
+              (short *)ch_mag_i,
+              (short *)llr16,
+              (short *)rho,
+              len);
+
+  llr16 += (len<<2);
+  *llr16p = (short *)llr16;
+
+  return(0);
+}
+
+void qam16_qam64(int16_t *stream0_in,
+                 int16_t *stream1_in,
+                 int16_t *ch_mag,
+                 int16_t *ch_mag_i,
+                 int16_t *stream0_out,
+                 int16_t *rho01,
+                 int32_t length
+     )
+{
+
+  /*
+    Author: Sebastian Wagner
+    Date: 2012-06-04
+
+    Input:
+    stream0_in:  MF filter for 1st stream, i.e., y0=h0'*y
+    stream!_in:  MF filter for 2nd stream, i.e., y1=h1'*y
+    ch_mag:      2*h0/sqrt(00), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    ch_mag_i:    2*h1/sqrt(00), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    rho01:       Channel cross correlation, i.e., h1'*h0
+
+    Output:
+    stream0_out: output LLRs for 1st stream
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rho01_128i       = (__m128i *)rho01;
+  __m128i *stream0_128i_in  = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in  = (__m128i *)stream1_in;
+  __m128i *stream0_128i_out = (__m128i *)stream0_out;
+  __m128i *ch_mag_128i      = (__m128i *)ch_mag;
+  __m128i *ch_mag_128i_i    = (__m128i *)ch_mag_i;
+
+
+  __m128i ONE_OVER_SQRT_2 = _mm_set1_epi16(23170); // round(1/sqrt(2)*2^15)
+  __m128i ONE_OVER_SQRT_10 = _mm_set1_epi16(20724); // round(1/sqrt(10)*2^16)
+  __m128i THREE_OVER_SQRT_10 = _mm_set1_epi16(31086); // round(3/sqrt(10)*2^15)
+  __m128i SQRT_10_OVER_FOUR = _mm_set1_epi16(25905); // round(sqrt(10)/4*2^15)
+  __m128i ONE_OVER_TWO_SQRT_10 = _mm_set1_epi16(10362); // round(1/2/sqrt(10)*2^16)
+  __m128i NINE_OVER_TWO_SQRT_10 = _mm_set1_epi16(23315); // round(9/2/sqrt(10)*2^14)
+  __m128i ONE_OVER_SQRT_2_42 = _mm_set1_epi16(3575); // round(1/sqrt(2*42)*2^15)
+  __m128i THREE_OVER_SQRT_2_42 = _mm_set1_epi16(10726); // round(3/sqrt(2*42)*2^15)
+  __m128i FIVE_OVER_SQRT_2_42 = _mm_set1_epi16(17876); // round(5/sqrt(2*42)*2^15)
+  __m128i SEVEN_OVER_SQRT_2_42 = _mm_set1_epi16(25027); // round(7/sqrt(2*42)*2^15)
+  __m128i SQRT_42_OVER_FOUR = _mm_set1_epi16(13272); // round(sqrt(42)/4*2^13), Q3.
+  __m128i ch_mag_des,ch_mag_int;
+  __m128i  y0r_over_sqrt10;
+  __m128i  y0i_over_sqrt10;
+  __m128i  y0r_three_over_sqrt10;
+  __m128i  y0i_three_over_sqrt10;
+  __m128i ch_mag_over_10;
+  __m128i ch_mag_over_2;
+  __m128i ch_mag_9_over_10;
+  __m128i ch_mag_int_with_sigma2;
+  __m128i two_ch_mag_int_with_sigma2;
+  __m128i three_ch_mag_int_with_sigma2;
+
+#elif defined(__arm__)
+
+#endif
+  int i;
+
+  for (i=0; i<length>>2; i+=2) {
+    // In one iteration, we deal with 8 REs
+
+#if defined(__x86_64__) || defined(__i386__)
+    // Get rho
+    xmm0 = rho01_128i[i];
+    xmm1 = rho01_128i[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // Compute the different rhos
+    rho_rpi_1_1 = _mm_mulhi_epi16(rho_rpi,ONE_OVER_SQRT_10);
+    rho_rmi_1_1 = _mm_mulhi_epi16(rho_rmi,ONE_OVER_SQRT_10);
+    rho_rpi_3_3 = _mm_mulhi_epi16(rho_rpi,THREE_OVER_SQRT_10);
+    rho_rmi_3_3 = _mm_mulhi_epi16(rho_rmi,THREE_OVER_SQRT_10);
+    rho_rpi_3_3 = _mm_slli_epi16(rho_rpi_3_3,1);
+    rho_rmi_3_3 = _mm_slli_epi16(rho_rmi_3_3,1);
+
+    xmm4 = _mm_mulhi_epi16(xmm2,ONE_OVER_SQRT_10); // Re(rho)
+    xmm5 = _mm_mulhi_epi16(xmm3,THREE_OVER_SQRT_10); // Im(rho)
+    xmm5 = _mm_slli_epi16(xmm5,1);
+
+    rho_rpi_1_3 = _mm_adds_epi16(xmm4,xmm5);
+    rho_rmi_1_3 = _mm_subs_epi16(xmm4,xmm5);
+
+    xmm6 = _mm_mulhi_epi16(xmm2,THREE_OVER_SQRT_10); // Re(rho)
+    xmm7 = _mm_mulhi_epi16(xmm3,ONE_OVER_SQRT_10); // Im(rho)
+    xmm6 = _mm_slli_epi16(xmm6,1);
+
+    rho_rpi_3_1 = _mm_adds_epi16(xmm6,xmm7);
+    rho_rmi_3_1 = _mm_subs_epi16(xmm6,xmm7);
+
+    // Rearrange interfering MF output
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    xmm0 = _mm_setzero_si128(); // ZERO
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1,y1r); // = [Re(rho)+ Im(rho)]/sqrt(10) - y1r
+    psi_r_p1_p1 = _mm_abs_epi16(xmm2); // = |[Re(rho)+ Im(rho)]/sqrt(10) - y1r|
+
+    xmm2= _mm_subs_epi16(rho_rmi_1_1,y1r);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_1,y1i);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_3,y1r);
+    psi_r_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_3,y1r);
+    psi_r_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_1,y1i);
+    psi_i_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_1,y1r);
+    psi_r_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_1,y1r);
+    psi_r_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_1_3,y1i);
+    psi_i_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_3,y1r);
+    psi_r_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_3,y1r);
+    psi_r_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rmi_3_3,y1i);
+    psi_i_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_1,y1i);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_1,y1i);
+    psi_i_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_1_3,y1i);
+    psi_i_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_subs_epi16(rho_rpi_3_3,y1i);
+    psi_i_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_1,y1i);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_1,y1i);
+    psi_i_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_3,y1i);
+    psi_i_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_3,y1i);
+    psi_i_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_1,y1r);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_1_3,y1r);
+    psi_r_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_1,y1r);
+    psi_r_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(rho_rpi_3_3,y1r);
+    psi_r_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_1_1);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_1_3);
+    psi_r_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_1_1);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_3_1);
+    psi_i_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_3_1);
+    psi_r_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1r,rho_rmi_3_3);
+    psi_r_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_1_3);
+    psi_i_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2= _mm_adds_epi16(y1i,rho_rmi_3_3);
+    psi_i_m3_m3 = _mm_abs_epi16(xmm2);
+
+    // Rearrange desired MF output
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // Rearrange desired channel magnitudes
+    xmm2 = ch_mag_128i[i]; // = [|h|^2(1),|h|^2(1),|h|^2(2),|h|^2(2)]*(2/sqrt(10))
+    xmm3 = ch_mag_128i[i+1]; // = [|h|^2(3),|h|^2(3),|h|^2(4),|h|^2(4)]*(2/sqrt(10))
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+
+    ch_mag_des = _mm_unpacklo_epi64(xmm2,xmm3); // = [|h|^2(1),|h|^2(2),|h|^2(3),|h|^2(4)]*(2/sqrt(10))
+
+    // Rearrange interfering channel magnitudes
+    xmm2 = ch_mag_128i_i[i];
+    xmm3 = ch_mag_128i_i[i+1];
+
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+
+    ch_mag_int  = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    // Scale MF output of desired signal
+    y0r_over_sqrt10 = _mm_mulhi_epi16(y0r,ONE_OVER_SQRT_10);
+    y0i_over_sqrt10 = _mm_mulhi_epi16(y0i,ONE_OVER_SQRT_10);
+    y0r_three_over_sqrt10 = _mm_mulhi_epi16(y0r,THREE_OVER_SQRT_10);
+    y0i_three_over_sqrt10 = _mm_mulhi_epi16(y0i,THREE_OVER_SQRT_10);
+    y0r_three_over_sqrt10 = _mm_slli_epi16(y0r_three_over_sqrt10,1);
+    y0i_three_over_sqrt10 = _mm_slli_epi16(y0i_three_over_sqrt10,1);
+
+    // Compute necessary combination of required terms
+    y0_p_1_1 = _mm_adds_epi16(y0r_over_sqrt10,y0i_over_sqrt10);
+    y0_m_1_1 = _mm_subs_epi16(y0r_over_sqrt10,y0i_over_sqrt10);
+
+    y0_p_1_3 = _mm_adds_epi16(y0r_over_sqrt10,y0i_three_over_sqrt10);
+    y0_m_1_3 = _mm_subs_epi16(y0r_over_sqrt10,y0i_three_over_sqrt10);
+
+    y0_p_3_1 = _mm_adds_epi16(y0r_three_over_sqrt10,y0i_over_sqrt10);
+    y0_m_3_1 = _mm_subs_epi16(y0r_three_over_sqrt10,y0i_over_sqrt10);
+
+    y0_p_3_3 = _mm_adds_epi16(y0r_three_over_sqrt10,y0i_three_over_sqrt10);
+    y0_m_3_3 = _mm_subs_epi16(y0r_three_over_sqrt10,y0i_three_over_sqrt10);
+
+    // Compute optimal interfering symbol magnitude
+    ch_mag_int_with_sigma2       = _mm_srai_epi16(ch_mag_int, 1); // *2
+    two_ch_mag_int_with_sigma2   = ch_mag_int; // *4
+    three_ch_mag_int_with_sigma2 = _mm_adds_epi16(ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2); // *6
+
+    interference_abs_64qam_epi16(psi_r_p1_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_p1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_p1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_p3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_p3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_m1 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_m1,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_m3 ,ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_m3,ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42,FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+
+    // Calculation of groups of two terms in the bit metric involving product of psi and interference magnitude
+    prodsum_psi_a_epi16(psi_r_p1_p1,a_r_p1_p1,psi_i_p1_p1,a_i_p1_p1,psi_a_p1_p1);
+    prodsum_psi_a_epi16(psi_r_p1_p3,a_r_p1_p3,psi_i_p1_p3,a_i_p1_p3,psi_a_p1_p3);
+    prodsum_psi_a_epi16(psi_r_p3_p1,a_r_p3_p1,psi_i_p3_p1,a_i_p3_p1,psi_a_p3_p1);
+    prodsum_psi_a_epi16(psi_r_p3_p3,a_r_p3_p3,psi_i_p3_p3,a_i_p3_p3,psi_a_p3_p3);
+    prodsum_psi_a_epi16(psi_r_p1_m1,a_r_p1_m1,psi_i_p1_m1,a_i_p1_m1,psi_a_p1_m1);
+    prodsum_psi_a_epi16(psi_r_p1_m3,a_r_p1_m3,psi_i_p1_m3,a_i_p1_m3,psi_a_p1_m3);
+    prodsum_psi_a_epi16(psi_r_p3_m1,a_r_p3_m1,psi_i_p3_m1,a_i_p3_m1,psi_a_p3_m1);
+    prodsum_psi_a_epi16(psi_r_p3_m3,a_r_p3_m3,psi_i_p3_m3,a_i_p3_m3,psi_a_p3_m3);
+    prodsum_psi_a_epi16(psi_r_m1_p1,a_r_m1_p1,psi_i_m1_p1,a_i_m1_p1,psi_a_m1_p1);
+    prodsum_psi_a_epi16(psi_r_m1_p3,a_r_m1_p3,psi_i_m1_p3,a_i_m1_p3,psi_a_m1_p3);
+    prodsum_psi_a_epi16(psi_r_m3_p1,a_r_m3_p1,psi_i_m3_p1,a_i_m3_p1,psi_a_m3_p1);
+    prodsum_psi_a_epi16(psi_r_m3_p3,a_r_m3_p3,psi_i_m3_p3,a_i_m3_p3,psi_a_m3_p3);
+    prodsum_psi_a_epi16(psi_r_m1_m1,a_r_m1_m1,psi_i_m1_m1,a_i_m1_m1,psi_a_m1_m1);
+    prodsum_psi_a_epi16(psi_r_m1_m3,a_r_m1_m3,psi_i_m1_m3,a_i_m1_m3,psi_a_m1_m3);
+    prodsum_psi_a_epi16(psi_r_m3_m1,a_r_m3_m1,psi_i_m3_m1,a_i_m3_m1,psi_a_m3_m1);
+    prodsum_psi_a_epi16(psi_r_m3_m3,a_r_m3_m3,psi_i_m3_m3,a_i_m3_m3,psi_a_m3_m3);
+
+    // Multiply by sqrt(2)
+    psi_a_p1_p1 = _mm_mulhi_epi16(psi_a_p1_p1, ONE_OVER_SQRT_2);
+    psi_a_p1_p1 = _mm_slli_epi16(psi_a_p1_p1, 2);
+    psi_a_p1_p3 = _mm_mulhi_epi16(psi_a_p1_p3, ONE_OVER_SQRT_2);
+    psi_a_p1_p3 = _mm_slli_epi16(psi_a_p1_p3, 2);
+    psi_a_p3_p1 = _mm_mulhi_epi16(psi_a_p3_p1, ONE_OVER_SQRT_2);
+    psi_a_p3_p1 = _mm_slli_epi16(psi_a_p3_p1, 2);
+    psi_a_p3_p3 = _mm_mulhi_epi16(psi_a_p3_p3, ONE_OVER_SQRT_2);
+    psi_a_p3_p3 = _mm_slli_epi16(psi_a_p3_p3, 2);
+    psi_a_p1_m1 = _mm_mulhi_epi16(psi_a_p1_m1, ONE_OVER_SQRT_2);
+    psi_a_p1_m1 = _mm_slli_epi16(psi_a_p1_m1, 2);
+    psi_a_p1_m3 = _mm_mulhi_epi16(psi_a_p1_m3, ONE_OVER_SQRT_2);
+    psi_a_p1_m3 = _mm_slli_epi16(psi_a_p1_m3, 2);
+    psi_a_p3_m1 = _mm_mulhi_epi16(psi_a_p3_m1, ONE_OVER_SQRT_2);
+    psi_a_p3_m1 = _mm_slli_epi16(psi_a_p3_m1, 2);
+    psi_a_p3_m3 = _mm_mulhi_epi16(psi_a_p3_m3, ONE_OVER_SQRT_2);
+    psi_a_p3_m3 = _mm_slli_epi16(psi_a_p3_m3, 2);
+    psi_a_m1_p1 = _mm_mulhi_epi16(psi_a_m1_p1, ONE_OVER_SQRT_2);
+    psi_a_m1_p1 = _mm_slli_epi16(psi_a_m1_p1, 2);
+    psi_a_m1_p3 = _mm_mulhi_epi16(psi_a_m1_p3, ONE_OVER_SQRT_2);
+    psi_a_m1_p3 = _mm_slli_epi16(psi_a_m1_p3, 2);
+    psi_a_m3_p1 = _mm_mulhi_epi16(psi_a_m3_p1, ONE_OVER_SQRT_2);
+    psi_a_m3_p1 = _mm_slli_epi16(psi_a_m3_p1, 2);
+    psi_a_m3_p3 = _mm_mulhi_epi16(psi_a_m3_p3, ONE_OVER_SQRT_2);
+    psi_a_m3_p3 = _mm_slli_epi16(psi_a_m3_p3, 2);
+    psi_a_m1_m1 = _mm_mulhi_epi16(psi_a_m1_m1, ONE_OVER_SQRT_2);
+    psi_a_m1_m1 = _mm_slli_epi16(psi_a_m1_m1, 2);
+    psi_a_m1_m3 = _mm_mulhi_epi16(psi_a_m1_m3, ONE_OVER_SQRT_2);
+    psi_a_m1_m3 = _mm_slli_epi16(psi_a_m1_m3, 2);
+    psi_a_m3_m1 = _mm_mulhi_epi16(psi_a_m3_m1, ONE_OVER_SQRT_2);
+    psi_a_m3_m1 = _mm_slli_epi16(psi_a_m3_m1, 2);
+    psi_a_m3_m3 = _mm_mulhi_epi16(psi_a_m3_m3, ONE_OVER_SQRT_2);
+    psi_a_m3_m3 = _mm_slli_epi16(psi_a_m3_m3, 2);
+
+    // squared interference magnitude times int. ch. power
+    square_a_64qam_epi16(a_r_p1_p1,a_i_p1_p1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p1_p1);
+    square_a_64qam_epi16(a_r_p1_p3,a_i_p1_p3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p1_p3);
+    square_a_64qam_epi16(a_r_p3_p1,a_i_p3_p1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p3_p1);
+    square_a_64qam_epi16(a_r_p3_p3,a_i_p3_p3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p3_p3);
+    square_a_64qam_epi16(a_r_p1_m1,a_i_p1_m1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p1_m1);
+    square_a_64qam_epi16(a_r_p1_m3,a_i_p1_m3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p1_m3);
+    square_a_64qam_epi16(a_r_p3_m1,a_i_p3_m1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p3_m1);
+    square_a_64qam_epi16(a_r_p3_m3,a_i_p3_m3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_p3_m3);
+    square_a_64qam_epi16(a_r_m1_p1,a_i_m1_p1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m1_p1);
+    square_a_64qam_epi16(a_r_m1_p3,a_i_m1_p3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m1_p3);
+    square_a_64qam_epi16(a_r_m3_p1,a_i_m3_p1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m3_p1);
+    square_a_64qam_epi16(a_r_m3_p3,a_i_m3_p3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m3_p3);
+    square_a_64qam_epi16(a_r_m1_m1,a_i_m1_m1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m1_m1);
+    square_a_64qam_epi16(a_r_m1_m3,a_i_m1_m3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m1_m3);
+    square_a_64qam_epi16(a_r_m3_m1,a_i_m3_m1,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m3_m1);
+    square_a_64qam_epi16(a_r_m3_m3,a_i_m3_m3,ch_mag_int,SQRT_42_OVER_FOUR,a_sq_m3_m3);
+
+    // Computing different multiples of channel norms
+    ch_mag_over_10=_mm_mulhi_epi16(ch_mag_des, ONE_OVER_TWO_SQRT_10);
+    ch_mag_over_2=_mm_mulhi_epi16(ch_mag_des, SQRT_10_OVER_FOUR);
+    ch_mag_over_2=_mm_slli_epi16(ch_mag_over_2, 1);
+    ch_mag_9_over_10=_mm_mulhi_epi16(ch_mag_des, NINE_OVER_TWO_SQRT_10);
+    ch_mag_9_over_10=_mm_slli_epi16(ch_mag_9_over_10, 2);
+
+    // Computing Metrics
+    xmm0 = _mm_subs_epi16(psi_a_p1_p1,a_sq_p1_p1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_1_1);
+    bit_met_p1_p1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_p3,a_sq_p1_p3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_1_3);
+    bit_met_p1_p3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_m1,a_sq_p1_m1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_1_1);
+    bit_met_p1_m1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_p1_m3,a_sq_p1_m3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_1_3);
+    bit_met_p1_m3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_p1,a_sq_p3_p1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_3_1);
+    bit_met_p3_p1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_p3,a_sq_p3_p3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_p_3_3);
+    bit_met_p3_p3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_m1,a_sq_p3_m1);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_3_1);
+    bit_met_p3_m1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_p3_m3,a_sq_p3_m3);
+    xmm1 = _mm_adds_epi16(xmm0,y0_m_3_3);
+    bit_met_p3_m3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p1,a_sq_m1_p1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_1_1);
+    bit_met_m1_p1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p3,a_sq_m1_p3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_1_3);
+    bit_met_m1_p3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_m1,a_sq_m1_m1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_1_1);
+    bit_met_m1_m1= _mm_subs_epi16(xmm1,ch_mag_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_m3,a_sq_m1_m3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_1_3);
+    bit_met_m1_m3= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_p1,a_sq_m3_p1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_3_1);
+    bit_met_m3_p1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_p3,a_sq_m3_p3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_m_3_3);
+    bit_met_m3_p3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_m1,a_sq_m3_m1);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_3_1);
+    bit_met_m3_m1= _mm_subs_epi16(xmm1,ch_mag_over_2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m3_m3,a_sq_m3_m3);
+    xmm1 = _mm_subs_epi16(xmm0,y0_p_3_3);
+    bit_met_m3_m3= _mm_subs_epi16(xmm1,ch_mag_9_over_10);
+
+    // LLR of the first bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_p3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1,bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_m1,bit_met_m3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_re0= _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_p3);
+    xmm1 = _mm_max_epi16(bit_met_p1_m1,bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m1,bit_met_p3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of first bit [L1(1), L1(2), L1(3), L1(4), L1(5), L1(6), L1(7), L1(8)]
+    y0r = _mm_subs_epi16(logmax_den_re0,logmax_num_re0);
+
+    // LLR of the second bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p1_m1,bit_met_p3_m1);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_m3,bit_met_p3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m1_m3,bit_met_m3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_re1 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_p1,bit_met_p3_p1);
+    xmm1 = _mm_max_epi16(bit_met_m1_p1,bit_met_m3_p1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p3,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p3,bit_met_m3_p3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_re1 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of second bit [L2(1), L2(2), L2(3), L2(4)]
+    y1r = _mm_subs_epi16(logmax_den_re1,logmax_num_re1);
+
+    // LLR of the third bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m3_p1,bit_met_m3_p3);
+    xmm1 = _mm_max_epi16(bit_met_m3_m1,bit_met_m3_m3);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m1,bit_met_p3_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_im0 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_m1_p1,bit_met_m1_p3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m1_m3);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1,bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_m1,bit_met_p1_m3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_im0 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of third bit [L3(1), L3(2), L3(3), L3(4)]
+    y0i = _mm_subs_epi16(logmax_den_im0,logmax_num_im0);
+
+    // LLR of the fourth bit
+    // Bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p1_m3,bit_met_p3_m3);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3,bit_met_m3_m3);
+    xmm2 = _mm_max_epi16(bit_met_p1_p3,bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p3,bit_met_m3_p3);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_num_im1 = _mm_max_epi16(xmm4,xmm5);
+
+    // Bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p1_m1,bit_met_p3_m1);
+    xmm1 = _mm_max_epi16(bit_met_m1_m1,bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1,bit_met_p3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m1_p1,bit_met_m3_p1);
+    xmm4 = _mm_max_epi16(xmm0,xmm1);
+    xmm5 = _mm_max_epi16(xmm2,xmm3);
+    logmax_den_im1 = _mm_max_epi16(xmm4,xmm5);
+
+    // LLR of fourth bit [L4(1), L4(2), L4(3), L4(4)]
+    y1i = _mm_subs_epi16(logmax_den_im1,logmax_num_im1);
+
+    // Pack LLRs in output
+    // [L1(1), L2(1), L1(2), L2(2), L1(3), L2(3), L1(4), L2(4)]
+    xmm0 = _mm_unpacklo_epi16(y0r,y1r);
+    // [L1(5), L2(5), L1(6), L2(6), L1(7), L2(7), L1(8), L2(8)]
+    xmm1 = _mm_unpackhi_epi16(y0r,y1r);
+    // [L3(1), L4(1), L3(2), L4(2), L3(3), L4(3), L3(4), L4(4)]
+    xmm2 = _mm_unpacklo_epi16(y0i,y1i);
+    // [L3(5), L4(5), L3(6), L4(6), L3(7), L4(7), L3(8), L4(8)]
+    xmm3 = _mm_unpackhi_epi16(y0i,y1i);
+
+    stream0_128i_out[2*i+0] = _mm_unpacklo_epi32(xmm0,xmm2); // 8LLRs, 2REs
+    stream0_128i_out[2*i+1] = _mm_unpackhi_epi32(xmm0,xmm2);
+    stream0_128i_out[2*i+2] = _mm_unpacklo_epi32(xmm1,xmm3);
+    stream0_128i_out[2*i+3] = _mm_unpackhi_epi32(xmm1,xmm3);
+#elif defined(__arm__)
+
+#endif
+
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+int dlsch_16qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                          int32_t **rxdataF_comp,
+                          int32_t **rxdataF_comp_i,
+                          int32_t **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
+                          int32_t **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                          int32_t **rho_i,
+                          int16_t *dlsch_llr,
+                          uint8_t symbol,
+                          uint8_t first_symbol_flag,
+                          uint16_t nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          int16_t **llr16p)
+{
+
+  int16_t *rxF      = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i    = (int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag   = (int16_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho      = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  // first symbol has different structure due to more pilots
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
+
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  // printf("symbol %d: qam16_llr, len %d (llr16 %p)\n",symbol,len,llr16);
+
+  qam16_qam64((short *)rxF,
+              (short *)rxF_i,
+              (short *)ch_mag,
+              (short *)ch_mag_i,
+              (short *)llr16,
+              (short *)rho,
+              len);
+
+  llr16 += (len<<2);
+  *llr16p = (short *)llr16;
+
+  return(0);
+}
+
+//----------------------------------------------------------------------------------------------
+// 64-QAM
+//----------------------------------------------------------------------------------------------
+
+/*
+__m128i ONE_OVER_SQRT_42 __attribute__((aligned(16)));
+__m128i THREE_OVER_SQRT_42 __attribute__((aligned(16)));
+__m128i FIVE_OVER_SQRT_42 __attribute__((aligned(16)));
+__m128i SEVEN_OVER_SQRT_42 __attribute__((aligned(16)));
+
+__m128i FORTYNINE_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i THIRTYSEVEN_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i TWENTYNINE_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i TWENTYFIVE_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i SEVENTEEN_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i NINE_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i THIRTEEN_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i FIVE_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+__m128i ONE_OVER_FOUR_SQRT_42 __attribute__((aligned(16)));
+
+__m128i  y0r_one_over_sqrt_21 __attribute__((aligned(16)));
+__m128i  y0r_three_over_sqrt_21 __attribute__((aligned(16)));
+__m128i  y0r_five_over_sqrt_21 __attribute__((aligned(16)));
+__m128i  y0r_seven_over_sqrt_21 __attribute__((aligned(16)));
+__m128i  y0i_one_over_sqrt_21 __attribute__((aligned(16)));
+__m128i  y0i_three_over_sqrt_21 __attribute__((aligned(16)));
+__m128i  y0i_five_over_sqrt_21 __attribute__((aligned(16)));
+__m128i  y0i_seven_over_sqrt_21 __attribute__((aligned(16)));
+
+__m128i ch_mag_98_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_74_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_58_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_50_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_34_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_18_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_26_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_10_over_42_with_sigma2 __attribute__((aligned(16)));
+__m128i ch_mag_2_over_42_with_sigma2 __attribute__((aligned(16)));
+
+*/
+
+void qam64_qpsk(int16_t *stream0_in,
+                int16_t *stream1_in,
+                int16_t *ch_mag,
+                int16_t *stream0_out,
+                int16_t *rho01,
+                int32_t length
+    )
+{
+
+  /*
+    Author: S. Wagner
+    Date: 31-07-12
+
+    Input:
+    stream0_in:  MF filter for 1st stream, i.e., y0=h0'*y
+    stream1_in:  MF filter for 2nd stream, i.e., y1=h1'*y
+    ch_mag:      4*h0/sqrt(42), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    ch_mag_i:    4*h1/sqrt(42), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    rho01:       Channel cross correlation, i.e., h1'*h0
+
+    Output:
+    stream0_out: output LLRs for 1st stream
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rho01_128i      = (__m128i *)rho01;
+  __m128i *stream0_128i_in = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in = (__m128i *)stream1_in;
+  __m128i *ch_mag_128i     = (__m128i *)ch_mag;
+
+
+  __m128i ONE_OVER_SQRT_42 = _mm_set1_epi16(10112); // round(1/sqrt(42)*2^16)
+  __m128i THREE_OVER_SQRT_42 = _mm_set1_epi16(30337); // round(3/sqrt(42)*2^16)
+  __m128i FIVE_OVER_SQRT_42 = _mm_set1_epi16(25281); // round(5/sqrt(42)*2^15)
+  __m128i SEVEN_OVER_SQRT_42 = _mm_set1_epi16(17697); // round(5/sqrt(42)*2^15)
+  __m128i ONE_OVER_SQRT_2 = _mm_set1_epi16(23170); // round(1/sqrt(2)*2^15)
+  __m128i FORTYNINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(30969); // round(49/(4*sqrt(42))*2^14), Q2.14
+  __m128i THIRTYSEVEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(23385); // round(37/(4*sqrt(42))*2^14), Q2.14
+  __m128i TWENTYFIVE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(31601); // round(25/(4*sqrt(42))*2^15)
+  __m128i TWENTYNINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(18329); // round(29/(4*sqrt(42))*2^15), Q2.14
+  __m128i SEVENTEEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(21489); // round(17/(4*sqrt(42))*2^15)
+  __m128i NINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(11376); // round(9/(4*sqrt(42))*2^15)
+  __m128i THIRTEEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(16433); // round(13/(4*sqrt(42))*2^15)
+  __m128i FIVE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(6320); // round(5/(4*sqrt(42))*2^15)
+  __m128i ONE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(1264); // round(1/(4*sqrt(42))*2^15)
+
+
+  __m128i ch_mag_des;
+  __m128i ch_mag_98_over_42_with_sigma2;
+  __m128i ch_mag_74_over_42_with_sigma2;
+  __m128i ch_mag_58_over_42_with_sigma2;
+  __m128i ch_mag_50_over_42_with_sigma2;
+  __m128i ch_mag_34_over_42_with_sigma2;
+  __m128i ch_mag_18_over_42_with_sigma2;
+  __m128i ch_mag_26_over_42_with_sigma2;
+  __m128i ch_mag_10_over_42_with_sigma2;
+  __m128i ch_mag_2_over_42_with_sigma2;
+  __m128i  y0r_one_over_sqrt_21;
+  __m128i  y0r_three_over_sqrt_21;
+  __m128i  y0r_five_over_sqrt_21;
+  __m128i  y0r_seven_over_sqrt_21;
+  __m128i  y0i_one_over_sqrt_21;
+  __m128i  y0i_three_over_sqrt_21;
+  __m128i  y0i_five_over_sqrt_21;
+  __m128i  y0i_seven_over_sqrt_21;
+#elif defined(__arm__)
+
+#endif
+
+  int i,j;
+
+  for (i=0; i<length>>2; i+=2) {
+
+#if defined(__x86_64) || defined(__i386__)
+    // Get rho
+    xmm0 = rho01_128i[i];
+    xmm1 = rho01_128i[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // Compute the different rhos
+    rho_rpi_1_1 = _mm_mulhi_epi16(rho_rpi, ONE_OVER_SQRT_42);
+    rho_rmi_1_1 = _mm_mulhi_epi16(rho_rmi, ONE_OVER_SQRT_42);
+    rho_rpi_3_3 = _mm_mulhi_epi16(rho_rpi, THREE_OVER_SQRT_42);
+    rho_rmi_3_3 = _mm_mulhi_epi16(rho_rmi, THREE_OVER_SQRT_42);
+    rho_rpi_5_5 = _mm_mulhi_epi16(rho_rpi, FIVE_OVER_SQRT_42);
+    rho_rmi_5_5 = _mm_mulhi_epi16(rho_rmi, FIVE_OVER_SQRT_42);
+    rho_rpi_7_7 = _mm_mulhi_epi16(rho_rpi, SEVEN_OVER_SQRT_42);
+    rho_rmi_7_7 = _mm_mulhi_epi16(rho_rmi, SEVEN_OVER_SQRT_42);
+
+    rho_rpi_5_5 = _mm_slli_epi16(rho_rpi_5_5, 1);
+    rho_rmi_5_5 = _mm_slli_epi16(rho_rmi_5_5, 1);
+    rho_rpi_7_7 = _mm_slli_epi16(rho_rpi_7_7, 2);
+    rho_rmi_7_7 = _mm_slli_epi16(rho_rmi_7_7, 2);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, ONE_OVER_SQRT_42);
+    xmm5 = _mm_mulhi_epi16(xmm3, ONE_OVER_SQRT_42);
+    xmm6 = _mm_mulhi_epi16(xmm3, THREE_OVER_SQRT_42);
+    xmm7 = _mm_mulhi_epi16(xmm3, FIVE_OVER_SQRT_42);
+    xmm8 = _mm_mulhi_epi16(xmm3, SEVEN_OVER_SQRT_42);
+    xmm7 = _mm_slli_epi16(xmm7, 1);
+    xmm8 = _mm_slli_epi16(xmm8, 2);
+
+    rho_rpi_1_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_1_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_1_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_1_5 = _mm_subs_epi16(xmm4, xmm7);
+    rho_rpi_1_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_1_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, THREE_OVER_SQRT_42);
+    rho_rpi_3_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_3_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_3_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_3_5 = _mm_subs_epi16(xmm4, xmm7);
+    rho_rpi_3_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_3_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, FIVE_OVER_SQRT_42);
+    xmm4 = _mm_slli_epi16(xmm4, 1);
+    rho_rpi_5_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_5_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_5_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_5_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_5_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_5_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, SEVEN_OVER_SQRT_42);
+    xmm4 = _mm_slli_epi16(xmm4, 2);
+    rho_rpi_7_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_7_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_7_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_7_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_7_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_7_5 = _mm_subs_epi16(xmm4, xmm7);
+
+    // Rearrange interfering MF output
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    // Psi_r calculation from rho_rpi or rho_rmi
+    xmm0 = _mm_setzero_si128(); // ZERO for abs_pi16
+    xmm2 = _mm_subs_epi16(rho_rpi_7_7, y1r);
+    psi_r_p7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_5, y1r);
+    psi_r_p7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_3, y1r);
+    psi_r_p7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_1, y1r);
+    psi_r_p7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_1, y1r);
+    psi_r_p7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_3, y1r);
+    psi_r_p7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_5, y1r);
+    psi_r_p7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_7, y1r);
+    psi_r_p7_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_7, y1r);
+    psi_r_p5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_5, y1r);
+    psi_r_p5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_3, y1r);
+    psi_r_p5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_1, y1r);
+    psi_r_p5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_1, y1r);
+    psi_r_p5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_3, y1r);
+    psi_r_p5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_5, y1r);
+    psi_r_p5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_7, y1r);
+    psi_r_p5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_7, y1r);
+    psi_r_p3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_5, y1r);
+    psi_r_p3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_3, y1r);
+    psi_r_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_1, y1r);
+    psi_r_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_1, y1r);
+    psi_r_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_3, y1r);
+    psi_r_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_5, y1r);
+    psi_r_p3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_7, y1r);
+    psi_r_p3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_7, y1r);
+    psi_r_p1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_5, y1r);
+    psi_r_p1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_3, y1r);
+    psi_r_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1, y1r);
+    psi_r_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_1, y1r);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_3, y1r);
+    psi_r_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_5, y1r);
+    psi_r_p1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_7, y1r);
+    psi_r_p1_m7 = _mm_abs_epi16(xmm2);
+
+    xmm2 = _mm_adds_epi16(rho_rmi_1_7, y1r);
+    psi_r_m1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_5, y1r);
+    psi_r_m1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_3, y1r);
+    psi_r_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_1, y1r);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_1, y1r);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_3, y1r);
+    psi_r_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_5, y1r);
+    psi_r_m1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_7, y1r);
+    psi_r_m1_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_7, y1r);
+    psi_r_m3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_5, y1r);
+    psi_r_m3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_3, y1r);
+    psi_r_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_1, y1r);
+    psi_r_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_1, y1r);
+    psi_r_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_3, y1r);
+    psi_r_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_5, y1r);
+    psi_r_m3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_7, y1r);
+    psi_r_m3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_7, y1r);
+    psi_r_m5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_5, y1r);
+    psi_r_m5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_3, y1r);
+    psi_r_m5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_1, y1r);
+    psi_r_m5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_1, y1r);
+    psi_r_m5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_3, y1r);
+    psi_r_m5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_5, y1r);
+    psi_r_m5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_7, y1r);
+    psi_r_m5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_7, y1r);
+    psi_r_m7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_5, y1r);
+    psi_r_m7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_3, y1r);
+    psi_r_m7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_1, y1r);
+    psi_r_m7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_1, y1r);
+    psi_r_m7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_3, y1r);
+    psi_r_m7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_5, y1r);
+    psi_r_m7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_7, y1r);
+    psi_r_m7_m7 = _mm_abs_epi16(xmm2);
+
+    // Psi_i calculation from rho_rpi or rho_rmi
+    xmm2 = _mm_subs_epi16(rho_rmi_7_7, y1i);
+    psi_i_p7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_7, y1i);
+    psi_i_p7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_7, y1i);
+    psi_i_p7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_7, y1i);
+    psi_i_p7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_7, y1i);
+    psi_i_p7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_7, y1i);
+    psi_i_p7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_7, y1i);
+    psi_i_p7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_7, y1i);
+    psi_i_p7_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_5, y1i);
+    psi_i_p5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_5, y1i);
+    psi_i_p5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_5, y1i);
+    psi_i_p5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_5, y1i);
+    psi_i_p5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_5, y1i);
+    psi_i_p5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_5, y1i);
+    psi_i_p5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_5, y1i);
+    psi_i_p5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_5, y1i);
+    psi_i_p5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_3, y1i);
+    psi_i_p3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_3, y1i);
+    psi_i_p3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_3, y1i);
+    psi_i_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_3, y1i);
+    psi_i_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_3, y1i);
+    psi_i_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_3, y1i);
+    psi_i_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_3, y1i);
+    psi_i_p3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_3, y1i);
+    psi_i_p3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_1, y1i);
+    psi_i_p1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_1, y1i);
+    psi_i_p1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_1, y1i);
+    psi_i_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_1, y1i);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_1, y1i);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_1, y1i);
+    psi_i_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_1, y1i);
+    psi_i_p1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_1, y1i);
+    psi_i_p1_m7 = _mm_abs_epi16(xmm2);
+
+    xmm2 = _mm_subs_epi16(rho_rpi_7_1, y1i);
+    psi_i_m1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_1, y1i);
+    psi_i_m1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_1, y1i);
+    psi_i_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1, y1i);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_1, y1i);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_1, y1i);
+    psi_i_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_1, y1i);
+    psi_i_m1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_1, y1i);
+    psi_i_m1_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_3, y1i);
+    psi_i_m3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_3, y1i);
+    psi_i_m3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_3, y1i);
+    psi_i_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_3, y1i);
+    psi_i_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_3, y1i);
+    psi_i_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_3, y1i);
+    psi_i_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_3, y1i);
+    psi_i_m3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_3, y1i);
+    psi_i_m3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_5, y1i);
+    psi_i_m5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_5, y1i);
+    psi_i_m5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_5, y1i);
+    psi_i_m5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_5, y1i);
+    psi_i_m5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_5, y1i);
+    psi_i_m5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_5, y1i);
+    psi_i_m5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_5, y1i);
+    psi_i_m5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_5, y1i);
+    psi_i_m5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_7, y1i);
+    psi_i_m7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_7, y1i);
+    psi_i_m7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_7, y1i);
+    psi_i_m7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_7, y1i);
+    psi_i_m7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_7, y1i);
+    psi_i_m7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_7, y1i);
+    psi_i_m7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_7, y1i);
+    psi_i_m7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_7, y1i);
+    psi_i_m7_m7 = _mm_abs_epi16(xmm2);
+
+
+    // Rearrange desired MF output
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // Rearrange desired channel magnitudes
+    xmm2 = ch_mag_128i[i]; // = [|h|^2(1),|h|^2(1),|h|^2(2),|h|^2(2)]*(2/sqrt(10))
+    xmm3 = ch_mag_128i[i+1]; // = [|h|^2(3),|h|^2(3),|h|^2(4),|h|^2(4)]*(2/sqrt(10))
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    ch_mag_des = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    y0r_one_over_sqrt_21   = _mm_mulhi_epi16(y0r, ONE_OVER_SQRT_42);
+    y0r_three_over_sqrt_21 = _mm_mulhi_epi16(y0r, THREE_OVER_SQRT_42);
+    y0r_five_over_sqrt_21  = _mm_mulhi_epi16(y0r, FIVE_OVER_SQRT_42);
+    y0r_five_over_sqrt_21  = _mm_slli_epi16(y0r_five_over_sqrt_21, 1);
+    y0r_seven_over_sqrt_21 = _mm_mulhi_epi16(y0r, SEVEN_OVER_SQRT_42);
+    y0r_seven_over_sqrt_21 = _mm_slli_epi16(y0r_seven_over_sqrt_21, 2); // Q2.14
+
+    y0i_one_over_sqrt_21   = _mm_mulhi_epi16(y0i, ONE_OVER_SQRT_42);
+    y0i_three_over_sqrt_21 = _mm_mulhi_epi16(y0i, THREE_OVER_SQRT_42);
+    y0i_five_over_sqrt_21  = _mm_mulhi_epi16(y0i, FIVE_OVER_SQRT_42);
+    y0i_five_over_sqrt_21  = _mm_slli_epi16(y0i_five_over_sqrt_21, 1);
+    y0i_seven_over_sqrt_21 = _mm_mulhi_epi16(y0i, SEVEN_OVER_SQRT_42);
+    y0i_seven_over_sqrt_21 = _mm_slli_epi16(y0i_seven_over_sqrt_21, 2); // Q2.14
+
+    y0_p_7_1 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_7_3 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_7_5 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_7_7 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_5_1 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_5_3 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_5_5 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_5_7 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_3_1 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_3_3 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_3_5 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_3_7 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_1_1 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_1_3 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_1_5 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_1_7 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_seven_over_sqrt_21);
+
+    y0_m_1_1 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_1_3 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_1_5 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_1_7 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_3_1 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_3_3 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_3_5 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_3_7 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_5_1 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_5_3 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_5_5 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_5_7 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_7_1 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_7_3 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_7_5 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_7_7 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_seven_over_sqrt_21);
+
+    // divide by sqrt(2)
+    psi_r_p7_p7 = _mm_mulhi_epi16(psi_r_p7_p7, ONE_OVER_SQRT_2);
+    psi_r_p7_p7 = _mm_slli_epi16(psi_r_p7_p7, 1);
+    psi_r_p7_p5 = _mm_mulhi_epi16(psi_r_p7_p5, ONE_OVER_SQRT_2);
+    psi_r_p7_p5 = _mm_slli_epi16(psi_r_p7_p5, 1);
+    psi_r_p7_p3 = _mm_mulhi_epi16(psi_r_p7_p3, ONE_OVER_SQRT_2);
+    psi_r_p7_p3 = _mm_slli_epi16(psi_r_p7_p3, 1);
+    psi_r_p7_p1 = _mm_mulhi_epi16(psi_r_p7_p1, ONE_OVER_SQRT_2);
+    psi_r_p7_p1 = _mm_slli_epi16(psi_r_p7_p1, 1);
+    psi_r_p7_m1 = _mm_mulhi_epi16(psi_r_p7_m1, ONE_OVER_SQRT_2);
+    psi_r_p7_m1 = _mm_slli_epi16(psi_r_p7_m1, 1);
+    psi_r_p7_m3 = _mm_mulhi_epi16(psi_r_p7_m3, ONE_OVER_SQRT_2);
+    psi_r_p7_m3 = _mm_slli_epi16(psi_r_p7_m3, 1);
+    psi_r_p7_m5 = _mm_mulhi_epi16(psi_r_p7_m5, ONE_OVER_SQRT_2);
+    psi_r_p7_m5 = _mm_slli_epi16(psi_r_p7_m5, 1);
+    psi_r_p7_m7 = _mm_mulhi_epi16(psi_r_p7_m7, ONE_OVER_SQRT_2);
+    psi_r_p7_m7 = _mm_slli_epi16(psi_r_p7_m7, 1);
+    psi_r_p5_p7 = _mm_mulhi_epi16(psi_r_p5_p7, ONE_OVER_SQRT_2);
+    psi_r_p5_p7 = _mm_slli_epi16(psi_r_p5_p7, 1);
+    psi_r_p5_p5 = _mm_mulhi_epi16(psi_r_p5_p5, ONE_OVER_SQRT_2);
+    psi_r_p5_p5 = _mm_slli_epi16(psi_r_p5_p5, 1);
+    psi_r_p5_p3 = _mm_mulhi_epi16(psi_r_p5_p3, ONE_OVER_SQRT_2);
+    psi_r_p5_p3 = _mm_slli_epi16(psi_r_p5_p3, 1);
+    psi_r_p5_p1 = _mm_mulhi_epi16(psi_r_p5_p1, ONE_OVER_SQRT_2);
+    psi_r_p5_p1 = _mm_slli_epi16(psi_r_p5_p1, 1);
+    psi_r_p5_m1 = _mm_mulhi_epi16(psi_r_p5_m1, ONE_OVER_SQRT_2);
+    psi_r_p5_m1 = _mm_slli_epi16(psi_r_p5_m1, 1);
+    psi_r_p5_m3 = _mm_mulhi_epi16(psi_r_p5_m3, ONE_OVER_SQRT_2);
+    psi_r_p5_m3 = _mm_slli_epi16(psi_r_p5_m3, 1);
+    psi_r_p5_m5 = _mm_mulhi_epi16(psi_r_p5_m5, ONE_OVER_SQRT_2);
+    psi_r_p5_m5 = _mm_slli_epi16(psi_r_p5_m5, 1);
+    psi_r_p5_m7 = _mm_mulhi_epi16(psi_r_p5_m7, ONE_OVER_SQRT_2);
+    psi_r_p5_m7 = _mm_slli_epi16(psi_r_p5_m7, 1);
+    psi_r_p3_p7 = _mm_mulhi_epi16(psi_r_p3_p7, ONE_OVER_SQRT_2);
+    psi_r_p3_p7 = _mm_slli_epi16(psi_r_p3_p7, 1);
+    psi_r_p3_p5 = _mm_mulhi_epi16(psi_r_p3_p5, ONE_OVER_SQRT_2);
+    psi_r_p3_p5 = _mm_slli_epi16(psi_r_p3_p5, 1);
+    psi_r_p3_p3 = _mm_mulhi_epi16(psi_r_p3_p3, ONE_OVER_SQRT_2);
+    psi_r_p3_p3 = _mm_slli_epi16(psi_r_p3_p3, 1);
+    psi_r_p3_p1 = _mm_mulhi_epi16(psi_r_p3_p1, ONE_OVER_SQRT_2);
+    psi_r_p3_p1 = _mm_slli_epi16(psi_r_p3_p1, 1);
+    psi_r_p3_m1 = _mm_mulhi_epi16(psi_r_p3_m1, ONE_OVER_SQRT_2);
+    psi_r_p3_m1 = _mm_slli_epi16(psi_r_p3_m1, 1);
+    psi_r_p3_m3 = _mm_mulhi_epi16(psi_r_p3_m3, ONE_OVER_SQRT_2);
+    psi_r_p3_m3 = _mm_slli_epi16(psi_r_p3_m3, 1);
+    psi_r_p3_m5 = _mm_mulhi_epi16(psi_r_p3_m5, ONE_OVER_SQRT_2);
+    psi_r_p3_m5 = _mm_slli_epi16(psi_r_p3_m5, 1);
+    psi_r_p3_m7 = _mm_mulhi_epi16(psi_r_p3_m7, ONE_OVER_SQRT_2);
+    psi_r_p3_m7 = _mm_slli_epi16(psi_r_p3_m7, 1);
+    psi_r_p1_p7 = _mm_mulhi_epi16(psi_r_p1_p7, ONE_OVER_SQRT_2);
+    psi_r_p1_p7 = _mm_slli_epi16(psi_r_p1_p7, 1);
+    psi_r_p1_p5 = _mm_mulhi_epi16(psi_r_p1_p5, ONE_OVER_SQRT_2);
+    psi_r_p1_p5 = _mm_slli_epi16(psi_r_p1_p5, 1);
+    psi_r_p1_p3 = _mm_mulhi_epi16(psi_r_p1_p3, ONE_OVER_SQRT_2);
+    psi_r_p1_p3 = _mm_slli_epi16(psi_r_p1_p3, 1);
+    psi_r_p1_p1 = _mm_mulhi_epi16(psi_r_p1_p1, ONE_OVER_SQRT_2);
+    psi_r_p1_p1 = _mm_slli_epi16(psi_r_p1_p1, 1);
+    psi_r_p1_m1 = _mm_mulhi_epi16(psi_r_p1_m1, ONE_OVER_SQRT_2);
+    psi_r_p1_m1 = _mm_slli_epi16(psi_r_p1_m1, 1);
+    psi_r_p1_m3 = _mm_mulhi_epi16(psi_r_p1_m3, ONE_OVER_SQRT_2);
+    psi_r_p1_m3 = _mm_slli_epi16(psi_r_p1_m3, 1);
+    psi_r_p1_m5 = _mm_mulhi_epi16(psi_r_p1_m5, ONE_OVER_SQRT_2);
+    psi_r_p1_m5 = _mm_slli_epi16(psi_r_p1_m5, 1);
+    psi_r_p1_m7 = _mm_mulhi_epi16(psi_r_p1_m7, ONE_OVER_SQRT_2);
+    psi_r_p1_m7 = _mm_slli_epi16(psi_r_p1_m7, 1);
+    psi_r_m1_p7 = _mm_mulhi_epi16(psi_r_m1_p7, ONE_OVER_SQRT_2);
+    psi_r_m1_p7 = _mm_slli_epi16(psi_r_m1_p7, 1);
+    psi_r_m1_p5 = _mm_mulhi_epi16(psi_r_m1_p5, ONE_OVER_SQRT_2);
+    psi_r_m1_p5 = _mm_slli_epi16(psi_r_m1_p5, 1);
+    psi_r_m1_p3 = _mm_mulhi_epi16(psi_r_m1_p3, ONE_OVER_SQRT_2);
+    psi_r_m1_p3 = _mm_slli_epi16(psi_r_m1_p3, 1);
+    psi_r_m1_p1 = _mm_mulhi_epi16(psi_r_m1_p1, ONE_OVER_SQRT_2);
+    psi_r_m1_p1 = _mm_slli_epi16(psi_r_m1_p1, 1);
+    psi_r_m1_m1 = _mm_mulhi_epi16(psi_r_m1_m1, ONE_OVER_SQRT_2);
+    psi_r_m1_m1 = _mm_slli_epi16(psi_r_m1_m1, 1);
+    psi_r_m1_m3 = _mm_mulhi_epi16(psi_r_m1_m3, ONE_OVER_SQRT_2);
+    psi_r_m1_m3 = _mm_slli_epi16(psi_r_m1_m3, 1);
+    psi_r_m1_m5 = _mm_mulhi_epi16(psi_r_m1_m5, ONE_OVER_SQRT_2);
+    psi_r_m1_m5 = _mm_slli_epi16(psi_r_m1_m5, 1);
+    psi_r_m1_m7 = _mm_mulhi_epi16(psi_r_m1_m7, ONE_OVER_SQRT_2);
+    psi_r_m1_m7 = _mm_slli_epi16(psi_r_m1_m7, 1);
+    psi_r_m3_p7 = _mm_mulhi_epi16(psi_r_m3_p7, ONE_OVER_SQRT_2);
+    psi_r_m3_p7 = _mm_slli_epi16(psi_r_m3_p7, 1);
+    psi_r_m3_p5 = _mm_mulhi_epi16(psi_r_m3_p5, ONE_OVER_SQRT_2);
+    psi_r_m3_p5 = _mm_slli_epi16(psi_r_m3_p5, 1);
+    psi_r_m3_p3 = _mm_mulhi_epi16(psi_r_m3_p3, ONE_OVER_SQRT_2);
+    psi_r_m3_p3 = _mm_slli_epi16(psi_r_m3_p3, 1);
+    psi_r_m3_p1 = _mm_mulhi_epi16(psi_r_m3_p1, ONE_OVER_SQRT_2);
+    psi_r_m3_p1 = _mm_slli_epi16(psi_r_m3_p1, 1);
+    psi_r_m3_m1 = _mm_mulhi_epi16(psi_r_m3_m1, ONE_OVER_SQRT_2);
+    psi_r_m3_m1 = _mm_slli_epi16(psi_r_m3_m1, 1);
+    psi_r_m3_m3 = _mm_mulhi_epi16(psi_r_m3_m3, ONE_OVER_SQRT_2);
+    psi_r_m3_m3 = _mm_slli_epi16(psi_r_m3_m3, 1);
+    psi_r_m3_m5 = _mm_mulhi_epi16(psi_r_m3_m5, ONE_OVER_SQRT_2);
+    psi_r_m3_m5 = _mm_slli_epi16(psi_r_m3_m5, 1);
+    psi_r_m3_m7 = _mm_mulhi_epi16(psi_r_m3_m7, ONE_OVER_SQRT_2);
+    psi_r_m3_m7 = _mm_slli_epi16(psi_r_m3_m7, 1);
+    psi_r_m5_p7 = _mm_mulhi_epi16(psi_r_m5_p7, ONE_OVER_SQRT_2);
+    psi_r_m5_p7 = _mm_slli_epi16(psi_r_m5_p7, 1);
+    psi_r_m5_p5 = _mm_mulhi_epi16(psi_r_m5_p5, ONE_OVER_SQRT_2);
+    psi_r_m5_p5 = _mm_slli_epi16(psi_r_m5_p5, 1);
+    psi_r_m5_p3 = _mm_mulhi_epi16(psi_r_m5_p3, ONE_OVER_SQRT_2);
+    psi_r_m5_p3 = _mm_slli_epi16(psi_r_m5_p3, 1);
+    psi_r_m5_p1 = _mm_mulhi_epi16(psi_r_m5_p1, ONE_OVER_SQRT_2);
+    psi_r_m5_p1 = _mm_slli_epi16(psi_r_m5_p1, 1);
+    psi_r_m5_m1 = _mm_mulhi_epi16(psi_r_m5_m1, ONE_OVER_SQRT_2);
+    psi_r_m5_m1 = _mm_slli_epi16(psi_r_m5_m1, 1);
+    psi_r_m5_m3 = _mm_mulhi_epi16(psi_r_m5_m3, ONE_OVER_SQRT_2);
+    psi_r_m5_m3 = _mm_slli_epi16(psi_r_m5_m3, 1);
+    psi_r_m5_m5 = _mm_mulhi_epi16(psi_r_m5_m5, ONE_OVER_SQRT_2);
+    psi_r_m5_m5 = _mm_slli_epi16(psi_r_m5_m5, 1);
+    psi_r_m5_m7 = _mm_mulhi_epi16(psi_r_m5_m7, ONE_OVER_SQRT_2);
+    psi_r_m5_m7 = _mm_slli_epi16(psi_r_m5_m7, 1);
+    psi_r_m7_p7 = _mm_mulhi_epi16(psi_r_m7_p7, ONE_OVER_SQRT_2);
+    psi_r_m7_p7 = _mm_slli_epi16(psi_r_m7_p7, 1);
+    psi_r_m7_p5 = _mm_mulhi_epi16(psi_r_m7_p5, ONE_OVER_SQRT_2);
+    psi_r_m7_p5 = _mm_slli_epi16(psi_r_m7_p5, 1);
+    psi_r_m7_p3 = _mm_mulhi_epi16(psi_r_m7_p3, ONE_OVER_SQRT_2);
+    psi_r_m7_p3 = _mm_slli_epi16(psi_r_m7_p3, 1);
+    psi_r_m7_p1 = _mm_mulhi_epi16(psi_r_m7_p1, ONE_OVER_SQRT_2);
+    psi_r_m7_p1 = _mm_slli_epi16(psi_r_m7_p1, 1);
+    psi_r_m7_m1 = _mm_mulhi_epi16(psi_r_m7_m1, ONE_OVER_SQRT_2);
+    psi_r_m7_m1 = _mm_slli_epi16(psi_r_m7_m1, 1);
+    psi_r_m7_m3 = _mm_mulhi_epi16(psi_r_m7_m3, ONE_OVER_SQRT_2);
+    psi_r_m7_m3 = _mm_slli_epi16(psi_r_m7_m3, 1);
+    psi_r_m7_m5 = _mm_mulhi_epi16(psi_r_m7_m5, ONE_OVER_SQRT_2);
+    psi_r_m7_m5 = _mm_slli_epi16(psi_r_m7_m5, 1);
+    psi_r_m7_m7 = _mm_mulhi_epi16(psi_r_m7_m7, ONE_OVER_SQRT_2);
+    psi_r_m7_m7 = _mm_slli_epi16(psi_r_m7_m7, 1);
+
+    psi_i_p7_p7 = _mm_mulhi_epi16(psi_i_p7_p7, ONE_OVER_SQRT_2);
+    psi_i_p7_p7 = _mm_slli_epi16(psi_i_p7_p7, 1);
+    psi_i_p7_p5 = _mm_mulhi_epi16(psi_i_p7_p5, ONE_OVER_SQRT_2);
+    psi_i_p7_p5 = _mm_slli_epi16(psi_i_p7_p5, 1);
+    psi_i_p7_p3 = _mm_mulhi_epi16(psi_i_p7_p3, ONE_OVER_SQRT_2);
+    psi_i_p7_p3 = _mm_slli_epi16(psi_i_p7_p3, 1);
+    psi_i_p7_p1 = _mm_mulhi_epi16(psi_i_p7_p1, ONE_OVER_SQRT_2);
+    psi_i_p7_p1 = _mm_slli_epi16(psi_i_p7_p1, 1);
+    psi_i_p7_m1 = _mm_mulhi_epi16(psi_i_p7_m1, ONE_OVER_SQRT_2);
+    psi_i_p7_m1 = _mm_slli_epi16(psi_i_p7_m1, 1);
+    psi_i_p7_m3 = _mm_mulhi_epi16(psi_i_p7_m3, ONE_OVER_SQRT_2);
+    psi_i_p7_m3 = _mm_slli_epi16(psi_i_p7_m3, 1);
+    psi_i_p7_m5 = _mm_mulhi_epi16(psi_i_p7_m5, ONE_OVER_SQRT_2);
+    psi_i_p7_m5 = _mm_slli_epi16(psi_i_p7_m5, 1);
+    psi_i_p7_m7 = _mm_mulhi_epi16(psi_i_p7_m7, ONE_OVER_SQRT_2);
+    psi_i_p7_m7 = _mm_slli_epi16(psi_i_p7_m7, 1);
+    psi_i_p5_p7 = _mm_mulhi_epi16(psi_i_p5_p7, ONE_OVER_SQRT_2);
+    psi_i_p5_p7 = _mm_slli_epi16(psi_i_p5_p7, 1);
+    psi_i_p5_p5 = _mm_mulhi_epi16(psi_i_p5_p5, ONE_OVER_SQRT_2);
+    psi_i_p5_p5 = _mm_slli_epi16(psi_i_p5_p5, 1);
+    psi_i_p5_p3 = _mm_mulhi_epi16(psi_i_p5_p3, ONE_OVER_SQRT_2);
+    psi_i_p5_p3 = _mm_slli_epi16(psi_i_p5_p3, 1);
+    psi_i_p5_p1 = _mm_mulhi_epi16(psi_i_p5_p1, ONE_OVER_SQRT_2);
+    psi_i_p5_p1 = _mm_slli_epi16(psi_i_p5_p1, 1);
+    psi_i_p5_m1 = _mm_mulhi_epi16(psi_i_p5_m1, ONE_OVER_SQRT_2);
+    psi_i_p5_m1 = _mm_slli_epi16(psi_i_p5_m1, 1);
+    psi_i_p5_m3 = _mm_mulhi_epi16(psi_i_p5_m3, ONE_OVER_SQRT_2);
+    psi_i_p5_m3 = _mm_slli_epi16(psi_i_p5_m3, 1);
+    psi_i_p5_m5 = _mm_mulhi_epi16(psi_i_p5_m5, ONE_OVER_SQRT_2);
+    psi_i_p5_m5 = _mm_slli_epi16(psi_i_p5_m5, 1);
+    psi_i_p5_m7 = _mm_mulhi_epi16(psi_i_p5_m7, ONE_OVER_SQRT_2);
+    psi_i_p5_m7 = _mm_slli_epi16(psi_i_p5_m7, 1);
+    psi_i_p3_p7 = _mm_mulhi_epi16(psi_i_p3_p7, ONE_OVER_SQRT_2);
+    psi_i_p3_p7 = _mm_slli_epi16(psi_i_p3_p7, 1);
+    psi_i_p3_p5 = _mm_mulhi_epi16(psi_i_p3_p5, ONE_OVER_SQRT_2);
+    psi_i_p3_p5 = _mm_slli_epi16(psi_i_p3_p5, 1);
+    psi_i_p3_p3 = _mm_mulhi_epi16(psi_i_p3_p3, ONE_OVER_SQRT_2);
+    psi_i_p3_p3 = _mm_slli_epi16(psi_i_p3_p3, 1);
+    psi_i_p3_p1 = _mm_mulhi_epi16(psi_i_p3_p1, ONE_OVER_SQRT_2);
+    psi_i_p3_p1 = _mm_slli_epi16(psi_i_p3_p1, 1);
+    psi_i_p3_m1 = _mm_mulhi_epi16(psi_i_p3_m1, ONE_OVER_SQRT_2);
+    psi_i_p3_m1 = _mm_slli_epi16(psi_i_p3_m1, 1);
+    psi_i_p3_m3 = _mm_mulhi_epi16(psi_i_p3_m3, ONE_OVER_SQRT_2);
+    psi_i_p3_m3 = _mm_slli_epi16(psi_i_p3_m3, 1);
+    psi_i_p3_m5 = _mm_mulhi_epi16(psi_i_p3_m5, ONE_OVER_SQRT_2);
+    psi_i_p3_m5 = _mm_slli_epi16(psi_i_p3_m5, 1);
+    psi_i_p3_m7 = _mm_mulhi_epi16(psi_i_p3_m7, ONE_OVER_SQRT_2);
+    psi_i_p3_m7 = _mm_slli_epi16(psi_i_p3_m7, 1);
+    psi_i_p1_p7 = _mm_mulhi_epi16(psi_i_p1_p7, ONE_OVER_SQRT_2);
+    psi_i_p1_p7 = _mm_slli_epi16(psi_i_p1_p7, 1);
+    psi_i_p1_p5 = _mm_mulhi_epi16(psi_i_p1_p5, ONE_OVER_SQRT_2);
+    psi_i_p1_p5 = _mm_slli_epi16(psi_i_p1_p5, 1);
+    psi_i_p1_p3 = _mm_mulhi_epi16(psi_i_p1_p3, ONE_OVER_SQRT_2);
+    psi_i_p1_p3 = _mm_slli_epi16(psi_i_p1_p3, 1);
+    psi_i_p1_p1 = _mm_mulhi_epi16(psi_i_p1_p1, ONE_OVER_SQRT_2);
+    psi_i_p1_p1 = _mm_slli_epi16(psi_i_p1_p1, 1);
+    psi_i_p1_m1 = _mm_mulhi_epi16(psi_i_p1_m1, ONE_OVER_SQRT_2);
+    psi_i_p1_m1 = _mm_slli_epi16(psi_i_p1_m1, 1);
+    psi_i_p1_m3 = _mm_mulhi_epi16(psi_i_p1_m3, ONE_OVER_SQRT_2);
+    psi_i_p1_m3 = _mm_slli_epi16(psi_i_p1_m3, 1);
+    psi_i_p1_m5 = _mm_mulhi_epi16(psi_i_p1_m5, ONE_OVER_SQRT_2);
+    psi_i_p1_m5 = _mm_slli_epi16(psi_i_p1_m5, 1);
+    psi_i_p1_m7 = _mm_mulhi_epi16(psi_i_p1_m7, ONE_OVER_SQRT_2);
+    psi_i_p1_m7 = _mm_slli_epi16(psi_i_p1_m7, 1);
+    psi_i_m1_p7 = _mm_mulhi_epi16(psi_i_m1_p7, ONE_OVER_SQRT_2);
+    psi_i_m1_p7 = _mm_slli_epi16(psi_i_m1_p7, 1);
+    psi_i_m1_p5 = _mm_mulhi_epi16(psi_i_m1_p5, ONE_OVER_SQRT_2);
+    psi_i_m1_p5 = _mm_slli_epi16(psi_i_m1_p5, 1);
+    psi_i_m1_p3 = _mm_mulhi_epi16(psi_i_m1_p3, ONE_OVER_SQRT_2);
+    psi_i_m1_p3 = _mm_slli_epi16(psi_i_m1_p3, 1);
+    psi_i_m1_p1 = _mm_mulhi_epi16(psi_i_m1_p1, ONE_OVER_SQRT_2);
+    psi_i_m1_p1 = _mm_slli_epi16(psi_i_m1_p1, 1);
+    psi_i_m1_m1 = _mm_mulhi_epi16(psi_i_m1_m1, ONE_OVER_SQRT_2);
+    psi_i_m1_m1 = _mm_slli_epi16(psi_i_m1_m1, 1);
+    psi_i_m1_m3 = _mm_mulhi_epi16(psi_i_m1_m3, ONE_OVER_SQRT_2);
+    psi_i_m1_m3 = _mm_slli_epi16(psi_i_m1_m3, 1);
+    psi_i_m1_m5 = _mm_mulhi_epi16(psi_i_m1_m5, ONE_OVER_SQRT_2);
+    psi_i_m1_m5 = _mm_slli_epi16(psi_i_m1_m5, 1);
+    psi_i_m1_m7 = _mm_mulhi_epi16(psi_i_m1_m7, ONE_OVER_SQRT_2);
+    psi_i_m1_m7 = _mm_slli_epi16(psi_i_m1_m7, 1);
+    psi_i_m3_p7 = _mm_mulhi_epi16(psi_i_m3_p7, ONE_OVER_SQRT_2);
+    psi_i_m3_p7 = _mm_slli_epi16(psi_i_m3_p7, 1);
+    psi_i_m3_p5 = _mm_mulhi_epi16(psi_i_m3_p5, ONE_OVER_SQRT_2);
+    psi_i_m3_p5 = _mm_slli_epi16(psi_i_m3_p5, 1);
+    psi_i_m3_p3 = _mm_mulhi_epi16(psi_i_m3_p3, ONE_OVER_SQRT_2);
+    psi_i_m3_p3 = _mm_slli_epi16(psi_i_m3_p3, 1);
+    psi_i_m3_p1 = _mm_mulhi_epi16(psi_i_m3_p1, ONE_OVER_SQRT_2);
+    psi_i_m3_p1 = _mm_slli_epi16(psi_i_m3_p1, 1);
+    psi_i_m3_m1 = _mm_mulhi_epi16(psi_i_m3_m1, ONE_OVER_SQRT_2);
+    psi_i_m3_m1 = _mm_slli_epi16(psi_i_m3_m1, 1);
+    psi_i_m3_m3 = _mm_mulhi_epi16(psi_i_m3_m3, ONE_OVER_SQRT_2);
+    psi_i_m3_m3 = _mm_slli_epi16(psi_i_m3_m3, 1);
+    psi_i_m3_m5 = _mm_mulhi_epi16(psi_i_m3_m5, ONE_OVER_SQRT_2);
+    psi_i_m3_m5 = _mm_slli_epi16(psi_i_m3_m5, 1);
+    psi_i_m3_m7 = _mm_mulhi_epi16(psi_i_m3_m7, ONE_OVER_SQRT_2);
+    psi_i_m3_m7 = _mm_slli_epi16(psi_i_m3_m7, 1);
+    psi_i_m5_p7 = _mm_mulhi_epi16(psi_i_m5_p7, ONE_OVER_SQRT_2);
+    psi_i_m5_p7 = _mm_slli_epi16(psi_i_m5_p7, 1);
+    psi_i_m5_p5 = _mm_mulhi_epi16(psi_i_m5_p5, ONE_OVER_SQRT_2);
+    psi_i_m5_p5 = _mm_slli_epi16(psi_i_m5_p5, 1);
+    psi_i_m5_p3 = _mm_mulhi_epi16(psi_i_m5_p3, ONE_OVER_SQRT_2);
+    psi_i_m5_p3 = _mm_slli_epi16(psi_i_m5_p3, 1);
+    psi_i_m5_p1 = _mm_mulhi_epi16(psi_i_m5_p1, ONE_OVER_SQRT_2);
+    psi_i_m5_p1 = _mm_slli_epi16(psi_i_m5_p1, 1);
+    psi_i_m5_m1 = _mm_mulhi_epi16(psi_i_m5_m1, ONE_OVER_SQRT_2);
+    psi_i_m5_m1 = _mm_slli_epi16(psi_i_m5_m1, 1);
+    psi_i_m5_m3 = _mm_mulhi_epi16(psi_i_m5_m3, ONE_OVER_SQRT_2);
+    psi_i_m5_m3 = _mm_slli_epi16(psi_i_m5_m3, 1);
+    psi_i_m5_m5 = _mm_mulhi_epi16(psi_i_m5_m5, ONE_OVER_SQRT_2);
+    psi_i_m5_m5 = _mm_slli_epi16(psi_i_m5_m5, 1);
+    psi_i_m5_m7 = _mm_mulhi_epi16(psi_i_m5_m7, ONE_OVER_SQRT_2);
+    psi_i_m5_m7 = _mm_slli_epi16(psi_i_m5_m7, 1);
+    psi_i_m7_p7 = _mm_mulhi_epi16(psi_i_m7_p7, ONE_OVER_SQRT_2);
+    psi_i_m7_p7 = _mm_slli_epi16(psi_i_m7_p7, 1);
+    psi_i_m7_p5 = _mm_mulhi_epi16(psi_i_m7_p5, ONE_OVER_SQRT_2);
+    psi_i_m7_p5 = _mm_slli_epi16(psi_i_m7_p5, 1);
+    psi_i_m7_p3 = _mm_mulhi_epi16(psi_i_m7_p3, ONE_OVER_SQRT_2);
+    psi_i_m7_p3 = _mm_slli_epi16(psi_i_m7_p3, 1);
+    psi_i_m7_p1 = _mm_mulhi_epi16(psi_i_m7_p1, ONE_OVER_SQRT_2);
+    psi_i_m7_p1 = _mm_slli_epi16(psi_i_m7_p1, 1);
+    psi_i_m7_m1 = _mm_mulhi_epi16(psi_i_m7_m1, ONE_OVER_SQRT_2);
+    psi_i_m7_m1 = _mm_slli_epi16(psi_i_m7_m1, 1);
+    psi_i_m7_m3 = _mm_mulhi_epi16(psi_i_m7_m3, ONE_OVER_SQRT_2);
+    psi_i_m7_m3 = _mm_slli_epi16(psi_i_m7_m3, 1);
+    psi_i_m7_m5 = _mm_mulhi_epi16(psi_i_m7_m5, ONE_OVER_SQRT_2);
+    psi_i_m7_m5 = _mm_slli_epi16(psi_i_m7_m5, 1);
+    psi_i_m7_m7 = _mm_mulhi_epi16(psi_i_m7_m7, ONE_OVER_SQRT_2);
+    psi_i_m7_m7 = _mm_slli_epi16(psi_i_m7_m7, 1);
+
+    psi_a_p7_p7 = _mm_adds_epi16(psi_r_p7_p7, psi_i_p7_p7);
+    psi_a_p7_p5 = _mm_adds_epi16(psi_r_p7_p5, psi_i_p7_p5);
+    psi_a_p7_p3 = _mm_adds_epi16(psi_r_p7_p3, psi_i_p7_p3);
+    psi_a_p7_p1 = _mm_adds_epi16(psi_r_p7_p1, psi_i_p7_p1);
+    psi_a_p7_m1 = _mm_adds_epi16(psi_r_p7_m1, psi_i_p7_m1);
+    psi_a_p7_m3 = _mm_adds_epi16(psi_r_p7_m3, psi_i_p7_m3);
+    psi_a_p7_m5 = _mm_adds_epi16(psi_r_p7_m5, psi_i_p7_m5);
+    psi_a_p7_m7 = _mm_adds_epi16(psi_r_p7_m7, psi_i_p7_m7);
+    psi_a_p5_p7 = _mm_adds_epi16(psi_r_p5_p7, psi_i_p5_p7);
+    psi_a_p5_p5 = _mm_adds_epi16(psi_r_p5_p5, psi_i_p5_p5);
+    psi_a_p5_p3 = _mm_adds_epi16(psi_r_p5_p3, psi_i_p5_p3);
+    psi_a_p5_p1 = _mm_adds_epi16(psi_r_p5_p1, psi_i_p5_p1);
+    psi_a_p5_m1 = _mm_adds_epi16(psi_r_p5_m1, psi_i_p5_m1);
+    psi_a_p5_m3 = _mm_adds_epi16(psi_r_p5_m3, psi_i_p5_m3);
+    psi_a_p5_m5 = _mm_adds_epi16(psi_r_p5_m5, psi_i_p5_m5);
+    psi_a_p5_m7 = _mm_adds_epi16(psi_r_p5_m7, psi_i_p5_m7);
+    psi_a_p3_p7 = _mm_adds_epi16(psi_r_p3_p7, psi_i_p3_p7);
+    psi_a_p3_p5 = _mm_adds_epi16(psi_r_p3_p5, psi_i_p3_p5);
+    psi_a_p3_p3 = _mm_adds_epi16(psi_r_p3_p3, psi_i_p3_p3);
+    psi_a_p3_p1 = _mm_adds_epi16(psi_r_p3_p1, psi_i_p3_p1);
+    psi_a_p3_m1 = _mm_adds_epi16(psi_r_p3_m1, psi_i_p3_m1);
+    psi_a_p3_m3 = _mm_adds_epi16(psi_r_p3_m3, psi_i_p3_m3);
+    psi_a_p3_m5 = _mm_adds_epi16(psi_r_p3_m5, psi_i_p3_m5);
+    psi_a_p3_m7 = _mm_adds_epi16(psi_r_p3_m7, psi_i_p3_m7);
+    psi_a_p1_p7 = _mm_adds_epi16(psi_r_p1_p7, psi_i_p1_p7);
+    psi_a_p1_p5 = _mm_adds_epi16(psi_r_p1_p5, psi_i_p1_p5);
+    psi_a_p1_p3 = _mm_adds_epi16(psi_r_p1_p3, psi_i_p1_p3);
+    psi_a_p1_p1 = _mm_adds_epi16(psi_r_p1_p1, psi_i_p1_p1);
+    psi_a_p1_m1 = _mm_adds_epi16(psi_r_p1_m1, psi_i_p1_m1);
+    psi_a_p1_m3 = _mm_adds_epi16(psi_r_p1_m3, psi_i_p1_m3);
+    psi_a_p1_m5 = _mm_adds_epi16(psi_r_p1_m5, psi_i_p1_m5);
+    psi_a_p1_m7 = _mm_adds_epi16(psi_r_p1_m7, psi_i_p1_m7);
+    psi_a_m1_p7 = _mm_adds_epi16(psi_r_m1_p7, psi_i_m1_p7);
+    psi_a_m1_p5 = _mm_adds_epi16(psi_r_m1_p5, psi_i_m1_p5);
+    psi_a_m1_p3 = _mm_adds_epi16(psi_r_m1_p3, psi_i_m1_p3);
+    psi_a_m1_p1 = _mm_adds_epi16(psi_r_m1_p1, psi_i_m1_p1);
+    psi_a_m1_m1 = _mm_adds_epi16(psi_r_m1_m1, psi_i_m1_m1);
+    psi_a_m1_m3 = _mm_adds_epi16(psi_r_m1_m3, psi_i_m1_m3);
+    psi_a_m1_m5 = _mm_adds_epi16(psi_r_m1_m5, psi_i_m1_m5);
+    psi_a_m1_m7 = _mm_adds_epi16(psi_r_m1_m7, psi_i_m1_m7);
+    psi_a_m3_p7 = _mm_adds_epi16(psi_r_m3_p7, psi_i_m3_p7);
+    psi_a_m3_p5 = _mm_adds_epi16(psi_r_m3_p5, psi_i_m3_p5);
+    psi_a_m3_p3 = _mm_adds_epi16(psi_r_m3_p3, psi_i_m3_p3);
+    psi_a_m3_p1 = _mm_adds_epi16(psi_r_m3_p1, psi_i_m3_p1);
+    psi_a_m3_m1 = _mm_adds_epi16(psi_r_m3_m1, psi_i_m3_m1);
+    psi_a_m3_m3 = _mm_adds_epi16(psi_r_m3_m3, psi_i_m3_m3);
+    psi_a_m3_m5 = _mm_adds_epi16(psi_r_m3_m5, psi_i_m3_m5);
+    psi_a_m3_m7 = _mm_adds_epi16(psi_r_m3_m7, psi_i_m3_m7);
+    psi_a_m5_p7 = _mm_adds_epi16(psi_r_m5_p7, psi_i_m5_p7);
+    psi_a_m5_p5 = _mm_adds_epi16(psi_r_m5_p5, psi_i_m5_p5);
+    psi_a_m5_p3 = _mm_adds_epi16(psi_r_m5_p3, psi_i_m5_p3);
+    psi_a_m5_p1 = _mm_adds_epi16(psi_r_m5_p1, psi_i_m5_p1);
+    psi_a_m5_m1 = _mm_adds_epi16(psi_r_m5_m1, psi_i_m5_m1);
+    psi_a_m5_m3 = _mm_adds_epi16(psi_r_m5_m3, psi_i_m5_m3);
+    psi_a_m5_m5 = _mm_adds_epi16(psi_r_m5_m5, psi_i_m5_m5);
+    psi_a_m5_m7 = _mm_adds_epi16(psi_r_m5_m7, psi_i_m5_m7);
+    psi_a_m7_p7 = _mm_adds_epi16(psi_r_m7_p7, psi_i_m7_p7);
+    psi_a_m7_p5 = _mm_adds_epi16(psi_r_m7_p5, psi_i_m7_p5);
+    psi_a_m7_p3 = _mm_adds_epi16(psi_r_m7_p3, psi_i_m7_p3);
+    psi_a_m7_p1 = _mm_adds_epi16(psi_r_m7_p1, psi_i_m7_p1);
+    psi_a_m7_m1 = _mm_adds_epi16(psi_r_m7_m1, psi_i_m7_m1);
+    psi_a_m7_m3 = _mm_adds_epi16(psi_r_m7_m3, psi_i_m7_m3);
+    psi_a_m7_m5 = _mm_adds_epi16(psi_r_m7_m5, psi_i_m7_m5);
+    psi_a_m7_m7 = _mm_adds_epi16(psi_r_m7_m7, psi_i_m7_m7);
+
+    // Computing different multiples of ||h0||^2
+    // x=1, y=1
+    ch_mag_2_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,ONE_OVER_FOUR_SQRT_42);
+    ch_mag_2_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_2_over_42_with_sigma2,1);
+    // x=1, y=3
+    ch_mag_10_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,FIVE_OVER_FOUR_SQRT_42);
+    ch_mag_10_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_10_over_42_with_sigma2,1);
+    // x=1, x=5
+    ch_mag_26_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,THIRTEEN_OVER_FOUR_SQRT_42);
+    ch_mag_26_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_26_over_42_with_sigma2,1);
+    // x=1, y=7
+    ch_mag_50_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYFIVE_OVER_FOUR_SQRT_42);
+    ch_mag_50_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_50_over_42_with_sigma2,1);
+    // x=3, y=3
+    ch_mag_18_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,NINE_OVER_FOUR_SQRT_42);
+    ch_mag_18_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_18_over_42_with_sigma2,1);
+    // x=3, y=5
+    ch_mag_34_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,SEVENTEEN_OVER_FOUR_SQRT_42);
+    ch_mag_34_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_34_over_42_with_sigma2,1);
+    // x=3, y=7
+    ch_mag_58_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYNINE_OVER_FOUR_SQRT_42);
+    ch_mag_58_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_58_over_42_with_sigma2,2);
+    // x=5, y=5
+    ch_mag_50_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYFIVE_OVER_FOUR_SQRT_42);
+    ch_mag_50_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_50_over_42_with_sigma2,1);
+    // x=5, y=7
+    ch_mag_74_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,THIRTYSEVEN_OVER_FOUR_SQRT_42);
+    ch_mag_74_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_74_over_42_with_sigma2,2);
+    // x=7, y=7
+    ch_mag_98_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,FORTYNINE_OVER_FOUR_SQRT_42);
+    ch_mag_98_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_98_over_42_with_sigma2,2);
+
+    // Computing Metrics
+    xmm1 = _mm_adds_epi16(psi_a_p7_p7, y0_p_7_7);
+    bit_met_p7_p7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p7_p5, y0_p_7_5);
+    bit_met_p7_p5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p7_p3, y0_p_7_3);
+    bit_met_p7_p3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p7_p1, y0_p_7_1);
+    bit_met_p7_p1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p7_m1, y0_m_7_1);
+    bit_met_p7_m1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p7_m3, y0_m_7_3);
+    bit_met_p7_m3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p7_m5, y0_m_7_5);
+    bit_met_p7_m5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p7_m7, y0_m_7_7);
+    bit_met_p7_m7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_p7, y0_p_5_7);
+    bit_met_p5_p7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_p5, y0_p_5_5);
+    bit_met_p5_p5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_p3, y0_p_5_3);
+    bit_met_p5_p3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_p1, y0_p_5_1);
+    bit_met_p5_p1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_m1, y0_m_5_1);
+    bit_met_p5_m1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_m3, y0_m_5_3);
+    bit_met_p5_m3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_m5, y0_m_5_5);
+    bit_met_p5_m5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p5_m7, y0_m_5_7);
+    bit_met_p5_m7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_p7, y0_p_3_7);
+    bit_met_p3_p7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_p5, y0_p_3_5);
+    bit_met_p3_p5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_p3, y0_p_3_3);
+    bit_met_p3_p3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_p1, y0_p_3_1);
+    bit_met_p3_p1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_m1, y0_m_3_1);
+    bit_met_p3_m1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_m3, y0_m_3_3);
+    bit_met_p3_m3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_m5, y0_m_3_5);
+    bit_met_p3_m5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p3_m7, y0_m_3_7);
+    bit_met_p3_m7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_p7, y0_p_1_7);
+    bit_met_p1_p7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_p5, y0_p_1_5);
+    bit_met_p1_p5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_p3, y0_p_1_3);
+    bit_met_p1_p3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_p1, y0_p_1_1);
+    bit_met_p1_p1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_m1, y0_m_1_1);
+    bit_met_p1_m1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_m3, y0_m_1_3);
+    bit_met_p1_m3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_m5, y0_m_1_5);
+    bit_met_p1_m5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_adds_epi16(psi_a_p1_m7, y0_m_1_7);
+    bit_met_p1_m7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+
+    xmm1 = _mm_subs_epi16(psi_a_m1_p7, y0_m_1_7);
+    bit_met_m1_p7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m1_p5, y0_m_1_5);
+    bit_met_m1_p5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m1_p3, y0_m_1_3);
+    bit_met_m1_p3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m1_p1, y0_m_1_1);
+    bit_met_m1_p1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m1_m1, y0_p_1_1);
+    bit_met_m1_m1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m1_m3, y0_p_1_3);
+    bit_met_m1_m3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m1_m5, y0_p_1_5);
+    bit_met_m1_m5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m1_m7, y0_p_1_7);
+    bit_met_m1_m7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_p7, y0_m_3_7);
+    bit_met_m3_p7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_p5, y0_m_3_5);
+    bit_met_m3_p5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_p3, y0_m_3_3);
+    bit_met_m3_p3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_p1, y0_m_3_1);
+    bit_met_m3_p1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_m1, y0_p_3_1);
+    bit_met_m3_m1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_m3, y0_p_3_3);
+    bit_met_m3_m3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_m5, y0_p_3_5);
+    bit_met_m3_m5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m3_m7, y0_p_3_7);
+    bit_met_m3_m7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_p7, y0_m_5_7);
+    bit_met_m5_p7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_p5, y0_m_5_5);
+    bit_met_m5_p5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_p3, y0_m_5_3);
+    bit_met_m5_p3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_p1, y0_m_5_1);
+    bit_met_m5_p1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_m1, y0_p_5_1);
+    bit_met_m5_m1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_m3, y0_p_5_3);
+    bit_met_m5_m3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_m5, y0_p_5_5);
+    bit_met_m5_m5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m5_m7, y0_p_5_7);
+    bit_met_m5_m7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_p7, y0_m_7_7);
+    bit_met_m7_p7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_p5, y0_m_7_5);
+    bit_met_m7_p5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_p3, y0_m_7_3);
+    bit_met_m7_p3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_p1, y0_m_7_1);
+    bit_met_m7_p1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_m1, y0_p_7_1);
+    bit_met_m7_m1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_m3, y0_p_7_3);
+    bit_met_m7_m3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_m5, y0_p_7_5);
+    bit_met_m7_m5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm1 = _mm_subs_epi16(psi_a_m7_m7, y0_p_7_7);
+    bit_met_m7_m7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+
+    // Detection for 1st bit (LTE mapping)
+    // bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m7_p7, bit_met_m7_p5);
+    xmm1 = _mm_max_epi16(bit_met_m7_p3, bit_met_m7_p1);
+    xmm2 = _mm_max_epi16(bit_met_m7_m1, bit_met_m7_m3);
+    xmm3 = _mm_max_epi16(bit_met_m7_m5, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m5_p7, bit_met_m5_p5);
+    xmm1 = _mm_max_epi16(bit_met_m5_p3, bit_met_m5_p1);
+    xmm2 = _mm_max_epi16(bit_met_m5_m1, bit_met_m5_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m5_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m3_p7, bit_met_m3_p5);
+    xmm1 = _mm_max_epi16(bit_met_m3_p3, bit_met_m3_p1);
+    xmm2 = _mm_max_epi16(bit_met_m3_m1, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m3_m5, bit_met_m3_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_p7, bit_met_m1_p5);
+    xmm1 = _mm_max_epi16(bit_met_m1_p3, bit_met_m1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m1_m3);
+    xmm3 = _mm_max_epi16(bit_met_m1_m5, bit_met_m1_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    // bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p7_p5);
+    xmm1 = _mm_max_epi16(bit_met_p7_p3, bit_met_p7_p1);
+    xmm2 = _mm_max_epi16(bit_met_p7_m1, bit_met_p7_m3);
+    xmm3 = _mm_max_epi16(bit_met_p7_m5, bit_met_p7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_p7, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p5_p3, bit_met_p5_p1);
+    xmm2 = _mm_max_epi16(bit_met_p5_m1, bit_met_p5_m3);
+    xmm3 = _mm_max_epi16(bit_met_p5_m5, bit_met_p5_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_p7, bit_met_p3_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p3_p1);
+    xmm2 = _mm_max_epi16(bit_met_p3_m1, bit_met_p3_m3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m5, bit_met_p3_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_p7, bit_met_p1_p5);
+    xmm1 = _mm_max_epi16(bit_met_p1_p3, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_p1_m1, bit_met_p1_m3);
+    xmm3 = _mm_max_epi16(bit_met_p1_m5, bit_met_p1_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y0r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 2nd bit (LTE mapping)
+    // bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    // bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m7_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m7_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y1r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 3rd bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_m7_m7, bit_met_m7_m5);
+    xmm1 = _mm_max_epi16(bit_met_m7_m3, bit_met_m7_m1);
+    xmm2 = _mm_max_epi16(bit_met_m7_p1, bit_met_m7_p3);
+    xmm3 = _mm_max_epi16(bit_met_m7_p5, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m5_m7, bit_met_m5_m5);
+    xmm1 = _mm_max_epi16(bit_met_m5_m3, bit_met_m5_m1);
+    xmm2 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_m7, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p5_m3, bit_met_p5_m1);
+    xmm2 = _mm_max_epi16(bit_met_p5_p1, bit_met_p5_p3);
+    xmm3 = _mm_max_epi16(bit_met_p5_p5, bit_met_p5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p7_m5);
+    xmm1 = _mm_max_epi16(bit_met_p7_m3, bit_met_p7_m1);
+    xmm2 = _mm_max_epi16(bit_met_p7_p1, bit_met_p7_p3);
+    xmm3 = _mm_max_epi16(bit_met_p7_p5, bit_met_p7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_m3_m7, bit_met_m3_m5);
+    xmm1 = _mm_max_epi16(bit_met_m3_m3, bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_p5, bit_met_m3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_m7, bit_met_m1_m5);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3, bit_met_m1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m1_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p5, bit_met_m1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_m7, bit_met_p1_m5);
+    xmm1 = _mm_max_epi16(bit_met_p1_m3, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1, bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_p5, bit_met_p1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_m7, bit_met_p3_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1, bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_p5, bit_met_p3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y2r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 4th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m7_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y0i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+
+    // Detection for 5th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_m7_m7, bit_met_m7_m5);
+    xmm1 = _mm_max_epi16(bit_met_m7_m3, bit_met_m7_m1);
+    xmm2 = _mm_max_epi16(bit_met_m7_p1, bit_met_m7_p3);
+    xmm3 = _mm_max_epi16(bit_met_m7_p5, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_m7, bit_met_m1_m5);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3, bit_met_m1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m1_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p5, bit_met_m1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_m7, bit_met_p1_m5);
+    xmm1 = _mm_max_epi16(bit_met_p1_m3, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1, bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_p5, bit_met_p1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p7_m5);
+    xmm1 = _mm_max_epi16(bit_met_p7_m3, bit_met_p7_m1);
+    xmm2 = _mm_max_epi16(bit_met_p7_p1, bit_met_p7_p3);
+    xmm3 = _mm_max_epi16(bit_met_p7_p5, bit_met_p7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_m5_m7, bit_met_m5_m5);
+    xmm1 = _mm_max_epi16(bit_met_m5_m3, bit_met_m5_m1);
+    xmm2 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m3_m7, bit_met_m3_m5);
+    xmm1 = _mm_max_epi16(bit_met_m3_m3, bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_p5, bit_met_m3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_m7, bit_met_p3_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1, bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_p5, bit_met_p3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_m7, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p5_m3, bit_met_p5_m1);
+    xmm2 = _mm_max_epi16(bit_met_p5_p1, bit_met_p5_p3);
+    xmm3 = _mm_max_epi16(bit_met_p5_p5, bit_met_p5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y1i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 6th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m7_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y2i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+
+    // map to output stream, difficult to do in SIMD since we have 6 16bit LLRs
+    // RE 1
+    j = 24*i;
+    stream0_out[j + 0] = ((short *)&y0r)[0];
+    stream0_out[j + 1] = ((short *)&y1r)[0];
+    stream0_out[j + 2] = ((short *)&y2r)[0];
+    stream0_out[j + 3] = ((short *)&y0i)[0];
+    stream0_out[j + 4] = ((short *)&y1i)[0];
+    stream0_out[j + 5] = ((short *)&y2i)[0];
+    // RE 2
+    stream0_out[j + 6] = ((short *)&y0r)[1];
+    stream0_out[j + 7] = ((short *)&y1r)[1];
+    stream0_out[j + 8] = ((short *)&y2r)[1];
+    stream0_out[j + 9] = ((short *)&y0i)[1];
+    stream0_out[j + 10] = ((short *)&y1i)[1];
+    stream0_out[j + 11] = ((short *)&y2i)[1];
+    // RE 3
+    stream0_out[j + 12] = ((short *)&y0r)[2];
+    stream0_out[j + 13] = ((short *)&y1r)[2];
+    stream0_out[j + 14] = ((short *)&y2r)[2];
+    stream0_out[j + 15] = ((short *)&y0i)[2];
+    stream0_out[j + 16] = ((short *)&y1i)[2];
+    stream0_out[j + 17] = ((short *)&y2i)[2];
+    // RE 4
+    stream0_out[j + 18] = ((short *)&y0r)[3];
+    stream0_out[j + 19] = ((short *)&y1r)[3];
+    stream0_out[j + 20] = ((short *)&y2r)[3];
+    stream0_out[j + 21] = ((short *)&y0i)[3];
+    stream0_out[j + 22] = ((short *)&y1i)[3];
+    stream0_out[j + 23] = ((short *)&y2i)[3];
+    // RE 5
+    stream0_out[j + 24] = ((short *)&y0r)[4];
+    stream0_out[j + 25] = ((short *)&y1r)[4];
+    stream0_out[j + 26] = ((short *)&y2r)[4];
+    stream0_out[j + 27] = ((short *)&y0i)[4];
+    stream0_out[j + 28] = ((short *)&y1i)[4];
+    stream0_out[j + 29] = ((short *)&y2i)[4];
+    // RE 6
+    stream0_out[j + 30] = ((short *)&y0r)[5];
+    stream0_out[j + 31] = ((short *)&y1r)[5];
+    stream0_out[j + 32] = ((short *)&y2r)[5];
+    stream0_out[j + 33] = ((short *)&y0i)[5];
+    stream0_out[j + 34] = ((short *)&y1i)[5];
+    stream0_out[j + 35] = ((short *)&y2i)[5];
+    // RE 7
+    stream0_out[j + 36] = ((short *)&y0r)[6];
+    stream0_out[j + 37] = ((short *)&y1r)[6];
+    stream0_out[j + 38] = ((short *)&y2r)[6];
+    stream0_out[j + 39] = ((short *)&y0i)[6];
+    stream0_out[j + 40] = ((short *)&y1i)[6];
+    stream0_out[j + 41] = ((short *)&y2i)[6];
+    // RE 8
+    stream0_out[j + 42] = ((short *)&y0r)[7];
+    stream0_out[j + 43] = ((short *)&y1r)[7];
+    stream0_out[j + 44] = ((short *)&y2r)[7];
+    stream0_out[j + 45] = ((short *)&y0i)[7];
+    stream0_out[j + 46] = ((short *)&y1i)[7];
+    stream0_out[j + 47] = ((short *)&y2i)[7];
+#elif defined(__arm__)
+
+#endif
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+
+int dlsch_64qam_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                         int32_t **rxdataF_comp,
+                         int32_t **rxdataF_comp_i,
+                         int32_t **dl_ch_mag,
+                         int32_t **rho_i,
+                         int16_t *dlsch_llr,
+                         uint8_t symbol,
+                         uint8_t first_symbol_flag,
+                         uint16_t nb_rb,
+                         uint16_t pbch_pss_sss_adjust,
+                         int16_t **llr16p)
+{
+
+  int16_t *rxF      = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i    = (int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag   = (int16_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho      = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  //first symbol has different structure due to more pilots
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  qam64_qpsk((short *)rxF,
+             (short *)rxF_i,
+             (short *)ch_mag,
+             (short *)llr16,
+             (short *)rho,
+             len);
+
+  llr16 += (6*len);
+  *llr16p = (short *)llr16;
+  return(0);
+}
+
+
+
+void qam64_qam16(short *stream0_in,
+                 short *stream1_in,
+                 short *ch_mag,
+                 short *ch_mag_i,
+                 short *stream0_out,
+                 short *rho01,
+                 int length
+     )
+{
+
+  /*
+    Author: S. Wagner
+    Date: 31-07-12
+
+    Input:
+    stream0_in:  MF filter for 1st stream, i.e., y0=h0'*y
+    stream1_in:  MF filter for 2nd stream, i.e., y1=h1'*y
+    ch_mag:      4*h0/sqrt(42), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    ch_mag_i:    4*h1/sqrt(42), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    rho01:       Channel cross correlation, i.e., h1'*h0
+
+    Output:
+    stream0_out: output LLRs for 1st stream
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+
+  __m128i *rho01_128i      = (__m128i *)rho01;
+  __m128i *stream0_128i_in = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in = (__m128i *)stream1_in;
+  __m128i *ch_mag_128i     = (__m128i *)ch_mag;
+  __m128i *ch_mag_128i_i   = (__m128i *)ch_mag_i;
+
+  __m128i ONE_OVER_SQRT_42 = _mm_set1_epi16(10112); // round(1/sqrt(42)*2^16)
+  __m128i THREE_OVER_SQRT_42 = _mm_set1_epi16(30337); // round(3/sqrt(42)*2^16)
+  __m128i FIVE_OVER_SQRT_42 = _mm_set1_epi16(25281); // round(5/sqrt(42)*2^15)
+  __m128i SEVEN_OVER_SQRT_42 = _mm_set1_epi16(17697); // round(5/sqrt(42)*2^15)
+  __m128i FORTYNINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(30969); // round(49/(4*sqrt(42))*2^14), Q2.14
+  __m128i THIRTYSEVEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(23385); // round(37/(4*sqrt(42))*2^14), Q2.14
+  __m128i TWENTYFIVE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(31601); // round(25/(4*sqrt(42))*2^15)
+  __m128i TWENTYNINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(18329); // round(29/(4*sqrt(42))*2^15), Q2.14
+  __m128i SEVENTEEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(21489); // round(17/(4*sqrt(42))*2^15)
+  __m128i NINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(11376); // round(9/(4*sqrt(42))*2^15)
+  __m128i THIRTEEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(16433); // round(13/(4*sqrt(42))*2^15)
+  __m128i FIVE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(6320); // round(5/(4*sqrt(42))*2^15)
+  __m128i ONE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(1264); // round(1/(4*sqrt(42))*2^15)
+  __m128i ONE_OVER_SQRT_10_Q15 = _mm_set1_epi16(10362); // round(1/sqrt(10)*2^15)
+  __m128i THREE_OVER_SQRT_10 = _mm_set1_epi16(31086); // round(3/sqrt(10)*2^15)
+  __m128i SQRT_10_OVER_FOUR = _mm_set1_epi16(25905); // round(sqrt(10)/4*2^15)
+
+
+  __m128i ch_mag_int;
+  __m128i ch_mag_des;
+  __m128i ch_mag_98_over_42_with_sigma2;
+  __m128i ch_mag_74_over_42_with_sigma2;
+  __m128i ch_mag_58_over_42_with_sigma2;
+  __m128i ch_mag_50_over_42_with_sigma2;
+  __m128i ch_mag_34_over_42_with_sigma2;
+  __m128i ch_mag_18_over_42_with_sigma2;
+  __m128i ch_mag_26_over_42_with_sigma2;
+  __m128i ch_mag_10_over_42_with_sigma2;
+  __m128i ch_mag_2_over_42_with_sigma2;
+  __m128i  y0r_one_over_sqrt_21;
+  __m128i  y0r_three_over_sqrt_21;
+  __m128i  y0r_five_over_sqrt_21;
+  __m128i  y0r_seven_over_sqrt_21;
+  __m128i  y0i_one_over_sqrt_21;
+  __m128i  y0i_three_over_sqrt_21;
+  __m128i  y0i_five_over_sqrt_21;
+  __m128i  y0i_seven_over_sqrt_21;
+
+#elif defined(__arm__)
+
+#endif
+  int i,j;
+
+
+
+  for (i=0; i<length>>2; i+=2) {
+
+#if defined(__x86_64__) || defined(__i386__)
+    // Get rho
+    xmm0 = rho01_128i[i];
+    xmm1 = rho01_128i[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // Compute the different rhos
+    rho_rpi_1_1 = _mm_mulhi_epi16(rho_rpi, ONE_OVER_SQRT_42);
+    rho_rmi_1_1 = _mm_mulhi_epi16(rho_rmi, ONE_OVER_SQRT_42);
+    rho_rpi_3_3 = _mm_mulhi_epi16(rho_rpi, THREE_OVER_SQRT_42);
+    rho_rmi_3_3 = _mm_mulhi_epi16(rho_rmi, THREE_OVER_SQRT_42);
+    rho_rpi_5_5 = _mm_mulhi_epi16(rho_rpi, FIVE_OVER_SQRT_42);
+    rho_rmi_5_5 = _mm_mulhi_epi16(rho_rmi, FIVE_OVER_SQRT_42);
+    rho_rpi_7_7 = _mm_mulhi_epi16(rho_rpi, SEVEN_OVER_SQRT_42);
+    rho_rmi_7_7 = _mm_mulhi_epi16(rho_rmi, SEVEN_OVER_SQRT_42);
+
+    rho_rpi_5_5 = _mm_slli_epi16(rho_rpi_5_5, 1);
+    rho_rmi_5_5 = _mm_slli_epi16(rho_rmi_5_5, 1);
+    rho_rpi_7_7 = _mm_slli_epi16(rho_rpi_7_7, 2);
+    rho_rmi_7_7 = _mm_slli_epi16(rho_rmi_7_7, 2);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, ONE_OVER_SQRT_42);
+    xmm5 = _mm_mulhi_epi16(xmm3, ONE_OVER_SQRT_42);
+    xmm6 = _mm_mulhi_epi16(xmm3, THREE_OVER_SQRT_42);
+    xmm7 = _mm_mulhi_epi16(xmm3, FIVE_OVER_SQRT_42);
+    xmm8 = _mm_mulhi_epi16(xmm3, SEVEN_OVER_SQRT_42);
+    xmm7 = _mm_slli_epi16(xmm7, 1);
+    xmm8 = _mm_slli_epi16(xmm8, 2);
+
+    rho_rpi_1_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_1_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_1_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_1_5 = _mm_subs_epi16(xmm4, xmm7);
+    rho_rpi_1_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_1_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, THREE_OVER_SQRT_42);
+    rho_rpi_3_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_3_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_3_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_3_5 = _mm_subs_epi16(xmm4, xmm7);
+    rho_rpi_3_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_3_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, FIVE_OVER_SQRT_42);
+    xmm4 = _mm_slli_epi16(xmm4, 1);
+    rho_rpi_5_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_5_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_5_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_5_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_5_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_5_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, SEVEN_OVER_SQRT_42);
+    xmm4 = _mm_slli_epi16(xmm4, 2);
+    rho_rpi_7_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_7_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_7_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_7_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_7_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_7_5 = _mm_subs_epi16(xmm4, xmm7);
+
+    // Rearrange interfering MF output
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    // Psi_r calculation from rho_rpi or rho_rmi
+    xmm0 = _mm_setzero_si128(); // ZERO for abs_pi16
+    xmm2 = _mm_subs_epi16(rho_rpi_7_7, y1r);
+    psi_r_p7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_5, y1r);
+    psi_r_p7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_3, y1r);
+    psi_r_p7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_1, y1r);
+    psi_r_p7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_1, y1r);
+    psi_r_p7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_3, y1r);
+    psi_r_p7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_5, y1r);
+    psi_r_p7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_7, y1r);
+    psi_r_p7_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_7, y1r);
+    psi_r_p5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_5, y1r);
+    psi_r_p5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_3, y1r);
+    psi_r_p5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_1, y1r);
+    psi_r_p5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_1, y1r);
+    psi_r_p5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_3, y1r);
+    psi_r_p5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_5, y1r);
+    psi_r_p5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_7, y1r);
+    psi_r_p5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_7, y1r);
+    psi_r_p3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_5, y1r);
+    psi_r_p3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_3, y1r);
+    psi_r_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_1, y1r);
+    psi_r_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_1, y1r);
+    psi_r_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_3, y1r);
+    psi_r_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_5, y1r);
+    psi_r_p3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_7, y1r);
+    psi_r_p3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_7, y1r);
+    psi_r_p1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_5, y1r);
+    psi_r_p1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_3, y1r);
+    psi_r_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1, y1r);
+    psi_r_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_1, y1r);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_3, y1r);
+    psi_r_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_5, y1r);
+    psi_r_p1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_7, y1r);
+    psi_r_p1_m7 = _mm_abs_epi16(xmm2);
+
+    xmm2 = _mm_adds_epi16(rho_rmi_1_7, y1r);
+    psi_r_m1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_5, y1r);
+    psi_r_m1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_3, y1r);
+    psi_r_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_1, y1r);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_1, y1r);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_3, y1r);
+    psi_r_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_5, y1r);
+    psi_r_m1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_7, y1r);
+    psi_r_m1_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_7, y1r);
+    psi_r_m3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_5, y1r);
+    psi_r_m3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_3, y1r);
+    psi_r_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_1, y1r);
+    psi_r_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_1, y1r);
+    psi_r_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_3, y1r);
+    psi_r_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_5, y1r);
+    psi_r_m3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_7, y1r);
+    psi_r_m3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_7, y1r);
+    psi_r_m5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_5, y1r);
+    psi_r_m5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_3, y1r);
+    psi_r_m5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_1, y1r);
+    psi_r_m5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_1, y1r);
+    psi_r_m5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_3, y1r);
+    psi_r_m5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_5, y1r);
+    psi_r_m5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_7, y1r);
+    psi_r_m5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_7, y1r);
+    psi_r_m7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_5, y1r);
+    psi_r_m7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_3, y1r);
+    psi_r_m7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_1, y1r);
+    psi_r_m7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_1, y1r);
+    psi_r_m7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_3, y1r);
+    psi_r_m7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_5, y1r);
+    psi_r_m7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_7, y1r);
+    psi_r_m7_m7 = _mm_abs_epi16(xmm2);
+
+    // Psi_i calculation from rho_rpi or rho_rmi
+    xmm2 = _mm_subs_epi16(rho_rmi_7_7, y1i);
+    psi_i_p7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_7, y1i);
+    psi_i_p7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_7, y1i);
+    psi_i_p7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_7, y1i);
+    psi_i_p7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_7, y1i);
+    psi_i_p7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_7, y1i);
+    psi_i_p7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_7, y1i);
+    psi_i_p7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_7, y1i);
+    psi_i_p7_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_5, y1i);
+    psi_i_p5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_5, y1i);
+    psi_i_p5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_5, y1i);
+    psi_i_p5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_5, y1i);
+    psi_i_p5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_5, y1i);
+    psi_i_p5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_5, y1i);
+    psi_i_p5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_5, y1i);
+    psi_i_p5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_5, y1i);
+    psi_i_p5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_3, y1i);
+    psi_i_p3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_3, y1i);
+    psi_i_p3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_3, y1i);
+    psi_i_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_3, y1i);
+    psi_i_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_3, y1i);
+    psi_i_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_3, y1i);
+    psi_i_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_3, y1i);
+    psi_i_p3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_3, y1i);
+    psi_i_p3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_1, y1i);
+    psi_i_p1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_1, y1i);
+    psi_i_p1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_1, y1i);
+    psi_i_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_1, y1i);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_1, y1i);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_1, y1i);
+    psi_i_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_1, y1i);
+    psi_i_p1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_1, y1i);
+    psi_i_p1_m7 = _mm_abs_epi16(xmm2);
+
+    xmm2 = _mm_subs_epi16(rho_rpi_7_1, y1i);
+    psi_i_m1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_1, y1i);
+    psi_i_m1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_1, y1i);
+    psi_i_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1, y1i);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_1, y1i);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_1, y1i);
+    psi_i_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_1, y1i);
+    psi_i_m1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_1, y1i);
+    psi_i_m1_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_3, y1i);
+    psi_i_m3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_3, y1i);
+    psi_i_m3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_3, y1i);
+    psi_i_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_3, y1i);
+    psi_i_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_3, y1i);
+    psi_i_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_3, y1i);
+    psi_i_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_3, y1i);
+    psi_i_m3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_3, y1i);
+    psi_i_m3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_5, y1i);
+    psi_i_m5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_5, y1i);
+    psi_i_m5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_5, y1i);
+    psi_i_m5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_5, y1i);
+    psi_i_m5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_5, y1i);
+    psi_i_m5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_5, y1i);
+    psi_i_m5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_5, y1i);
+    psi_i_m5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_5, y1i);
+    psi_i_m5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_7, y1i);
+    psi_i_m7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_7, y1i);
+    psi_i_m7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_7, y1i);
+    psi_i_m7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_7, y1i);
+    psi_i_m7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_7, y1i);
+    psi_i_m7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_7, y1i);
+    psi_i_m7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_7, y1i);
+    psi_i_m7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_7, y1i);
+    psi_i_m7_m7 = _mm_abs_epi16(xmm2);
+
+
+    // Rearrange desired MF output
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // Rearrange desired channel magnitudes
+    xmm2 = ch_mag_128i[i]; // = [|h|^2(1),|h|^2(1),|h|^2(2),|h|^2(2)]*(2/sqrt(10))
+    xmm3 = ch_mag_128i[i+1]; // = [|h|^2(3),|h|^2(3),|h|^2(4),|h|^2(4)]*(2/sqrt(10))
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    ch_mag_des = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    // Rearrange interfering channel magnitudes
+    xmm2 = ch_mag_128i_i[i];
+    xmm3 = ch_mag_128i_i[i+1];
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    ch_mag_int  = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    y0r_one_over_sqrt_21   = _mm_mulhi_epi16(y0r, ONE_OVER_SQRT_42);
+    y0r_three_over_sqrt_21 = _mm_mulhi_epi16(y0r, THREE_OVER_SQRT_42);
+    y0r_five_over_sqrt_21  = _mm_mulhi_epi16(y0r, FIVE_OVER_SQRT_42);
+    y0r_five_over_sqrt_21  = _mm_slli_epi16(y0r_five_over_sqrt_21, 1);
+    y0r_seven_over_sqrt_21 = _mm_mulhi_epi16(y0r, SEVEN_OVER_SQRT_42);
+    y0r_seven_over_sqrt_21 = _mm_slli_epi16(y0r_seven_over_sqrt_21, 2); // Q2.14
+
+    y0i_one_over_sqrt_21   = _mm_mulhi_epi16(y0i, ONE_OVER_SQRT_42);
+    y0i_three_over_sqrt_21 = _mm_mulhi_epi16(y0i, THREE_OVER_SQRT_42);
+    y0i_five_over_sqrt_21  = _mm_mulhi_epi16(y0i, FIVE_OVER_SQRT_42);
+    y0i_five_over_sqrt_21  = _mm_slli_epi16(y0i_five_over_sqrt_21, 1);
+    y0i_seven_over_sqrt_21 = _mm_mulhi_epi16(y0i, SEVEN_OVER_SQRT_42);
+    y0i_seven_over_sqrt_21 = _mm_slli_epi16(y0i_seven_over_sqrt_21, 2); // Q2.14
+
+    y0_p_7_1 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_7_3 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_7_5 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_7_7 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_5_1 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_5_3 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_5_5 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_5_7 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_3_1 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_3_3 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_3_5 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_3_7 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_1_1 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_1_3 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_1_5 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_1_7 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_seven_over_sqrt_21);
+
+    y0_m_1_1 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_1_3 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_1_5 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_1_7 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_3_1 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_3_3 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_3_5 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_3_7 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_5_1 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_5_3 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_5_5 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_5_7 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_7_1 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_7_3 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_7_5 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_7_7 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_seven_over_sqrt_21);
+
+    interference_abs_epi16(psi_r_p7_p7, ch_mag_int, a_r_p7_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p7_p5, ch_mag_int, a_r_p7_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p7_p3, ch_mag_int, a_r_p7_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p7_p1, ch_mag_int, a_r_p7_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p7_m1, ch_mag_int, a_r_p7_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p7_m3, ch_mag_int, a_r_p7_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p7_m5, ch_mag_int, a_r_p7_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p7_m7, ch_mag_int, a_r_p7_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_p7, ch_mag_int, a_r_p5_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_p5, ch_mag_int, a_r_p5_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_p3, ch_mag_int, a_r_p5_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_p1, ch_mag_int, a_r_p5_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_m1, ch_mag_int, a_r_p5_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_m3, ch_mag_int, a_r_p5_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_m5, ch_mag_int, a_r_p5_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p5_m7, ch_mag_int, a_r_p5_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_p7, ch_mag_int, a_r_p3_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_p5, ch_mag_int, a_r_p3_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_p3, ch_mag_int, a_r_p3_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_p1, ch_mag_int, a_r_p3_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_m1, ch_mag_int, a_r_p3_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_m3, ch_mag_int, a_r_p3_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_m5, ch_mag_int, a_r_p3_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p3_m7, ch_mag_int, a_r_p3_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_p7, ch_mag_int, a_r_p1_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_p5, ch_mag_int, a_r_p1_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_p3, ch_mag_int, a_r_p1_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_p1, ch_mag_int, a_r_p1_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_m1, ch_mag_int, a_r_p1_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_m3, ch_mag_int, a_r_p1_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_m5, ch_mag_int, a_r_p1_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_p1_m7, ch_mag_int, a_r_p1_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_p7, ch_mag_int, a_r_m1_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_p5, ch_mag_int, a_r_m1_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_p3, ch_mag_int, a_r_m1_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_p1, ch_mag_int, a_r_m1_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_m1, ch_mag_int, a_r_m1_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_m3, ch_mag_int, a_r_m1_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_m5, ch_mag_int, a_r_m1_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m1_m7, ch_mag_int, a_r_m1_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_p7, ch_mag_int, a_r_m3_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_p5, ch_mag_int, a_r_m3_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_p3, ch_mag_int, a_r_m3_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_p1, ch_mag_int, a_r_m3_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_m1, ch_mag_int, a_r_m3_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_m3, ch_mag_int, a_r_m3_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_m5, ch_mag_int, a_r_m3_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m3_m7, ch_mag_int, a_r_m3_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_p7, ch_mag_int, a_r_m5_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_p5, ch_mag_int, a_r_m5_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_p3, ch_mag_int, a_r_m5_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_p1, ch_mag_int, a_r_m5_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_m1, ch_mag_int, a_r_m5_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_m3, ch_mag_int, a_r_m5_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_m5, ch_mag_int, a_r_m5_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m5_m7, ch_mag_int, a_r_m5_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_p7, ch_mag_int, a_r_m7_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_p5, ch_mag_int, a_r_m7_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_p3, ch_mag_int, a_r_m7_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_p1, ch_mag_int, a_r_m7_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_m1, ch_mag_int, a_r_m7_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_m3, ch_mag_int, a_r_m7_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_m5, ch_mag_int, a_r_m7_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_r_m7_m7, ch_mag_int, a_r_m7_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+
+    interference_abs_epi16(psi_i_p7_p7, ch_mag_int, a_i_p7_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p7_p5, ch_mag_int, a_i_p7_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p7_p3, ch_mag_int, a_i_p7_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p7_p1, ch_mag_int, a_i_p7_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p7_m1, ch_mag_int, a_i_p7_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p7_m3, ch_mag_int, a_i_p7_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p7_m5, ch_mag_int, a_i_p7_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p7_m7, ch_mag_int, a_i_p7_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_p7, ch_mag_int, a_i_p5_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_p5, ch_mag_int, a_i_p5_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_p3, ch_mag_int, a_i_p5_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_p1, ch_mag_int, a_i_p5_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_m1, ch_mag_int, a_i_p5_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_m3, ch_mag_int, a_i_p5_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_m5, ch_mag_int, a_i_p5_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p5_m7, ch_mag_int, a_i_p5_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_p7, ch_mag_int, a_i_p3_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_p5, ch_mag_int, a_i_p3_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_p3, ch_mag_int, a_i_p3_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_p1, ch_mag_int, a_i_p3_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_m1, ch_mag_int, a_i_p3_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_m3, ch_mag_int, a_i_p3_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_m5, ch_mag_int, a_i_p3_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p3_m7, ch_mag_int, a_i_p3_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_p7, ch_mag_int, a_i_p1_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_p5, ch_mag_int, a_i_p1_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_p3, ch_mag_int, a_i_p1_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_p1, ch_mag_int, a_i_p1_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_m1, ch_mag_int, a_i_p1_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_m3, ch_mag_int, a_i_p1_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_m5, ch_mag_int, a_i_p1_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_p1_m7, ch_mag_int, a_i_p1_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_p7, ch_mag_int, a_i_m1_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_p5, ch_mag_int, a_i_m1_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_p3, ch_mag_int, a_i_m1_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_p1, ch_mag_int, a_i_m1_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_m1, ch_mag_int, a_i_m1_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_m3, ch_mag_int, a_i_m1_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_m5, ch_mag_int, a_i_m1_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m1_m7, ch_mag_int, a_i_m1_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_p7, ch_mag_int, a_i_m3_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_p5, ch_mag_int, a_i_m3_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_p3, ch_mag_int, a_i_m3_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_p1, ch_mag_int, a_i_m3_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_m1, ch_mag_int, a_i_m3_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_m3, ch_mag_int, a_i_m3_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_m5, ch_mag_int, a_i_m3_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m3_m7, ch_mag_int, a_i_m3_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_p7, ch_mag_int, a_i_m5_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_p5, ch_mag_int, a_i_m5_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_p3, ch_mag_int, a_i_m5_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_p1, ch_mag_int, a_i_m5_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_m1, ch_mag_int, a_i_m5_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_m3, ch_mag_int, a_i_m5_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_m5, ch_mag_int, a_i_m5_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m5_m7, ch_mag_int, a_i_m5_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_p7, ch_mag_int, a_i_m7_p7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_p5, ch_mag_int, a_i_m7_p5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_p3, ch_mag_int, a_i_m7_p3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_p1, ch_mag_int, a_i_m7_p1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_m1, ch_mag_int, a_i_m7_m1, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_m3, ch_mag_int, a_i_m7_m3, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_m5, ch_mag_int, a_i_m7_m5, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+    interference_abs_epi16(psi_i_m7_m7, ch_mag_int, a_i_m7_m7, ONE_OVER_SQRT_10_Q15, THREE_OVER_SQRT_10);
+
+    // Calculation of a group of two terms in the bit metric involving product of psi and interference
+    prodsum_psi_a_epi16(psi_r_p7_p7, a_r_p7_p7, psi_i_p7_p7, a_i_p7_p7, psi_a_p7_p7);
+    prodsum_psi_a_epi16(psi_r_p7_p5, a_r_p7_p5, psi_i_p7_p5, a_i_p7_p5, psi_a_p7_p5);
+    prodsum_psi_a_epi16(psi_r_p7_p3, a_r_p7_p3, psi_i_p7_p3, a_i_p7_p3, psi_a_p7_p3);
+    prodsum_psi_a_epi16(psi_r_p7_p1, a_r_p7_p1, psi_i_p7_p1, a_i_p7_p1, psi_a_p7_p1);
+    prodsum_psi_a_epi16(psi_r_p7_m1, a_r_p7_m1, psi_i_p7_m1, a_i_p7_m1, psi_a_p7_m1);
+    prodsum_psi_a_epi16(psi_r_p7_m3, a_r_p7_m3, psi_i_p7_m3, a_i_p7_m3, psi_a_p7_m3);
+    prodsum_psi_a_epi16(psi_r_p7_m5, a_r_p7_m5, psi_i_p7_m5, a_i_p7_m5, psi_a_p7_m5);
+    prodsum_psi_a_epi16(psi_r_p7_m7, a_r_p7_m7, psi_i_p7_m7, a_i_p7_m7, psi_a_p7_m7);
+    prodsum_psi_a_epi16(psi_r_p5_p7, a_r_p5_p7, psi_i_p5_p7, a_i_p5_p7, psi_a_p5_p7);
+    prodsum_psi_a_epi16(psi_r_p5_p5, a_r_p5_p5, psi_i_p5_p5, a_i_p5_p5, psi_a_p5_p5);
+    prodsum_psi_a_epi16(psi_r_p5_p3, a_r_p5_p3, psi_i_p5_p3, a_i_p5_p3, psi_a_p5_p3);
+    prodsum_psi_a_epi16(psi_r_p5_p1, a_r_p5_p1, psi_i_p5_p1, a_i_p5_p1, psi_a_p5_p1);
+    prodsum_psi_a_epi16(psi_r_p5_m1, a_r_p5_m1, psi_i_p5_m1, a_i_p5_m1, psi_a_p5_m1);
+    prodsum_psi_a_epi16(psi_r_p5_m3, a_r_p5_m3, psi_i_p5_m3, a_i_p5_m3, psi_a_p5_m3);
+    prodsum_psi_a_epi16(psi_r_p5_m5, a_r_p5_m5, psi_i_p5_m5, a_i_p5_m5, psi_a_p5_m5);
+    prodsum_psi_a_epi16(psi_r_p5_m7, a_r_p5_m7, psi_i_p5_m7, a_i_p5_m7, psi_a_p5_m7);
+    prodsum_psi_a_epi16(psi_r_p3_p7, a_r_p3_p7, psi_i_p3_p7, a_i_p3_p7, psi_a_p3_p7);
+    prodsum_psi_a_epi16(psi_r_p3_p5, a_r_p3_p5, psi_i_p3_p5, a_i_p3_p5, psi_a_p3_p5);
+    prodsum_psi_a_epi16(psi_r_p3_p3, a_r_p3_p3, psi_i_p3_p3, a_i_p3_p3, psi_a_p3_p3);
+    prodsum_psi_a_epi16(psi_r_p3_p1, a_r_p3_p1, psi_i_p3_p1, a_i_p3_p1, psi_a_p3_p1);
+    prodsum_psi_a_epi16(psi_r_p3_m1, a_r_p3_m1, psi_i_p3_m1, a_i_p3_m1, psi_a_p3_m1);
+    prodsum_psi_a_epi16(psi_r_p3_m3, a_r_p3_m3, psi_i_p3_m3, a_i_p3_m3, psi_a_p3_m3);
+    prodsum_psi_a_epi16(psi_r_p3_m5, a_r_p3_m5, psi_i_p3_m5, a_i_p3_m5, psi_a_p3_m5);
+    prodsum_psi_a_epi16(psi_r_p3_m7, a_r_p3_m7, psi_i_p3_m7, a_i_p3_m7, psi_a_p3_m7);
+    prodsum_psi_a_epi16(psi_r_p1_p7, a_r_p1_p7, psi_i_p1_p7, a_i_p1_p7, psi_a_p1_p7);
+    prodsum_psi_a_epi16(psi_r_p1_p5, a_r_p1_p5, psi_i_p1_p5, a_i_p1_p5, psi_a_p1_p5);
+    prodsum_psi_a_epi16(psi_r_p1_p3, a_r_p1_p3, psi_i_p1_p3, a_i_p1_p3, psi_a_p1_p3);
+    prodsum_psi_a_epi16(psi_r_p1_p1, a_r_p1_p1, psi_i_p1_p1, a_i_p1_p1, psi_a_p1_p1);
+    prodsum_psi_a_epi16(psi_r_p1_m1, a_r_p1_m1, psi_i_p1_m1, a_i_p1_m1, psi_a_p1_m1);
+    prodsum_psi_a_epi16(psi_r_p1_m3, a_r_p1_m3, psi_i_p1_m3, a_i_p1_m3, psi_a_p1_m3);
+    prodsum_psi_a_epi16(psi_r_p1_m5, a_r_p1_m5, psi_i_p1_m5, a_i_p1_m5, psi_a_p1_m5);
+    prodsum_psi_a_epi16(psi_r_p1_m7, a_r_p1_m7, psi_i_p1_m7, a_i_p1_m7, psi_a_p1_m7);
+    prodsum_psi_a_epi16(psi_r_m1_p7, a_r_m1_p7, psi_i_m1_p7, a_i_m1_p7, psi_a_m1_p7);
+    prodsum_psi_a_epi16(psi_r_m1_p5, a_r_m1_p5, psi_i_m1_p5, a_i_m1_p5, psi_a_m1_p5);
+    prodsum_psi_a_epi16(psi_r_m1_p3, a_r_m1_p3, psi_i_m1_p3, a_i_m1_p3, psi_a_m1_p3);
+    prodsum_psi_a_epi16(psi_r_m1_p1, a_r_m1_p1, psi_i_m1_p1, a_i_m1_p1, psi_a_m1_p1);
+    prodsum_psi_a_epi16(psi_r_m1_m1, a_r_m1_m1, psi_i_m1_m1, a_i_m1_m1, psi_a_m1_m1);
+    prodsum_psi_a_epi16(psi_r_m1_m3, a_r_m1_m3, psi_i_m1_m3, a_i_m1_m3, psi_a_m1_m3);
+    prodsum_psi_a_epi16(psi_r_m1_m5, a_r_m1_m5, psi_i_m1_m5, a_i_m1_m5, psi_a_m1_m5);
+    prodsum_psi_a_epi16(psi_r_m1_m7, a_r_m1_m7, psi_i_m1_m7, a_i_m1_m7, psi_a_m1_m7);
+    prodsum_psi_a_epi16(psi_r_m3_p7, a_r_m3_p7, psi_i_m3_p7, a_i_m3_p7, psi_a_m3_p7);
+    prodsum_psi_a_epi16(psi_r_m3_p5, a_r_m3_p5, psi_i_m3_p5, a_i_m3_p5, psi_a_m3_p5);
+    prodsum_psi_a_epi16(psi_r_m3_p3, a_r_m3_p3, psi_i_m3_p3, a_i_m3_p3, psi_a_m3_p3);
+    prodsum_psi_a_epi16(psi_r_m3_p1, a_r_m3_p1, psi_i_m3_p1, a_i_m3_p1, psi_a_m3_p1);
+    prodsum_psi_a_epi16(psi_r_m3_m1, a_r_m3_m1, psi_i_m3_m1, a_i_m3_m1, psi_a_m3_m1);
+    prodsum_psi_a_epi16(psi_r_m3_m3, a_r_m3_m3, psi_i_m3_m3, a_i_m3_m3, psi_a_m3_m3);
+    prodsum_psi_a_epi16(psi_r_m3_m5, a_r_m3_m5, psi_i_m3_m5, a_i_m3_m5, psi_a_m3_m5);
+    prodsum_psi_a_epi16(psi_r_m3_m7, a_r_m3_m7, psi_i_m3_m7, a_i_m3_m7, psi_a_m3_m7);
+    prodsum_psi_a_epi16(psi_r_m5_p7, a_r_m5_p7, psi_i_m5_p7, a_i_m5_p7, psi_a_m5_p7);
+    prodsum_psi_a_epi16(psi_r_m5_p5, a_r_m5_p5, psi_i_m5_p5, a_i_m5_p5, psi_a_m5_p5);
+    prodsum_psi_a_epi16(psi_r_m5_p3, a_r_m5_p3, psi_i_m5_p3, a_i_m5_p3, psi_a_m5_p3);
+    prodsum_psi_a_epi16(psi_r_m5_p1, a_r_m5_p1, psi_i_m5_p1, a_i_m5_p1, psi_a_m5_p1);
+    prodsum_psi_a_epi16(psi_r_m5_m1, a_r_m5_m1, psi_i_m5_m1, a_i_m5_m1, psi_a_m5_m1);
+    prodsum_psi_a_epi16(psi_r_m5_m3, a_r_m5_m3, psi_i_m5_m3, a_i_m5_m3, psi_a_m5_m3);
+    prodsum_psi_a_epi16(psi_r_m5_m5, a_r_m5_m5, psi_i_m5_m5, a_i_m5_m5, psi_a_m5_m5);
+    prodsum_psi_a_epi16(psi_r_m5_m7, a_r_m5_m7, psi_i_m5_m7, a_i_m5_m7, psi_a_m5_m7);
+    prodsum_psi_a_epi16(psi_r_m7_p7, a_r_m7_p7, psi_i_m7_p7, a_i_m7_p7, psi_a_m7_p7);
+    prodsum_psi_a_epi16(psi_r_m7_p5, a_r_m7_p5, psi_i_m7_p5, a_i_m7_p5, psi_a_m7_p5);
+    prodsum_psi_a_epi16(psi_r_m7_p3, a_r_m7_p3, psi_i_m7_p3, a_i_m7_p3, psi_a_m7_p3);
+    prodsum_psi_a_epi16(psi_r_m7_p1, a_r_m7_p1, psi_i_m7_p1, a_i_m7_p1, psi_a_m7_p1);
+    prodsum_psi_a_epi16(psi_r_m7_m1, a_r_m7_m1, psi_i_m7_m1, a_i_m7_m1, psi_a_m7_m1);
+    prodsum_psi_a_epi16(psi_r_m7_m3, a_r_m7_m3, psi_i_m7_m3, a_i_m7_m3, psi_a_m7_m3);
+    prodsum_psi_a_epi16(psi_r_m7_m5, a_r_m7_m5, psi_i_m7_m5, a_i_m7_m5, psi_a_m7_m5);
+    prodsum_psi_a_epi16(psi_r_m7_m7, a_r_m7_m7, psi_i_m7_m7, a_i_m7_m7, psi_a_m7_m7);
+
+    // Calculation of a group of two terms in the bit metric involving squares of interference
+    square_a_epi16(a_r_p7_p7, a_i_p7_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_p7);
+    square_a_epi16(a_r_p7_p5, a_i_p7_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_p5);
+    square_a_epi16(a_r_p7_p3, a_i_p7_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_p3);
+    square_a_epi16(a_r_p7_p1, a_i_p7_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_p1);
+    square_a_epi16(a_r_p7_m1, a_i_p7_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_m1);
+    square_a_epi16(a_r_p7_m3, a_i_p7_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_m3);
+    square_a_epi16(a_r_p7_m5, a_i_p7_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_m5);
+    square_a_epi16(a_r_p7_m7, a_i_p7_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p7_m7);
+    square_a_epi16(a_r_p5_p7, a_i_p5_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_p7);
+    square_a_epi16(a_r_p5_p5, a_i_p5_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_p5);
+    square_a_epi16(a_r_p5_p3, a_i_p5_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_p3);
+    square_a_epi16(a_r_p5_p1, a_i_p5_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_p1);
+    square_a_epi16(a_r_p5_m1, a_i_p5_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_m1);
+    square_a_epi16(a_r_p5_m3, a_i_p5_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_m3);
+    square_a_epi16(a_r_p5_m5, a_i_p5_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_m5);
+    square_a_epi16(a_r_p5_m7, a_i_p5_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p5_m7);
+    square_a_epi16(a_r_p3_p7, a_i_p3_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_p7);
+    square_a_epi16(a_r_p3_p5, a_i_p3_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_p5);
+    square_a_epi16(a_r_p3_p3, a_i_p3_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_p3);
+    square_a_epi16(a_r_p3_p1, a_i_p3_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_p1);
+    square_a_epi16(a_r_p3_m1, a_i_p3_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_m1);
+    square_a_epi16(a_r_p3_m3, a_i_p3_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_m3);
+    square_a_epi16(a_r_p3_m5, a_i_p3_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_m5);
+    square_a_epi16(a_r_p3_m7, a_i_p3_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p3_m7);
+    square_a_epi16(a_r_p1_p7, a_i_p1_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_p7);
+    square_a_epi16(a_r_p1_p5, a_i_p1_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_p5);
+    square_a_epi16(a_r_p1_p3, a_i_p1_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_p3);
+    square_a_epi16(a_r_p1_p1, a_i_p1_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_p1);
+    square_a_epi16(a_r_p1_m1, a_i_p1_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_m1);
+    square_a_epi16(a_r_p1_m3, a_i_p1_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_m3);
+    square_a_epi16(a_r_p1_m5, a_i_p1_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_m5);
+    square_a_epi16(a_r_p1_m7, a_i_p1_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_p1_m7);
+    square_a_epi16(a_r_m1_p7, a_i_m1_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_p7);
+    square_a_epi16(a_r_m1_p5, a_i_m1_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_p5);
+    square_a_epi16(a_r_m1_p3, a_i_m1_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_p3);
+    square_a_epi16(a_r_m1_p1, a_i_m1_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_p1);
+    square_a_epi16(a_r_m1_m1, a_i_m1_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_m1);
+    square_a_epi16(a_r_m1_m3, a_i_m1_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_m3);
+    square_a_epi16(a_r_m1_m5, a_i_m1_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_m5);
+    square_a_epi16(a_r_m1_m7, a_i_m1_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m1_m7);
+    square_a_epi16(a_r_m3_p7, a_i_m3_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_p7);
+    square_a_epi16(a_r_m3_p5, a_i_m3_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_p5);
+    square_a_epi16(a_r_m3_p3, a_i_m3_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_p3);
+    square_a_epi16(a_r_m3_p1, a_i_m3_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_p1);
+    square_a_epi16(a_r_m3_m1, a_i_m3_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_m1);
+    square_a_epi16(a_r_m3_m3, a_i_m3_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_m3);
+    square_a_epi16(a_r_m3_m5, a_i_m3_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_m5);
+    square_a_epi16(a_r_m3_m7, a_i_m3_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m3_m7);
+    square_a_epi16(a_r_m5_p7, a_i_m5_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_p7);
+    square_a_epi16(a_r_m5_p5, a_i_m5_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_p5);
+    square_a_epi16(a_r_m5_p3, a_i_m5_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_p3);
+    square_a_epi16(a_r_m5_p1, a_i_m5_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_p1);
+    square_a_epi16(a_r_m5_m1, a_i_m5_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_m1);
+    square_a_epi16(a_r_m5_m3, a_i_m5_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_m3);
+    square_a_epi16(a_r_m5_m5, a_i_m5_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_m5);
+    square_a_epi16(a_r_m5_m7, a_i_m5_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m5_m7);
+    square_a_epi16(a_r_m7_p7, a_i_m7_p7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_p7);
+    square_a_epi16(a_r_m7_p5, a_i_m7_p5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_p5);
+    square_a_epi16(a_r_m7_p3, a_i_m7_p3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_p3);
+    square_a_epi16(a_r_m7_p1, a_i_m7_p1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_p1);
+    square_a_epi16(a_r_m7_m1, a_i_m7_m1, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_m1);
+    square_a_epi16(a_r_m7_m3, a_i_m7_m3, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_m3);
+    square_a_epi16(a_r_m7_m5, a_i_m7_m5, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_m5);
+    square_a_epi16(a_r_m7_m7, a_i_m7_m7, ch_mag_int, SQRT_10_OVER_FOUR, a_sq_m7_m7);
+
+    // Computing different multiples of ||h0||^2
+    // x=1, y=1
+    ch_mag_2_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,ONE_OVER_FOUR_SQRT_42);
+    ch_mag_2_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_2_over_42_with_sigma2,1);
+    // x=1, y=3
+    ch_mag_10_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,FIVE_OVER_FOUR_SQRT_42);
+    ch_mag_10_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_10_over_42_with_sigma2,1);
+    // x=1, x=5
+    ch_mag_26_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,THIRTEEN_OVER_FOUR_SQRT_42);
+    ch_mag_26_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_26_over_42_with_sigma2,1);
+    // x=1, y=7
+    ch_mag_50_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYFIVE_OVER_FOUR_SQRT_42);
+    ch_mag_50_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_50_over_42_with_sigma2,1);
+    // x=3, y=3
+    ch_mag_18_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,NINE_OVER_FOUR_SQRT_42);
+    ch_mag_18_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_18_over_42_with_sigma2,1);
+    // x=3, y=5
+    ch_mag_34_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,SEVENTEEN_OVER_FOUR_SQRT_42);
+    ch_mag_34_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_34_over_42_with_sigma2,1);
+    // x=3, y=7
+    ch_mag_58_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYNINE_OVER_FOUR_SQRT_42);
+    ch_mag_58_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_58_over_42_with_sigma2,2);
+    // x=5, y=5
+    ch_mag_50_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYFIVE_OVER_FOUR_SQRT_42);
+    ch_mag_50_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_50_over_42_with_sigma2,1);
+    // x=5, y=7
+    ch_mag_74_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,THIRTYSEVEN_OVER_FOUR_SQRT_42);
+    ch_mag_74_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_74_over_42_with_sigma2,2);
+    // x=7, y=7
+    ch_mag_98_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,FORTYNINE_OVER_FOUR_SQRT_42);
+    ch_mag_98_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_98_over_42_with_sigma2,2);
+
+    // Computing Metrics
+    xmm0 = _mm_subs_epi16(psi_a_p7_p7, a_sq_p7_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_7);
+    bit_met_p7_p7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_p5, a_sq_p7_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_5);
+    bit_met_p7_p5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_p3, a_sq_p7_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_3);
+    bit_met_p7_p3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_p1, a_sq_p7_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_1);
+    bit_met_p7_p1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m1, a_sq_p7_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_1);
+    bit_met_p7_m1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m3, a_sq_p7_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_3);
+    bit_met_p7_m3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m5, a_sq_p7_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_5);
+    bit_met_p7_m5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m7, a_sq_p7_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_7);
+    bit_met_p7_m7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p7, a_sq_p5_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_7);
+    bit_met_p5_p7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p5, a_sq_p5_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_5);
+    bit_met_p5_p5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p3, a_sq_p5_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_3);
+    bit_met_p5_p3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p1, a_sq_p5_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_1);
+    bit_met_p5_p1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m1, a_sq_p5_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_1);
+    bit_met_p5_m1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m3, a_sq_p5_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_3);
+    bit_met_p5_m3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m5, a_sq_p5_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_5);
+    bit_met_p5_m5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m7, a_sq_p5_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_7);
+    bit_met_p5_m7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p7, a_sq_p3_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_7);
+    bit_met_p3_p7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p5, a_sq_p3_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_5);
+    bit_met_p3_p5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p3, a_sq_p3_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_3);
+    bit_met_p3_p3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p1, a_sq_p3_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_1);
+    bit_met_p3_p1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m1, a_sq_p3_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_1);
+    bit_met_p3_m1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m3, a_sq_p3_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_3);
+    bit_met_p3_m3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m5, a_sq_p3_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_5);
+    bit_met_p3_m5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m7, a_sq_p3_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_7);
+    bit_met_p3_m7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p7, a_sq_p1_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_7);
+    bit_met_p1_p7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p5, a_sq_p1_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_5);
+    bit_met_p1_p5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p3, a_sq_p1_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_3);
+    bit_met_p1_p3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p1, a_sq_p1_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_1);
+    bit_met_p1_p1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m1, a_sq_p1_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_1);
+    bit_met_p1_m1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m3, a_sq_p1_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_3);
+    bit_met_p1_m3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m5, a_sq_p1_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_5);
+    bit_met_p1_m5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m7, a_sq_p1_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_7);
+    bit_met_p1_m7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p7, a_sq_m1_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_7);
+    bit_met_m1_p7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_p5, a_sq_m1_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_5);
+    bit_met_m1_p5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_p3, a_sq_m1_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_3);
+    bit_met_m1_p3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_p1, a_sq_m1_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_1);
+    bit_met_m1_p1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m1, a_sq_m1_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_1);
+    bit_met_m1_m1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m3, a_sq_m1_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_3);
+    bit_met_m1_m3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m5, a_sq_m1_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_5);
+    bit_met_m1_m5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m7, a_sq_m1_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_7);
+    bit_met_m1_m7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p7, a_sq_m3_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_7);
+    bit_met_m3_p7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p5, a_sq_m3_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_5);
+    bit_met_m3_p5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p3, a_sq_m3_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_3);
+    bit_met_m3_p3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p1, a_sq_m3_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_1);
+    bit_met_m3_p1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m1, a_sq_m3_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_1);
+    bit_met_m3_m1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m3, a_sq_m3_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_3);
+    bit_met_m3_m3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m5, a_sq_m3_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_5);
+    bit_met_m3_m5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m7, a_sq_m3_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_7);
+    bit_met_m3_m7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p7, a_sq_m5_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_7);
+    bit_met_m5_p7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p5, a_sq_m5_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_5);
+    bit_met_m5_p5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p3, a_sq_m5_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_3);
+    bit_met_m5_p3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p1, a_sq_m5_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_1);
+    bit_met_m5_p1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m1, a_sq_m5_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_1);
+    bit_met_m5_m1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m3, a_sq_m5_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_3);
+    bit_met_m5_m3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m5, a_sq_m5_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_5);
+    bit_met_m5_m5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m7, a_sq_m5_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_7);
+    bit_met_m5_m7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p7, a_sq_m7_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_7);
+    bit_met_m7_p7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p5, a_sq_m7_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_5);
+    bit_met_m7_p5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p3, a_sq_m7_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_3);
+    bit_met_m7_p3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p1, a_sq_m7_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_1);
+    bit_met_m7_p1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m1, a_sq_m7_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_1);
+    bit_met_m7_m1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m3, a_sq_m7_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_3);
+    bit_met_m7_m3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m5, a_sq_m7_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_5);
+    bit_met_m7_m5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m7, a_sq_m7_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_7);
+    bit_met_m7_m7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+
+    // Detection for 1st bit (LTE mapping)
+    // bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m7_p7, bit_met_m7_p5);
+    xmm1 = _mm_max_epi16(bit_met_m7_p3, bit_met_m7_p1);
+    xmm2 = _mm_max_epi16(bit_met_m7_m1, bit_met_m7_m3);
+    xmm3 = _mm_max_epi16(bit_met_m7_m5, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m5_p7, bit_met_m5_p5);
+    xmm1 = _mm_max_epi16(bit_met_m5_p3, bit_met_m5_p1);
+    xmm2 = _mm_max_epi16(bit_met_m5_m1, bit_met_m5_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m5_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m3_p7, bit_met_m3_p5);
+    xmm1 = _mm_max_epi16(bit_met_m3_p3, bit_met_m3_p1);
+    xmm2 = _mm_max_epi16(bit_met_m3_m1, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m3_m5, bit_met_m3_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_p7, bit_met_m1_p5);
+    xmm1 = _mm_max_epi16(bit_met_m1_p3, bit_met_m1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m1_m3);
+    xmm3 = _mm_max_epi16(bit_met_m1_m5, bit_met_m1_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    // bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p7_p5);
+    xmm1 = _mm_max_epi16(bit_met_p7_p3, bit_met_p7_p1);
+    xmm2 = _mm_max_epi16(bit_met_p7_m1, bit_met_p7_m3);
+    xmm3 = _mm_max_epi16(bit_met_p7_m5, bit_met_p7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_p7, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p5_p3, bit_met_p5_p1);
+    xmm2 = _mm_max_epi16(bit_met_p5_m1, bit_met_p5_m3);
+    xmm3 = _mm_max_epi16(bit_met_p5_m5, bit_met_p5_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_p7, bit_met_p3_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p3_p1);
+    xmm2 = _mm_max_epi16(bit_met_p3_m1, bit_met_p3_m3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m5, bit_met_p3_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_p7, bit_met_p1_p5);
+    xmm1 = _mm_max_epi16(bit_met_p1_p3, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_p1_m1, bit_met_p1_m3);
+    xmm3 = _mm_max_epi16(bit_met_p1_m5, bit_met_p1_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y0r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 2nd bit (LTE mapping)
+    // bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    // bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m7_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m7_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y1r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 3rd bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_m7_m7, bit_met_m7_m5);
+    xmm1 = _mm_max_epi16(bit_met_m7_m3, bit_met_m7_m1);
+    xmm2 = _mm_max_epi16(bit_met_m7_p1, bit_met_m7_p3);
+    xmm3 = _mm_max_epi16(bit_met_m7_p5, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m5_m7, bit_met_m5_m5);
+    xmm1 = _mm_max_epi16(bit_met_m5_m3, bit_met_m5_m1);
+    xmm2 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_m7, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p5_m3, bit_met_p5_m1);
+    xmm2 = _mm_max_epi16(bit_met_p5_p1, bit_met_p5_p3);
+    xmm3 = _mm_max_epi16(bit_met_p5_p5, bit_met_p5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p7_m5);
+    xmm1 = _mm_max_epi16(bit_met_p7_m3, bit_met_p7_m1);
+    xmm2 = _mm_max_epi16(bit_met_p7_p1, bit_met_p7_p3);
+    xmm3 = _mm_max_epi16(bit_met_p7_p5, bit_met_p7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_m3_m7, bit_met_m3_m5);
+    xmm1 = _mm_max_epi16(bit_met_m3_m3, bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_p5, bit_met_m3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_m7, bit_met_m1_m5);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3, bit_met_m1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m1_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p5, bit_met_m1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_m7, bit_met_p1_m5);
+    xmm1 = _mm_max_epi16(bit_met_p1_m3, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1, bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_p5, bit_met_p1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_m7, bit_met_p3_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1, bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_p5, bit_met_p3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y2r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 4th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m7_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y0i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+
+    // Detection for 5th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_m7_m7, bit_met_m7_m5);
+    xmm1 = _mm_max_epi16(bit_met_m7_m3, bit_met_m7_m1);
+    xmm2 = _mm_max_epi16(bit_met_m7_p1, bit_met_m7_p3);
+    xmm3 = _mm_max_epi16(bit_met_m7_p5, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_m7, bit_met_m1_m5);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3, bit_met_m1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m1_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p5, bit_met_m1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_m7, bit_met_p1_m5);
+    xmm1 = _mm_max_epi16(bit_met_p1_m3, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1, bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_p5, bit_met_p1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p7_m5);
+    xmm1 = _mm_max_epi16(bit_met_p7_m3, bit_met_p7_m1);
+    xmm2 = _mm_max_epi16(bit_met_p7_p1, bit_met_p7_p3);
+    xmm3 = _mm_max_epi16(bit_met_p7_p5, bit_met_p7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_m5_m7, bit_met_m5_m5);
+    xmm1 = _mm_max_epi16(bit_met_m5_m3, bit_met_m5_m1);
+    xmm2 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m3_m7, bit_met_m3_m5);
+    xmm1 = _mm_max_epi16(bit_met_m3_m3, bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_p5, bit_met_m3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_m7, bit_met_p3_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1, bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_p5, bit_met_p3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_m7, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p5_m3, bit_met_p5_m1);
+    xmm2 = _mm_max_epi16(bit_met_p5_p1, bit_met_p5_p3);
+    xmm3 = _mm_max_epi16(bit_met_p5_p5, bit_met_p5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y1i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 6th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m7_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y2i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+
+    // map to output stream, difficult to do in SIMD since we have 6 16bit LLRs
+    // RE 1
+    j = 24*i;
+    stream0_out[j + 0] = ((short *)&y0r)[0];
+    stream0_out[j + 1] = ((short *)&y1r)[0];
+    stream0_out[j + 2] = ((short *)&y2r)[0];
+    stream0_out[j + 3] = ((short *)&y0i)[0];
+    stream0_out[j + 4] = ((short *)&y1i)[0];
+    stream0_out[j + 5] = ((short *)&y2i)[0];
+    // RE 2
+    stream0_out[j + 6] = ((short *)&y0r)[1];
+    stream0_out[j + 7] = ((short *)&y1r)[1];
+    stream0_out[j + 8] = ((short *)&y2r)[1];
+    stream0_out[j + 9] = ((short *)&y0i)[1];
+    stream0_out[j + 10] = ((short *)&y1i)[1];
+    stream0_out[j + 11] = ((short *)&y2i)[1];
+    // RE 3
+    stream0_out[j + 12] = ((short *)&y0r)[2];
+    stream0_out[j + 13] = ((short *)&y1r)[2];
+    stream0_out[j + 14] = ((short *)&y2r)[2];
+    stream0_out[j + 15] = ((short *)&y0i)[2];
+    stream0_out[j + 16] = ((short *)&y1i)[2];
+    stream0_out[j + 17] = ((short *)&y2i)[2];
+    // RE 4
+    stream0_out[j + 18] = ((short *)&y0r)[3];
+    stream0_out[j + 19] = ((short *)&y1r)[3];
+    stream0_out[j + 20] = ((short *)&y2r)[3];
+    stream0_out[j + 21] = ((short *)&y0i)[3];
+    stream0_out[j + 22] = ((short *)&y1i)[3];
+    stream0_out[j + 23] = ((short *)&y2i)[3];
+    // RE 5
+    stream0_out[j + 24] = ((short *)&y0r)[4];
+    stream0_out[j + 25] = ((short *)&y1r)[4];
+    stream0_out[j + 26] = ((short *)&y2r)[4];
+    stream0_out[j + 27] = ((short *)&y0i)[4];
+    stream0_out[j + 28] = ((short *)&y1i)[4];
+    stream0_out[j + 29] = ((short *)&y2i)[4];
+    // RE 6
+    stream0_out[j + 30] = ((short *)&y0r)[5];
+    stream0_out[j + 31] = ((short *)&y1r)[5];
+    stream0_out[j + 32] = ((short *)&y2r)[5];
+    stream0_out[j + 33] = ((short *)&y0i)[5];
+    stream0_out[j + 34] = ((short *)&y1i)[5];
+    stream0_out[j + 35] = ((short *)&y2i)[5];
+    // RE 7
+    stream0_out[j + 36] = ((short *)&y0r)[6];
+    stream0_out[j + 37] = ((short *)&y1r)[6];
+    stream0_out[j + 38] = ((short *)&y2r)[6];
+    stream0_out[j + 39] = ((short *)&y0i)[6];
+    stream0_out[j + 40] = ((short *)&y1i)[6];
+    stream0_out[j + 41] = ((short *)&y2i)[6];
+    // RE 8
+    stream0_out[j + 42] = ((short *)&y0r)[7];
+    stream0_out[j + 43] = ((short *)&y1r)[7];
+    stream0_out[j + 44] = ((short *)&y2r)[7];
+    stream0_out[j + 45] = ((short *)&y0i)[7];
+    stream0_out[j + 46] = ((short *)&y1i)[7];
+    stream0_out[j + 47] = ((short *)&y2i)[7];
+
+#elif defined(__arm__)
+
+#endif
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+
+}
+
+
+int dlsch_64qam_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                          int32_t **rxdataF_comp,
+                          int32_t **rxdataF_comp_i,
+                          int32_t **dl_ch_mag,
+                          int32_t **dl_ch_mag_i,
+                          int32_t **rho_i,
+                          int16_t *dlsch_llr,
+                          uint8_t symbol,
+                          uint8_t first_symbol_flag,
+                          uint16_t nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          int16_t **llr16p)
+{
+
+  int16_t *rxF      = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i    = (int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag   = (int16_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho      = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  //first symbol has different structure due to more pilots
+  if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }
+
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  qam64_qam16((short *)rxF,
+              (short *)rxF_i,
+              (short *)ch_mag,
+              (short *)ch_mag_i,
+              (short *)llr16,
+              (short *)rho,
+              len);
+
+  llr16 += (6*len);
+  *llr16p = (short *)llr16;
+  return(0);
+}
+
+void qam64_qam64(short *stream0_in,
+                 short *stream1_in,
+                 short *ch_mag,
+                 short *ch_mag_i,
+                 short *stream0_out,
+                 short *rho01,
+                 int length
+     )
+{
+
+  /*
+    Author: S. Wagner
+    Date: 31-07-12
+
+    Input:
+    stream0_in:  MF filter for 1st stream, i.e., y0=h0'*y
+    stream1_in:  MF filter for 2nd stream, i.e., y1=h1'*y
+    ch_mag:      4*h0/sqrt(42), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    ch_mag_i:    4*h1/sqrt(42), [Re0 Im0 Re1 Im1] s.t. Im0=Re0, Im1=Re1, etc
+    rho01:       Channel cross correlation, i.e., h1'*h0
+
+    Output:
+    stream0_out: output LLRs for 1st stream
+  */
+
+#if defined(__x86_64__) || defined(__i386__)
+
+  __m128i *rho01_128i      = (__m128i *)rho01;
+  __m128i *stream0_128i_in = (__m128i *)stream0_in;
+  __m128i *stream1_128i_in = (__m128i *)stream1_in;
+  __m128i *ch_mag_128i     = (__m128i *)ch_mag;
+  __m128i *ch_mag_128i_i   = (__m128i *)ch_mag_i;
+
+  __m128i ONE_OVER_SQRT_42 = _mm_set1_epi16(10112); // round(1/sqrt(42)*2^16)
+  __m128i THREE_OVER_SQRT_42 = _mm_set1_epi16(30337); // round(3/sqrt(42)*2^16)
+  __m128i FIVE_OVER_SQRT_42 = _mm_set1_epi16(25281); // round(5/sqrt(42)*2^15)
+  __m128i SEVEN_OVER_SQRT_42 = _mm_set1_epi16(17697); // round(7/sqrt(42)*2^14) Q2.14
+  __m128i ONE_OVER_SQRT_2 = _mm_set1_epi16(23170); // round(1/sqrt(2)*2^15)
+  __m128i ONE_OVER_SQRT_2_42 = _mm_set1_epi16(3575); // round(1/sqrt(2*42)*2^15)
+  __m128i THREE_OVER_SQRT_2_42 = _mm_set1_epi16(10726); // round(3/sqrt(2*42)*2^15)
+  __m128i FIVE_OVER_SQRT_2_42 = _mm_set1_epi16(17876); // round(5/sqrt(2*42)*2^15)
+  __m128i SEVEN_OVER_SQRT_2_42 = _mm_set1_epi16(25027); // round(7/sqrt(2*42)*2^15)
+  __m128i FORTYNINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(30969); // round(49/(4*sqrt(42))*2^14), Q2.14
+  __m128i THIRTYSEVEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(23385); // round(37/(4*sqrt(42))*2^14), Q2.14
+  __m128i TWENTYFIVE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(31601); // round(25/(4*sqrt(42))*2^15)
+  __m128i TWENTYNINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(18329); // round(29/(4*sqrt(42))*2^15), Q2.14
+  __m128i SEVENTEEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(21489); // round(17/(4*sqrt(42))*2^15)
+  __m128i NINE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(11376); // round(9/(4*sqrt(42))*2^15)
+  __m128i THIRTEEN_OVER_FOUR_SQRT_42 = _mm_set1_epi16(16433); // round(13/(4*sqrt(42))*2^15)
+  __m128i FIVE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(6320); // round(5/(4*sqrt(42))*2^15)
+  __m128i ONE_OVER_FOUR_SQRT_42 = _mm_set1_epi16(1264); // round(1/(4*sqrt(42))*2^15)
+  __m128i SQRT_42_OVER_FOUR = _mm_set1_epi16(13272); // round(sqrt(42)/4*2^13), Q3.12
+
+  __m128i ch_mag_des;
+  __m128i ch_mag_int;
+  __m128i ch_mag_98_over_42_with_sigma2;
+  __m128i ch_mag_74_over_42_with_sigma2;
+  __m128i ch_mag_58_over_42_with_sigma2;
+  __m128i ch_mag_50_over_42_with_sigma2;
+  __m128i ch_mag_34_over_42_with_sigma2;
+  __m128i ch_mag_18_over_42_with_sigma2;
+  __m128i ch_mag_26_over_42_with_sigma2;
+  __m128i ch_mag_10_over_42_with_sigma2;
+  __m128i ch_mag_2_over_42_with_sigma2;
+  __m128i  y0r_one_over_sqrt_21;
+  __m128i  y0r_three_over_sqrt_21;
+  __m128i  y0r_five_over_sqrt_21;
+  __m128i  y0r_seven_over_sqrt_21;
+  __m128i  y0i_one_over_sqrt_21;
+  __m128i  y0i_three_over_sqrt_21;
+  __m128i  y0i_five_over_sqrt_21;
+  __m128i  y0i_seven_over_sqrt_21;
+  __m128i ch_mag_int_with_sigma2;
+  __m128i two_ch_mag_int_with_sigma2;
+  __m128i three_ch_mag_int_with_sigma2;
+#elif defined(__arm__)
+
+#endif
+
+  int i,j;
+
+
+  for (i=0; i<length>>2; i+=2) {
+
+#if defined(__x86_64__) || defined(__i386__)
+
+    // Get rho
+    xmm0 = rho01_128i[i];
+    xmm1 = rho01_128i[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    xmm2 = _mm_unpacklo_epi64(xmm0,xmm1); // Re(rho)
+    xmm3 = _mm_unpackhi_epi64(xmm0,xmm1); // Im(rho)
+    rho_rpi = _mm_adds_epi16(xmm2,xmm3); // rho = Re(rho) + Im(rho)
+    rho_rmi = _mm_subs_epi16(xmm2,xmm3); // rho* = Re(rho) - Im(rho)
+
+    // Compute the different rhos
+    rho_rpi_1_1 = _mm_mulhi_epi16(rho_rpi, ONE_OVER_SQRT_42);
+    rho_rmi_1_1 = _mm_mulhi_epi16(rho_rmi, ONE_OVER_SQRT_42);
+    rho_rpi_3_3 = _mm_mulhi_epi16(rho_rpi, THREE_OVER_SQRT_42);
+    rho_rmi_3_3 = _mm_mulhi_epi16(rho_rmi, THREE_OVER_SQRT_42);
+    rho_rpi_5_5 = _mm_mulhi_epi16(rho_rpi, FIVE_OVER_SQRT_42);
+    rho_rmi_5_5 = _mm_mulhi_epi16(rho_rmi, FIVE_OVER_SQRT_42);
+    rho_rpi_7_7 = _mm_mulhi_epi16(rho_rpi, SEVEN_OVER_SQRT_42);
+    rho_rmi_7_7 = _mm_mulhi_epi16(rho_rmi, SEVEN_OVER_SQRT_42);
+
+    rho_rpi_5_5 = _mm_slli_epi16(rho_rpi_5_5, 1);
+    rho_rmi_5_5 = _mm_slli_epi16(rho_rmi_5_5, 1);
+    rho_rpi_7_7 = _mm_slli_epi16(rho_rpi_7_7, 2);
+    rho_rmi_7_7 = _mm_slli_epi16(rho_rmi_7_7, 2);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, ONE_OVER_SQRT_42);
+    xmm5 = _mm_mulhi_epi16(xmm3, ONE_OVER_SQRT_42);
+    xmm6 = _mm_mulhi_epi16(xmm3, THREE_OVER_SQRT_42);
+    xmm7 = _mm_mulhi_epi16(xmm3, FIVE_OVER_SQRT_42);
+    xmm8 = _mm_mulhi_epi16(xmm3, SEVEN_OVER_SQRT_42);
+    xmm7 = _mm_slli_epi16(xmm7, 1);
+    xmm8 = _mm_slli_epi16(xmm8, 2);
+
+    rho_rpi_1_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_1_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_1_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_1_5 = _mm_subs_epi16(xmm4, xmm7);
+    rho_rpi_1_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_1_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, THREE_OVER_SQRT_42);
+    rho_rpi_3_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_3_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_3_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_3_5 = _mm_subs_epi16(xmm4, xmm7);
+    rho_rpi_3_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_3_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, FIVE_OVER_SQRT_42);
+    xmm4 = _mm_slli_epi16(xmm4, 1);
+    rho_rpi_5_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_5_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_5_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_5_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_5_7 = _mm_adds_epi16(xmm4, xmm8);
+    rho_rmi_5_7 = _mm_subs_epi16(xmm4, xmm8);
+
+    xmm4 = _mm_mulhi_epi16(xmm2, SEVEN_OVER_SQRT_42);
+    xmm4 = _mm_slli_epi16(xmm4, 2);
+    rho_rpi_7_1 = _mm_adds_epi16(xmm4, xmm5);
+    rho_rmi_7_1 = _mm_subs_epi16(xmm4, xmm5);
+    rho_rpi_7_3 = _mm_adds_epi16(xmm4, xmm6);
+    rho_rmi_7_3 = _mm_subs_epi16(xmm4, xmm6);
+    rho_rpi_7_5 = _mm_adds_epi16(xmm4, xmm7);
+    rho_rmi_7_5 = _mm_subs_epi16(xmm4, xmm7);
+
+    // Rearrange interfering MF output
+    xmm0 = stream1_128i_in[i];
+    xmm1 = stream1_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y1r = _mm_unpacklo_epi64(xmm0,xmm1); //[y1r(1),y1r(2),y1r(3),y1r(4)]
+    y1i = _mm_unpackhi_epi64(xmm0,xmm1); //[y1i(1),y1i(2),y1i(3),y1i(4)]
+
+    // Psi_r calculation from rho_rpi or rho_rmi
+    xmm0 = _mm_setzero_si128(); // ZERO for abs_pi16
+    xmm2 = _mm_subs_epi16(rho_rpi_7_7, y1r);
+    psi_r_p7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_5, y1r);
+    psi_r_p7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_3, y1r);
+    psi_r_p7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_1, y1r);
+    psi_r_p7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_1, y1r);
+    psi_r_p7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_3, y1r);
+    psi_r_p7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_5, y1r);
+    psi_r_p7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_7, y1r);
+    psi_r_p7_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_7, y1r);
+    psi_r_p5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_5, y1r);
+    psi_r_p5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_3, y1r);
+    psi_r_p5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_1, y1r);
+    psi_r_p5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_1, y1r);
+    psi_r_p5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_3, y1r);
+    psi_r_p5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_5, y1r);
+    psi_r_p5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_7, y1r);
+    psi_r_p5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_7, y1r);
+    psi_r_p3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_5, y1r);
+    psi_r_p3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_3, y1r);
+    psi_r_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_1, y1r);
+    psi_r_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_1, y1r);
+    psi_r_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_3, y1r);
+    psi_r_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_5, y1r);
+    psi_r_p3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_7, y1r);
+    psi_r_p3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_7, y1r);
+    psi_r_p1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_5, y1r);
+    psi_r_p1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_3, y1r);
+    psi_r_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1, y1r);
+    psi_r_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_1, y1r);
+    psi_r_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_3, y1r);
+    psi_r_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_5, y1r);
+    psi_r_p1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_7, y1r);
+    psi_r_p1_m7 = _mm_abs_epi16(xmm2);
+
+    xmm2 = _mm_adds_epi16(rho_rmi_1_7, y1r);
+    psi_r_m1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_5, y1r);
+    psi_r_m1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_3, y1r);
+    psi_r_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_1, y1r);
+    psi_r_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_1, y1r);
+    psi_r_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_3, y1r);
+    psi_r_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_5, y1r);
+    psi_r_m1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_7, y1r);
+    psi_r_m1_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_7, y1r);
+    psi_r_m3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_5, y1r);
+    psi_r_m3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_3, y1r);
+    psi_r_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_1, y1r);
+    psi_r_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_1, y1r);
+    psi_r_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_3, y1r);
+    psi_r_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_5, y1r);
+    psi_r_m3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_7, y1r);
+    psi_r_m3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_7, y1r);
+    psi_r_m5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_5, y1r);
+    psi_r_m5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_3, y1r);
+    psi_r_m5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_1, y1r);
+    psi_r_m5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_1, y1r);
+    psi_r_m5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_3, y1r);
+    psi_r_m5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_5, y1r);
+    psi_r_m5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_7, y1r);
+    psi_r_m5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_7, y1r);
+    psi_r_m7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_5, y1r);
+    psi_r_m7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_3, y1r);
+    psi_r_m7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_1, y1r);
+    psi_r_m7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_1, y1r);
+    psi_r_m7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_3, y1r);
+    psi_r_m7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_5, y1r);
+    psi_r_m7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_7, y1r);
+    psi_r_m7_m7 = _mm_abs_epi16(xmm2);
+
+    // Psi_i calculation from rho_rpi or rho_rmi
+    xmm2 = _mm_subs_epi16(rho_rmi_7_7, y1i);
+    psi_i_p7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_7, y1i);
+    psi_i_p7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_7, y1i);
+    psi_i_p7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_7, y1i);
+    psi_i_p7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_7, y1i);
+    psi_i_p7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_7, y1i);
+    psi_i_p7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_7, y1i);
+    psi_i_p7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_7, y1i);
+    psi_i_p7_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_5, y1i);
+    psi_i_p5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_5, y1i);
+    psi_i_p5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_5, y1i);
+    psi_i_p5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_5, y1i);
+    psi_i_p5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_5, y1i);
+    psi_i_p5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_5, y1i);
+    psi_i_p5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_5, y1i);
+    psi_i_p5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_5, y1i);
+    psi_i_p5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_3, y1i);
+    psi_i_p3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_3, y1i);
+    psi_i_p3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_3, y1i);
+    psi_i_p3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_3, y1i);
+    psi_i_p3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_3, y1i);
+    psi_i_p3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_3, y1i);
+    psi_i_p3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_3, y1i);
+    psi_i_p3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_3, y1i);
+    psi_i_p3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_7_1, y1i);
+    psi_i_p1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_5_1, y1i);
+    psi_i_p1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_3_1, y1i);
+    psi_i_p1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rmi_1_1, y1i);
+    psi_i_p1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_1_1, y1i);
+    psi_i_p1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_3_1, y1i);
+    psi_i_p1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_5_1, y1i);
+    psi_i_p1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rpi_7_1, y1i);
+    psi_i_p1_m7 = _mm_abs_epi16(xmm2);
+
+    xmm2 = _mm_subs_epi16(rho_rpi_7_1, y1i);
+    psi_i_m1_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_1, y1i);
+    psi_i_m1_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_1, y1i);
+    psi_i_m1_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_1, y1i);
+    psi_i_m1_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_1, y1i);
+    psi_i_m1_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_1, y1i);
+    psi_i_m1_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_1, y1i);
+    psi_i_m1_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_1, y1i);
+    psi_i_m1_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_3, y1i);
+    psi_i_m3_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_3, y1i);
+    psi_i_m3_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_3, y1i);
+    psi_i_m3_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_3, y1i);
+    psi_i_m3_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_3, y1i);
+    psi_i_m3_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_3, y1i);
+    psi_i_m3_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_3, y1i);
+    psi_i_m3_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_3, y1i);
+    psi_i_m3_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_5, y1i);
+    psi_i_m5_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_5, y1i);
+    psi_i_m5_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_5, y1i);
+    psi_i_m5_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_5, y1i);
+    psi_i_m5_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_5, y1i);
+    psi_i_m5_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_5, y1i);
+    psi_i_m5_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_5, y1i);
+    psi_i_m5_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_5, y1i);
+    psi_i_m5_m7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_7_7, y1i);
+    psi_i_m7_p7 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_5_7, y1i);
+    psi_i_m7_p5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_3_7, y1i);
+    psi_i_m7_p3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_subs_epi16(rho_rpi_1_7, y1i);
+    psi_i_m7_p1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_1_7, y1i);
+    psi_i_m7_m1 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_3_7, y1i);
+    psi_i_m7_m3 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_5_7, y1i);
+    psi_i_m7_m5 = _mm_abs_epi16(xmm2);
+    xmm2 = _mm_adds_epi16(rho_rmi_7_7, y1i);
+    psi_i_m7_m7 = _mm_abs_epi16(xmm2);
+
+
+    // Rearrange desired MF output
+    xmm0 = stream0_128i_in[i];
+    xmm1 = stream0_128i_in[i+1];
+    xmm0 = _mm_shufflelo_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shufflehi_epi16(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm0 = _mm_shuffle_epi32(xmm0,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflelo_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shufflehi_epi16(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm1 = _mm_shuffle_epi32(xmm1,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    //xmm0 = [Re(0,1) Re(2,3) Im(0,1) Im(2,3)]
+    //xmm1 = [Re(4,5) Re(6,7) Im(4,5) Im(6,7)]
+    y0r = _mm_unpacklo_epi64(xmm0,xmm1); // = [y0r(1),y0r(2),y0r(3),y0r(4)]
+    y0i = _mm_unpackhi_epi64(xmm0,xmm1);
+
+    // Rearrange desired channel magnitudes
+    xmm2 = ch_mag_128i[i]; // = [|h|^2(1),|h|^2(1),|h|^2(2),|h|^2(2)]*(2/sqrt(10))
+    xmm3 = ch_mag_128i[i+1]; // = [|h|^2(3),|h|^2(3),|h|^2(4),|h|^2(4)]*(2/sqrt(10))
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    ch_mag_des = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    // Rearrange interfering channel magnitudes
+    xmm2 = ch_mag_128i_i[i];
+    xmm3 = ch_mag_128i_i[i+1];
+    xmm2 = _mm_shufflelo_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shufflehi_epi16(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm2 = _mm_shuffle_epi32(xmm2,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflelo_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shufflehi_epi16(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    xmm3 = _mm_shuffle_epi32(xmm3,0xd8); //_MM_SHUFFLE(0,2,1,3));
+    ch_mag_int  = _mm_unpacklo_epi64(xmm2,xmm3);
+
+    y0r_one_over_sqrt_21   = _mm_mulhi_epi16(y0r, ONE_OVER_SQRT_42);
+    y0r_three_over_sqrt_21 = _mm_mulhi_epi16(y0r, THREE_OVER_SQRT_42);
+    y0r_five_over_sqrt_21  = _mm_mulhi_epi16(y0r, FIVE_OVER_SQRT_42);
+    y0r_five_over_sqrt_21  = _mm_slli_epi16(y0r_five_over_sqrt_21, 1);
+    y0r_seven_over_sqrt_21 = _mm_mulhi_epi16(y0r, SEVEN_OVER_SQRT_42);
+    y0r_seven_over_sqrt_21 = _mm_slli_epi16(y0r_seven_over_sqrt_21, 2); // Q2.14
+
+    y0i_one_over_sqrt_21   = _mm_mulhi_epi16(y0i, ONE_OVER_SQRT_42);
+    y0i_three_over_sqrt_21 = _mm_mulhi_epi16(y0i, THREE_OVER_SQRT_42);
+    y0i_five_over_sqrt_21  = _mm_mulhi_epi16(y0i, FIVE_OVER_SQRT_42);
+    y0i_five_over_sqrt_21  = _mm_slli_epi16(y0i_five_over_sqrt_21, 1);
+    y0i_seven_over_sqrt_21 = _mm_mulhi_epi16(y0i, SEVEN_OVER_SQRT_42);
+    y0i_seven_over_sqrt_21 = _mm_slli_epi16(y0i_seven_over_sqrt_21, 2); // Q2.14
+
+    y0_p_7_1 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_7_3 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_7_5 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_7_7 = _mm_adds_epi16(y0r_seven_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_5_1 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_5_3 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_5_5 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_5_7 = _mm_adds_epi16(y0r_five_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_3_1 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_3_3 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_3_5 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_3_7 = _mm_adds_epi16(y0r_three_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_p_1_1 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_p_1_3 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_p_1_5 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_p_1_7 = _mm_adds_epi16(y0r_one_over_sqrt_21, y0i_seven_over_sqrt_21);
+
+    y0_m_1_1 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_1_3 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_1_5 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_1_7 = _mm_subs_epi16(y0r_one_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_3_1 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_3_3 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_3_5 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_3_7 = _mm_subs_epi16(y0r_three_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_5_1 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_5_3 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_5_5 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_5_7 = _mm_subs_epi16(y0r_five_over_sqrt_21, y0i_seven_over_sqrt_21);
+    y0_m_7_1 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_one_over_sqrt_21);
+    y0_m_7_3 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_three_over_sqrt_21);
+    y0_m_7_5 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_five_over_sqrt_21);
+    y0_m_7_7 = _mm_subs_epi16(y0r_seven_over_sqrt_21, y0i_seven_over_sqrt_21);
+
+    // Detection of interference term
+    ch_mag_int_with_sigma2       = _mm_srai_epi16(ch_mag_int, 1); // *2
+    two_ch_mag_int_with_sigma2   = ch_mag_int; // *4
+    three_ch_mag_int_with_sigma2 = _mm_adds_epi16(ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2); // *6
+
+    interference_abs_64qam_epi16(psi_r_p7_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p7_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p7_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p7_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p7_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p7_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p7_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p7_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p7_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p5_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p5_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p3_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p3_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_p1_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_p1_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m1_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m1_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m3_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m3_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m5_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m5_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_r_m7_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_r_m7_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+
+    interference_abs_64qam_epi16(psi_i_p7_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p7_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p7_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p7_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p7_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p7_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p7_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p7_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p7_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p5_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p5_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p3_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p3_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_p1_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_p1_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m1_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m1_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m3_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m3_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m5_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m5_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_p7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_p7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_p5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_p5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_p3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_p3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_p1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_p1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_m1, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_m1, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_m3, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_m3, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_m5, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_m5, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+    interference_abs_64qam_epi16(psi_i_m7_m7, ch_mag_int_with_sigma2, two_ch_mag_int_with_sigma2, three_ch_mag_int_with_sigma2, a_i_m7_m7, ONE_OVER_SQRT_2_42, THREE_OVER_SQRT_2_42, FIVE_OVER_SQRT_2_42,
+                                 SEVEN_OVER_SQRT_2_42);
+
+    // Calculation of a group of two terms in the bit metric involving product of psi and interference
+    prodsum_psi_a_epi16(psi_r_p7_p7, a_r_p7_p7, psi_i_p7_p7, a_i_p7_p7, psi_a_p7_p7);
+    prodsum_psi_a_epi16(psi_r_p7_p5, a_r_p7_p5, psi_i_p7_p5, a_i_p7_p5, psi_a_p7_p5);
+    prodsum_psi_a_epi16(psi_r_p7_p3, a_r_p7_p3, psi_i_p7_p3, a_i_p7_p3, psi_a_p7_p3);
+    prodsum_psi_a_epi16(psi_r_p7_p1, a_r_p7_p1, psi_i_p7_p1, a_i_p7_p1, psi_a_p7_p1);
+    prodsum_psi_a_epi16(psi_r_p7_m1, a_r_p7_m1, psi_i_p7_m1, a_i_p7_m1, psi_a_p7_m1);
+    prodsum_psi_a_epi16(psi_r_p7_m3, a_r_p7_m3, psi_i_p7_m3, a_i_p7_m3, psi_a_p7_m3);
+    prodsum_psi_a_epi16(psi_r_p7_m5, a_r_p7_m5, psi_i_p7_m5, a_i_p7_m5, psi_a_p7_m5);
+    prodsum_psi_a_epi16(psi_r_p7_m7, a_r_p7_m7, psi_i_p7_m7, a_i_p7_m7, psi_a_p7_m7);
+    prodsum_psi_a_epi16(psi_r_p5_p7, a_r_p5_p7, psi_i_p5_p7, a_i_p5_p7, psi_a_p5_p7);
+    prodsum_psi_a_epi16(psi_r_p5_p5, a_r_p5_p5, psi_i_p5_p5, a_i_p5_p5, psi_a_p5_p5);
+    prodsum_psi_a_epi16(psi_r_p5_p3, a_r_p5_p3, psi_i_p5_p3, a_i_p5_p3, psi_a_p5_p3);
+    prodsum_psi_a_epi16(psi_r_p5_p1, a_r_p5_p1, psi_i_p5_p1, a_i_p5_p1, psi_a_p5_p1);
+    prodsum_psi_a_epi16(psi_r_p5_m1, a_r_p5_m1, psi_i_p5_m1, a_i_p5_m1, psi_a_p5_m1);
+    prodsum_psi_a_epi16(psi_r_p5_m3, a_r_p5_m3, psi_i_p5_m3, a_i_p5_m3, psi_a_p5_m3);
+    prodsum_psi_a_epi16(psi_r_p5_m5, a_r_p5_m5, psi_i_p5_m5, a_i_p5_m5, psi_a_p5_m5);
+    prodsum_psi_a_epi16(psi_r_p5_m7, a_r_p5_m7, psi_i_p5_m7, a_i_p5_m7, psi_a_p5_m7);
+    prodsum_psi_a_epi16(psi_r_p3_p7, a_r_p3_p7, psi_i_p3_p7, a_i_p3_p7, psi_a_p3_p7);
+    prodsum_psi_a_epi16(psi_r_p3_p5, a_r_p3_p5, psi_i_p3_p5, a_i_p3_p5, psi_a_p3_p5);
+    prodsum_psi_a_epi16(psi_r_p3_p3, a_r_p3_p3, psi_i_p3_p3, a_i_p3_p3, psi_a_p3_p3);
+    prodsum_psi_a_epi16(psi_r_p3_p1, a_r_p3_p1, psi_i_p3_p1, a_i_p3_p1, psi_a_p3_p1);
+    prodsum_psi_a_epi16(psi_r_p3_m1, a_r_p3_m1, psi_i_p3_m1, a_i_p3_m1, psi_a_p3_m1);
+    prodsum_psi_a_epi16(psi_r_p3_m3, a_r_p3_m3, psi_i_p3_m3, a_i_p3_m3, psi_a_p3_m3);
+    prodsum_psi_a_epi16(psi_r_p3_m5, a_r_p3_m5, psi_i_p3_m5, a_i_p3_m5, psi_a_p3_m5);
+    prodsum_psi_a_epi16(psi_r_p3_m7, a_r_p3_m7, psi_i_p3_m7, a_i_p3_m7, psi_a_p3_m7);
+    prodsum_psi_a_epi16(psi_r_p1_p7, a_r_p1_p7, psi_i_p1_p7, a_i_p1_p7, psi_a_p1_p7);
+    prodsum_psi_a_epi16(psi_r_p1_p5, a_r_p1_p5, psi_i_p1_p5, a_i_p1_p5, psi_a_p1_p5);
+    prodsum_psi_a_epi16(psi_r_p1_p3, a_r_p1_p3, psi_i_p1_p3, a_i_p1_p3, psi_a_p1_p3);
+    prodsum_psi_a_epi16(psi_r_p1_p1, a_r_p1_p1, psi_i_p1_p1, a_i_p1_p1, psi_a_p1_p1);
+    prodsum_psi_a_epi16(psi_r_p1_m1, a_r_p1_m1, psi_i_p1_m1, a_i_p1_m1, psi_a_p1_m1);
+    prodsum_psi_a_epi16(psi_r_p1_m3, a_r_p1_m3, psi_i_p1_m3, a_i_p1_m3, psi_a_p1_m3);
+    prodsum_psi_a_epi16(psi_r_p1_m5, a_r_p1_m5, psi_i_p1_m5, a_i_p1_m5, psi_a_p1_m5);
+    prodsum_psi_a_epi16(psi_r_p1_m7, a_r_p1_m7, psi_i_p1_m7, a_i_p1_m7, psi_a_p1_m7);
+    prodsum_psi_a_epi16(psi_r_m1_p7, a_r_m1_p7, psi_i_m1_p7, a_i_m1_p7, psi_a_m1_p7);
+    prodsum_psi_a_epi16(psi_r_m1_p5, a_r_m1_p5, psi_i_m1_p5, a_i_m1_p5, psi_a_m1_p5);
+    prodsum_psi_a_epi16(psi_r_m1_p3, a_r_m1_p3, psi_i_m1_p3, a_i_m1_p3, psi_a_m1_p3);
+    prodsum_psi_a_epi16(psi_r_m1_p1, a_r_m1_p1, psi_i_m1_p1, a_i_m1_p1, psi_a_m1_p1);
+    prodsum_psi_a_epi16(psi_r_m1_m1, a_r_m1_m1, psi_i_m1_m1, a_i_m1_m1, psi_a_m1_m1);
+    prodsum_psi_a_epi16(psi_r_m1_m3, a_r_m1_m3, psi_i_m1_m3, a_i_m1_m3, psi_a_m1_m3);
+    prodsum_psi_a_epi16(psi_r_m1_m5, a_r_m1_m5, psi_i_m1_m5, a_i_m1_m5, psi_a_m1_m5);
+    prodsum_psi_a_epi16(psi_r_m1_m7, a_r_m1_m7, psi_i_m1_m7, a_i_m1_m7, psi_a_m1_m7);
+    prodsum_psi_a_epi16(psi_r_m3_p7, a_r_m3_p7, psi_i_m3_p7, a_i_m3_p7, psi_a_m3_p7);
+    prodsum_psi_a_epi16(psi_r_m3_p5, a_r_m3_p5, psi_i_m3_p5, a_i_m3_p5, psi_a_m3_p5);
+    prodsum_psi_a_epi16(psi_r_m3_p3, a_r_m3_p3, psi_i_m3_p3, a_i_m3_p3, psi_a_m3_p3);
+    prodsum_psi_a_epi16(psi_r_m3_p1, a_r_m3_p1, psi_i_m3_p1, a_i_m3_p1, psi_a_m3_p1);
+    prodsum_psi_a_epi16(psi_r_m3_m1, a_r_m3_m1, psi_i_m3_m1, a_i_m3_m1, psi_a_m3_m1);
+    prodsum_psi_a_epi16(psi_r_m3_m3, a_r_m3_m3, psi_i_m3_m3, a_i_m3_m3, psi_a_m3_m3);
+    prodsum_psi_a_epi16(psi_r_m3_m5, a_r_m3_m5, psi_i_m3_m5, a_i_m3_m5, psi_a_m3_m5);
+    prodsum_psi_a_epi16(psi_r_m3_m7, a_r_m3_m7, psi_i_m3_m7, a_i_m3_m7, psi_a_m3_m7);
+    prodsum_psi_a_epi16(psi_r_m5_p7, a_r_m5_p7, psi_i_m5_p7, a_i_m5_p7, psi_a_m5_p7);
+    prodsum_psi_a_epi16(psi_r_m5_p5, a_r_m5_p5, psi_i_m5_p5, a_i_m5_p5, psi_a_m5_p5);
+    prodsum_psi_a_epi16(psi_r_m5_p3, a_r_m5_p3, psi_i_m5_p3, a_i_m5_p3, psi_a_m5_p3);
+    prodsum_psi_a_epi16(psi_r_m5_p1, a_r_m5_p1, psi_i_m5_p1, a_i_m5_p1, psi_a_m5_p1);
+    prodsum_psi_a_epi16(psi_r_m5_m1, a_r_m5_m1, psi_i_m5_m1, a_i_m5_m1, psi_a_m5_m1);
+    prodsum_psi_a_epi16(psi_r_m5_m3, a_r_m5_m3, psi_i_m5_m3, a_i_m5_m3, psi_a_m5_m3);
+    prodsum_psi_a_epi16(psi_r_m5_m5, a_r_m5_m5, psi_i_m5_m5, a_i_m5_m5, psi_a_m5_m5);
+    prodsum_psi_a_epi16(psi_r_m5_m7, a_r_m5_m7, psi_i_m5_m7, a_i_m5_m7, psi_a_m5_m7);
+    prodsum_psi_a_epi16(psi_r_m7_p7, a_r_m7_p7, psi_i_m7_p7, a_i_m7_p7, psi_a_m7_p7);
+    prodsum_psi_a_epi16(psi_r_m7_p5, a_r_m7_p5, psi_i_m7_p5, a_i_m7_p5, psi_a_m7_p5);
+    prodsum_psi_a_epi16(psi_r_m7_p3, a_r_m7_p3, psi_i_m7_p3, a_i_m7_p3, psi_a_m7_p3);
+    prodsum_psi_a_epi16(psi_r_m7_p1, a_r_m7_p1, psi_i_m7_p1, a_i_m7_p1, psi_a_m7_p1);
+    prodsum_psi_a_epi16(psi_r_m7_m1, a_r_m7_m1, psi_i_m7_m1, a_i_m7_m1, psi_a_m7_m1);
+    prodsum_psi_a_epi16(psi_r_m7_m3, a_r_m7_m3, psi_i_m7_m3, a_i_m7_m3, psi_a_m7_m3);
+    prodsum_psi_a_epi16(psi_r_m7_m5, a_r_m7_m5, psi_i_m7_m5, a_i_m7_m5, psi_a_m7_m5);
+    prodsum_psi_a_epi16(psi_r_m7_m7, a_r_m7_m7, psi_i_m7_m7, a_i_m7_m7, psi_a_m7_m7);
+
+    // Multiply by sqrt(2)
+    psi_a_p7_p7 = _mm_mulhi_epi16(psi_a_p7_p7, ONE_OVER_SQRT_2);
+    psi_a_p7_p7 = _mm_slli_epi16(psi_a_p7_p7, 2);
+    psi_a_p7_p5 = _mm_mulhi_epi16(psi_a_p7_p5, ONE_OVER_SQRT_2);
+    psi_a_p7_p5 = _mm_slli_epi16(psi_a_p7_p5, 2);
+    psi_a_p7_p3 = _mm_mulhi_epi16(psi_a_p7_p3, ONE_OVER_SQRT_2);
+    psi_a_p7_p3 = _mm_slli_epi16(psi_a_p7_p3, 2);
+    psi_a_p7_p1 = _mm_mulhi_epi16(psi_a_p7_p1, ONE_OVER_SQRT_2);
+    psi_a_p7_p1 = _mm_slli_epi16(psi_a_p7_p1, 2);
+    psi_a_p7_m1 = _mm_mulhi_epi16(psi_a_p7_m1, ONE_OVER_SQRT_2);
+    psi_a_p7_m1 = _mm_slli_epi16(psi_a_p7_m1, 2);
+    psi_a_p7_m3 = _mm_mulhi_epi16(psi_a_p7_m3, ONE_OVER_SQRT_2);
+    psi_a_p7_m3 = _mm_slli_epi16(psi_a_p7_m3, 2);
+    psi_a_p7_m5 = _mm_mulhi_epi16(psi_a_p7_m5, ONE_OVER_SQRT_2);
+    psi_a_p7_m5 = _mm_slli_epi16(psi_a_p7_m5, 2);
+    psi_a_p7_m7 = _mm_mulhi_epi16(psi_a_p7_m7, ONE_OVER_SQRT_2);
+    psi_a_p7_m7 = _mm_slli_epi16(psi_a_p7_m7, 2);
+    psi_a_p5_p7 = _mm_mulhi_epi16(psi_a_p5_p7, ONE_OVER_SQRT_2);
+    psi_a_p5_p7 = _mm_slli_epi16(psi_a_p5_p7, 2);
+    psi_a_p5_p5 = _mm_mulhi_epi16(psi_a_p5_p5, ONE_OVER_SQRT_2);
+    psi_a_p5_p5 = _mm_slli_epi16(psi_a_p5_p5, 2);
+    psi_a_p5_p3 = _mm_mulhi_epi16(psi_a_p5_p3, ONE_OVER_SQRT_2);
+    psi_a_p5_p3 = _mm_slli_epi16(psi_a_p5_p3, 2);
+    psi_a_p5_p1 = _mm_mulhi_epi16(psi_a_p5_p1, ONE_OVER_SQRT_2);
+    psi_a_p5_p1 = _mm_slli_epi16(psi_a_p5_p1, 2);
+    psi_a_p5_m1 = _mm_mulhi_epi16(psi_a_p5_m1, ONE_OVER_SQRT_2);
+    psi_a_p5_m1 = _mm_slli_epi16(psi_a_p5_m1, 2);
+    psi_a_p5_m3 = _mm_mulhi_epi16(psi_a_p5_m3, ONE_OVER_SQRT_2);
+    psi_a_p5_m3 = _mm_slli_epi16(psi_a_p5_m3, 2);
+    psi_a_p5_m5 = _mm_mulhi_epi16(psi_a_p5_m5, ONE_OVER_SQRT_2);
+    psi_a_p5_m5 = _mm_slli_epi16(psi_a_p5_m5, 2);
+    psi_a_p5_m7 = _mm_mulhi_epi16(psi_a_p5_m7, ONE_OVER_SQRT_2);
+    psi_a_p5_m7 = _mm_slli_epi16(psi_a_p5_m7, 2);
+    psi_a_p3_p7 = _mm_mulhi_epi16(psi_a_p3_p7, ONE_OVER_SQRT_2);
+    psi_a_p3_p7 = _mm_slli_epi16(psi_a_p3_p7, 2);
+    psi_a_p3_p5 = _mm_mulhi_epi16(psi_a_p3_p5, ONE_OVER_SQRT_2);
+    psi_a_p3_p5 = _mm_slli_epi16(psi_a_p3_p5, 2);
+    psi_a_p3_p3 = _mm_mulhi_epi16(psi_a_p3_p3, ONE_OVER_SQRT_2);
+    psi_a_p3_p3 = _mm_slli_epi16(psi_a_p3_p3, 2);
+    psi_a_p3_p1 = _mm_mulhi_epi16(psi_a_p3_p1, ONE_OVER_SQRT_2);
+    psi_a_p3_p1 = _mm_slli_epi16(psi_a_p3_p1, 2);
+    psi_a_p3_m1 = _mm_mulhi_epi16(psi_a_p3_m1, ONE_OVER_SQRT_2);
+    psi_a_p3_m1 = _mm_slli_epi16(psi_a_p3_m1, 2);
+    psi_a_p3_m3 = _mm_mulhi_epi16(psi_a_p3_m3, ONE_OVER_SQRT_2);
+    psi_a_p3_m3 = _mm_slli_epi16(psi_a_p3_m3, 2);
+    psi_a_p3_m5 = _mm_mulhi_epi16(psi_a_p3_m5, ONE_OVER_SQRT_2);
+    psi_a_p3_m5 = _mm_slli_epi16(psi_a_p3_m5, 2);
+    psi_a_p3_m7 = _mm_mulhi_epi16(psi_a_p3_m7, ONE_OVER_SQRT_2);
+    psi_a_p3_m7 = _mm_slli_epi16(psi_a_p3_m7, 2);
+    psi_a_p1_p7 = _mm_mulhi_epi16(psi_a_p1_p7, ONE_OVER_SQRT_2);
+    psi_a_p1_p7 = _mm_slli_epi16(psi_a_p1_p7, 2);
+    psi_a_p1_p5 = _mm_mulhi_epi16(psi_a_p1_p5, ONE_OVER_SQRT_2);
+    psi_a_p1_p5 = _mm_slli_epi16(psi_a_p1_p5, 2);
+    psi_a_p1_p3 = _mm_mulhi_epi16(psi_a_p1_p3, ONE_OVER_SQRT_2);
+    psi_a_p1_p3 = _mm_slli_epi16(psi_a_p1_p3, 2);
+    psi_a_p1_p1 = _mm_mulhi_epi16(psi_a_p1_p1, ONE_OVER_SQRT_2);
+    psi_a_p1_p1 = _mm_slli_epi16(psi_a_p1_p1, 2);
+    psi_a_p1_m1 = _mm_mulhi_epi16(psi_a_p1_m1, ONE_OVER_SQRT_2);
+    psi_a_p1_m1 = _mm_slli_epi16(psi_a_p1_m1, 2);
+    psi_a_p1_m3 = _mm_mulhi_epi16(psi_a_p1_m3, ONE_OVER_SQRT_2);
+    psi_a_p1_m3 = _mm_slli_epi16(psi_a_p1_m3, 2);
+    psi_a_p1_m5 = _mm_mulhi_epi16(psi_a_p1_m5, ONE_OVER_SQRT_2);
+    psi_a_p1_m5 = _mm_slli_epi16(psi_a_p1_m5, 2);
+    psi_a_p1_m7 = _mm_mulhi_epi16(psi_a_p1_m7, ONE_OVER_SQRT_2);
+    psi_a_p1_m7 = _mm_slli_epi16(psi_a_p1_m7, 2);
+    psi_a_m1_p7 = _mm_mulhi_epi16(psi_a_m1_p7, ONE_OVER_SQRT_2);
+    psi_a_m1_p7 = _mm_slli_epi16(psi_a_m1_p7, 2);
+    psi_a_m1_p5 = _mm_mulhi_epi16(psi_a_m1_p5, ONE_OVER_SQRT_2);
+    psi_a_m1_p5 = _mm_slli_epi16(psi_a_m1_p5, 2);
+    psi_a_m1_p3 = _mm_mulhi_epi16(psi_a_m1_p3, ONE_OVER_SQRT_2);
+    psi_a_m1_p3 = _mm_slli_epi16(psi_a_m1_p3, 2);
+    psi_a_m1_p1 = _mm_mulhi_epi16(psi_a_m1_p1, ONE_OVER_SQRT_2);
+    psi_a_m1_p1 = _mm_slli_epi16(psi_a_m1_p1, 2);
+    psi_a_m1_m1 = _mm_mulhi_epi16(psi_a_m1_m1, ONE_OVER_SQRT_2);
+    psi_a_m1_m1 = _mm_slli_epi16(psi_a_m1_m1, 2);
+    psi_a_m1_m3 = _mm_mulhi_epi16(psi_a_m1_m3, ONE_OVER_SQRT_2);
+    psi_a_m1_m3 = _mm_slli_epi16(psi_a_m1_m3, 2);
+    psi_a_m1_m5 = _mm_mulhi_epi16(psi_a_m1_m5, ONE_OVER_SQRT_2);
+    psi_a_m1_m5 = _mm_slli_epi16(psi_a_m1_m5, 2);
+    psi_a_m1_m7 = _mm_mulhi_epi16(psi_a_m1_m7, ONE_OVER_SQRT_2);
+    psi_a_m1_m7 = _mm_slli_epi16(psi_a_m1_m7, 2);
+    psi_a_m3_p7 = _mm_mulhi_epi16(psi_a_m3_p7, ONE_OVER_SQRT_2);
+    psi_a_m3_p7 = _mm_slli_epi16(psi_a_m3_p7, 2);
+    psi_a_m3_p5 = _mm_mulhi_epi16(psi_a_m3_p5, ONE_OVER_SQRT_2);
+    psi_a_m3_p5 = _mm_slli_epi16(psi_a_m3_p5, 2);
+    psi_a_m3_p3 = _mm_mulhi_epi16(psi_a_m3_p3, ONE_OVER_SQRT_2);
+    psi_a_m3_p3 = _mm_slli_epi16(psi_a_m3_p3, 2);
+    psi_a_m3_p1 = _mm_mulhi_epi16(psi_a_m3_p1, ONE_OVER_SQRT_2);
+    psi_a_m3_p1 = _mm_slli_epi16(psi_a_m3_p1, 2);
+    psi_a_m3_m1 = _mm_mulhi_epi16(psi_a_m3_m1, ONE_OVER_SQRT_2);
+    psi_a_m3_m1 = _mm_slli_epi16(psi_a_m3_m1, 2);
+    psi_a_m3_m3 = _mm_mulhi_epi16(psi_a_m3_m3, ONE_OVER_SQRT_2);
+    psi_a_m3_m3 = _mm_slli_epi16(psi_a_m3_m3, 2);
+    psi_a_m3_m5 = _mm_mulhi_epi16(psi_a_m3_m5, ONE_OVER_SQRT_2);
+    psi_a_m3_m5 = _mm_slli_epi16(psi_a_m3_m5, 2);
+    psi_a_m3_m7 = _mm_mulhi_epi16(psi_a_m3_m7, ONE_OVER_SQRT_2);
+    psi_a_m3_m7 = _mm_slli_epi16(psi_a_m3_m7, 2);
+    psi_a_m5_p7 = _mm_mulhi_epi16(psi_a_m5_p7, ONE_OVER_SQRT_2);
+    psi_a_m5_p7 = _mm_slli_epi16(psi_a_m5_p7, 2);
+    psi_a_m5_p5 = _mm_mulhi_epi16(psi_a_m5_p5, ONE_OVER_SQRT_2);
+    psi_a_m5_p5 = _mm_slli_epi16(psi_a_m5_p5, 2);
+    psi_a_m5_p3 = _mm_mulhi_epi16(psi_a_m5_p3, ONE_OVER_SQRT_2);
+    psi_a_m5_p3 = _mm_slli_epi16(psi_a_m5_p3, 2);
+    psi_a_m5_p1 = _mm_mulhi_epi16(psi_a_m5_p1, ONE_OVER_SQRT_2);
+    psi_a_m5_p1 = _mm_slli_epi16(psi_a_m5_p1, 2);
+    psi_a_m5_m1 = _mm_mulhi_epi16(psi_a_m5_m1, ONE_OVER_SQRT_2);
+    psi_a_m5_m1 = _mm_slli_epi16(psi_a_m5_m1, 2);
+    psi_a_m5_m3 = _mm_mulhi_epi16(psi_a_m5_m3, ONE_OVER_SQRT_2);
+    psi_a_m5_m3 = _mm_slli_epi16(psi_a_m5_m3, 2);
+    psi_a_m5_m5 = _mm_mulhi_epi16(psi_a_m5_m5, ONE_OVER_SQRT_2);
+    psi_a_m5_m5 = _mm_slli_epi16(psi_a_m5_m5, 2);
+    psi_a_m5_m7 = _mm_mulhi_epi16(psi_a_m5_m7, ONE_OVER_SQRT_2);
+    psi_a_m5_m7 = _mm_slli_epi16(psi_a_m5_m7, 2);
+    psi_a_m7_p7 = _mm_mulhi_epi16(psi_a_m7_p7, ONE_OVER_SQRT_2);
+    psi_a_m7_p7 = _mm_slli_epi16(psi_a_m7_p7, 2);
+    psi_a_m7_p5 = _mm_mulhi_epi16(psi_a_m7_p5, ONE_OVER_SQRT_2);
+    psi_a_m7_p5 = _mm_slli_epi16(psi_a_m7_p5, 2);
+    psi_a_m7_p3 = _mm_mulhi_epi16(psi_a_m7_p3, ONE_OVER_SQRT_2);
+    psi_a_m7_p3 = _mm_slli_epi16(psi_a_m7_p3, 2);
+    psi_a_m7_p1 = _mm_mulhi_epi16(psi_a_m7_p1, ONE_OVER_SQRT_2);
+    psi_a_m7_p1 = _mm_slli_epi16(psi_a_m7_p1, 2);
+    psi_a_m7_m1 = _mm_mulhi_epi16(psi_a_m7_m1, ONE_OVER_SQRT_2);
+    psi_a_m7_m1 = _mm_slli_epi16(psi_a_m7_m1, 2);
+    psi_a_m7_m3 = _mm_mulhi_epi16(psi_a_m7_m3, ONE_OVER_SQRT_2);
+    psi_a_m7_m3 = _mm_slli_epi16(psi_a_m7_m3, 2);
+    psi_a_m7_m5 = _mm_mulhi_epi16(psi_a_m7_m5, ONE_OVER_SQRT_2);
+    psi_a_m7_m5 = _mm_slli_epi16(psi_a_m7_m5, 2);
+    psi_a_m7_m7 = _mm_mulhi_epi16(psi_a_m7_m7, ONE_OVER_SQRT_2);
+    psi_a_m7_m7 = _mm_slli_epi16(psi_a_m7_m7, 2);
+
+    // Calculation of a group of two terms in the bit metric involving squares of interference
+    square_a_64qam_epi16(a_r_p7_p7, a_i_p7_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_p7);
+    square_a_64qam_epi16(a_r_p7_p5, a_i_p7_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_p5);
+    square_a_64qam_epi16(a_r_p7_p3, a_i_p7_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_p3);
+    square_a_64qam_epi16(a_r_p7_p1, a_i_p7_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_p1);
+    square_a_64qam_epi16(a_r_p7_m1, a_i_p7_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_m1);
+    square_a_64qam_epi16(a_r_p7_m3, a_i_p7_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_m3);
+    square_a_64qam_epi16(a_r_p7_m5, a_i_p7_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_m5);
+    square_a_64qam_epi16(a_r_p7_m7, a_i_p7_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p7_m7);
+    square_a_64qam_epi16(a_r_p5_p7, a_i_p5_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_p7);
+    square_a_64qam_epi16(a_r_p5_p5, a_i_p5_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_p5);
+    square_a_64qam_epi16(a_r_p5_p3, a_i_p5_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_p3);
+    square_a_64qam_epi16(a_r_p5_p1, a_i_p5_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_p1);
+    square_a_64qam_epi16(a_r_p5_m1, a_i_p5_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_m1);
+    square_a_64qam_epi16(a_r_p5_m3, a_i_p5_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_m3);
+    square_a_64qam_epi16(a_r_p5_m5, a_i_p5_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_m5);
+    square_a_64qam_epi16(a_r_p5_m7, a_i_p5_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p5_m7);
+    square_a_64qam_epi16(a_r_p3_p7, a_i_p3_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_p7);
+    square_a_64qam_epi16(a_r_p3_p5, a_i_p3_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_p5);
+    square_a_64qam_epi16(a_r_p3_p3, a_i_p3_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_p3);
+    square_a_64qam_epi16(a_r_p3_p1, a_i_p3_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_p1);
+    square_a_64qam_epi16(a_r_p3_m1, a_i_p3_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_m1);
+    square_a_64qam_epi16(a_r_p3_m3, a_i_p3_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_m3);
+    square_a_64qam_epi16(a_r_p3_m5, a_i_p3_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_m5);
+    square_a_64qam_epi16(a_r_p3_m7, a_i_p3_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p3_m7);
+    square_a_64qam_epi16(a_r_p1_p7, a_i_p1_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_p7);
+    square_a_64qam_epi16(a_r_p1_p5, a_i_p1_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_p5);
+    square_a_64qam_epi16(a_r_p1_p3, a_i_p1_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_p3);
+    square_a_64qam_epi16(a_r_p1_p1, a_i_p1_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_p1);
+    square_a_64qam_epi16(a_r_p1_m1, a_i_p1_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_m1);
+    square_a_64qam_epi16(a_r_p1_m3, a_i_p1_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_m3);
+    square_a_64qam_epi16(a_r_p1_m5, a_i_p1_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_m5);
+    square_a_64qam_epi16(a_r_p1_m7, a_i_p1_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_p1_m7);
+    square_a_64qam_epi16(a_r_m1_p7, a_i_m1_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_p7);
+    square_a_64qam_epi16(a_r_m1_p5, a_i_m1_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_p5);
+    square_a_64qam_epi16(a_r_m1_p3, a_i_m1_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_p3);
+    square_a_64qam_epi16(a_r_m1_p1, a_i_m1_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_p1);
+    square_a_64qam_epi16(a_r_m1_m1, a_i_m1_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_m1);
+    square_a_64qam_epi16(a_r_m1_m3, a_i_m1_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_m3);
+    square_a_64qam_epi16(a_r_m1_m5, a_i_m1_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_m5);
+    square_a_64qam_epi16(a_r_m1_m7, a_i_m1_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m1_m7);
+    square_a_64qam_epi16(a_r_m3_p7, a_i_m3_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_p7);
+    square_a_64qam_epi16(a_r_m3_p5, a_i_m3_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_p5);
+    square_a_64qam_epi16(a_r_m3_p3, a_i_m3_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_p3);
+    square_a_64qam_epi16(a_r_m3_p1, a_i_m3_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_p1);
+    square_a_64qam_epi16(a_r_m3_m1, a_i_m3_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_m1);
+    square_a_64qam_epi16(a_r_m3_m3, a_i_m3_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_m3);
+    square_a_64qam_epi16(a_r_m3_m5, a_i_m3_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_m5);
+    square_a_64qam_epi16(a_r_m3_m7, a_i_m3_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m3_m7);
+    square_a_64qam_epi16(a_r_m5_p7, a_i_m5_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_p7);
+    square_a_64qam_epi16(a_r_m5_p5, a_i_m5_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_p5);
+    square_a_64qam_epi16(a_r_m5_p3, a_i_m5_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_p3);
+    square_a_64qam_epi16(a_r_m5_p1, a_i_m5_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_p1);
+    square_a_64qam_epi16(a_r_m5_m1, a_i_m5_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_m1);
+    square_a_64qam_epi16(a_r_m5_m3, a_i_m5_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_m3);
+    square_a_64qam_epi16(a_r_m5_m5, a_i_m5_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_m5);
+    square_a_64qam_epi16(a_r_m5_m7, a_i_m5_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m5_m7);
+    square_a_64qam_epi16(a_r_m7_p7, a_i_m7_p7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_p7);
+    square_a_64qam_epi16(a_r_m7_p5, a_i_m7_p5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_p5);
+    square_a_64qam_epi16(a_r_m7_p3, a_i_m7_p3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_p3);
+    square_a_64qam_epi16(a_r_m7_p1, a_i_m7_p1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_p1);
+    square_a_64qam_epi16(a_r_m7_m1, a_i_m7_m1, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_m1);
+    square_a_64qam_epi16(a_r_m7_m3, a_i_m7_m3, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_m3);
+    square_a_64qam_epi16(a_r_m7_m5, a_i_m7_m5, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_m5);
+    square_a_64qam_epi16(a_r_m7_m7, a_i_m7_m7, ch_mag_int, SQRT_42_OVER_FOUR, a_sq_m7_m7);
+
+    // Computing different multiples of ||h0||^2
+    // x=1, y=1
+    ch_mag_2_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,ONE_OVER_FOUR_SQRT_42);
+    ch_mag_2_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_2_over_42_with_sigma2,1);
+    // x=1, y=3
+    ch_mag_10_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,FIVE_OVER_FOUR_SQRT_42);
+    ch_mag_10_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_10_over_42_with_sigma2,1);
+    // x=1, x=5
+    ch_mag_26_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,THIRTEEN_OVER_FOUR_SQRT_42);
+    ch_mag_26_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_26_over_42_with_sigma2,1);
+    // x=1, y=7
+    ch_mag_50_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYFIVE_OVER_FOUR_SQRT_42);
+    ch_mag_50_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_50_over_42_with_sigma2,1);
+    // x=3, y=3
+    ch_mag_18_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,NINE_OVER_FOUR_SQRT_42);
+    ch_mag_18_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_18_over_42_with_sigma2,1);
+    // x=3, y=5
+    ch_mag_34_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,SEVENTEEN_OVER_FOUR_SQRT_42);
+    ch_mag_34_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_34_over_42_with_sigma2,1);
+    // x=3, y=7
+    ch_mag_58_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYNINE_OVER_FOUR_SQRT_42);
+    ch_mag_58_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_58_over_42_with_sigma2,2);
+    // x=5, y=5
+    ch_mag_50_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,TWENTYFIVE_OVER_FOUR_SQRT_42);
+    ch_mag_50_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_50_over_42_with_sigma2,1);
+    // x=5, y=7
+    ch_mag_74_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,THIRTYSEVEN_OVER_FOUR_SQRT_42);
+    ch_mag_74_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_74_over_42_with_sigma2,2);
+    // x=7, y=7
+    ch_mag_98_over_42_with_sigma2 = _mm_mulhi_epi16(ch_mag_des,FORTYNINE_OVER_FOUR_SQRT_42);
+    ch_mag_98_over_42_with_sigma2 = _mm_slli_epi16(ch_mag_98_over_42_with_sigma2,2);
+
+    // Computing Metrics
+    xmm0 = _mm_subs_epi16(psi_a_p7_p7, a_sq_p7_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_7);
+    bit_met_p7_p7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_p5, a_sq_p7_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_5);
+    bit_met_p7_p5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_p3, a_sq_p7_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_3);
+    bit_met_p7_p3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_p1, a_sq_p7_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_7_1);
+    bit_met_p7_p1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m1, a_sq_p7_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_1);
+    bit_met_p7_m1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m3, a_sq_p7_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_3);
+    bit_met_p7_m3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m5, a_sq_p7_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_5);
+    bit_met_p7_m5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p7_m7, a_sq_p7_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_7_7);
+    bit_met_p7_m7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p7, a_sq_p5_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_7);
+    bit_met_p5_p7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p5, a_sq_p5_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_5);
+    bit_met_p5_p5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p3, a_sq_p5_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_3);
+    bit_met_p5_p3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_p1, a_sq_p5_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_5_1);
+    bit_met_p5_p1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m1, a_sq_p5_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_1);
+    bit_met_p5_m1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m3, a_sq_p5_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_3);
+    bit_met_p5_m3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m5, a_sq_p5_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_5);
+    bit_met_p5_m5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p5_m7, a_sq_p5_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_5_7);
+    bit_met_p5_m7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p7, a_sq_p3_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_7);
+    bit_met_p3_p7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p5, a_sq_p3_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_5);
+    bit_met_p3_p5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p3, a_sq_p3_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_3);
+    bit_met_p3_p3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_p1, a_sq_p3_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_3_1);
+    bit_met_p3_p1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m1, a_sq_p3_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_1);
+    bit_met_p3_m1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m3, a_sq_p3_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_3);
+    bit_met_p3_m3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m5, a_sq_p3_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_5);
+    bit_met_p3_m5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p3_m7, a_sq_p3_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_3_7);
+    bit_met_p3_m7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p7, a_sq_p1_p7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_7);
+    bit_met_p1_p7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p5, a_sq_p1_p5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_5);
+    bit_met_p1_p5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p3, a_sq_p1_p3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_3);
+    bit_met_p1_p3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_p1, a_sq_p1_p1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_p_1_1);
+    bit_met_p1_p1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m1, a_sq_p1_m1);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_1);
+    bit_met_p1_m1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m3, a_sq_p1_m3);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_3);
+    bit_met_p1_m3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m5, a_sq_p1_m5);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_5);
+    bit_met_p1_m5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_p1_m7, a_sq_p1_m7);
+    xmm1 = _mm_adds_epi16(xmm0, y0_m_1_7);
+    bit_met_p1_m7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+
+    xmm0 = _mm_subs_epi16(psi_a_m1_p7, a_sq_m1_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_7);
+    bit_met_m1_p7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_p5, a_sq_m1_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_5);
+    bit_met_m1_p5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_p3, a_sq_m1_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_3);
+    bit_met_m1_p3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_p1, a_sq_m1_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_1_1);
+    bit_met_m1_p1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m1, a_sq_m1_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_1);
+    bit_met_m1_m1 = _mm_subs_epi16(xmm1, ch_mag_2_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m3, a_sq_m1_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_3);
+    bit_met_m1_m3 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m5, a_sq_m1_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_5);
+    bit_met_m1_m5 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m1_m7, a_sq_m1_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_1_7);
+    bit_met_m1_m7 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p7, a_sq_m3_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_7);
+    bit_met_m3_p7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p5, a_sq_m3_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_5);
+    bit_met_m3_p5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p3, a_sq_m3_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_3);
+    bit_met_m3_p3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_p1, a_sq_m3_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_3_1);
+    bit_met_m3_p1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m1, a_sq_m3_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_1);
+    bit_met_m3_m1 = _mm_subs_epi16(xmm1, ch_mag_10_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m3, a_sq_m3_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_3);
+    bit_met_m3_m3 = _mm_subs_epi16(xmm1, ch_mag_18_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m5, a_sq_m3_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_5);
+    bit_met_m3_m5 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m3_m7, a_sq_m3_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_3_7);
+    bit_met_m3_m7 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p7, a_sq_m5_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_7);
+    bit_met_m5_p7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p5, a_sq_m5_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_5);
+    bit_met_m5_p5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p3, a_sq_m5_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_3);
+    bit_met_m5_p3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_p1, a_sq_m5_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_5_1);
+    bit_met_m5_p1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m1, a_sq_m5_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_1);
+    bit_met_m5_m1 = _mm_subs_epi16(xmm1, ch_mag_26_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m3, a_sq_m5_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_3);
+    bit_met_m5_m3 = _mm_subs_epi16(xmm1, ch_mag_34_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m5, a_sq_m5_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_5);
+    bit_met_m5_m5 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m5_m7, a_sq_m5_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_5_7);
+    bit_met_m5_m7 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p7, a_sq_m7_p7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_7);
+    bit_met_m7_p7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p5, a_sq_m7_p5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_5);
+    bit_met_m7_p5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p3, a_sq_m7_p3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_3);
+    bit_met_m7_p3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_p1, a_sq_m7_p1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_m_7_1);
+    bit_met_m7_p1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m1, a_sq_m7_m1);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_1);
+    bit_met_m7_m1 = _mm_subs_epi16(xmm1, ch_mag_50_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m3, a_sq_m7_m3);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_3);
+    bit_met_m7_m3 = _mm_subs_epi16(xmm1, ch_mag_58_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m5, a_sq_m7_m5);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_5);
+    bit_met_m7_m5 = _mm_subs_epi16(xmm1, ch_mag_74_over_42_with_sigma2);
+    xmm0 = _mm_subs_epi16(psi_a_m7_m7, a_sq_m7_m7);
+    xmm1 = _mm_subs_epi16(xmm0, y0_p_7_7);
+    bit_met_m7_m7 = _mm_subs_epi16(xmm1, ch_mag_98_over_42_with_sigma2);
+
+    // Detection for 1st bit (LTE mapping)
+    // bit = 1
+    xmm0 = _mm_max_epi16(bit_met_m7_p7, bit_met_m7_p5);
+    xmm1 = _mm_max_epi16(bit_met_m7_p3, bit_met_m7_p1);
+    xmm2 = _mm_max_epi16(bit_met_m7_m1, bit_met_m7_m3);
+    xmm3 = _mm_max_epi16(bit_met_m7_m5, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m5_p7, bit_met_m5_p5);
+    xmm1 = _mm_max_epi16(bit_met_m5_p3, bit_met_m5_p1);
+    xmm2 = _mm_max_epi16(bit_met_m5_m1, bit_met_m5_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m5_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m3_p7, bit_met_m3_p5);
+    xmm1 = _mm_max_epi16(bit_met_m3_p3, bit_met_m3_p1);
+    xmm2 = _mm_max_epi16(bit_met_m3_m1, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m3_m5, bit_met_m3_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_p7, bit_met_m1_p5);
+    xmm1 = _mm_max_epi16(bit_met_m1_p3, bit_met_m1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m1_m3);
+    xmm3 = _mm_max_epi16(bit_met_m1_m5, bit_met_m1_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    // bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p7_p5);
+    xmm1 = _mm_max_epi16(bit_met_p7_p3, bit_met_p7_p1);
+    xmm2 = _mm_max_epi16(bit_met_p7_m1, bit_met_p7_m3);
+    xmm3 = _mm_max_epi16(bit_met_p7_m5, bit_met_p7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_p7, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p5_p3, bit_met_p5_p1);
+    xmm2 = _mm_max_epi16(bit_met_p5_m1, bit_met_p5_m3);
+    xmm3 = _mm_max_epi16(bit_met_p5_m5, bit_met_p5_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_p7, bit_met_p3_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p3_p1);
+    xmm2 = _mm_max_epi16(bit_met_p3_m1, bit_met_p3_m3);
+    xmm3 = _mm_max_epi16(bit_met_p3_m5, bit_met_p3_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_p7, bit_met_p1_p5);
+    xmm1 = _mm_max_epi16(bit_met_p1_p3, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_p1_m1, bit_met_p1_m3);
+    xmm3 = _mm_max_epi16(bit_met_p1_m5, bit_met_p1_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y0r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 2nd bit (LTE mapping)
+    // bit = 1
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    // bit = 0
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m7_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m7_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y1r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 3rd bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_m7_m7, bit_met_m7_m5);
+    xmm1 = _mm_max_epi16(bit_met_m7_m3, bit_met_m7_m1);
+    xmm2 = _mm_max_epi16(bit_met_m7_p1, bit_met_m7_p3);
+    xmm3 = _mm_max_epi16(bit_met_m7_p5, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m5_m7, bit_met_m5_m5);
+    xmm1 = _mm_max_epi16(bit_met_m5_m3, bit_met_m5_m1);
+    xmm2 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_m7, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p5_m3, bit_met_p5_m1);
+    xmm2 = _mm_max_epi16(bit_met_p5_p1, bit_met_p5_p3);
+    xmm3 = _mm_max_epi16(bit_met_p5_p5, bit_met_p5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p7_m5);
+    xmm1 = _mm_max_epi16(bit_met_p7_m3, bit_met_p7_m1);
+    xmm2 = _mm_max_epi16(bit_met_p7_p1, bit_met_p7_p3);
+    xmm3 = _mm_max_epi16(bit_met_p7_p5, bit_met_p7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_m3_m7, bit_met_m3_m5);
+    xmm1 = _mm_max_epi16(bit_met_m3_m3, bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_p5, bit_met_m3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_m7, bit_met_m1_m5);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3, bit_met_m1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m1_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p5, bit_met_m1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_m7, bit_met_p1_m5);
+    xmm1 = _mm_max_epi16(bit_met_p1_m3, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1, bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_p5, bit_met_p1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_m7, bit_met_p3_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1, bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_p5, bit_met_p3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y2r = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 4th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m7_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y0i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+
+    // Detection for 5th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_m7_m7, bit_met_m7_m5);
+    xmm1 = _mm_max_epi16(bit_met_m7_m3, bit_met_m7_m1);
+    xmm2 = _mm_max_epi16(bit_met_m7_p1, bit_met_m7_p3);
+    xmm3 = _mm_max_epi16(bit_met_m7_p5, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m1_m7, bit_met_m1_m5);
+    xmm1 = _mm_max_epi16(bit_met_m1_m3, bit_met_m1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m1_p3);
+    xmm3 = _mm_max_epi16(bit_met_m1_p5, bit_met_m1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p1_m7, bit_met_p1_m5);
+    xmm1 = _mm_max_epi16(bit_met_p1_m3, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_p1_p1, bit_met_p1_p3);
+    xmm3 = _mm_max_epi16(bit_met_p1_p5, bit_met_p1_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p7_m5);
+    xmm1 = _mm_max_epi16(bit_met_p7_m3, bit_met_p7_m1);
+    xmm2 = _mm_max_epi16(bit_met_p7_p1, bit_met_p7_p3);
+    xmm3 = _mm_max_epi16(bit_met_p7_p5, bit_met_p7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_m5_m7, bit_met_m5_m5);
+    xmm1 = _mm_max_epi16(bit_met_m5_m3, bit_met_m5_m1);
+    xmm2 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_m3_m7, bit_met_m3_m5);
+    xmm1 = _mm_max_epi16(bit_met_m3_m3, bit_met_m3_m1);
+    xmm2 = _mm_max_epi16(bit_met_m3_p1, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m3_p5, bit_met_m3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p3_m7, bit_met_p3_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p3_m1);
+    xmm2 = _mm_max_epi16(bit_met_p3_p1, bit_met_p3_p3);
+    xmm3 = _mm_max_epi16(bit_met_p3_p5, bit_met_p3_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p5_m7, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p5_m3, bit_met_p5_m1);
+    xmm2 = _mm_max_epi16(bit_met_p5_p1, bit_met_p5_p3);
+    xmm3 = _mm_max_epi16(bit_met_p5_p5, bit_met_p5_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y1i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+    // Detection for 6th bit (LTE mapping)
+    xmm0 = _mm_max_epi16(bit_met_p7_p7, bit_met_p5_p7);
+    xmm1 = _mm_max_epi16(bit_met_p3_p7, bit_met_p1_p7);
+    xmm2 = _mm_max_epi16(bit_met_m1_p7, bit_met_m3_p7);
+    xmm3 = _mm_max_epi16(bit_met_m5_p7, bit_met_m7_p7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p1, bit_met_p5_p1);
+    xmm1 = _mm_max_epi16(bit_met_p3_p1, bit_met_p1_p1);
+    xmm2 = _mm_max_epi16(bit_met_m1_p1, bit_met_m3_p1);
+    xmm3 = _mm_max_epi16(bit_met_m5_p1, bit_met_m5_p1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m1, bit_met_p5_m1);
+    xmm1 = _mm_max_epi16(bit_met_p3_m1, bit_met_p1_m1);
+    xmm2 = _mm_max_epi16(bit_met_m1_m1, bit_met_m3_m1);
+    xmm3 = _mm_max_epi16(bit_met_m5_m1, bit_met_m7_m1);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m7, bit_met_p5_m7);
+    xmm1 = _mm_max_epi16(bit_met_p3_m7, bit_met_p1_m7);
+    xmm2 = _mm_max_epi16(bit_met_m1_m7, bit_met_m3_m7);
+    xmm3 = _mm_max_epi16(bit_met_m5_m7, bit_met_m7_m7);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm4);
+    logmax_den_re0 = _mm_max_epi16(logmax_den_re0, xmm5);
+
+    xmm0 = _mm_max_epi16(bit_met_p7_m5, bit_met_p5_m5);
+    xmm1 = _mm_max_epi16(bit_met_p3_m5, bit_met_p1_m5);
+    xmm2 = _mm_max_epi16(bit_met_m1_m5, bit_met_m3_m5);
+    xmm3 = _mm_max_epi16(bit_met_m5_m5, bit_met_m7_m5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(xmm4, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_m3, bit_met_p5_m3);
+    xmm1 = _mm_max_epi16(bit_met_p3_m3, bit_met_p1_m3);
+    xmm2 = _mm_max_epi16(bit_met_m1_m3, bit_met_m3_m3);
+    xmm3 = _mm_max_epi16(bit_met_m5_m3, bit_met_m7_m3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p3, bit_met_p5_p3);
+    xmm1 = _mm_max_epi16(bit_met_p3_p3, bit_met_p1_p3);
+    xmm2 = _mm_max_epi16(bit_met_m1_p3, bit_met_m3_p3);
+    xmm3 = _mm_max_epi16(bit_met_m5_p3, bit_met_m7_p3);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+    xmm0 = _mm_max_epi16(bit_met_p7_p5, bit_met_p5_p5);
+    xmm1 = _mm_max_epi16(bit_met_p3_p5, bit_met_p1_p5);
+    xmm2 = _mm_max_epi16(bit_met_m1_p5, bit_met_m3_p5);
+    xmm3 = _mm_max_epi16(bit_met_m5_p5, bit_met_m7_p5);
+    xmm4 = _mm_max_epi16(xmm0, xmm1);
+    xmm5 = _mm_max_epi16(xmm2, xmm3);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm4);
+    logmax_num_re0 = _mm_max_epi16(logmax_num_re0, xmm5);
+
+    y2i = _mm_subs_epi16(logmax_num_re0, logmax_den_re0);
+
+
+    // map to output stream, difficult to do in SIMD since we have 6 16bit LLRs
+    // RE 1
+    j = 24*i;
+    stream0_out[j + 0] = ((short *)&y0r)[0];
+    stream0_out[j + 1] = ((short *)&y1r)[0];
+    stream0_out[j + 2] = ((short *)&y2r)[0];
+    stream0_out[j + 3] = ((short *)&y0i)[0];
+    stream0_out[j + 4] = ((short *)&y1i)[0];
+    stream0_out[j + 5] = ((short *)&y2i)[0];
+    // RE 2
+    stream0_out[j + 6] = ((short *)&y0r)[1];
+    stream0_out[j + 7] = ((short *)&y1r)[1];
+    stream0_out[j + 8] = ((short *)&y2r)[1];
+    stream0_out[j + 9] = ((short *)&y0i)[1];
+    stream0_out[j + 10] = ((short *)&y1i)[1];
+    stream0_out[j + 11] = ((short *)&y2i)[1];
+    // RE 3
+    stream0_out[j + 12] = ((short *)&y0r)[2];
+    stream0_out[j + 13] = ((short *)&y1r)[2];
+    stream0_out[j + 14] = ((short *)&y2r)[2];
+    stream0_out[j + 15] = ((short *)&y0i)[2];
+    stream0_out[j + 16] = ((short *)&y1i)[2];
+    stream0_out[j + 17] = ((short *)&y2i)[2];
+    // RE 4
+    stream0_out[j + 18] = ((short *)&y0r)[3];
+    stream0_out[j + 19] = ((short *)&y1r)[3];
+    stream0_out[j + 20] = ((short *)&y2r)[3];
+    stream0_out[j + 21] = ((short *)&y0i)[3];
+    stream0_out[j + 22] = ((short *)&y1i)[3];
+    stream0_out[j + 23] = ((short *)&y2i)[3];
+    // RE 5
+    stream0_out[j + 24] = ((short *)&y0r)[4];
+    stream0_out[j + 25] = ((short *)&y1r)[4];
+    stream0_out[j + 26] = ((short *)&y2r)[4];
+    stream0_out[j + 27] = ((short *)&y0i)[4];
+    stream0_out[j + 28] = ((short *)&y1i)[4];
+    stream0_out[j + 29] = ((short *)&y2i)[4];
+    // RE 6
+    stream0_out[j + 30] = ((short *)&y0r)[5];
+    stream0_out[j + 31] = ((short *)&y1r)[5];
+    stream0_out[j + 32] = ((short *)&y2r)[5];
+    stream0_out[j + 33] = ((short *)&y0i)[5];
+    stream0_out[j + 34] = ((short *)&y1i)[5];
+    stream0_out[j + 35] = ((short *)&y2i)[5];
+    // RE 7
+    stream0_out[j + 36] = ((short *)&y0r)[6];
+    stream0_out[j + 37] = ((short *)&y1r)[6];
+    stream0_out[j + 38] = ((short *)&y2r)[6];
+    stream0_out[j + 39] = ((short *)&y0i)[6];
+    stream0_out[j + 40] = ((short *)&y1i)[6];
+    stream0_out[j + 41] = ((short *)&y2i)[6];
+    // RE 8
+    stream0_out[j + 42] = ((short *)&y0r)[7];
+    stream0_out[j + 43] = ((short *)&y1r)[7];
+    stream0_out[j + 44] = ((short *)&y2r)[7];
+    stream0_out[j + 45] = ((short *)&y0i)[7];
+    stream0_out[j + 46] = ((short *)&y1i)[7];
+    stream0_out[j + 47] = ((short *)&y2i)[7];
+
+#elif defined(__arm__)
+
+#endif
+
+  }
+
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+
+int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
+                          int32_t **rxdataF_comp,
+                          int32_t **rxdataF_comp_i,
+                          int32_t **dl_ch_mag,
+                          int32_t **dl_ch_mag_i,
+                          int32_t **rho_i,
+                          int16_t *dlsch_llr,
+                          uint8_t symbol,
+                          uint8_t first_symbol_flag,
+                          uint16_t nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          //int16_t **llr16p,
+                          uint32_t llr_offset)
+{
+
+  int16_t *rxF      = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rxF_i    = (int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag   = (int16_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *rho      = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)];
+  int16_t *llr16;
+  int8_t  *pllr_symbol; // pointer where llrs should filled for this ofdm symbol
+  int len;
+  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
+
+  //first symbol has different structure due to more pilots
+  /*if (first_symbol_flag == 1) {
+    llr16 = (int16_t*)dlsch_llr;
+  } else {
+    llr16 = (int16_t*)(*llr16p);
+  }*/
+
+  llr16 = (int16_t*)dlsch_llr;
+
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
+
+
+  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
+    // if symbol has pilots
+    if (frame_parms->nb_antenna_ports_eNB!=1)
+      // in 2 antenna ports we have 8 REs per symbol per RB
+      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
+    else
+      // for 1 antenna port we have 10 REs per symbol per RB
+      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
+  } else {
+    // symbol has no pilots
+    len = (nb_rb*12) - pbch_pss_sss_adjust;
+  }
+
+  pllr_symbol = (int8_t*)dlsch_llr;
+  pllr_symbol += llr_offset;
+  //printf("dlsch_64qam_64qam_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust);
+  /*LOG_I(PHY,"dlsch_64qam_64qam_llr [symb %d / FirstSym %d / Length %d / LLR Offset %d]: @LLR Buff %x, @LLR Buff(symb) %x, , @Compute LLR Buff(symb) %x  \n",
+             symbol,
+             first_symbol_flag,
+             len,
+             llr_offset,
+             (int16_t*)dlsch_llr,
+             llr16,
+             pllr_symbol);*/
+
+#ifdef __AVX2__
+
+  // Round length up to multiple of 16 words
+  uint32_t len256i = ((len+16)>>4)*16;
+  int32_t *rxF_256i      = (int32_t*) malloc16_clear(len256i*4);
+  int32_t *rxF_i_256i    = (int32_t*) malloc16_clear(len256i*4);
+  int32_t *ch_mag_256i   = (int32_t*) malloc16_clear(len256i*4);
+  int32_t *ch_mag_i_256i = (int32_t*) malloc16_clear(len256i*4);
+  int32_t *rho_256i      = (int32_t*) malloc16_clear(len256i*4);
+
+  memcpy(rxF_256i, rxF, len*4);
+  memcpy(rxF_i_256i, rxF_i, len*4);
+  memcpy(ch_mag_256i, ch_mag, len*4);
+  memcpy(ch_mag_i_256i, ch_mag_i, len*4);
+  memcpy(rho_256i, rho, len*4);
+
+#if 0
+  qam64_qam16_avx2((short *)rxF_256i,
+                   (short *)rxF_i_256i,
+                   (short *)ch_mag_256i,
+                   (short *)ch_mag_i_256i,
+                   (short *)llr16,
+                   (short *) rho_256i,
+                   len);
+#else
+  qam64_qam64_avx2((int32_t *)rxF_256i,
+                   (int32_t *)rxF_i_256i,
+                   (int32_t *)ch_mag_256i,
+                   (int32_t *)ch_mag_i_256i,
+                   (int16_t *)llr16,
+                   (int32_t *) rho_256i,
+                   len);
+#endif
+  
+  free16(rxF_256i, sizeof(rxF_256i));
+  free16(rxF_i_256i, sizeof(rxF_i_256i));
+  free16(ch_mag_256i, sizeof(ch_mag_256i));
+  free16(ch_mag_i_256i, sizeof(ch_mag_i_256i));
+  free16(rho_256i, sizeof(rho_256i));
+
+#else
+  qam64_qam64((short *)rxF,
+              (short *)rxF_i,
+              (short *)ch_mag,
+              (short *)ch_mag_i,
+              (short *)llr16,
+              (short *)rho,
+              len);
+#endif
+
+  llr16 += (6*len);
+  //*llr16p = (short *)llr16;
+
+  return(0);
+}
diff --git a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c b/openair1/PHY/LTE_TRANSPORT/drs_modulation.c
new file mode 100644
index 0000000000000000000000000000000000000000..a0bde219b57706e59b5d5746f8408bc1307f46be
--- /dev/null
+++ b/openair1/PHY/LTE_TRANSPORT/drs_modulation.c
@@ -0,0 +1,173 @@
+/*
+ * 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/drs_modulation.c
+* \brief Top-level routines for generating the Demodulation Reference Signals from 36-211, V8.6 2009-03
+* \author R. Knopp, F. Kaltenberger, A. Bhamri
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,ankit.bhamri@eurecom.fr
+* \note
+* \warning
+*/
+#include "PHY/defs.h"
+#include "PHY/extern.h"
+#include "PHY/sse_intrin.h"
+//#define DEBUG_DRS
+
+int generate_drs_pusch(PHY_VARS_UE *ue,
+		       UE_rxtx_proc_t *proc,
+                       uint8_t eNB_id,
+                       short amp,
+                       unsigned int subframe,
+                       unsigned int first_rb,
+                       unsigned int nb_rb,
+                       uint8_t ant)
+{
+
+  uint16_t k,l,Msc_RS,Msc_RS_idx,rb,drs_offset;
+  uint16_t * Msc_idx_ptr;
+  int subframe_offset,re_offset,symbol_offset;
+
+  //uint32_t phase_shift; // phase shift for cyclic delay in DM RS
+  //uint8_t alpha_ind;
+
+  int16_t alpha_re[12] = {32767, 28377, 16383,     0,-16384,  -28378,-32768,-28378,-16384,    -1, 16383, 28377};
+  int16_t alpha_im[12] = {0,     16383, 28377, 32767, 28377,   16383,     0,-16384,-28378,-32768,-28378,-16384};
+
+  uint8_t cyclic_shift,cyclic_shift0,cyclic_shift1;
+  LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
+  int32_t *txdataF = ue->common_vars.txdataF[ant];
+  uint32_t u,v,alpha_ind;
+  uint32_t u0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1];
+  uint32_t u1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)];
+  uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1];
+  uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)];
+  int32_t ref_re,ref_im;
+  uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_tx,subframe);
+
+  cyclic_shift0 = (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift +
+                   ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2 +
+                   frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]+
+                   ((ue->ulsch[0]->cooperation_flag==2)?10:0)+
+                   ant*6) % 12;
+  //  printf("PUSCH.cyclicShift %d, n_DMRS2 %d, nPRS %d\n",frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift,ue->ulsch[eNB_id]->n_DMRS2,ue->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]);
+  cyclic_shift1 = (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift +
+                   ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2 +
+                   frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[(subframe<<1)+1]+
+                   ((ue->ulsch[0]->cooperation_flag==2)?10:0)+
+                   ant*6) % 12;
+
+  //       cyclic_shift0 = 0;
+  //        cyclic_shift1 = 0;
+  Msc_RS = 12*nb_rb;
+
+  Msc_idx_ptr = (uint16_t*) bsearch(&Msc_RS, dftsizes, 33, sizeof(uint16_t), compareints);
+
+  if (Msc_idx_ptr)
+    Msc_RS_idx = Msc_idx_ptr - dftsizes;
+  else {
+    LOG_I(PHY,"generate_drs_pusch: index for Msc_RS=%d not found\n",Msc_RS);
+    return(-1);
+  }
+
+  for (l = (3 - frame_parms->Ncp),u=u0,v=v0,cyclic_shift=cyclic_shift0;
+       l<frame_parms->symbols_per_tti;
+       l += (7 - frame_parms->Ncp),u=u1,v=v1,cyclic_shift=cyclic_shift1) {
+
+    drs_offset = 0;
+#ifdef DEBUG_DRS
+    printf("drs_modulation: Msc_RS = %d, Msc_RS_idx = %d, u=%d,v=%d\n",Msc_RS, Msc_RS_idx,u,v);
+#endif
+
+
+    re_offset = frame_parms->first_carrier_offset;
+    subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size;
+    symbol_offset = subframe_offset + frame_parms->ofdm_symbol_size*l;
+
+
+#ifdef DEBUG_DRS
+    printf("generate_drs_pusch: symbol_offset %d, subframe offset %d, cyclic shift %d\n",symbol_offset,subframe_offset,cyclic_shift);
+#endif
+    alpha_ind = 0;
+
+    for (rb=0; rb<frame_parms->N_RB_UL; rb++) {
+
+      if ((rb >= first_rb) && (rb<(first_rb+nb_rb))) {
+
+#ifdef DEBUG_DRS
+        printf("generate_drs_pusch: doing RB %d, re_offset=%d, drs_offset=%d,cyclic shift %d\n",rb,re_offset,drs_offset,cyclic_shift);
+#endif
+
+        for (k=0; k<12; k++) {
+          ref_re = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1];
+          ref_im = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1];
+
+          ((int16_t*) txdataF)[2*(symbol_offset + re_offset)]   = (int16_t) (((ref_re*alpha_re[alpha_ind]) -
+              (ref_im*alpha_im[alpha_ind]))>>15);
+          ((int16_t*) txdataF)[2*(symbol_offset + re_offset)+1] = (int16_t) (((ref_re*alpha_im[alpha_ind]) +
+              (ref_im*alpha_re[alpha_ind]))>>15);
+          ((short*) txdataF)[2*(symbol_offset + re_offset)]   = (short) ((((short*) txdataF)[2*(symbol_offset + re_offset)]*(int32_t)amp)>>15);
+          ((short*) txdataF)[2*(symbol_offset + re_offset)+1] = (short) ((((short*) txdataF)[2*(symbol_offset + re_offset)+1]*(int32_t)amp)>>15);
+
+
+          alpha_ind = (alpha_ind + cyclic_shift);
+
+          if (alpha_ind > 11)
+            alpha_ind-=12;
+
+#ifdef DEBUG_DRS
+          printf("symbol_offset %d, alpha_ind %d , re_offset %d : (%d,%d)\n",
+              symbol_offset,
+              alpha_ind,
+              re_offset,
+              ((short*) txdataF)[2*(symbol_offset + re_offset)],
+              ((short*) txdataF)[2*(symbol_offset + re_offset)+1]);
+
+#endif  // DEBUG_DRS
+          re_offset++;
+          drs_offset++;
+
+          if (re_offset >= frame_parms->ofdm_symbol_size)
+            re_offset = 0;
+        }
+
+      } else {
+        re_offset+=12; // go to next RB
+
+        // check if we crossed the symbol boundary and skip DC
+
+        if (re_offset >= frame_parms->ofdm_symbol_size) {
+          if (frame_parms->N_RB_DL&1)  // odd number of RBs
+            re_offset=6;
+          else                         // even number of RBs (doesn't straddle DC)
+            re_offset=0;
+        }
+
+
+      }
+    }
+  }
+
+  return(0);
+}
+
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c
new file mode 100644
index 0000000000000000000000000000000000000000..09420f48ab1a7029fdbbb2015fd7f28f47ffcd8c
--- /dev/null
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c
@@ -0,0 +1,933 @@
+/*
+ * 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/ulsch_coding.c
+* \brief Top-level routines for coding the ULSCH transport channel as described in 36.212 V8.6 2009-03
+* \author R. Knopp
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: knopp@eurecom.fr
+* \note
+* \warning
+*/
+
+#include "PHY/defs.h"
+#include "PHY/extern.h"
+
+#include "PHY/CODING/defs.h"
+#include "PHY/CODING/extern.h"
+#include "PHY/CODING/lte_interleaver_inline.h"
+#include "PHY/LTE_TRANSPORT/defs.h"
+#include "defs.h"
+#include "extern.h"
+#include "SIMULATION/ETH_TRANSPORT/extern.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+
+//#define DEBUG_ULSCH_CODING
+//#define DEBUG_ULSCH_FREE 1
+
+/*
+#define is_not_pilot(pilots,first_pilot,re) (pilots==0) || \
+  ((pilots==1)&&(first_pilot==1)&&(((re>2)&&(re<6))||((re>8)&&(re<12)))) || \
+  ((pilots==1)&&(first_pilot==0)&&(((re<3))||((re>5)&&(re<9)))) \
+*/
+#define is_not_pilot(pilots,first_pilot,re) (1)
+
+
+
+
+void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch)
+{
+  int i;
+  int r;
+
+  if (ulsch) {
+#ifdef DEBUG_ULSCH_FREE
+    printf("Freeing ulsch %p\n",ulsch);
+#endif
+
+    for (i=0; i<8; i++) {
+      if (ulsch->harq_processes[i]) {
+        if (ulsch->harq_processes[i]->b) {
+          free16(ulsch->harq_processes[i]->b,MAX_ULSCH_PAYLOAD_BYTES);
+          ulsch->harq_processes[i]->b = NULL;
+        }
+        for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++) {
+          if (ulsch->harq_processes[i]->c[r]) {
+            free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
+            ulsch->harq_processes[i]->c[r] = NULL;
+          }
+        }
+
+        free16(ulsch->harq_processes[i],sizeof(LTE_UL_UE_HARQ_t));
+        ulsch->harq_processes[i] = NULL;
+      }
+    }
+    free16(ulsch,sizeof(LTE_UE_ULSCH_t));
+    ulsch = NULL;
+  }
+
+}
+
+LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag)
+{
+
+  LTE_UE_ULSCH_t *ulsch;
+  unsigned char exit_flag = 0,i,j,r;
+  unsigned char bw_scaling =1;
+
+  switch (N_RB_UL) {
+  case 6:
+    bw_scaling =16;
+    break;
+
+  case 25:
+    bw_scaling =4;
+    break;
+
+  case 50:
+    bw_scaling =2;
+    break;
+
+  default:
+    bw_scaling =1;
+    break;
+  }
+
+  ulsch = (LTE_UE_ULSCH_t *)malloc16(sizeof(LTE_UE_ULSCH_t));
+
+  if (ulsch) {
+    memset(ulsch,0,sizeof(LTE_UE_ULSCH_t));
+
+    ulsch->Mlimit = 4;
+
+    for (i=0; i<8; i++) {
+
+      ulsch->harq_processes[i] = (LTE_UL_UE_HARQ_t *)malloc16(sizeof(LTE_UL_UE_HARQ_t));
+
+      //      printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]);
+      if (ulsch->harq_processes[i]) {
+        memset(ulsch->harq_processes[i], 0, sizeof(LTE_UL_UE_HARQ_t));
+        ulsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_ULSCH_PAYLOAD_BYTES/bw_scaling);
+
+        if (ulsch->harq_processes[i]->b)
+          memset(ulsch->harq_processes[i]->b,0,MAX_ULSCH_PAYLOAD_BYTES/bw_scaling);
+        else {
+          LOG_E(PHY,"Can't get b\n");
+          exit_flag=1;
+        }
+
+        if (abstraction_flag==0) {
+          for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++) {
+            ulsch->harq_processes[i]->c[r] = (unsigned char*)malloc16(((r==0)?8:0) + 3+768);  // account for filler in first segment and CRCs for multiple segment case
+
+            if (ulsch->harq_processes[i]->c[r])
+              memset(ulsch->harq_processes[i]->c[r],0,((r==0)?8:0) + 3+768);
+            else {
+              LOG_E(PHY,"Can't get c\n");
+              exit_flag=2;
+            }
+          }
+        }
+
+        ulsch->harq_processes[i]->subframe_scheduling_flag = 0;
+        ulsch->harq_processes[i]->first_tx = 1;
+      } else {
+        LOG_E(PHY,"Can't get harq_p %d\n",i);
+        exit_flag=3;
+      }
+    }
+
+    if ((abstraction_flag == 0) && (exit_flag==0)) {
+      for (i=0; i<8; i++)
+        for (j=0; j<96; j++)
+          for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++)
+            ulsch->harq_processes[i]->d[r][j] = LTE_NULL;
+
+      return(ulsch);
+    } else if (abstraction_flag==1)
+      return(ulsch);
+  }
+
+  LOG_E(PHY,"new_ue_ulsch exit flag, size of  %d ,   %zu\n",exit_flag, sizeof(LTE_UE_ULSCH_t));
+  free_ue_ulsch(ulsch);
+  return(NULL);
+
+
+}
+
+
+uint32_t ulsch_encoding(uint8_t *a,
+                        PHY_VARS_UE *ue,
+                        uint8_t harq_pid,
+                        uint8_t eNB_id,
+                        uint8_t subframe_rx,
+                        uint8_t tmode,
+                        uint8_t control_only_flag,
+                        uint8_t Nbundled)
+{
+
+  time_stats_t *seg_stats=&ue->ulsch_segmentation_stats;
+  time_stats_t *rm_stats=&ue->ulsch_rate_matching_stats;
+  time_stats_t *te_stats=&ue->ulsch_turbo_encoding_stats;
+  time_stats_t *i_stats=&ue->ulsch_interleaving_stats;
+  time_stats_t *m_stats=&ue->ulsch_multiplexing_stats;
+
+  //  uint16_t offset;
+  uint32_t crc=1;
+  uint16_t iind;
+  uint32_t A;
+  uint8_t Q_m=0;
+  uint32_t Kr=0,Kr_bytes,r,r_offset=0;
+  uint8_t y[6*14*1200],*yptr;;
+  uint8_t *columnset;
+  uint32_t sumKr=0;
+  uint32_t Qprime,L,G,Q_CQI=0,Q_RI=0,Q_ACK=0,H=0,Hprime=0,Hpp=0,Cmux=0,Rmux=0,Rmux_prime=0;
+  uint32_t Qprime_ACK=0,Qprime_CQI=0,Qprime_RI=0,len_ACK=0,len_RI=0;
+  //  uint32_t E;
+  uint8_t ack_parity;
+  uint32_t i,q,j,iprime,j2;
+  uint16_t o_RCC;
+  uint8_t o_flip[8];
+  uint32_t wACK_idx;
+  LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
+  PHY_MEASUREMENTS *meas = &ue->measurements;
+  LTE_UE_ULSCH_t *ulsch=ue->ulsch[eNB_id];
+  LTE_UE_DLSCH_t **dlsch = ue->dlsch[0][eNB_id];
+  uint16_t rnti = 0xffff;
+
+  if (!ulsch) {
+    LOG_E(PHY,"Null ulsch ptr %p\n",ulsch);
+    return(-1);
+  }
+
+  if (harq_pid >= 8) {
+    LOG_E(PHY,"Illegal harq_pid %d\n",harq_pid);
+    return(-1);
+  }
+
+  if (ulsch->harq_processes[harq_pid]->O_ACK > 2) {
+    LOG_E(PHY,"Illegal O_ACK %d\n",ulsch->harq_processes[harq_pid]->O_ACK);
+    return(-1);
+  }
+
+  if (ulsch->O_RI > 1) {
+    LOG_E(PHY,"Illegal O_RI %d\n",ulsch->O_RI);
+    return(-1);
+  }
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_IN);
+
+  // fill CQI/PMI information
+  if (ulsch->O>0) {
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING_FILL_CQI, VCD_FUNCTION_IN);
+    rnti = ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti;
+    fill_CQI(ulsch,meas,0,harq_pid,ue->frame_parms.N_RB_DL,rnti, tmode,ue->sinr_eff);
+
+    LOG_D(PHY,"ULSCH Encoding rnti %x \n", rnti);
+    print_CQI(ulsch->o,ulsch->uci_format,0,ue->frame_parms.N_RB_DL);
+
+    // save PUSCH pmi for later (transmission modes 4,5,6)
+    if (dlsch[0]) {
+      //LOG_I(PHY,"XXX saving pmi for DL %x\n",pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)ulsch->o)->pmi));
+      dlsch[0]->pmi_alloc = ((wideband_cqi_rank1_2A_5MHz *)ulsch->o)->pmi;
+    }
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING_FILL_CQI, VCD_FUNCTION_OUT);
+  }
+
+  if (ulsch->O<=32) {
+    o_flip[0] = ulsch->o[3];
+    o_flip[1] = ulsch->o[2];
+    o_flip[2] = ulsch->o[1];
+    o_flip[3] = ulsch->o[0];
+  } else {
+    o_flip[0] = ulsch->o[7];
+    o_flip[1] = ulsch->o[6];
+    o_flip[2] = ulsch->o[5];
+    o_flip[3] = ulsch->o[4];
+    o_flip[4] = ulsch->o[3];
+    o_flip[5] = ulsch->o[2];
+    o_flip[6] = ulsch->o[1];
+    o_flip[7] = ulsch->o[0];
+  }
+
+  if (control_only_flag == 0) {
+    A=ulsch->harq_processes[harq_pid]->TBS;
+    Q_m = get_Qm_ul(ulsch->harq_processes[harq_pid]->mcs);
+
+    ulsch->harq_processes[harq_pid]->control_only = 0;
+
+#ifdef DEBUG_ULSCH_CODING
+    printf("[PHY][UE] ULSCH coding : A %d, Qm %d, mcs %d, harq_pid %d, round %d, RV %d\n",
+        ulsch->harq_processes[harq_pid]->TBS,
+        Q_m,
+        ulsch->harq_processes[harq_pid]->mcs,
+        harq_pid,
+        ulsch->harq_processes[harq_pid]->round,
+        ulsch->harq_processes[harq_pid]->rvidx);
+
+    for (i=0; i<ulsch->harq_processes[harq_pid]->O_ACK; i++)
+      printf("ulsch_coding: o_ACK[%d] %d\n",i,ulsch->o_ACK[i]);
+
+    for (i=0; i<ulsch->O_RI; i++)
+      printf("ulsch_coding: o_RI[%d] %d\n",i,ulsch->o_RI[i]);
+
+    printf("ulsch_coding: O=%d\n",ulsch->O);
+
+    for (i=0; i<1+((8+ulsch->O)/8); i++) {
+      //    ulsch->o[i] = i;
+      printf("ulsch_coding: O[%d] %d\n",i,ulsch->o[i]);
+    }
+
+    if ((tmode != 4))
+      print_CQI(ulsch->o,wideband_cqi_rank1_2A,0,ue->frame_parms.N_RB_DL);
+    else
+      print_CQI(ulsch->o,HLC_subband_cqi_rank1_2A,0,ue->frame_parms.N_RB_DL);
+
+#endif
+
+    if (ulsch->harq_processes[harq_pid]->round == 0) {  // this is a new packet
+
+      start_meas(seg_stats);
+      // Add 24-bit crc (polynomial A) to payload
+      crc = crc24a(a,
+                   A)>>8;
+
+      a[A>>3] = ((uint8_t*)&crc)[2];
+      a[1+(A>>3)] = ((uint8_t*)&crc)[1];
+      a[2+(A>>3)] = ((uint8_t*)&crc)[0];
+
+      ulsch->harq_processes[harq_pid]->B = A+24;
+      ulsch->harq_processes[harq_pid]->b = a;
+      lte_segmentation(ulsch->harq_processes[harq_pid]->b,
+                       ulsch->harq_processes[harq_pid]->c,
+                       ulsch->harq_processes[harq_pid]->B,
+                       &ulsch->harq_processes[harq_pid]->C,
+                       &ulsch->harq_processes[harq_pid]->Cplus,
+                       &ulsch->harq_processes[harq_pid]->Cminus,
+                       &ulsch->harq_processes[harq_pid]->Kplus,
+                       &ulsch->harq_processes[harq_pid]->Kminus,
+                       &ulsch->harq_processes[harq_pid]->F);
+
+      stop_meas(seg_stats);
+
+      for (r=0; r<ulsch->harq_processes[harq_pid]->C; r++) {
+        if (r<ulsch->harq_processes[harq_pid]->Cminus)
+          Kr = ulsch->harq_processes[harq_pid]->Kminus;
+        else
+          Kr = ulsch->harq_processes[harq_pid]->Kplus;
+
+        Kr_bytes = Kr>>3;
+
+        // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14)
+        if (Kr_bytes<=64)
+          iind = (Kr_bytes-5);
+        else if (Kr_bytes <=128)
+          iind = 59 + ((Kr_bytes-64)>>1);
+        else if (Kr_bytes <= 256)
+          iind = 91 + ((Kr_bytes-128)>>2);
+        else if (Kr_bytes <= 768)
+          iind = 123 + ((Kr_bytes-256)>>3);
+        else {
+          LOG_E(PHY,"ulsch_coding: Illegal codeword size %d!!!\n",Kr_bytes);
+          VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+          return(-1);
+        }
+
+
+#ifdef DEBUG_ULSCH_CODING
+        printf("Generating Code Segment %d (%d bits)\n",r,Kr);
+        // generate codewords
+
+        printf("bits_per_codeword (Kr)= %d\n",Kr);
+        printf("N_RB = %d\n",ulsch->harq_processes[harq_pid]->nb_rb);
+        printf("Ncp %d\n",frame_parms->Ncp);
+        printf("Qm %d\n",Q_m);
+#endif
+
+        //  offset=0;
+
+
+#ifdef DEBUG_ULSCH_CODING
+        printf("Encoding ... iind %d f1 %d, f2 %d\n",iind,f1f2mat_old[iind*2],f1f2mat_old[(iind*2)+1]);
+#endif
+        start_meas(te_stats);
+        encoder(ulsch->harq_processes[harq_pid]->c[r],
+        	Kr>>3,
+        	&ulsch->harq_processes[harq_pid]->d[r][96],
+        	(r==0) ? ulsch->harq_processes[harq_pid]->F : 0,
+        	f1f2mat_old[iind*2],   // f1 (see 36212-820, page 14)
+        	f1f2mat_old[(iind*2)+1]  // f2 (see 36212-820, page 14)
+               );
+        stop_meas(te_stats);
+#ifdef DEBUG_ULSCH_CODING
+
+        if (r==0)
+          write_output("enc_output0.m","enc0",&ulsch->harq_processes[harq_pid]->d[r][96],(3*8*Kr_bytes)+12,1,4);
+
+#endif
+        start_meas(i_stats);
+        ulsch->harq_processes[harq_pid]->RTC[r] =
+          sub_block_interleaving_turbo(4+(Kr_bytes*8),
+                                       &ulsch->harq_processes[harq_pid]->d[r][96],
+                                       ulsch->harq_processes[harq_pid]->w[r]);
+        stop_meas(i_stats);
+      }
+
+    }
+
+    if (ulsch->harq_processes[harq_pid]->C == 0) {
+      LOG_E(PHY,"null segment\n");
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+      return(-1);
+    }
+
+    sumKr = 0;
+
+    for (r=0; r<ulsch->harq_processes[harq_pid]->C; r++) {
+      if (r<ulsch->harq_processes[harq_pid]->Cminus)
+        Kr = ulsch->harq_processes[harq_pid]->Kminus;
+      else
+        Kr = ulsch->harq_processes[harq_pid]->Kplus;
+
+      sumKr += Kr;
+    }
+  } else { // This is a control-only PUSCH, set sumKr to O_CQI-MIN
+    ulsch->harq_processes[harq_pid]->control_only = 1;
+    sumKr = ulsch->O_CQI_MIN;
+  }
+
+  ulsch->harq_processes[harq_pid]->sumKr = sumKr;
+  // Compute Q_ri (p. 23 36-212)
+
+  Qprime = ulsch->O_RI*ulsch->harq_processes[harq_pid]->Msc_initial*ulsch->harq_processes[harq_pid]->Nsymb_initial * ulsch->beta_offset_ri_times8;
+
+  if (Qprime > 0) {
+    if ((Qprime % (8*sumKr)) > 0)
+      Qprime = 1+(Qprime/(8*sumKr));
+    else
+      Qprime = Qprime/(8*sumKr);
+
+    if (Qprime > 4*ulsch->harq_processes[harq_pid]->nb_rb * 12)
+      Qprime = 4*ulsch->harq_processes[harq_pid]->nb_rb * 12;
+  }
+
+  Q_RI = Q_m*Qprime;
+  Qprime_RI = Qprime;
+
+  // Compute Q_ack (p. 23 36-212)
+  Qprime = ulsch->harq_processes[harq_pid]->O_ACK*ulsch->harq_processes[harq_pid]->Msc_initial*ulsch->harq_processes[harq_pid]->Nsymb_initial * ulsch->beta_offset_harqack_times8;
+
+  if (Qprime > 0) {
+    if ((Qprime % (8*sumKr)) > 0)
+      Qprime = 1+(Qprime/(8*sumKr));
+    else
+      Qprime = Qprime/(8*sumKr);
+
+    if (Qprime > 4*ulsch->harq_processes[harq_pid]->nb_rb * 12)
+      Qprime = 4*ulsch->harq_processes[harq_pid]->nb_rb * 12;
+  }
+
+  Q_ACK = Qprime * Q_m;
+  Qprime_ACK = Qprime;
+
+  LOG_D(PHY,"UE (%x/%d) O_ACK %d, Mcs_initial %d, Nsymb_initial %d, beta_offset_harqack*8 %d, sum Kr %d, Qprime_ACK %d, Q_ACK %d\n",
+      rnti, harq_pid,
+      ulsch->harq_processes[harq_pid]->O_ACK,
+      ulsch->harq_processes[harq_pid]->Msc_initial,
+      ulsch->harq_processes[harq_pid]->Nsymb_initial,
+      ulsch->beta_offset_harqack_times8,
+      sumKr,
+      Qprime_ACK,
+      Q_ACK);
+
+  // Compute Q_cqi, assume O>11, p. 26 36-212
+  if (control_only_flag == 0) {
+
+    if (ulsch->O < 12)
+      L=0;
+    else
+      L=8;
+
+    if (ulsch->O > 0)
+      Qprime = (ulsch->O + L) * ulsch->harq_processes[harq_pid]->Msc_initial*ulsch->harq_processes[harq_pid]->Nsymb_initial * ulsch->beta_offset_cqi_times8;
+    else
+      Qprime = 0;
+
+    if (Qprime > 0) {
+      if ((Qprime % (8*sumKr)) > 0)
+        Qprime = 1+(Qprime/(8*sumKr));
+      else
+        Qprime = Qprime/(8*sumKr);
+    }
+
+    G = ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch);
+
+    if (Qprime > (G - ulsch->O_RI))
+      Qprime = G - ulsch->O_RI;
+
+    Q_CQI = Q_m * Qprime;
+    Qprime_CQI = Qprime;
+
+
+
+    G = G - Q_RI - Q_CQI;
+    ulsch->harq_processes[harq_pid]->G = G;
+
+/*
+    LOG_I(PHY,"ULSCH Encoding G %d, Q_RI %d (O_RI%d, Msc_initial %d, Nsymb_initial%d, beta_offset_ri_times8 %d), Q_CQI %d, Q_ACK %d \n",G,Q_RI,ulsch->O_RI,ulsch->harq_processes[harq_pid]->Msc_initial,ulsch->harq_processes[harq_pid]->Nsymb_initial,ulsch->beta_offset_ri_times8,Q_CQI,Q_ACK);
+
+    LOG_I(PHY,"ULSCH Encoding (Nid_cell %d, rnti %x): harq_pid %d round %d, RV %d, mcs %d, O_RI %d, O_ACK %d, G %d\n",
+          frame_parms->Nid_cell,ulsch->rnti,
+          harq_pid,
+          ulsch->harq_processes[harq_pid]->round,
+          ulsch->harq_processes[harq_pid]->rvidx,
+          ulsch->harq_processes[harq_pid]->mcs,
+          ulsch->O_RI,
+          ulsch->harq_processes[harq_pid]->O_ACK,
+          G);
+*/
+
+    if ((int)G < 0) {
+      LOG_E(PHY,"FATAL: ulsch_coding.c G < 0 (%d) : Q_RI %d, Q_CQI %d, O %d, betaCQI_times8 %d)\n",G,Q_RI,Q_CQI,ulsch->O,ulsch->beta_offset_cqi_times8);
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+      return(-1);
+    }
+
+
+    // Data and control multiplexing (5.2.2.7 36-212)
+
+    H = G + Q_CQI;
+    Hprime = H/Q_m;
+
+
+
+    // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the
+    // outputs for each code segment, see Section 5.1.5 p.20
+
+    for (r=0; r<ulsch->harq_processes[harq_pid]->C; r++) {
+#ifdef DEBUG_ULSCH_CODING
+      printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n",
+          r,
+          G,
+          Kr*3,
+          Q_m,ulsch->harq_processes[harq_pid]->nb_rb);
+#endif
+
+      start_meas(rm_stats);
+      r_offset += lte_rate_matching_turbo(ulsch->harq_processes[harq_pid]->RTC[r],
+                                          G,
+                                          ulsch->harq_processes[harq_pid]->w[r],
+                                          ulsch->e+r_offset,
+                                          ulsch->harq_processes[harq_pid]->C, // C
+                                          NSOFT,                    // Nsoft,
+                                          0,  // this means UL
+                                          1,
+                                          ulsch->harq_processes[harq_pid]->rvidx,
+                                          get_Qm_ul(ulsch->harq_processes[harq_pid]->mcs),
+                                          1,
+                                          r,
+                                          ulsch->harq_processes[harq_pid]->nb_rb);
+                                          //ulsch->harq_processes[harq_pid]->mcs);                       // r
+      stop_meas(rm_stats);
+#ifdef DEBUG_ULSCH_CODING
+
+      if (r==ulsch->harq_processes[harq_pid]->C-1)
+        write_output("enc_output.m","enc",ulsch->e,r_offset,1,4);
+
+#endif
+    }
+  } else { //control-only PUSCH
+    Q_CQI = (ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch)) - Q_RI;
+    H = Q_CQI;
+    Hprime = H/Q_m;
+  }
+
+
+  //  Do CQI coding
+  if ((ulsch->O>1) && (ulsch->O < 12)) {
+    LOG_E(PHY,"short CQI sizes not supported yet\n");
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+    return(-1);
+  } else {
+    // add 8-bit CRC
+    crc = crc8(o_flip,
+               ulsch->O)>>24;
+#ifdef DEBUG_ULSCH_CODING
+    printf("crc(cqi) tx : %x\n",crc);
+#endif
+    memset((void *)&ulsch->o_d[0],LTE_NULL,96);
+
+    ccodelte_encode(ulsch->O,
+                    1,
+                    o_flip,
+                    &ulsch->o_d[96],
+                    0);
+
+
+    o_RCC = sub_block_interleaving_cc(8+ulsch->O,
+                                      &ulsch->o_d[96],
+                                      ulsch->o_w);
+
+    lte_rate_matching_cc(o_RCC,
+                         Q_CQI,
+                         ulsch->o_w,
+                         ulsch->q);
+
+  }
+
+  i=0;
+
+  //  Do RI coding
+  if (ulsch->O_RI == 1) {
+    switch (Q_m) {
+    case 2:
+      ulsch->q_RI[0] = ulsch->o_RI[0];
+      ulsch->q_RI[1] = PUSCH_y;//ulsch->o_RI[0];
+      len_RI=2;
+      break;
+
+    case 4:
+      ulsch->q_RI[0] = ulsch->o_RI[0];
+      ulsch->q_RI[1] = PUSCH_y;//1;
+      ulsch->q_RI[2] = PUSCH_x;//ulsch->o_RI[0];
+      ulsch->q_RI[3] = PUSCH_x;//1;
+      len_RI=4;
+      break;
+
+    case 6:
+      ulsch->q_RI[0] = ulsch->o_RI[0];
+      ulsch->q_RI[1] = PUSCH_y;//1;
+      ulsch->q_RI[2] = PUSCH_x;//1;
+      ulsch->q_RI[3] = PUSCH_x;//ulsch->o_RI[0];
+      ulsch->q_RI[4] = PUSCH_x;//1;
+      ulsch->q_RI[5] = PUSCH_x;//1;
+      len_RI=6;
+      break;
+    }
+  } else if (ulsch->O_RI>1) {
+    LOG_E(PHY,"RI cannot be more than 1 bit yet\n");
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+    return(-1);
+  }
+
+  //  Do ACK coding, Section 5.2.2.6 36.213 (p.23-24 in v8.6)
+  wACK_idx = (ulsch->bundling==0) ? 4 : ((Nbundled-1)&3);
+#ifdef DEBUG_ULSCH_CODING
+  printf("ulsch_coding.c: Bundling %d, Nbundled %d, wACK_idx %d\n",
+      ulsch->bundling,Nbundled,wACK_idx);
+#endif
+
+  // 1-bit ACK/NAK
+  if (ulsch->harq_processes[harq_pid]->O_ACK == 1) {
+    switch (Q_m) {
+    case 2:
+      ulsch->q_ACK[0] = (ulsch->o_ACK[0]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[1] = (ulsch->bundling==0)? PUSCH_y : ((ulsch->o_ACK[0]+wACK[wACK_idx][1])&1);//ulsch->o_ACK[0];
+      len_ACK = 2;
+      break;
+
+    case 4:
+      ulsch->q_ACK[0] = (ulsch->o_ACK[0]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[1] = (ulsch->bundling==0)? PUSCH_y : ((ulsch->o_ACK[0]+wACK[wACK_idx][1])&1);
+      ulsch->q_ACK[2] = PUSCH_x;
+      ulsch->q_ACK[3] = PUSCH_x;
+      len_ACK = 4;
+      break;
+
+    case 6:
+      ulsch->q_ACK[0] = (ulsch->o_ACK[0]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[1] = (ulsch->bundling==0)? PUSCH_y : ((ulsch->o_ACK[0]+wACK[wACK_idx][1])&1);
+      ulsch->q_ACK[2] = PUSCH_x;
+      ulsch->q_ACK[3] = PUSCH_x;
+      ulsch->q_ACK[4] = PUSCH_x;
+      ulsch->q_ACK[6] = PUSCH_x;
+      len_ACK = 6;
+      break;
+    }
+  }
+
+  // two-bit ACK/NAK
+  if (ulsch->harq_processes[harq_pid]->O_ACK == 2) {
+    ack_parity = (ulsch->o_ACK[0]+ulsch->o_ACK[1])&1;
+
+    switch (Q_m) {
+    case 2:
+      ulsch->q_ACK[0] = (ulsch->o_ACK[0]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[1] = (ulsch->o_ACK[1]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[2] = (ack_parity+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[3] = (ulsch->o_ACK[0]+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[4] = (ulsch->o_ACK[1]+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[5] = (ack_parity+wACK[wACK_idx][1])&1;
+      len_ACK = 6;
+      break;
+
+    case 4:
+      ulsch->q_ACK[0]  = (ulsch->o_ACK[0]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[1]  = (ulsch->o_ACK[1]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[2]  = PUSCH_x;
+      ulsch->q_ACK[3]  = PUSCH_x;//1;
+      ulsch->q_ACK[4]  = (ack_parity+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[5]  = (ulsch->o_ACK[0]+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[6]  = PUSCH_x;
+      ulsch->q_ACK[7]  = PUSCH_x;//1;
+      ulsch->q_ACK[8]  = (ulsch->o_ACK[1]+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[9]  = (ack_parity+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[10] = PUSCH_x;
+      ulsch->q_ACK[11] = PUSCH_x;//1;
+      len_ACK = 12;
+      break;
+
+    case 6:
+      ulsch->q_ACK[0] = (ulsch->o_ACK[0]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[1] = (ulsch->o_ACK[1]+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[2] = PUSCH_x;
+      ulsch->q_ACK[3] = PUSCH_x;
+      ulsch->q_ACK[4] = PUSCH_x;
+      ulsch->q_ACK[5] = PUSCH_x;
+
+      ulsch->q_ACK[6] = (ack_parity+wACK[wACK_idx][0])&1;
+      ulsch->q_ACK[7] = (ulsch->o_ACK[0]+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[8] = PUSCH_x;
+      ulsch->q_ACK[9] = PUSCH_x;
+      ulsch->q_ACK[10] = PUSCH_x;
+      ulsch->q_ACK[11] = PUSCH_x;
+
+      ulsch->q_ACK[12] = (ulsch->o_ACK[1]+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[13] = (ack_parity+wACK[wACK_idx][1])&1;
+      ulsch->q_ACK[14] = PUSCH_x;
+      ulsch->q_ACK[15] = PUSCH_x;
+      ulsch->q_ACK[16] = PUSCH_x;
+      ulsch->q_ACK[17] = PUSCH_x;
+      len_ACK = 18;
+
+      break;
+    }
+  }
+
+  if (ulsch->harq_processes[harq_pid]->O_ACK > 2) {
+    LOG_E(PHY,"ACK cannot be more than 2 bits yet\n");
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+    return(-1);
+  }
+
+
+  // channel multiplexing/interleaving
+
+  start_meas(m_stats);
+  Hpp = Hprime + Q_RI;
+
+  Cmux       = ulsch->Nsymb_pusch;
+  Rmux       = Hpp*Q_m/Cmux;
+  Rmux_prime = Rmux/Q_m;
+
+  Qprime_RI  = Q_RI / Q_m;
+  Qprime_ACK = Q_ACK / Q_m;
+  Qprime_CQI = Q_CQI / Q_m;
+
+  //  printf("Qprime_CQI = %d\n",Qprime_CQI);
+  // RI BITS
+
+  memset(y,LTE_NULL,Q_m*Hpp);
+
+  if (frame_parms->Ncp == 0)
+    columnset = cs_ri_normal;
+  else
+    columnset = cs_ri_extended;
+
+  j=0;
+
+  for (i=0; i<Qprime_RI; i++) {
+    r = Rmux_prime - 1 - (i>>2);
+
+    for (q=0; q<Q_m; q++)  {
+      y[q+(Q_m*((r*Cmux) + columnset[j]))]  = ulsch->q_RI[(q+(Q_m*i))%len_RI];
+      //      printf("ri[%d] %d => y[%d]\n",q+(Q_m*i)%len_RI,ulsch->q_RI[(q+(Q_m*i))%len_RI],q+(Q_m*((r*Cmux) + columnset[j])),y[q+(Q_m*((r*Cmux) + columnset[j]))]);
+    }
+
+    j=(j+3)&3;
+
+  }
+
+
+  // CQI and Data bits
+  j=0;
+  /*
+  for (i=0,iprime=-Qprime_CQI;i<Hprime;i++,iprime++) {
+
+    while (y[Q_m*j] != LTE_NULL) j++;
+
+    if (i<Qprime_CQI) {
+      for (q=0;q<Q_m;q++) {
+  y[q+(Q_m*j)] = ulsch->q[q+(Q_m*i)];
+  //printf("cqi[%d] %d => y[%d]\n",q+(Q_m*i),ulsch->q[q+(Q_m*i)],q+(Q_m*j));
+      }
+    }
+    else {
+      for (q=0;q<Q_m;q++) {
+  y[q+(Q_m*j)] = ulsch->e[q+(Q_m*iprime)];
+  //  printf("e[%d] %d => y[%d]\n",q+(Q_m*iprime),ulsch->e[q+(Q_m*iprime)],q+(Q_m*j));
+      }
+    }
+    j++;
+  }
+  */
+
+  for (i=0; i<Qprime_CQI; i++) {
+
+    while (y[Q_m*j] != LTE_NULL) j++;
+
+    for (q=0; q<Q_m; q++) {
+      y[q+(Q_m*j)] = ulsch->q[q+(Q_m*i)];
+      //        printf("cqi[%d] %d => y[%d] (j %d)\n",q+(Q_m*i),ulsch->q[q+(Q_m*i)],q+(Q_m*j),j);
+    }
+
+    j++;
+  }
+
+  j2 = j*Q_m;
+
+  switch (Q_m) {
+
+  case 2:
+
+    for (iprime=0; iprime<(Hprime-Qprime_CQI)<<1; iprime+=2) {
+      while (y[j2] != LTE_NULL) j2+=2;
+
+      y[j2]   = ulsch->e[iprime];
+      y[1+j2] = ulsch->e[1+iprime];
+      j2+=2;
+    }
+
+    break;
+
+  case 4:
+    for (iprime=0; iprime<(Hprime-Qprime_CQI)<<2; iprime+=4) {
+      while (y[j2] != LTE_NULL) j2+=4;
+
+      y[j2]   = ulsch->e[iprime];
+      y[1+j2] = ulsch->e[1+iprime];
+      y[2+j2] = ulsch->e[2+iprime];
+      y[3+j2] = ulsch->e[3+iprime];
+      j2+=4;
+    }
+
+    break;
+
+  case 6:
+    for (iprime=0; iprime<(Hprime-Qprime_CQI)*6; iprime+=6) {
+      while (y[j2] != LTE_NULL) j2+=6;
+
+      y[j2]   = ulsch->e[iprime];
+      y[1+j2] = ulsch->e[1+iprime];
+      y[2+j2] = ulsch->e[2+iprime];
+      y[3+j2] = ulsch->e[3+iprime];
+      y[4+j2] = ulsch->e[4+iprime];
+      y[5+j2] = ulsch->e[5+iprime];
+      j2+=6;
+    }
+
+    break;
+
+  }
+
+  // HARQ-ACK Bits (Note these overwrite some bits)
+
+  if (frame_parms->Ncp == 0)
+    columnset = cs_ack_normal;
+  else
+    columnset = cs_ack_extended;
+
+  j=0;
+
+  for (i=0; i<Qprime_ACK; i++) {
+    r = Rmux_prime - 1 - (i>>2);
+
+    for (q=0; q<Q_m; q++) {
+      y[q+(Q_m*((r*Cmux) + columnset[j]))]  = ulsch->q_ACK[(q+(Q_m*i))%len_ACK];
+#ifdef DEBUG_ULSCH_CODING
+      printf("ulsch_coding.c: ACK %d => y[%d]=%d (i %d, r*Cmux %d, columnset %d)\n",q+(Q_m*i),
+          q+(Q_m*((r*Cmux) + columnset[j])),ulsch->q_ACK[(q+(Q_m*i))%len_ACK],
+          i,r*Cmux,columnset[j]);
+#endif
+    }
+
+    j=(j+3)&3;
+
+  }
+
+  // write out buffer
+  j=0;
+
+  switch (Q_m) {
+  case 2:
+    for (i=0; i<Cmux; i++)
+      for (r=0; r<Rmux_prime; r++) {
+        yptr=&y[((r*Cmux)+i)<<1];
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+      }
+
+    break;
+
+  case 4:
+    for (i=0; i<Cmux; i++)
+      for (r=0; r<Rmux_prime; r++) {
+        yptr = &y[((r*Cmux)+i)<<2];
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+      }
+
+    break;
+
+  case 6:
+    for (i=0; i<Cmux; i++)
+      for (r=0; r<Rmux_prime; r++) {
+        yptr = &y[((r*Cmux)+i)*6];
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+        ulsch->h[j++] = *yptr++;
+      }
+
+    break;
+
+  default:
+    break;
+  }
+
+  stop_meas(m_stats);
+
+  if (j!=(H+Q_RI)) {
+    LOG_E(PHY,"Error in output buffer length (j %d, H+Q_RI %d)\n",j,H+Q_RI);
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+    return(-1);
+  }
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT);
+  return(0);
+}
+
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c
new file mode 100644
index 0000000000000000000000000000000000000000..d1718f6e90f600927f5d93f3a18e93213bea86f8
--- /dev/null
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c
@@ -0,0 +1,777 @@
+/*
+ * 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/ulsch_modulation.c
+* \brief Top-level routines for generating PUSCH physical channel from 36.211 V8.6 2009-03
+* \author R. Knopp, F. Kaltenberger, A. Bhamri
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,ankit.bhamri@eurecom.fr
+* \note
+* \warning
+*/
+#include "PHY/defs.h"
+#include "PHY/extern.h"
+#include "PHY/CODING/defs.h"
+#include "PHY/CODING/extern.h"
+#include "PHY/LTE_TRANSPORT/defs.h"
+#include "defs.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+
+
+
+//#define DEBUG_ULSCH_MODULATION
+
+#ifndef OFDMA_ULSCH
+void dft_lte(int32_t *z,int32_t *d, int32_t Msc_PUSCH, uint8_t Nsymb)
+{
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i dft_in128[4][1200],dft_out128[4][1200];
+#elif defined(__arm__)
+  int16x8_t dft_in128[4][1200],dft_out128[4][1200];
+#endif
+  uint32_t *dft_in0=(uint32_t*)dft_in128[0],*dft_out0=(uint32_t*)dft_out128[0];
+  uint32_t *dft_in1=(uint32_t*)dft_in128[1],*dft_out1=(uint32_t*)dft_out128[1];
+  uint32_t *dft_in2=(uint32_t*)dft_in128[2],*dft_out2=(uint32_t*)dft_out128[2];
+  //  uint32_t *dft_in3=(uint32_t*)dft_in128[3],*dft_out3=(uint32_t*)dft_out128[3];
+
+  uint32_t *d0,*d1,*d2,*d3,*d4,*d5,*d6,*d7,*d8,*d9,*d10,*d11;
+
+  uint32_t *z0,*z1,*z2,*z3,*z4,*z5,*z6,*z7,*z8,*z9,*z10,*z11;
+  uint32_t i,ip;
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i norm128;
+#elif defined(__arm__)
+  int16x8_t norm128;
+#endif
+  //  printf("Doing lte_dft for Msc_PUSCH %d\n",Msc_PUSCH);
+
+  d0 = (uint32_t *)d;
+  d1 = d0+Msc_PUSCH;
+  d2 = d1+Msc_PUSCH;
+  d3 = d2+Msc_PUSCH;
+  d4 = d3+Msc_PUSCH;
+  d5 = d4+Msc_PUSCH;
+  d6 = d5+Msc_PUSCH;
+  d7 = d6+Msc_PUSCH;
+  d8 = d7+Msc_PUSCH;
+  d9 = d8+Msc_PUSCH;
+  d10 = d9+Msc_PUSCH;
+  d11 = d10+Msc_PUSCH;
+
+  //  printf("symbol 0 (d0 %p, d %p)\n",d0,d);
+  for (i=0,ip=0; i<Msc_PUSCH; i++,ip+=4) {
+    dft_in0[ip]   =  d0[i];
+    dft_in0[ip+1] =  d1[i];
+    dft_in0[ip+2] =  d2[i];
+    dft_in0[ip+3] =  d3[i];
+    dft_in1[ip]   =  d4[i];
+    dft_in1[ip+1] =  d5[i];
+    dft_in1[ip+2] =  d6[i];
+    dft_in1[ip+3] =  d7[i];
+    dft_in2[ip]   =  d8[i];
+    dft_in2[ip+1] =  d9[i];
+    dft_in2[ip+2] =  d10[i];
+    dft_in2[ip+3] =  d11[i];
+    //    printf("dft%d %d: %d,%d,%d,%d\n",Msc_PUSCH,ip,d0[i],d1[i],d2[i],d3[i]);
+
+    //    dft_in_re2[ip+1] =  d9[i];
+    //    dft_in_re2[ip+2] =  d10[i];
+  }
+
+  //  printf("\n");
+
+  switch (Msc_PUSCH) {
+  case 12:
+    dft12((int16_t *)dft_in0,(int16_t *)dft_out0);
+    dft12((int16_t *)dft_in1,(int16_t *)dft_out1);
+    dft12((int16_t *)dft_in2,(int16_t *)dft_out2);
+
+    /*
+    dft12f(&((__m128i *)dft_in0)[0],&((__m128i *)dft_in0)[1],&((__m128i *)dft_in0)[2],&((__m128i *)dft_in0)[3],&((__m128i *)dft_in0)[4],&((__m128i *)dft_in0)[5],&((__m128i *)dft_in0)[6],&((__m128i *)dft_in0)[7],&((__m128i *)dft_in0)[8],&((__m128i *)dft_in0)[9],&((__m128i *)dft_in0)[10],&((__m128i *)dft_in0)[11],
+    &((__m128i *)dft_out0)[0],&((__m128i *)dft_out0)[1],&((__m128i *)dft_out0)[2],&((__m128i *)dft_out0)[3],&((__m128i *)dft_out0)[4],&((__m128i *)dft_out0)[5],&((__m128i *)dft_out0)[6],&((__m128i *)dft_out0)[7],&((__m128i *)dft_out0)[8],&((__m128i *)dft_out0)[9],&((__m128i *)dft_out0)[10],&((__m128i *)dft_out0)[11]);
+
+    dft12f(&((__m128i *)dft_in1)[0],&((__m128i *)dft_in1)[1],&((__m128i *)dft_in1)[2],&((__m128i *)dft_in1)[3],&((__m128i *)dft_in1)[4],&((__m128i *)dft_in1)[5],&((__m128i *)dft_in1)[6],&((__m128i *)dft_in1)[7],&((__m128i *)dft_in1)[8],&((__m128i *)dft_in1)[9],&((__m128i *)dft_in1)[10],&((__m128i *)dft_in1)[11],
+    &((__m128i *)dft_out1)[0],&((__m128i *)dft_out1)[1],&((__m128i *)dft_out1)[2],&((__m128i *)dft_out1)[3],&((__m128i *)dft_out1)[4],&((__m128i *)dft_out1)[5],&((__m128i *)dft_out1)[6],&((__m128i *)dft_out1)[7],&((__m128i *)dft_out1)[8],&((__m128i *)dft_out1)[9],&((__m128i *)dft_out1)[10],&((__m128i *)dft_out1)[11]);
+
+    dft12f(&((__m128i *)dft_in2)[0],&((__m128i *)dft_in2)[1],&((__m128i *)dft_in2)[2],&((__m128i *)dft_in2)[3],&((__m128i *)dft_in2)[4],&((__m128i *)dft_in2)[5],&((__m128i *)dft_in2)[6],&((__m128i *)dft_in2)[7],&((__m128i *)dft_in2)[8],&((__m128i *)dft_in2)[9],&((__m128i *)dft_in2)[10],&((__m128i *)dft_in2)[11],
+    &((__m128i *)dft_out2)[0],&((__m128i *)dft_out2)[1],&((__m128i *)dft_out2)[2],&((__m128i *)dft_out2)[3],&((__m128i *)dft_out2)[4],&((__m128i *)dft_out2)[5],&((__m128i *)dft_out2)[6],&((__m128i *)dft_out2)[7],&((__m128i *)dft_out2)[8],&((__m128i *)dft_out2)[9],&((__m128i *)dft_out2)[10],&((__m128i *)dft_out2)[11]);
+    */
+#if defined(__x86_64__) || defined(__i386__)
+    norm128 = _mm_set1_epi16(9459);
+#elif defined(__arm__)
+    norm128 = vdupq_n_s16(9459);
+#endif
+    for (i=0; i<12; i++) {
+#if defined(__x86_64__) || defined(__i386__)
+      ((__m128i*)dft_out0)[i] = _mm_slli_epi16(_mm_mulhi_epi16(((__m128i*)dft_out0)[i],norm128),1);
+      ((__m128i*)dft_out1)[i] = _mm_slli_epi16(_mm_mulhi_epi16(((__m128i*)dft_out1)[i],norm128),1);
+      ((__m128i*)dft_out2)[i] = _mm_slli_epi16(_mm_mulhi_epi16(((__m128i*)dft_out2)[i],norm128),1);
+#elif defined(__arm__)
+      ((int16x8_t*)dft_out0)[i] = vqdmulhq_s16(((int16x8_t*)dft_out0)[i],norm128);
+      ((int16x8_t*)dft_out1)[i] = vqdmulhq_s16(((int16x8_t*)dft_out1)[i],norm128);
+      ((int16x8_t*)dft_out2)[i] = vqdmulhq_s16(((int16x8_t*)dft_out2)[i],norm128);
+#endif
+    }
+
+    break;
+
+  case 24:
+    dft24((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft24((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft24((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 36:
+    dft36((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft36((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft36((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 48:
+    dft48((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft48((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft48((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 60:
+    dft60((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft60((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft60((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 72:
+    dft72((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft72((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft72((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 96:
+    dft96((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft96((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft96((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 108:
+    dft108((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft108((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft108((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 120:
+    dft120((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft120((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft120((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 144:
+    dft144((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft144((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft144((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 180:
+    dft180((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft180((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft180((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 192:
+    dft192((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft192((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft192((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 216:
+    dft216((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft216((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft216((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 240:
+    dft240((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft240((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft240((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 288:
+    dft288((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft288((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft288((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 300:
+    dft300((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft300((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft300((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 324:
+    dft324((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft324((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft324((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 360:
+    dft360((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft360((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft360((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 384:
+    dft384((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft384((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft384((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 432:
+    dft432((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft432((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft432((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 480:
+    dft480((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft480((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft480((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 540:
+    dft540((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft540((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft540((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 576:
+    dft576((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft576((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft576((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 600:
+    dft600((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft600((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft600((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 648:
+    dft648((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft648((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft648((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 720:
+    dft720((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft720((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft720((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 864:
+    dft864((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft864((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft864((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 900:
+    dft900((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft900((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft900((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 960:
+    dft960((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft960((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft960((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 972:
+    dft972((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft972((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft972((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 1080:
+    dft1080((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft1080((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft1080((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 1152:
+    dft1152((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft1152((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft1152((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
+  case 1200:
+    dft1200((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft1200((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft1200((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+  }
+
+  z0 = (uint32_t *)z;
+  z1 = z0+Msc_PUSCH;
+  z2 = z1+Msc_PUSCH;
+  z3 = z2+Msc_PUSCH;
+  z4 = z3+Msc_PUSCH;
+  z5 = z4+Msc_PUSCH;
+  z6 = z5+Msc_PUSCH;
+  z7 = z6+Msc_PUSCH;
+  z8 = z7+Msc_PUSCH;
+  z9 = z8+Msc_PUSCH;
+  z10 = z9+Msc_PUSCH;
+  z11 = z10+Msc_PUSCH;
+
+  //  printf("symbol0 (dft)\n");
+  for (i=0,ip=0; i<Msc_PUSCH; i++,ip+=4) {
+    z0[i]     = dft_out0[ip];
+    //    printf("%d,%d,",((short*)&z0[i])[0],((short*)&z0[i])[1]);
+    z1[i]     = dft_out0[ip+1];
+    z2[i]     = dft_out0[ip+2];
+    z3[i]     = dft_out0[ip+3];
+    z4[i]     = dft_out1[ip+0];
+    z5[i]     = dft_out1[ip+1];
+    z6[i]     = dft_out1[ip+2];
+    z7[i]     = dft_out1[ip+3];
+    z8[i]     = dft_out2[ip];
+    z9[i]     = dft_out2[ip+1];
+    z10[i]    = dft_out2[ip+2];
+    z11[i]    = dft_out2[ip+3];
+    //    printf("out dft%d %d: %d,%d,%d,%d,%d,%d,%d,%d\n",Msc_PUSCH,ip,z0[i],z1[i],z2[i],z3[i],z4[i],z5[i],z6[i],z7[i]);
+
+  }
+
+  //  printf("\n");
+}
+
+#endif
+void ulsch_modulation(int32_t **txdataF,
+                      short amp,
+                      uint32_t frame,
+                      uint32_t subframe,
+                      LTE_DL_FRAME_PARMS *frame_parms,
+                      LTE_UE_ULSCH_t *ulsch)
+{
+
+  uint8_t qam64_table_offset_re = 0;
+  uint8_t qam64_table_offset_im = 0;
+  uint8_t qam16_table_offset_re = 0;
+  uint8_t qam16_table_offset_im = 0;
+  short gain_lin_QPSK;
+
+  DevAssert(frame_parms);
+
+  int re_offset,re_offset0,i,Msymb,j,k,nsymb,Msc_PUSCH,l;
+  //  uint8_t harq_pid = (rag_flag == 1) ? 0 : subframe2harq_pid_tdd(frame_parms->tdd_config,subframe);
+  uint8_t harq_pid = subframe2harq_pid(frame_parms,frame,subframe);
+  uint8_t Q_m;
+  int32_t *txptr;
+  uint32_t symbol_offset;
+  uint16_t first_rb;
+  uint16_t nb_rb;
+  int G;
+
+  uint32_t x1, x2, s=0;
+  uint8_t c;
+
+  if (!ulsch) {
+    printf("ulsch_modulation.c: Null ulsch\n");
+    return;
+  }
+
+  // x1 is set in lte_gold_generic
+  x2 = (ulsch->rnti<<14) + (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.3.1
+
+  if (harq_pid>=8) {
+    printf("ulsch_modulation.c: Illegal harq_pid %d\n",harq_pid);
+    return;
+  }
+
+  first_rb = ulsch->harq_processes[harq_pid]->first_rb;
+  nb_rb = ulsch->harq_processes[harq_pid]->nb_rb;
+
+  if (nb_rb == 0) {
+    printf("ulsch_modulation.c: Frame %d, Subframe %d Illegal nb_rb %d\n",frame,subframe,nb_rb);
+    return;
+  }
+
+  if (first_rb > frame_parms->N_RB_UL) {
+    printf("ulsch_modulation.c: Frame %d, Subframe %d Illegal first_rb %d\n",frame,subframe,first_rb);
+    return;
+  }
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_MODULATION, VCD_FUNCTION_IN);
+
+  Q_m = get_Qm_ul(ulsch->harq_processes[harq_pid]->mcs);
+
+  G = (int)ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch);
+
+
+  // Mapping
+  nsymb = (frame_parms->Ncp==0) ? 14:12;
+  Msc_PUSCH = ulsch->harq_processes[harq_pid]->nb_rb*12;
+
+#ifdef DEBUG_ULSCH_MODULATION
+  LOG_D(PHY,"ulsch_modulation.c: Doing modulation (rnti %x,x2 %x) for G=%d bits, harq_pid %d , nb_rb %d, Q_m %d, Nsymb_pusch %d (nsymb %d), subframe %d\n",
+        ulsch->rnti,x2,G,harq_pid,ulsch->harq_processes[harq_pid]->nb_rb,Q_m, ulsch->Nsymb_pusch,nsymb,subframe);
+#endif
+
+  // scrambling (Note the placeholding bits are handled in ulsch_coding.c directly!)
+  //printf("ulsch bits: ");
+  s = lte_gold_generic(&x1, &x2, 1);
+  k=0;
+
+  //printf("G %d\n",G);
+  for (i=0; i<(1+(G>>5)); i++) {
+    for (j=0; j<32; j++,k++) {
+      c = (uint8_t)((s>>j)&1);
+
+      if (ulsch->h[k] == PUSCH_x) {
+        //  printf("i %d: PUSCH_x\n",i);
+        ulsch->b_tilde[k] = 1;
+      } else if (ulsch->h[k] == PUSCH_y) {
+        //  printf("i %d: PUSCH_y\n",i);
+        ulsch->b_tilde[k] = ulsch->b_tilde[k-1];
+      } else {
+        ulsch->b_tilde[k] = (ulsch->h[k]+c)&1;
+        //  printf("i %d : %d (h %d c %d)\n", (i<<5)+j,ulsch->b_tilde[k],ulsch->h[k],c);
+      }
+
+    }
+
+    s = lte_gold_generic(&x1, &x2, 0);
+  }
+
+  //printf("\n");
+
+
+  gain_lin_QPSK = (short)((amp*ONE_OVER_SQRT2_Q15)>>15);
+
+
+  // Modulation
+
+  Msymb = G/Q_m;
+
+  if(ulsch->cooperation_flag == 2)
+    // For Distributed Alamouti Scheme in Collabrative Communication
+  {
+    for (i=0,j=Q_m; i<Msymb; i+=2,j+=2*Q_m) {
+
+      switch (Q_m) {
+
+      case 2:
+
+
+        //UE1, -x1*
+        ((int16_t*)&ulsch->d[i])[0] = (ulsch->b_tilde[j] == 1)  ? (gain_lin_QPSK) : -gain_lin_QPSK;
+        ((int16_t*)&ulsch->d[i])[1] = (ulsch->b_tilde[j+1] == 1)? (-gain_lin_QPSK) : gain_lin_QPSK;
+        //      if (i<Msc_PUSCH)
+        //  printf("input %d (%p): %d,%d\n", i,&ulsch->d[i],((int16_t*)&ulsch->d[i])[0],((int16_t*)&ulsch->d[i])[1]);
+
+        // UE1, x0*
+        ((int16_t*)&ulsch->d[i+1])[0] = (ulsch->b_tilde[j-2] == 1)  ? (-gain_lin_QPSK) : gain_lin_QPSK;
+        ((int16_t*)&ulsch->d[i+1])[1] = (ulsch->b_tilde[j-1] == 1)? (gain_lin_QPSK) : -gain_lin_QPSK;
+
+        break;
+
+      case 4:
+
+
+        //UE1,-x1*
+        qam16_table_offset_re = 0;
+        qam16_table_offset_im = 0;
+
+        if (ulsch->b_tilde[j] == 1)
+          qam16_table_offset_re+=2;
+
+        if (ulsch->b_tilde[j+1] == 1)
+          qam16_table_offset_im+=2;
+
+
+
+        if (ulsch->b_tilde[j+2] == 1)
+          qam16_table_offset_re+=1;
+
+        if (ulsch->b_tilde[j+3] == 1)
+          qam16_table_offset_im+=1;
+
+
+        ((int16_t*)&ulsch->d[i])[0]=-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15);
+        ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15);
+
+        //UE1,x0*
+        qam16_table_offset_re = 0;
+        qam16_table_offset_im = 0;
+
+        if (ulsch->b_tilde[j-4] == 1)
+          qam16_table_offset_re+=2;
+
+        if (ulsch->b_tilde[j-3] == 1)
+          qam16_table_offset_im+=2;
+
+
+        if (ulsch->b_tilde[j-2] == 1)
+          qam16_table_offset_re+=1;
+
+        if (ulsch->b_tilde[j-1] == 1)
+          qam16_table_offset_im+=1;
+
+
+        //    ((int16_t*)&ulsch->d[i+1])[0]=-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15);
+        //    ((int16_t*)&ulsch->d[i+1])[1]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15);
+        ((int16_t*)&ulsch->d[i+1])[0]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15);
+        ((int16_t*)&ulsch->d[i+1])[1]=-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15);
+
+
+        break;
+
+      case 6:
+
+
+
+        //UE1,-x1*FPGA_UE
+        qam64_table_offset_re = 0;
+        qam64_table_offset_im = 0;
+
+        if (ulsch->b_tilde[j] == 1)
+          qam64_table_offset_re+=4;
+
+        if (ulsch->b_tilde[j+1] == 1)
+          qam64_table_offset_im+=4;
+
+        if (ulsch->b_tilde[j+2] == 1)
+          qam64_table_offset_re+=2;
+
+
+        if (ulsch->b_tilde[j+3] == 1)
+          qam64_table_offset_im+=2;
+
+        if (ulsch->b_tilde[j+4] == 1)
+          qam64_table_offset_re+=1;
+
+        if (ulsch->b_tilde[j+5] == 1)
+          qam64_table_offset_im+=1;
+
+
+        ((int16_t*)&ulsch->d[i])[0]=-(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15);
+        ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15);
+
+        //UE1,x0*
+        qam64_table_offset_re = 0;
+        qam64_table_offset_im = 0;
+
+        if (ulsch->b_tilde[j-6] == 1)
+          qam64_table_offset_re+=4;
+
+        if (ulsch->b_tilde[j-5] == 1)
+          qam64_table_offset_im+=4;
+
+        if (ulsch->b_tilde[j-4] == 1)
+          qam64_table_offset_re+=2;
+
+
+        if (ulsch->b_tilde[j-3] == 1)
+          qam64_table_offset_im+=2;
+
+        if (ulsch->b_tilde[j-2] == 1)
+          qam64_table_offset_re+=1;
+
+        if (ulsch->b_tilde[j-1] == 1)
+          qam64_table_offset_im+=1;
+
+
+        ((int16_t*)&ulsch->d[i+1])[0]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15);
+        ((int16_t*)&ulsch->d[i+1])[1]=-(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15);
+
+        break;
+
+      }//switch
+    }//for
+  }//cooperation_flag == 2
+  else {
+    for (i=0,j=0; i<Msymb; i++,j+=Q_m) {
+
+      switch (Q_m) {
+
+      case 2:
+        // TODO: this has to be updated!!!
+
+        ((int16_t*)&ulsch->d[i])[0] = (ulsch->b_tilde[j] == 1)  ? (-gain_lin_QPSK) : gain_lin_QPSK;
+        ((int16_t*)&ulsch->d[i])[1] = (ulsch->b_tilde[j+1] == 1)? (-gain_lin_QPSK) : gain_lin_QPSK;
+        //        if (i<Msc_PUSCH)
+        //    printf("input %d/%d Msc_PUSCH %d (%p): %d,%d\n", i,Msymb,Msc_PUSCH,&ulsch->d[i],((int16_t*)&ulsch->d[i])[0],((int16_t*)&ulsch->d[i])[1]);
+
+        break;
+
+      case 4:
+
+        qam16_table_offset_re = 0;
+        qam16_table_offset_im = 0;
+
+        if (ulsch->b_tilde[j] == 1)
+          qam16_table_offset_re+=2;
+
+        if (ulsch->b_tilde[j+1] == 1)
+          qam16_table_offset_im+=2;
+
+        if (ulsch->b_tilde[j+2] == 1)
+          qam16_table_offset_re+=1;
+
+        if (ulsch->b_tilde[j+3] == 1)
+          qam16_table_offset_im+=1;
+
+
+        ((int16_t*)&ulsch->d[i])[0]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15);
+        ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15);
+        //      printf("input(16qam) %d (%p): %d,%d\n", i,&ulsch->d[i],((int16_t*)&ulsch->d[i])[0],((int16_t*)&ulsch->d[i])[1]);
+        break;
+
+      case 6:
+
+
+        qam64_table_offset_re = 0;
+        qam64_table_offset_im = 0;
+
+        if (ulsch->b_tilde[j] == 1)
+          qam64_table_offset_re+=4;
+
+        if (ulsch->b_tilde[j+1] == 1)
+          qam64_table_offset_im+=4;
+
+        if (ulsch->b_tilde[j+2] == 1)
+          qam64_table_offset_re+=2;
+
+        if (ulsch->b_tilde[j+3] == 1)
+          qam64_table_offset_im+=2;
+
+        if (ulsch->b_tilde[j+4] == 1)
+          qam64_table_offset_re+=1;
+
+        if (ulsch->b_tilde[j+5] == 1)
+          qam64_table_offset_im+=1;
+
+
+        ((int16_t*)&ulsch->d[i])[0]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15);
+        ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15);
+
+        break;
+
+      }
+    }
+  }// normal symbols
+
+
+  // Transform Precoding
+
+#ifdef OFDMA_ULSCH
+
+  for (i=0; i<Msymb; i++) {
+    ulsch->z[i] = ulsch->d[i];
+  }
+
+#else
+  dft_lte(ulsch->z,ulsch->d,Msc_PUSCH,ulsch->Nsymb_pusch);
+#endif
+
+  DevAssert(txdataF);
+
+#ifdef OFDMA_ULSCH
+  re_offset0 = frame_parms->first_carrier_offset + (ulsch->harq_processes[harq_pid]->first_rb*12);
+
+  if (re_offset0>frame_parms->ofdm_symbol_size) {
+    re_offset0 -= frame_parms->ofdm_symbol_size;
+    //    re_offset0++;
+  }
+
+  //  printf("re_offset0 %d\n",re_offset0);
+
+
+  for (j=0,l=0; l<(nsymb-ulsch->srs_active); l++) {
+    re_offset = re_offset0;
+    symbol_offset = (int)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb));
+#ifdef DEBUG_ULSCH_MODULATION
+    printf("symbol %d (subframe %d): symbol_offset %d\n",l,subframe,symbol_offset);
+#endif
+    txptr = &txdataF[0][symbol_offset];
+
+    if (((frame_parms->Ncp == 0) && ((l==3) || (l==10)))||
+        ((frame_parms->Ncp == 1) && ((l==2) || (l==8)))) {
+    }
+    // Skip reference symbols
+    else {
+
+      //      printf("copying %d REs\n",Msc_PUSCH);
+      for (i=0; i<Msc_PUSCH; i++,j++) {
+#ifdef DEBUG_ULSCH_MODULATION
+        printf("re_offset %d (%p): %d,%d\n", re_offset,&ulsch->z[j],((int16_t*)&ulsch->z[j])[0],((int16_t*)&ulsch->z[j])[1]);
+#endif
+        txptr[re_offset++] = ulsch->z[j];
+
+        if (re_offset==frame_parms->ofdm_symbol_size)
+          re_offset = 0;
+      }
+    }
+  }
+
+# else  // OFDMA_ULSCH = 0
+  re_offset0 = frame_parms->first_carrier_offset + (ulsch->harq_processes[harq_pid]->first_rb*12);
+
+  if (re_offset0>frame_parms->ofdm_symbol_size) {
+    re_offset0 -= frame_parms->ofdm_symbol_size;
+    //    re_offset0++;
+  }
+
+  //    printf("re_offset0 %d\n",re_offset0);
+  //  printf("txdataF %p\n",&txdataF[0][0]);
+  for (j=0,l=0; l<(nsymb-ulsch->srs_active); l++) {
+    re_offset = re_offset0;
+    symbol_offset = (uint32_t)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb));
+#ifdef DEBUG_ULSCH_MODULATION
+    printf("ulsch_mod (SC-FDMA) symbol %d (subframe %d): symbol_offset %d\n",l,subframe,symbol_offset);
+#endif
+    txptr = &txdataF[0][symbol_offset];
+
+    if (((frame_parms->Ncp == 0) && ((l==3) || (l==10)))||
+        ((frame_parms->Ncp == 1) && ((l==2) || (l==8)))) {
+    }
+    // Skip reference symbols
+    else {
+      //      printf("copying %d REs\n",Msc_PUSCH);
+      for (i=0; i<Msc_PUSCH; i++,j++) {
+
+#ifdef DEBUG_ULSCH_MODULATION
+        printf("re_offset %d (%p): %d,%d => %p\n", re_offset,&ulsch->z[j],((int16_t*)&ulsch->z[j])[0],((int16_t*)&ulsch->z[j])[1],&txptr[re_offset]);
+#endif //DEBUG_ULSCH_MODULATION
+        txptr[re_offset++] = ulsch->z[j];
+
+        if (re_offset==frame_parms->ofdm_symbol_size)
+          re_offset = 0;
+      }
+    }
+  }
+
+#endif
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_MODULATION, VCD_FUNCTION_OUT);
+
+}
+
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c
index 81cd18c954f647ceb9bd58c50a828fdf94a35b14..3f0c3407cc67d556a17747d39199dcdc42be923e 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c
@@ -32,8 +32,8 @@
 
 #include "PHY/defs_UE.h"
 #include "PHY/TOOLS/tools_defs.h"
-#include "PHY/phy_extern_ue.h"
-#include "transport_ue.h"
+#include "PHY/extern_ue.h"
+#include "tools_defs.h"
 #include "PHY/sse_intrin.h"
 
 int16_t ones256[16] __attribute__ ((aligned(32))) = {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
diff --git a/openair1/PHY/TOOLS/twiddle3072.h b/openair1/PHY/TOOLS/twiddle3072.h
index b3794c5ac8b4dc313c12f4558d23789eb27193d6..099ef574556542ce6e7ada9e57cd927248e9960b 100644
--- a/openair1/PHY/TOOLS/twiddle3072.h
+++ b/openair1/PHY/TOOLS/twiddle3072.h
@@ -21,7 +21,7 @@
 
 /* Twiddles generated with
 twa = floor(32767*exp(-sqrt(-1)*2*pi*(0:1023)/3072));
-twb = floor(32767*exp(-sqrt(-1)*2*pi*(0:2:1023)/3072));
+twb = floor(32767*exp(-sqrt(-1)*2*pi*(0:2:2046)/3072));
 twa2 = zeros(1,2048);
 twb2 = zeros(1,2048);
 twa2(1:2:end) = real(twa);
@@ -39,5 +39,4 @@ fclose(fd);
  */
 
 static int16_t twa3072[2048] = {32767,0,32766,-68,32766,-135,32766,-202,32765,-269,32765,-336,32764,-403,32763,-470,32762,-537,32761,-604,32760,-671,32758,-738,32757,-805,32755,-872,32753,-939,32751,-1006,32749,-1073,32747,-1140,32744,-1207,32742,-1274,32739,-1340,32736,-1407,32733,-1474,32730,-1541,32727,-1608,32724,-1675,32720,-1742,32717,-1809,32713,-1876,32709,-1943,32705,-2010,32701,-2077,32696,-2144,32692,-2210,32687,-2277,32683,-2344,32678,-2411,32673,-2478,32668,-2545,32662,-2611,32657,-2678,32651,-2745,32646,-2812,32640,-2879,32634,-2945,32628,-3012,32622,-3079,32615,-3146,32609,-3212,32602,-3279,32595,-3346,32588,-3412,32581,-3479,32574,-3546,32567,-3612,32559,-3679,32552,-3745,32544,-3812,32536,-3878,32528,-3945,32520,-4012,32512,-4078,32503,-4145,32495,-4211,32486,-4277,32477,-4344,32468,-4410,32459,-4477,32450,-4543,32441,-4609,32431,-4676,32422,-4742,32412,-4808,32402,-4875,32392,-4941,32382,-5007,32371,-5073,32361,-5140,32350,-5206,32340,-5272,32329,-5338,32318,-5404,32307,-5470,32295,-5536,32284,-5602,32273,-5668,32261,-5734,32249,-5800,32237,-5866,32225,-5932,32213,-5998,32201,-6064,32188,-6130,32176,-6196,32163,-6262,32150,-6327,32137,-6393,32124,-6459,32110,-6524,32097,-6590,32084,-6656,32070,-6721,32056,-6787,32042,-6852,32028,-6918,32014,-6983,31999,-7049,31985,-7114,31970,-7180,31956,-7245,31941,-7311,31926,-7376,31911,-7441,31895,-7506,31880,-7572,31864,-7637,31849,-7702,31833,-7767,31817,-7832,31801,-7897,31785,-7962,31768,-8027,31752,-8092,31735,-8157,31718,-8222,31701,-8287,31684,-8352,31667,-8416,31650,-8481,31633,-8546,31615,-8611,31597,-8675,31580,-8740,31562,-8804,31544,-8869,31525,-8933,31507,-8998,31489,-9062,31470,-9127,31451,-9191,31432,-9255,31413,-9320,31394,-9384,31375,-9448,31356,-9512,31336,-9576,31316,-9640,31297,-9704,31277,-9768,31257,-9832,31236,-9896,31216,-9960,31196,-10024,31175,-10088,31154,-10152,31134,-10215,31113,-10279,31092,-10343,31070,-10406,31049,-10470,31028,-10533,31006,-10597,30984,-10660,30962,-10723,30940,-10787,30918,-10850,30896,-10913,30874,-10976,30851,-11039,30828,-11102,30806,-11165,30783,-11228,30760,-11291,30737,-11354,30713,-11417,30690,-11480,30666,-11543,30643,-11605,30619,-11668,30595,-11731,30571,-11793,30547,-11856,30522,-11918,30498,-11981,30473,-12043,30449,-12105,30424,-12167,30399,-12230,30374,-12292,30349,-12354,30323,-12416,30298,-12478,30272,-12540,30247,-12602,30221,-12664,30195,-12725,30169,-12787,30142,-12849,30116,-12910,30090,-12972,30063,-13034,30036,-13095,30009,-13156,29983,-13218,29955,-13279,29928,-13340,29901,-13401,29873,-13463,29846,-13524,29818,-13585,29790,-13646,29762,-13707,29734,-13767,29706,-13828,29678,-13889,29649,-13950,29621,-14010,29592,-14071,29563,-14131,29534,-14192,29505,-14252,29476,-14312,29446,-14373,29417,-14433,29387,-14493,29358,-14553,29328,-14613,29298,-14673,29268,-14733,29238,-14793,29207,-14853,29177,-14912,29146,-14972,29116,-15031,29085,-15091,29054,-15150,29023,-15210,28992,-15269,28960,-15328,28929,-15388,28897,-15447,28866,-15506,28834,-15565,28802,-15624,28770,-15683,28738,-15741,28706,-15800,28673,-15859,28641,-15918,28608,-15976,28575,-16035,28543,-16093,28510,-16151,28477,-16210,28443,-16268,28410,-16326,28377,-16384,28343,-16442,28309,-16500,28275,-16558,28242,-16616,28208,-16673,28173,-16731,28139,-16789,28105,-16846,28070,-16904,28036,-16961,28001,-17018,27966,-17075,27931,-17133,27896,-17190,27861,-17247,27825,-17304,27790,-17361,27754,-17417,27719,-17474,27683,-17531,27647,-17587,27611,-17644,27575,-17700,27538,-17757,27502,-17813,27466,-17869,27429,-17925,27392,-17981,27355,-18037,27319,-18093,27281,-18149,27244,-18205,27207,-18261,27170,-18316,27132,-18372,27094,-18427,27057,-18483,27019,-18538,26981,-18593,26943,-18648,26905,-18703,26866,-18758,26828,-18813,26789,-18868,26751,-18923,26712,-18977,26673,-19032,26634,-19087,26595,-19141,26556,-19195,26516,-19250,26477,-19304,26437,-19358,26398,-19412,26358,-19466,26318,-19520,26278,-19574,26238,-19627,26198,-19681,26158,-19734,26117,-19788,26077,-19841,26036,-19895,25995,-19948,25954,-20001,25913,-20054,25872,-20107,25831,-20160,25790,-20213,25749,-20265,25707,-20318,25665,-20370,25624,-20423,25582,-20475,25540,-20528,25498,-20580,25456,-20632,25414,-20684,25371,-20736,25329,-20788,25286,-20839,25243,-20891,25201,-20943,25158,-20994,25115,-21046,25072,-21097,25029,-21148,24985,-21199,24942,-21250,24898,-21301,24855,-21352,24811,-21403,24767,-21454,24723,-21504,24679,-21555,24635,-21605,24591,-21656,24546,-21706,24502,-21756,24457,-21806,24413,-21856,24368,-21906,24323,-21956,24278,-22005,24233,-22055,24188,-22105,24143,-22154,24097,-22203,24052,-22253,24006,-22302,23961,-22351,23915,-22400,23869,-22449,23823,-22497,23777,-22546,23731,-22595,23685,-22643,23638,-22692,23592,-22740,23545,-22788,23499,-22836,23452,-22884,23405,-22932,23358,-22980,23311,-23028,23264,-23075,23217,-23123,23169,-23170,23122,-23218,23074,-23265,23027,-23312,22979,-23359,22931,-23406,22883,-23453,22835,-23500,22787,-23546,22739,-23593,22691,-23639,22642,-23686,22594,-23732,22545,-23778,22496,-23824,22448,-23870,22399,-23916,22350,-23962,22301,-24007,22252,-24053,22202,-24098,22153,-24144,22104,-24189,22054,-24234,22004,-24279,21955,-24324,21905,-24369,21855,-24414,21805,-24458,21755,-24503,21705,-24547,21655,-24592,21604,-24636,21554,-24680,21503,-24724,21453,-24768,21402,-24812,21351,-24856,21300,-24899,21249,-24943,21198,-24986,21147,-25030,21096,-25073,21045,-25116,20993,-25159,20942,-25202,20890,-25244,20838,-25287,20787,-25330,20735,-25372,20683,-25415,20631,-25457,20579,-25499,20527,-25541,20474,-25583,20422,-25625,20369,-25666,20317,-25708,20264,-25750,20212,-25791,20159,-25832,20106,-25873,20053,-25914,20000,-25955,19947,-25996,19894,-26037,19840,-26078,19787,-26118,19733,-26159,19680,-26199,19626,-26239,19573,-26279,19519,-26319,19465,-26359,19411,-26399,19357,-26438,19303,-26478,19249,-26517,19194,-26557,19140,-26596,19086,-26635,19031,-26674,18976,-26713,18922,-26752,18867,-26790,18812,-26829,18757,-26867,18702,-26906,18647,-26944,18592,-26982,18537,-27020,18482,-27058,18426,-27095,18371,-27133,18315,-27171,18260,-27208,18204,-27245,18148,-27282,18092,-27320,18036,-27356,17980,-27393,17924,-27430,17868,-27467,17812,-27503,17756,-27539,17699,-27576,17643,-27612,17586,-27648,17530,-27684,17473,-27720,17416,-27755,17360,-27791,17303,-27826,17246,-27862,17189,-27897,17132,-27932,17074,-27967,17017,-28002,16960,-28037,16903,-28071,16845,-28106,16788,-28140,16730,-28174,16672,-28209,16615,-28243,16557,-28276,16499,-28310,16441,-28344,16383,-28378,16325,-28411,16267,-28444,16209,-28478,16150,-28511,16092,-28544,16034,-28576,15975,-28609,15917,-28642,15858,-28674,15799,-28707,15740,-28739,15682,-28771,15623,-28803,15564,-28835,15505,-28867,15446,-28898,15387,-28930,15327,-28961,15268,-28993,15209,-29024,15149,-29055,15090,-29086,15030,-29117,14971,-29147,14911,-29178,14852,-29208,14792,-29239,14732,-29269,14672,-29299,14612,-29329,14552,-29359,14492,-29388,14432,-29418,14372,-29447,14311,-29477,14251,-29506,14191,-29535,14130,-29564,14070,-29593,14009,-29622,13949,-29650,13888,-29679,13827,-29707,13766,-29735,13706,-29763,13645,-29791,13584,-29819,13523,-29847,13462,-29874,13400,-29902,13339,-29929,13278,-29956,13217,-29984,13155,-30010,13094,-30037,13033,-30064,12971,-30091,12909,-30117,12848,-30143,12786,-30170,12724,-30196,12663,-30222,12601,-30248,12539,-30273,12477,-30299,12415,-30324,12353,-30350,12291,-30375,12229,-30400,12166,-30425,12104,-30450,12042,-30474,11980,-30499,11917,-30523,11855,-30548,11792,-30572,11730,-30596,11667,-30620,11604,-30644,11542,-30667,11479,-30691,11416,-30714,11353,-30738,11290,-30761,11227,-30784,11164,-30807,11101,-30829,11038,-30852,10975,-30875,10912,-30897,10849,-30919,10786,-30941,10722,-30963,10659,-30985,10596,-31007,10532,-31029,10469,-31050,10405,-31071,10342,-31093,10278,-31114,10214,-31135,10151,-31155,10087,-31176,10023,-31197,9959,-31217,9895,-31237,9831,-31258,9767,-31278,9703,-31298,9639,-31317,9575,-31337,9511,-31357,9447,-31376,9383,-31395,9319,-31414,9254,-31433,9190,-31452,9126,-31471,9061,-31490,8997,-31508,8932,-31526,8868,-31545,8803,-31563,8739,-31581,8674,-31598,8610,-31616,8545,-31634,8480,-31651,8415,-31668,8351,-31685,8286,-31702,8221,-31719,8156,-31736,8091,-31753,8026,-31769,7961,-31786,7896,-31802,7831,-31818,7766,-31834,7701,-31850,7636,-31865,7571,-31881,7505,-31896,7440,-31912,7375,-31927,7310,-31942,7244,-31957,7179,-31971,7113,-31986,7048,-32000,6982,-32015,6917,-32029,6851,-32043,6786,-32057,6720,-32071,6655,-32085,6589,-32098,6523,-32111,6458,-32125,6392,-32138,6326,-32151,6261,-32164,6195,-32177,6129,-32189,6063,-32202,5997,-32214,5931,-32226,5865,-32238,5799,-32250,5733,-32262,5667,-32274,5601,-32285,5535,-32296,5469,-32308,5403,-32319,5337,-32330,5271,-32341,5205,-32351,5139,-32362,5072,-32372,5006,-32383,4940,-32393,4874,-32403,4807,-32413,4741,-32423,4675,-32432,4608,-32442,4542,-32451,4476,-32460,4409,-32469,4343,-32478,4276,-32487,4210,-32496,4144,-32504,4077,-32513,4011,-32521,3944,-32529,3877,-32537,3811,-32545,3744,-32553,3678,-32560,3611,-32568,3545,-32575,3478,-32582,3411,-32589,3345,-32596,3278,-32603,3211,-32610,3145,-32616,3078,-32623,3011,-32629,2944,-32635,2878,-32641,2811,-32647,2744,-32652,2677,-32658,2610,-32663,2544,-32669,2477,-32674,2410,-32679,2343,-32684,2276,-32688,2209,-32693,2143,-32697,2076,-32702,2009,-32706,1942,-32710,1875,-32714,1808,-32718,1741,-32721,1674,-32725,1607,-32728,1540,-32731,1473,-32734,1406,-32737,1339,-32740,1273,-32743,1206,-32745,1139,-32748,1072,-32750,1005,-32752,938,-32754,871,-32756,804,-32758,737,-32759,670,-32761,603,-32762,536,-32763,469,-32764,402,-32765,335,-32766,268,-32766,201,-32767,134,-32767,67,-32767,0,-32767,-68,-32767,-135,-32767,-202,-32767,-269,-32766,-336,-32766,-403,-32765,-470,-32764,-537,-32763,-604,-32762,-671,-32761,-738,-32759,-805,-32758,-872,-32756,-939,-32754,-1006,-32752,-1073,-32750,-1140,-32748,-1207,-32745,-1274,-32743,-1340,-32740,-1407,-32737,-1474,-32734,-1541,-32731,-1608,-32728,-1675,-32725,-1742,-32721,-1809,-32718,-1876,-32714,-1943,-32710,-2010,-32706,-2077,-32702,-2144,-32697,-2210,-32693,-2277,-32688,-2344,-32684,-2411,-32679,-2478,-32674,-2545,-32669,-2611,-32663,-2678,-32658,-2745,-32652,-2812,-32647,-2879,-32641,-2945,-32635,-3012,-32629,-3079,-32623,-3146,-32616,-3212,-32610,-3279,-32603,-3346,-32596,-3412,-32589,-3479,-32582,-3546,-32575,-3612,-32568,-3679,-32560,-3745,-32553,-3812,-32545,-3878,-32537,-3945,-32529,-4012,-32521,-4078,-32513,-4145,-32504,-4211,-32496,-4277,-32487,-4344,-32478,-4410,-32469,-4477,-32460,-4543,-32451,-4609,-32442,-4676,-32432,-4742,-32423,-4808,-32413,-4875,-32403,-4941,-32393,-5007,-32383,-5073,-32372,-5140,-32362,-5206,-32351,-5272,-32341,-5338,-32330,-5404,-32319,-5470,-32308,-5536,-32296,-5602,-32285,-5668,-32274,-5734,-32262,-5800,-32250,-5866,-32238,-5932,-32226,-5998,-32214,-6064,-32202,-6130,-32189,-6196,-32177,-6262,-32164,-6327,-32151,-6393,-32138,-6459,-32125,-6524,-32111,-6590,-32098,-6656,-32085,-6721,-32071,-6787,-32057,-6852,-32043,-6918,-32029,-6983,-32015,-7049,-32000,-7114,-31986,-7180,-31971,-7245,-31957,-7311,-31942,-7376,-31927,-7441,-31912,-7506,-31896,-7572,-31881,-7637,-31865,-7702,-31850,-7767,-31834,-7832,-31818,-7897,-31802,-7962,-31786,-8027,-31769,-8092,-31753,-8157,-31736,-8222,-31719,-8287,-31702,-8352,-31685,-8416,-31668,-8481,-31651,-8546,-31634,-8611,-31616,-8675,-31598,-8740,-31581,-8804,-31563,-8869,-31545,-8933,-31526,-8998,-31508,-9062,-31490,-9127,-31471,-9191,-31452,-9255,-31433,-9320,-31414,-9384,-31395,-9448,-31376,-9512,-31357,-9576,-31337,-9640,-31317,-9704,-31298,-9768,-31278,-9832,-31258,-9896,-31237,-9960,-31217,-10024,-31197,-10088,-31176,-10152,-31155,-10215,-31135,-10279,-31114,-10343,-31093,-10406,-31071,-10470,-31050,-10533,-31029,-10597,-31007,-10660,-30985,-10723,-30963,-10787,-30941,-10850,-30919,-10913,-30897,-10976,-30875,-11039,-30852,-11102,-30829,-11165,-30807,-11228,-30784,-11291,-30761,-11354,-30738,-11417,-30714,-11480,-30691,-11543,-30667,-11605,-30644,-11668,-30620,-11731,-30596,-11793,-30572,-11856,-30548,-11918,-30523,-11981,-30499,-12043,-30474,-12105,-30450,-12167,-30425,-12230,-30400,-12292,-30375,-12354,-30350,-12416,-30324,-12478,-30299,-12540,-30273,-12602,-30248,-12664,-30222,-12725,-30196,-12787,-30170,-12849,-30143,-12910,-30117,-12972,-30091,-13034,-30064,-13095,-30037,-13156,-30010,-13218,-29984,-13279,-29956,-13340,-29929,-13401,-29902,-13463,-29874,-13524,-29847,-13585,-29819,-13646,-29791,-13707,-29763,-13767,-29735,-13828,-29707,-13889,-29679,-13950,-29650,-14010,-29622,-14071,-29593,-14131,-29564,-14192,-29535,-14252,-29506,-14312,-29477,-14373,-29447,-14433,-29418,-14493,-29388,-14553,-29359,-14613,-29329,-14673,-29299,-14733,-29269,-14793,-29239,-14853,-29208,-14912,-29178,-14972,-29147,-15031,-29117,-15091,-29086,-15150,-29055,-15210,-29024,-15269,-28993,-15328,-28961,-15388,-28930,-15447,-28898,-15506,-28867,-15565,-28835,-15624,-28803,-15683,-28771,-15741,-28739,-15800,-28707,-15859,-28674,-15918,-28642,-15976,-28609,-16035,-28576,-16093,-28544,-16151,-28511,-16210,-28478,-16268,-28444,-16326,-28411,};
-
 static int16_t twb3072[2048] = {32767,0,32766,-135,32765,-269,32764,-403,32762,-537,32760,-671,32757,-805,32753,-939,32749,-1073,32744,-1207,32739,-1340,32733,-1474,32727,-1608,32720,-1742,32713,-1876,32705,-2010,32696,-2144,32687,-2277,32678,-2411,32668,-2545,32657,-2678,32646,-2812,32634,-2945,32622,-3079,32609,-3212,32595,-3346,32581,-3479,32567,-3612,32552,-3745,32536,-3878,32520,-4012,32503,-4145,32486,-4277,32468,-4410,32450,-4543,32431,-4676,32412,-4808,32392,-4941,32371,-5073,32350,-5206,32329,-5338,32307,-5470,32284,-5602,32261,-5734,32237,-5866,32213,-5998,32188,-6130,32163,-6262,32137,-6393,32110,-6524,32084,-6656,32056,-6787,32028,-6918,31999,-7049,31970,-7180,31941,-7311,31911,-7441,31880,-7572,31849,-7702,31817,-7832,31785,-7962,31752,-8092,31718,-8222,31684,-8352,31650,-8481,31615,-8611,31580,-8740,31544,-8869,31507,-8998,31470,-9127,31432,-9255,31394,-9384,31356,-9512,31316,-9640,31277,-9768,31236,-9896,31196,-10024,31154,-10152,31113,-10279,31070,-10406,31028,-10533,30984,-10660,30940,-10787,30896,-10913,30851,-11039,30806,-11165,30760,-11291,30713,-11417,30666,-11543,30619,-11668,30571,-11793,30522,-11918,30473,-12043,30424,-12167,30374,-12292,30323,-12416,30272,-12540,30221,-12664,30169,-12787,30116,-12910,30063,-13034,30009,-13156,29955,-13279,29901,-13401,29846,-13524,29790,-13646,29734,-13767,29678,-13889,29621,-14010,29563,-14131,29505,-14252,29446,-14373,29387,-14493,29328,-14613,29268,-14733,29207,-14853,29146,-14972,29085,-15091,29023,-15210,28960,-15328,28897,-15447,28834,-15565,28770,-15683,28706,-15800,28641,-15918,28575,-16035,28510,-16151,28443,-16268,28377,-16384,28309,-16500,28242,-16616,28173,-16731,28105,-16846,28036,-16961,27966,-17075,27896,-17190,27825,-17304,27754,-17417,27683,-17531,27611,-17644,27538,-17757,27466,-17869,27392,-17981,27319,-18093,27244,-18205,27170,-18316,27094,-18427,27019,-18538,26943,-18648,26866,-18758,26789,-18868,26712,-18977,26634,-19087,26556,-19195,26477,-19304,26398,-19412,26318,-19520,26238,-19627,26158,-19734,26077,-19841,25995,-19948,25913,-20054,25831,-20160,25749,-20265,25665,-20370,25582,-20475,25498,-20580,25414,-20684,25329,-20788,25243,-20891,25158,-20994,25072,-21097,24985,-21199,24898,-21301,24811,-21403,24723,-21504,24635,-21605,24546,-21706,24457,-21806,24368,-21906,24278,-22005,24188,-22105,24097,-22203,24006,-22302,23915,-22400,23823,-22497,23731,-22595,23638,-22692,23545,-22788,23452,-22884,23358,-22980,23264,-23075,23169,-23170,23074,-23265,22979,-23359,22883,-23453,22787,-23546,22691,-23639,22594,-23732,22496,-23824,22399,-23916,22301,-24007,22202,-24098,22104,-24189,22004,-24279,21905,-24369,21805,-24458,21705,-24547,21604,-24636,21503,-24724,21402,-24812,21300,-24899,21198,-24986,21096,-25073,20993,-25159,20890,-25244,20787,-25330,20683,-25415,20579,-25499,20474,-25583,20369,-25666,20264,-25750,20159,-25832,20053,-25914,19947,-25996,19840,-26078,19733,-26159,19626,-26239,19519,-26319,19411,-26399,19303,-26478,19194,-26557,19086,-26635,18976,-26713,18867,-26790,18757,-26867,18647,-26944,18537,-27020,18426,-27095,18315,-27171,18204,-27245,18092,-27320,17980,-27393,17868,-27467,17756,-27539,17643,-27612,17530,-27684,17416,-27755,17303,-27826,17189,-27897,17074,-27967,16960,-28037,16845,-28106,16730,-28174,16615,-28243,16499,-28310,16383,-28378,16267,-28444,16150,-28511,16034,-28576,15917,-28642,15799,-28707,15682,-28771,15564,-28835,15446,-28898,15327,-28961,15209,-29024,15090,-29086,14971,-29147,14852,-29208,14732,-29269,14612,-29329,14492,-29388,14372,-29447,14251,-29506,14130,-29564,14009,-29622,13888,-29679,13766,-29735,13645,-29791,13523,-29847,13400,-29902,13278,-29956,13155,-30010,13033,-30064,12909,-30117,12786,-30170,12663,-30222,12539,-30273,12415,-30324,12291,-30375,12166,-30425,12042,-30474,11917,-30523,11792,-30572,11667,-30620,11542,-30667,11416,-30714,11290,-30761,11164,-30807,11038,-30852,10912,-30897,10786,-30941,10659,-30985,10532,-31029,10405,-31071,10278,-31114,10151,-31155,10023,-31197,9895,-31237,9767,-31278,9639,-31317,9511,-31357,9383,-31395,9254,-31433,9126,-31471,8997,-31508,8868,-31545,8739,-31581,8610,-31616,8480,-31651,8351,-31685,8221,-31719,8091,-31753,7961,-31786,7831,-31818,7701,-31850,7571,-31881,7440,-31912,7310,-31942,7179,-31971,7048,-32000,6917,-32029,6786,-32057,6655,-32085,6523,-32111,6392,-32138,6261,-32164,6129,-32189,5997,-32214,5865,-32238,5733,-32262,5601,-32285,5469,-32308,5337,-32330,5205,-32351,5072,-32372,4940,-32393,4807,-32413,4675,-32432,4542,-32451,4409,-32469,4276,-32487,4144,-32504,4011,-32521,3877,-32537,3744,-32553,3611,-32568,3478,-32582,3345,-32596,3211,-32610,3078,-32623,2944,-32635,2811,-32647,2677,-32658,2544,-32669,2410,-32679,2276,-32688,2143,-32697,2009,-32706,1875,-32714,1741,-32721,1607,-32728,1473,-32734,1339,-32740,1206,-32745,1072,-32750,938,-32754,804,-32758,670,-32761,536,-32763,402,-32765,268,-32766,134,-32767,0,-32767,-135,-32767,-269,-32766,-403,-32765,-537,-32763,-671,-32761,-805,-32758,-939,-32754,-1073,-32750,-1207,-32745,-1340,-32740,-1474,-32734,-1608,-32728,-1742,-32721,-1876,-32714,-2010,-32706,-2144,-32697,-2277,-32688,-2411,-32679,-2545,-32669,-2678,-32658,-2812,-32647,-2945,-32635,-3079,-32623,-3212,-32610,-3346,-32596,-3479,-32582,-3612,-32568,-3745,-32553,-3878,-32537,-4012,-32521,-4145,-32504,-4277,-32487,-4410,-32469,-4543,-32451,-4676,-32432,-4808,-32413,-4941,-32393,-5073,-32372,-5206,-32351,-5338,-32330,-5470,-32308,-5602,-32285,-5734,-32262,-5866,-32238,-5998,-32214,-6130,-32189,-6262,-32164,-6393,-32138,-6524,-32111,-6656,-32085,-6787,-32057,-6918,-32029,-7049,-32000,-7180,-31971,-7311,-31942,-7441,-31912,-7572,-31881,-7702,-31850,-7832,-31818,-7962,-31786,-8092,-31753,-8222,-31719,-8352,-31685,-8481,-31651,-8611,-31616,-8740,-31581,-8869,-31545,-8998,-31508,-9127,-31471,-9255,-31433,-9384,-31395,-9512,-31357,-9640,-31317,-9768,-31278,-9896,-31237,-10024,-31197,-10152,-31155,-10279,-31114,-10406,-31071,-10533,-31029,-10660,-30985,-10787,-30941,-10913,-30897,-11039,-30852,-11165,-30807,-11291,-30761,-11417,-30714,-11543,-30667,-11668,-30620,-11793,-30572,-11918,-30523,-12043,-30474,-12167,-30425,-12292,-30375,-12416,-30324,-12540,-30273,-12664,-30222,-12787,-30170,-12910,-30117,-13034,-30064,-13156,-30010,-13279,-29956,-13401,-29902,-13524,-29847,-13646,-29791,-13767,-29735,-13889,-29679,-14010,-29622,-14131,-29564,-14252,-29506,-14373,-29447,-14493,-29388,-14613,-29329,-14733,-29269,-14853,-29208,-14972,-29147,-15091,-29086,-15210,-29024,-15328,-28961,-15447,-28898,-15565,-28835,-15683,-28771,-15800,-28707,-15918,-28642,-16035,-28576,-16151,-28511,-16268,-28444,-16384,-28378,-16500,-28310,-16616,-28243,-16731,-28174,-16846,-28106,-16961,-28037,-17075,-27967,-17190,-27897,-17304,-27826,-17417,-27755,-17531,-27684,-17644,-27612,-17757,-27539,-17869,-27467,-17981,-27393,-18093,-27320,-18205,-27245,-18316,-27171,-18427,-27095,-18538,-27020,-18648,-26944,-18758,-26867,-18868,-26790,-18977,-26713,-19087,-26635,-19195,-26557,-19304,-26478,-19412,-26399,-19520,-26319,-19627,-26239,-19734,-26159,-19841,-26078,-19948,-25996,-20054,-25914,-20160,-25832,-20265,-25750,-20370,-25666,-20475,-25583,-20580,-25499,-20684,-25415,-20788,-25330,-20891,-25244,-20994,-25159,-21097,-25073,-21199,-24986,-21301,-24899,-21403,-24812,-21504,-24724,-21605,-24636,-21706,-24547,-21806,-24458,-21906,-24369,-22005,-24279,-22105,-24189,-22203,-24098,-22302,-24007,-22400,-23916,-22497,-23824,-22595,-23732,-22692,-23639,-22788,-23546,-22884,-23453,-22980,-23359,-23075,-23265,-23170,-23170,-23265,-23075,-23359,-22980,-23453,-22884,-23546,-22788,-23639,-22692,-23732,-22595,-23824,-22497,-23916,-22400,-24007,-22302,-24098,-22203,-24189,-22105,-24279,-22005,-24369,-21906,-24458,-21806,-24547,-21706,-24636,-21605,-24724,-21504,-24812,-21403,-24899,-21301,-24986,-21199,-25073,-21097,-25159,-20994,-25244,-20891,-25330,-20788,-25415,-20684,-25499,-20580,-25583,-20475,-25666,-20370,-25750,-20265,-25832,-20160,-25914,-20054,-25996,-19948,-26078,-19841,-26159,-19734,-26239,-19627,-26319,-19520,-26399,-19412,-26478,-19304,-26557,-19195,-26635,-19087,-26713,-18977,-26790,-18868,-26867,-18758,-26944,-18648,-27020,-18538,-27095,-18427,-27171,-18316,-27245,-18205,-27320,-18093,-27393,-17981,-27467,-17869,-27539,-17757,-27612,-17644,-27684,-17531,-27755,-17417,-27826,-17304,-27897,-17190,-27967,-17075,-28037,-16961,-28106,-16846,-28174,-16731,-28243,-16616,-28310,-16500,-28378,-16384,-28444,-16268,-28511,-16151,-28576,-16035,-28642,-15918,-28707,-15800,-28771,-15683,-28835,-15565,-28898,-15447,-28961,-15328,-29024,-15210,-29086,-15091,-29147,-14972,-29208,-14853,-29269,-14733,-29329,-14613,-29388,-14493,-29447,-14373,-29506,-14252,-29564,-14131,-29622,-14010,-29679,-13889,-29735,-13767,-29791,-13646,-29847,-13524,-29902,-13401,-29956,-13279,-30010,-13156,-30064,-13034,-30117,-12910,-30170,-12787,-30222,-12664,-30273,-12540,-30324,-12416,-30375,-12292,-30425,-12167,-30474,-12043,-30523,-11918,-30572,-11793,-30620,-11668,-30667,-11543,-30714,-11417,-30761,-11291,-30807,-11165,-30852,-11039,-30897,-10913,-30941,-10787,-30985,-10660,-31029,-10533,-31071,-10406,-31114,-10279,-31155,-10152,-31197,-10024,-31237,-9896,-31278,-9768,-31317,-9640,-31357,-9512,-31395,-9384,-31433,-9255,-31471,-9127,-31508,-8998,-31545,-8869,-31581,-8740,-31616,-8611,-31651,-8481,-31685,-8352,-31719,-8222,-31753,-8092,-31786,-7962,-31818,-7832,-31850,-7702,-31881,-7572,-31912,-7441,-31942,-7311,-31971,-7180,-32000,-7049,-32029,-6918,-32057,-6787,-32085,-6656,-32111,-6524,-32138,-6393,-32164,-6262,-32189,-6130,-32214,-5998,-32238,-5866,-32262,-5734,-32285,-5602,-32308,-5470,-32330,-5338,-32351,-5206,-32372,-5073,-32393,-4941,-32413,-4808,-32432,-4676,-32451,-4543,-32469,-4410,-32487,-4277,-32504,-4145,-32521,-4012,-32537,-3878,-32553,-3745,-32568,-3612,-32582,-3479,-32596,-3346,-32610,-3212,-32623,-3079,-32635,-2945,-32647,-2812,-32658,-2678,-32669,-2545,-32679,-2411,-32688,-2277,-32697,-2144,-32706,-2010,-32714,-1876,-32721,-1742,-32728,-1608,-32734,-1474,-32740,-1340,-32745,-1207,-32750,-1073,-32754,-939,-32758,-805,-32761,-671,-32763,-537,-32765,-403,-32766,-269,-32767,-135,-32767,-1,-32767,134,-32766,268,-32765,402,-32763,536,-32761,670,-32758,804,-32754,938,-32750,1072,-32745,1206,-32740,1339,-32734,1473,-32728,1607,-32721,1741,-32714,1875,-32706,2009,-32697,2143,-32688,2276,-32679,2410,-32669,2544,-32658,2677,-32647,2811,-32635,2944,-32623,3078,-32610,3211,-32596,3345,-32582,3478,-32568,3611,-32553,3744,-32537,3877,-32521,4011,-32504,4144,-32487,4276,-32469,4409,-32451,4542,-32432,4675,-32413,4807,-32393,4940,-32372,5072,-32351,5205,-32330,5337,-32308,5469,-32285,5601,-32262,5733,-32238,5865,-32214,5997,-32189,6129,-32164,6261,-32138,6392,-32111,6523,-32085,6655,-32057,6786,-32029,6917,-32000,7048,-31971,7179,-31942,7310,-31912,7440,-31881,7571,-31850,7701,-31818,7831,-31786,7961,-31753,8091,-31719,8221,-31685,8351,-31651,8480,-31616,8610,-31581,8739,-31545,8868,-31508,8997,-31471,9126,-31433,9254,-31395,9383,-31357,9511,-31317,9639,-31278,9767,-31237,9895,-31197,10023,-31155,10151,-31114,10278,-31071,10405,-31029,10532,-30985,10659,-30941,10786,-30897,10912,-30852,11038,-30807,11164,-30761,11290,-30714,11416,-30667,11542,-30620,11667,-30572,11792,-30523,11917,-30474,12042,-30425,12166,-30375,12291,-30324,12415,-30273,12539,-30222,12663,-30170,12786,-30117,12909,-30064,13033,-30010,13155,-29956,13278,-29902,13400,-29847,13523,-29791,13645,-29735,13766,-29679,13888,-29622,14009,-29564,14130,-29506,14251,-29447,14372,-29388,14492,-29329,14612,-29269,14732,-29208,14852,-29147,14971,-29086,15090,-29024,15209,-28961,15327,-28898,15446,-28835,15564,-28771,15682,-28707,15799,-28642,15917,-28576,16034,-28511,16150,-28444,16267,-28378,16383,-28310,16499,-28243,16615,-28174,16730,-28106,16845,-28037,16960,-27967,17074,-27897,17189,-27826,17303,-27755,17416,-27684,17530,-27612,17643,-27539,17756,-27467,17868,-27393,17980,-27320,18092,-27245,18204,-27171,18315,-27095,18426,-27020,18537,-26944,18647,-26867,18757,-26790,18867,-26713,18976,-26635,19086,-26557,19194,-26478,19303,-26399,19411,-26319,19519,-26239,19626,-26159,19733,-26078,19840,-25996,19947,-25914,20053,-25832,20159,-25750,20264,-25666,20369,-25583,20474,-25499,20579,-25415,20683,-25330,20787,-25244,20890,-25159,20993,-25073,21096,-24986,21198,-24899,21300,-24812,21402,-24724,21503,-24636,21604,-24547,21705,-24458,21805,-24369,21905,-24279,22004,-24189,22104,-24098,22202,-24007,22301,-23916,22399,-23824,22496,-23732,22594,-23639,22691,-23546,22787,-23453,22883,-23359,22979,-23265,23074,-23170,23169,-23075,23264,-22980,23358,-22884,23452,-22788,23545,-22692,23638,-22595,23731,-22497,23823,-22400,23915,-22302,24006,-22203,24097,-22105,24188,-22005,24278,-21906,24368,-21806,24457,-21706,24546,-21605,24635,-21504,24723,-21403,24811,-21301,24898,-21199,24985,-21097,25072,-20994,25158,-20891,25243,-20788,25329,-20684,25414,-20580,25498,-20475,25582,-20370,25665,-20265,25749,-20160,25831,-20054,25913,-19948,25995,-19841,26077,-19734,26158,-19627,26238,-19520,26318,-19412,26398,-19304,26477,-19195,26556,-19087,26634,-18977,26712,-18868,26789,-18758,26866,-18648,26943,-18538,27019,-18427,27094,-18316,27170,-18205,27244,-18093,27319,-17981,27392,-17869,27466,-17757,27538,-17644,27611,-17531,27683,-17417,27754,-17304,27825,-17190,27896,-17075,27966,-16961,28036,-16846,28105,-16731,28173,-16616,28242,-16500,28309,};
diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h
index 0ab8d9670145ceab059356b9d6675e94b786b2b7..71c8dad4a6789510a6f1df38c9f01a3c94c72aa1 100644
--- a/openair2/COMMON/platform_types.h
+++ b/openair2/COMMON/platform_types.h
@@ -84,6 +84,10 @@ typedef boolean_t             eNB_flag_t;
 #define  ENB_FLAG_NO          FALSE
 #define  ENB_FLAG_YES         TRUE
 
+typedef boolean_t             gNB_flag_t;
+#define  GNB_FLAG_NO          FALSE
+#define  GNB_FLAG_YES         TRUE
+
 typedef boolean_t             srb_flag_t;
 #define  SRB_FLAG_NO          FALSE
 #define  SRB_FLAG_YES         TRUE
@@ -236,6 +240,9 @@ typedef struct protocol_ctxt_s {
 #define UE_INSTANCE_TO_MODULE_ID( iNSTANCE ) iNSTANCE - NB_eNB_INST
 #define ENB_INSTANCE_TO_MODULE_ID( iNSTANCE )iNSTANCE
 
+//NR
+#define GNB_MODULE_ID_TO_INSTANCE( mODULE_iD ) mODULE_iD
+#define GNB_INSTANCE_TO_MODULE_ID( iNSTANCE )iNSTANCE
 
 #define MODULE_ID_TO_INSTANCE(mODULE_iD, iNSTANCE, eNB_fLAG) \
     if(eNB_fLAG == ENB_FLAG_YES) \
diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h
index 9bd25d3b3aa52075eaf3acf5f5c51b0f9f7581b5..93f1e4ea80ecab06c0cc3cc1fc965186c4899331 100644
--- a/openair2/COMMON/rrc_messages_types.h
+++ b/openair2/COMMON/rrc_messages_types.h
@@ -64,6 +64,8 @@ typedef UL_DCCH_Message_t       RrcUlDcchMessage;
 
 #define NBIOTRRC_CONFIGURATION_REQ(mSGpTR)   (mSGpTR)->ittiMsg.nbiotrrc_configuration_req
 
+#define NRRRC_CONFIGURATION_REQ(mSGpTR)   (mSGpTR)->ittiMsg.nrrrc_configuration_req
+
 #define NAS_KENB_REFRESH_REQ(mSGpTR)    (mSGpTR)->ittiMsg.nas_kenb_refresh_req
 #define NAS_CELL_SELECTION_REQ(mSGpTR)  (mSGpTR)->ittiMsg.nas_cell_selection_req
 #define NAS_CONN_ESTABLI_REQ(mSGpTR)    (mSGpTR)->ittiMsg.nas_conn_establi_req
@@ -87,13 +89,13 @@ typedef struct RrcStateInd_s {
 
 // 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;
-  uint16_t            mnc;
-  uint8_t             mnc_digit_length;
+  uint16_t                mcc;
+  uint16_t                mnc;
+  uint8_t                 mnc_digit_length;
 
   
   paging_drx_t            default_drx;
@@ -171,75 +173,275 @@ typedef struct RrcConfigurationReq_s {
 } RrcConfigurationReq;
 #define MAX_NUM_NBIOT_CELEVELS    3
 typedef struct NbIoTRrcConfigurationReq_s {
-  uint32_t            cell_identity;
+  uint32_t                cell_identity;
 
-  uint16_t            tac;
+  uint16_t                tac;
 
-  uint16_t	      mcc;
-  uint16_t	      mnc;
-  uint8_t	      mnc_digit_length;
-  lte_frame_type_t	  frame_type;
+  uint16_t                mcc;
+  uint16_t                mnc;
+  uint8_t                 mnc_digit_length;
+  lte_frame_type_t        frame_type;
   uint8_t                 tdd_config;
   uint8_t                 tdd_config_s;
   lte_prefix_type_t       prefix_type;
-  lte_prefix_type_t	  prefix_type_UL;
+  lte_prefix_type_t       prefix_type_UL;
   int16_t                 eutra_band;
   uint32_t                downlink_frequency;
   int32_t                 uplink_frequency_offset;
   int16_t                 Nid_cell;// for testing, change later
   int16_t                 N_RB_DL;// for testing, change later
   //RACH
-  long					  rach_raResponseWindowSize_NB;
-  long					  rach_macContentionResolutionTimer_NB;
-  long					  rach_powerRampingStep_NB;
-  long					  rach_preambleInitialReceivedTargetPower_NB;
-  long					  rach_preambleTransMax_CE_NB;
+  long                    rach_raResponseWindowSize_NB;
+  long                    rach_macContentionResolutionTimer_NB;
+  long                    rach_powerRampingStep_NB;
+  long                    rach_preambleInitialReceivedTargetPower_NB;
+  long                    rach_preambleTransMax_CE_NB;
   //BCCH
-  long					  bcch_modificationPeriodCoeff_NB;
+  long                    bcch_modificationPeriodCoeff_NB;
   //PCCH
-  long					  pcch_defaultPagingCycle_NB;
-  long					  pcch_nB_NB;
-  long					  pcch_npdcch_NumRepetitionPaging_NB;
+  long                    pcch_defaultPagingCycle_NB;
+  long                    pcch_nB_NB;
+  long                    pcch_npdcch_NumRepetitionPaging_NB;
   //NPRACH
-  long					  nprach_CP_Length;
-  long					  nprach_rsrp_range;
-  long					  nprach_Periodicity[MAX_NUM_NBIOT_CELEVELS];
-  long					  nprach_StartTime[MAX_NUM_NBIOT_CELEVELS];
-  long					  nprach_SubcarrierOffset[MAX_NUM_NBIOT_CELEVELS];
-  long					  nprach_NumSubcarriers[MAX_NUM_NBIOT_CELEVELS];
-  long					  numRepetitionsPerPreambleAttempt_NB[MAX_NUM_NBIOT_CELEVELS];
-  long					  nprach_SubcarrierMSG3_RangeStart;
-  long					  maxNumPreambleAttemptCE_NB;
-  long					  npdcch_NumRepetitions_RA[MAX_NUM_NBIOT_CELEVELS];
-  long					  npdcch_StartSF_CSS_RA[MAX_NUM_NBIOT_CELEVELS];
-  long					  npdcch_Offset_RA[MAX_NUM_NBIOT_CELEVELS];
+  long                    nprach_CP_Length;
+  long                    nprach_rsrp_range;
+  long                    nprach_Periodicity[MAX_NUM_NBIOT_CELEVELS];
+  long                    nprach_StartTime[MAX_NUM_NBIOT_CELEVELS];
+  long                    nprach_SubcarrierOffset[MAX_NUM_NBIOT_CELEVELS];
+  long                    nprach_NumSubcarriers[MAX_NUM_NBIOT_CELEVELS];
+  long                    numRepetitionsPerPreambleAttempt_NB[MAX_NUM_NBIOT_CELEVELS];
+  long                    nprach_SubcarrierMSG3_RangeStart;
+  long                    maxNumPreambleAttemptCE_NB;
+  long                    npdcch_NumRepetitions_RA[MAX_NUM_NBIOT_CELEVELS];
+  long                    npdcch_StartSF_CSS_RA[MAX_NUM_NBIOT_CELEVELS];
+  long                    npdcch_Offset_RA[MAX_NUM_NBIOT_CELEVELS];
   //NPDSCH
-  long					  npdsch_nrs_Power;
+  long                    npdsch_nrs_Power;
   //NPUSCH
-  long					  npusch_ack_nack_numRepetitions_NB;
-  long					  npusch_srs_SubframeConfig_NB;
-  long					  npusch_threeTone_CyclicShift_r13;
-  long					  npusch_sixTone_CyclicShift_r13;
-  BOOLEAN_t				  npusch_groupHoppingEnabled;
-  long					  npusch_groupAssignmentNPUSCH_r13;
+  long                    npusch_ack_nack_numRepetitions_NB;
+  long                    npusch_srs_SubframeConfig_NB;
+  long                    npusch_threeTone_CyclicShift_r13;
+  long                    npusch_sixTone_CyclicShift_r13;
+  BOOLEAN_t               npusch_groupHoppingEnabled;
+  long                    npusch_groupAssignmentNPUSCH_r13;
 
   //DL_GapConfig
-  long					  dl_GapThreshold_NB;
-  long	 				  dl_GapPeriodicity_NB;
-  long	 				  dl_GapDurationCoeff_NB;
+  long                    dl_GapThreshold_NB;
+  long                    dl_GapPeriodicity_NB;
+  long                    dl_GapDurationCoeff_NB;
   //Uplink power control Common
-  long					  npusch_p0_NominalNPUSCH;
-  long					  npusch_alpha;
-  long					  deltaPreambleMsg3;
+  long                    npusch_p0_NominalNPUSCH;
+  long                    npusch_alpha;
+  long                    deltaPreambleMsg3;
   //UE timers and constants
-  long					  ue_TimersAndConstants_t300_NB;
-  long					  ue_TimersAndConstants_t301_NB;
-  long					  ue_TimersAndConstants_t310_NB;
-  long					  ue_TimersAndConstants_t311_NB;
-  long					  ue_TimersAndConstants_n310_NB;
-  long					  ue_TimersAndConstants_n311_NB;
+  long                    ue_TimersAndConstants_t300_NB;
+  long                    ue_TimersAndConstants_t301_NB;
+  long                    ue_TimersAndConstants_t310_NB;
+  long                    ue_TimersAndConstants_t311_NB;
+  long                    ue_TimersAndConstants_n310_NB;
+  long                    ue_TimersAndConstants_n311_NB;
 } NbIoTRrcConfigurationReq;
 
+// gNB: GNB_APP -> RRC messages
+typedef struct NRRrcConfigurationReq_s {
+  uint32_t                cell_identity;
+  uint16_t                tac;
+  uint16_t                mcc;
+  uint16_t                mnc;
+  uint8_t                 mnc_digit_length;
+  int16_t                 nb_cc;
+  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  uint8_t                 tdd_config[MAX_NUM_CCs];
+  uint8_t                 tdd_config_s[MAX_NUM_CCs];
+  lte_prefix_type_t       DL_prefix_type[MAX_NUM_CCs];
+  lte_prefix_type_t       UL_prefix_type[MAX_NUM_CCs];
+  int16_t                 eutra_band[MAX_NUM_CCs];
+  uint32_t                downlink_frequency[MAX_NUM_CCs];
+  int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
+  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];
+
+  ///NR
+  //MIB
+  long                    MIB_subCarrierSpacingCommon[MAX_NUM_CCs]; 
+  uint32_t                MIB_ssb_SubcarrierOffset[MAX_NUM_CCs]; 
+  long                    MIB_dmrs_TypeA_Position[MAX_NUM_CCs];
+  uint32_t                pdcch_ConfigSIB1[MAX_NUM_CCs];
+
+  //SIB1
+  long                    SIB1_frequencyOffsetSSB[MAX_NUM_CCs]; 
+  long                    SIB1_ssb_PeriodicityServingCell[MAX_NUM_CCs];
+  long                    SIB1_ss_PBCH_BlockPower[MAX_NUM_CCs];
+  //NR FrequencyInfoDL
+  long                    absoluteFrequencySSB[MAX_NUM_CCs];
+  uint32_t                ssb_SubcarrierOffset[MAX_NUM_CCs];
+  long                    DL_FreqBandIndicatorNR[MAX_NUM_CCs];
+  long                    DL_absoluteFrequencyPointA[MAX_NUM_CCs];
+
+  //NR DL SCS-SpecificCarrier
+  uint32_t                DL_offsetToCarrier[MAX_NUM_CCs];
+  long                    DL_SCS_SubcarrierSpacing[MAX_NUM_CCs];
+  long                    DL_SCS_SpecificCarrier_k0[MAX_NUM_CCs];
+  uint32_t                DL_carrierBandwidth[MAX_NUM_CCs];
+
+  //NR BWP-DownlinkCommon
+  uint32_t                DL_locationAndBandwidth[MAX_NUM_CCs]; 
+  long                    DL_BWP_SubcarrierSpacing[MAX_NUM_CCs];
+  lte_prefix_type_t       DL_BWP_prefix_type[MAX_NUM_CCs];   
+
+  //NR FrequencyInfoUL
+  long                    UL_FreqBandIndicatorNR[MAX_NUM_CCs];
+  long                    UL_absoluteFrequencyPointA[MAX_NUM_CCs];
+  lte_prefix_type_t       UL_additionalSpectrumEmission[MAX_NUM_CCs];
+  long                    UL_p_Max[MAX_NUM_CCs];
+  long                    ULfrequencyShift7p5khz[MAX_NUM_CCs];
+
+  //NR UL SCS-SpecificCarrier
+  uint32_t                UL_offsetToCarrier[MAX_NUM_CCs];
+  long                    UL_SCS_SubcarrierSpacing[MAX_NUM_CCs];
+  long                    UL_SCS_SpecificCarrier_k0[MAX_NUM_CCs];
+  uint32_t                UL_carrierBandwidth[MAX_NUM_CCs];
+
+  // NR BWP-UplinkCommon
+  uint32_t                UL_locationAndBandwidth[MAX_NUM_CCs];
+  long                    UL_BWP_SubcarrierSpacing[MAX_NUM_CCs];
+  lte_prefix_type_t       UL_BWP_prefix_type[MAX_NUM_CCs];
+
+  long                    ServingCellConfigCommon_ssb_PositionsInBurst_PR[MAX_NUM_CCs];
+  long                    ServingCellConfigCommon_ssb_periodicityServingCell[MAX_NUM_CCs]; //ServingCellConfigCommon
+  long                    ServingCellConfigCommon_dmrs_TypeA_Position[MAX_NUM_CCs];        //ServingCellConfigCommon
+  long                    NIA_SubcarrierSpacing[MAX_NUM_CCs];      //ServingCellConfigCommon Used only for non-initial access
+  long                    ServingCellConfigCommon_ss_PBCH_BlockPower[MAX_NUM_CCs];         //ServingCellConfigCommon
+
+
+  //NR TDD-UL-DL-ConfigCommon
+  long                    referenceSubcarrierSpacing[MAX_NUM_CCs];
+  long                    dl_UL_TransmissionPeriodicity[MAX_NUM_CCs];
+  long                    nrofDownlinkSlots[MAX_NUM_CCs];
+  long                    nrofDownlinkSymbols[MAX_NUM_CCs];
+  long                    nrofUplinkSlots[MAX_NUM_CCs];
+  long                    nrofUplinkSymbols[MAX_NUM_CCs];
+
+  //NR RACH-ConfigCommon
+  long                    rach_totalNumberOfRA_Preambles[MAX_NUM_CCs];
+  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[MAX_NUM_CCs];
+  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[MAX_NUM_CCs];
+  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[MAX_NUM_CCs];
+  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[MAX_NUM_CCs];
+  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[MAX_NUM_CCs];
+  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[MAX_NUM_CCs];
+  uint32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four[MAX_NUM_CCs];
+  uint32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight[MAX_NUM_CCs];
+  uint32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen[MAX_NUM_CCs];
+  BOOLEAN_t               rach_groupBconfigured[MAX_NUM_CCs];
+  long                    rach_ra_Msg3SizeGroupA[MAX_NUM_CCs];
+  long                    rach_messagePowerOffsetGroupB[MAX_NUM_CCs];
+  long                    rach_numberOfRA_PreamblesGroupA[MAX_NUM_CCs];
+  long                    rach_ra_ContentionResolutionTimer[MAX_NUM_CCs];
+  long                    rsrp_ThresholdSSB[MAX_NUM_CCs];
+  long                    rsrp_ThresholdSSB_SUL[MAX_NUM_CCs];
+  long                    prach_RootSequenceIndex_choice[MAX_NUM_CCs];
+  uint32_t                prach_RootSequenceIndex_l839[MAX_NUM_CCs];
+  uint32_t                prach_RootSequenceIndex_l139[MAX_NUM_CCs];
+  long                    prach_msg1_SubcarrierSpacing[MAX_NUM_CCs];
+  long                    restrictedSetConfig[MAX_NUM_CCs];
+  long                    msg3_transformPrecoding[MAX_NUM_CCs];
+  //ssb-perRACH-OccasionAndCB-PreamblesPerSSB not sure
+
+  //NR RACH-ConfigGeneric
+  uint32_t                prach_ConfigurationIndex[MAX_NUM_CCs];
+  long                    prach_msg1_FDM[MAX_NUM_CCs];
+  long                    prach_msg1_FrequencyStart[MAX_NUM_CCs];
+  uint32_t                zeroCorrelationZoneConfig[MAX_NUM_CCs];
+  long                    preambleReceivedTargetPower[MAX_NUM_CCs];
+  long                    preambleTransMax[MAX_NUM_CCs];
+  long                    powerRampingStep[MAX_NUM_CCs];
+  long                    ra_ResponseWindow[MAX_NUM_CCs];
+
+  //NR PUSCH-ConfigCommon
+  BOOLEAN_t               groupHoppingEnabledTransformPrecoding[MAX_NUM_CCs];
+  long                    msg3_DeltaPreamble[MAX_NUM_CCs];
+  long                    p0_NominalWithGrant[MAX_NUM_CCs];
+
+  ///NR PUSCH-TimeDomainResourceAllocation
+  uint32_t                PUSCH_TimeDomainResourceAllocation_k2[MAX_NUM_CCs];
+  long                    PUSCH_TimeDomainResourceAllocation_mappingType[MAX_NUM_CCs];
+
+  //NR PUCCH-ConfigCommon
+  long                    pucch_GroupHopping[MAX_NUM_CCs];
+  long                    p0_nominal[MAX_NUM_CCs];
+
+  //NR PDSCH-ConfigCOmmon
+  //NR PDSCH-TimeDomainResourceAllocation
+  uint32_t                PDSCH_TimeDomainResourceAllocation_k0[MAX_NUM_CCs];
+  long                    PDSCH_TimeDomainResourceAllocation_mappingType[MAX_NUM_CCs];
+
+
+  //NR RateMatchPattern  is used to configure one rate matching pattern for PDSCH
+  long                    rateMatchPatternId[MAX_NUM_CCs];
+  long                    RateMatchPattern_patternType[MAX_NUM_CCs];
+  long                    symbolsInResourceBlock[MAX_NUM_CCs];
+  long                    periodicityAndPattern[MAX_NUM_CCs];
+  long                    RateMatchPattern_controlResourceSet[MAX_NUM_CCs]; ///ControlResourceSetId
+  long                    RateMatchPattern_subcarrierSpacing[MAX_NUM_CCs];
+  long                    RateMatchPattern_mode[MAX_NUM_CCs];
+
+  //NR PDCCH-ConfigCommon
+  long                    searchSpaceSIB1[MAX_NUM_CCs];
+  long                    searchSpaceOtherSystemInformation[MAX_NUM_CCs];
+  long                    pagingSearchSpace[MAX_NUM_CCs];
+  long                    ra_SearchSpace[MAX_NUM_CCs];
+  long                    rach_ra_ControlResourceSet[MAX_NUM_CCs];  
+  //NR PDCCH-ConfigCommon commonControlResourcesSets
+  long                    PDCCH_common_controlResourceSetId[MAX_NUM_CCs];
+  long                    PDCCH_common_ControlResourceSet_duration[MAX_NUM_CCs];
+  long                    PDCCH_cce_REG_MappingType[MAX_NUM_CCs];
+  long                    PDCCH_reg_BundleSize[MAX_NUM_CCs];
+  long                    PDCCH_interleaverSize[MAX_NUM_CCs];
+  long                    PDCCH_shiftIndex[MAX_NUM_CCs];  
+  long                    PDCCH_precoderGranularity[MAX_NUM_CCs]; //Corresponds to L1 parameter 'CORESET-precoder-granuality'
+  long                    PDCCH_TCI_StateId[MAX_NUM_CCs];
+  BOOLEAN_t               tci_PresentInDCI[MAX_NUM_CCs];
+
+  //NR PDCCH-ConfigCommon commonSearchSpaces
+  long                    SearchSpaceId[MAX_NUM_CCs];
+  long                    commonSearchSpaces_controlResourceSetId[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_choice[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl1[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl2[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl4[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl5[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl8[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl10[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl16[MAX_NUM_CCs];
+  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_sl20[MAX_NUM_CCs];
+  long                    SearchSpace_nrofCandidates_aggregationLevel1[MAX_NUM_CCs];
+  long                    SearchSpace_nrofCandidates_aggregationLevel2[MAX_NUM_CCs];
+  long                    SearchSpace_nrofCandidates_aggregationLevel4[MAX_NUM_CCs];
+  long                    SearchSpace_nrofCandidates_aggregationLevel8[MAX_NUM_CCs];
+  long                    SearchSpace_nrofCandidates_aggregationLevel16[MAX_NUM_CCs];
+  long                    SearchSpace_searchSpaceType[MAX_NUM_CCs];
+  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[MAX_NUM_CCs];
+  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[MAX_NUM_CCs];
+  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[MAX_NUM_CCs];
+  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[MAX_NUM_CCs];
+  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[MAX_NUM_CCs];  
+  long                    Common_dci_Format2_3_monitoringPeriodicity[MAX_NUM_CCs];
+  long                    Common_dci_Format2_3_nrofPDCCH_Candidates[MAX_NUM_CCs];
+  long                    ue_Specific__dci_Formats[MAX_NUM_CCs];
+
+  //RateMatchPatternLTE-CRS
+  uint32_t                RateMatchPatternLTE_CRS_carrierFreqDL[MAX_NUM_CCs];
+  long                    RateMatchPatternLTE_CRS_carrierBandwidthDL[MAX_NUM_CCs];
+  long                    RateMatchPatternLTE_CRS_nrofCRS_Ports[MAX_NUM_CCs];
+  long                    RateMatchPatternLTE_CRS_v_Shift[MAX_NUM_CCs];
+  long                    RateMatchPatternLTE_CRS_radioframeAllocationPeriod[MAX_NUM_CCs];
+  uint32_t                RateMatchPatternLTE_CRS_radioframeAllocationOffset[MAX_NUM_CCs];
+  long                    RateMatchPatternLTE_CRS_subframeAllocation_choice[MAX_NUM_CCs];
+
+} gNB_RrcConfigurationReq;
+
 
 // UE: NAS -> RRC messages
 typedef kenb_refresh_req_t      NasKenbRefreshReq;
diff --git a/openair2/ENB_APP/NRRRC_paramsvalues.h b/openair2/ENB_APP/NRRRC_paramsvalues.h
new file mode 100644
index 0000000000000000000000000000000000000000..aae1fc3300d913f8926611111572a3c351ac17a9
--- /dev/null
+++ b/openair2/ENB_APP/NRRRC_paramsvalues.h
@@ -0,0 +1,91 @@
+/*
+ * 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/GNB_APP/RRC_paramsvalues.h
+ * \brief macro definitions for RRC authorized and asn1 parameters values, to be used in paramdef_t/chechedparam_t structure initializations 
+ * \author Francois TABURET
+ * \date 2017
+ * \version 0.1
+ * \company NOKIA BellLabs France
+ * \email: francois.taburet@nokia-bell-labs.com
+ * \note
+ * \warning
+ */
+#ifndef __NRRRC_PARAMSVALUES__H__
+#define __NRRRC_PARAMSVALUES__H__
+/*    cell configuration section name */
+#define GNB_CONFIG_STRING_GNB_LIST                    "gNBs"
+/* component carriers configuration section name */		
+#define GNB_CONFIG_STRING_COMPONENT_CARRIERS          "component_carriers"		 
+
+#define GNB_CONFIG_STRING_FRAME_TYPE                  "frame_type"
+#define GNB_CONFIG_STRING_DL_PREFIX_TYPE              "DL_prefix_type"
+#define GNB_CONFIG_STRING_UL_PREFIX_TYPE           	  "UL_prefix_type"
+#define GNB_CONFIG_STRING_EUTRA_BAND                  "eutra_band"
+#define GNB_CONFIG_STRING_DOWNLINK_FREQUENCY          "downlink_frequency"
+#define GNB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET     "uplink_frequency_offset"
+#define GNB_CONFIG_STRING_NID_CELL                    "Nid_cell"
+#define GNB_CONFIG_STRING_N_RB_DL                     "N_RB_DL"
+#define GNB_CONFIG_STRING_CELL_MBSFN                  "Nid_cell_mbsfn"
+
+
+#define FRAMETYPE_OKVALUES                                      {"FDD","TDD"}
+#define FRAMETYPE_MODVALUES                                     { FDD, TDD} 
+
+#define TDDCFG(A)                                               TDD_Config__subframeAssignment_ ## A
+#define TDDCONFIG_OKRANGE                                       { TDDCFG(sa0), TDDCFG(sa6)}   
+
+#define TDDCFGS(A)                                              TDD_Config__specialSubframePatterns_ ## A
+#define TDDCONFIGS_OKRANGE                                      { TDDCFGS(ssp0), TDDCFGS(ssp8)}   
+
+#define PREFIX_OKVALUES                                         {"NORMAL","EXTENDED"}
+#define PREFIX_MODVALUES                                        { NORMAL, EXTENDED} 
+
+#define PREFIXUL_OKVALUES                                       {"NORMAL","EXTENDED"}
+#define PREFIXUL_MODVALUES                                      { NORMAL, EXTENDED} 
+
+#define NRBDL_OKVALUES                                          {6,15,25,50,75,100}
+
+#define UETIMER_T300_OKVALUES                                   {100,200,300,400,600,1000,1500,2000}
+#define UETT300(A)                                              UE_TimersAndConstants__t300_ ## A
+#define UETIMER_T300_MODVALUES                                  { UETT300(ms100), UETT300(ms200),UETT300(ms300),UETT300(ms400),UETT300(ms600),UETT300(ms1000),UETT300(ms1500),UETT300(ms2000)}           		
+
+#define UETIMER_T301_OKVALUES                                   {100,200,300,400,600,1000,1500,2000}
+#define UETT301(A)                                              UE_TimersAndConstants__t301_ ## A
+#define UETIMER_T301_MODVALUES                                  { UETT301(ms100), UETT301(ms200),UETT301(ms300),UETT301(ms400),UETT301(ms600),UETT301(ms1000),UETT301(ms1500),UETT301(ms2000)}
+
+#define UETIMER_T310_OKVALUES                                   {0,50,100,200,500,1000,2000}
+#define UETT310(A)                                              UE_TimersAndConstants__t310_ ## A
+#define UETIMER_T310_MODVALUES                                  { UETT310(ms0), UETT310(ms50),UETT310(ms100),UETT310(ms200),UETT310(ms500),UETT310(ms1000),UETT310(ms2000)}
+
+#define UETIMER_T311_OKVALUES                                   {1000,3110,5000,10000,15000,20000,31100}
+#define UETT311(A)                                              UE_TimersAndConstants__t311_ ## A
+#define UETIMER_T311_MODVALUES                                  { UETT311(ms1000), UETT311(ms3000),UETT311(ms5000),UETT311(ms10000),UETT311(ms15000),UETT311(ms20000),UETT311(ms30000)}
+
+#define UETIMER_N310_OKVALUES                                   {1,2,3,4,6,8,10,20}
+#define UETN310(A)                                              UE_TimersAndConstants__n310_ ## A
+#define UETIMER_N310_MODVALUES                                  { UETN310(n1), UETN310(n2),UETN310(n3),UETN310(n4),UETN310(n6),UETN310(n8),UETN310(n10),UETN310(n20)}
+
+#define UETIMER_N311_OKVALUES                                   {1,2,3,4,5,6,8,10}
+#define UETN311(A)                                              UE_TimersAndConstants__n311_ ## A
+#define UETIMER_N311_MODVALUES                                  { UETN311(n1), UETN311(n2),UETN311(n3),UETN311(n4),UETN311(n5),UETN311(n6),UETN311(n8),UETN311(n10)}
+
+#endif
diff --git a/openair2/ENB_APP/gnb_app.c b/openair2/ENB_APP/gnb_app.c
new file mode 100644
index 0000000000000000000000000000000000000000..15d5ef6fea10543d66bee49608940837c6c6b77f
--- /dev/null
+++ b/openair2/ENB_APP/gnb_app.c
@@ -0,0 +1,291 @@
+/*
+ * 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
+ */
+
+/*
+                                gnb_app.c
+                             -------------------
+  AUTHOR  : Laurent Winckel, Sebastien ROUX, Lionel GAUTHIER, Navid Nikaein
+  COMPANY : EURECOM
+  EMAIL   : Lionel.Gauthier@eurecom.fr and Navid Nikaein
+*/
+
+#include <string.h>
+#include <stdio.h>
+
+#include "gnb_app.h"
+#include "gnb_config.h"
+#include "assertions.h"
+#include "common/ran_context.h"
+
+#include "log.h"
+
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+# include "timer.h"
+# if defined(ENABLE_USE_MME)
+#   include "s1ap_eNB.h"
+#   include "sctp_eNB_task.h"
+#   include "gtpv1u_eNB_task.h"
+# endif
+
+extern unsigned char NB_gNB_INST;
+#endif
+
+extern RAN_CONTEXT_t RC;
+
+#if defined(ENABLE_ITTI)
+
+/*------------------------------------------------------------------------------*/
+# if defined(ENABLE_USE_MME)
+#   define GNB_REGISTER_RETRY_DELAY 10
+# endif
+
+/*------------------------------------------------------------------------------*/
+
+/*
+static void configure_phy(module_id_t enb_id, const Enb_properties_array_t* enb_properties)
+{
+  MessageDef *msg_p;
+  int CC_id;
+
+  msg_p = itti_alloc_new_message (TASK_ENB_APP, PHY_CONFIGURATION_REQ);
+
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+    PHY_CONFIGURATION_REQ (msg_p).frame_type[CC_id]              = enb_properties->properties[enb_id]->frame_type[CC_id];
+    PHY_CONFIGURATION_REQ (msg_p).prefix_type[CC_id]             = enb_properties->properties[enb_id]->prefix_type[CC_id];
+    PHY_CONFIGURATION_REQ (msg_p).downlink_frequency[CC_id]      = enb_properties->properties[enb_id]->downlink_frequency[CC_id];
+    PHY_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[CC_id] = enb_properties->properties[enb_id]->uplink_frequency_offset[CC_id];
+    PHY_CONFIGURATION_REQ (msg_p).nb_antennas_tx[CC_id]          = enb_properties->properties[enb_id]->nb_antennas_tx[CC_id];
+    PHY_CONFIGURATION_REQ (msg_p).nb_antennas_rx[CC_id]          = enb_properties->properties[enb_id]->nb_antennas_rx[CC_id];
+    PHY_CONFIGURATION_REQ (msg_p).tx_gain[CC_id]                 = enb_properties->properties[enb_id]->tx_gain[CC_id];
+    PHY_CONFIGURATION_REQ (msg_p).rx_gain[CC_id]                 = enb_properties->properties[enb_id]->rx_gain[CC_id];
+  }
+
+  itti_send_msg_to_task (TASK_PHY_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
+}
+*/
+
+/*------------------------------------------------------------------------------*/
+static void configure_nrrrc(uint32_t gnb_id)
+{
+  MessageDef *msg_p = NULL;
+  //  int CC_id;
+
+  msg_p = itti_alloc_new_message (TASK_GNB_APP, NRRRC_CONFIGURATION_REQ);
+
+  if (RC.nr_rrc[gnb_id]) {
+    RCconfig_NRRRC(msg_p,gnb_id, RC.nrrrc[gnb_id]);
+    
+
+    LOG_I(GNB_APP,"Sending configuration message to NR_RRC task\n");
+    itti_send_msg_to_task (TASK_RRC_GNB, GNB_MODULE_ID_TO_INSTANCE(gnb_id), msg_p);
+
+  }
+  else AssertFatal(0,"NRRRC context for gNB %d not allocated\n",gnb_id);
+}
+
+/*------------------------------------------------------------------------------*/
+# if defined(ENABLE_USE_MME)
+static uint32_t gNB_app_register(uint32_t gnb_id_start, uint32_t gnb_id_end)//, const Enb_properties_array_t *enb_properties)
+{
+  uint32_t         gnb_id;
+  MessageDef      *msg_p;
+  uint32_t         register_gnb_pending = 0;
+
+  for (gnb_id = gnb_id_start; (gnb_id < gnb_id_end) ; gnb_id++) {
+    {
+      s1ap_register_gnb_req_t *s1ap_register_gNB;
+
+      /* note:  there is an implicit relationship between the data structure and the message name */
+      msg_p = itti_alloc_new_message (TASK_GNB_APP, S1AP_REGISTER_GNB_REQ);
+
+      RCconfig_S1(msg_p, gnb_id);
+
+      if (gnb_id == 0) RCconfig_gtpu();
+
+      s1ap_register_gNB = &S1AP_REGISTER_GNB_REQ(msg_p);
+      LOG_I(GNB_APP,"default drx %d\n",s1ap_register_gNB->default_drx);
+
+      LOG_I(GNB_APP,"[gNB %d] gNB_app_register for instance %d\n", gnb_id, GNB_MODULE_ID_TO_INSTANCE(gnb_id));
+
+      itti_send_msg_to_task (TASK_S1AP, GNB_MODULE_ID_TO_INSTANCE(gnb_id), msg_p);
+
+      register_gnb_pending++;
+    }
+  }
+
+  return register_gnb_pending;
+}
+# endif
+#endif
+
+/*------------------------------------------------------------------------------*/
+void *gNB_app_task(void *args_p)
+{
+#if defined(ENABLE_ITTI)
+  uint32_t                        gnb_nb = RC.nb_nr_inst; 
+  uint32_t                        gnb_id_start = 0;
+  uint32_t                        gnb_id_end = gnb_id_start + gnb_nb;
+# if defined(ENABLE_USE_MME)
+  uint32_t                        register_gnb_pending;
+  uint32_t                        registered_gnb;
+  long                            gnb_register_retry_timer_id;
+# endif
+  uint32_t                        gnb_id;
+  MessageDef                     *msg_p           = NULL;
+  const char                     *msg_name        = NULL;
+  instance_t                      instance;
+  int                             result;
+  /* for no gcc warnings */
+  (void)instance;
+
+  itti_mark_task_ready (TASK_GNB_APP);
+
+  LOG_I(PHY, "%s() Task ready initialise structures\n", __FUNCTION__);
+
+  //RCconfig_L1();
+
+  //RCconfig_macrlc();
+
+  LOG_I(PHY, "%s() RC.nb_L1_inst:%d\n", __FUNCTION__, RC.nb_L1_inst);
+
+  if (RC.nb_L1_inst>0) AssertFatal(l1_north_init_gNB()==0,"could not initialize L1 north interface\n");
+
+  AssertFatal (gnb_nb <= RC.nb_nr_inst,
+               "Number of gNB is greater than gNB defined in configuration file (%d/%d)!",
+               gnb_nb, RC.nb_nr_inst);
+
+  LOG_I(GNB_APP,"Allocating gNB_RRC_INST for %d instances\n",RC.nb_nr_inst);
+
+  RC.rrc = (gNB_RRC_INST **)malloc(RC.nb_nr_inst*sizeof(gNB_RRC_INST *));
+  LOG_I(PHY, "%s() RC.nb_nr_inst:%d RC.rrc:%p\n", __FUNCTION__, RC.nb_nr_inst, RC.rrc);
+
+  for (gnb_id = gnb_id_start; (gnb_id < gnb_id_end) ; gnb_id++) {
+    RC.rrc[gnb_id] = (gNB_RRC_INST*)malloc(sizeof(gNB_RRC_INST));
+    LOG_I(PHY, "%s() Creating RRC instance RC.rrc[%d]:%p (%d of %d)\n", __FUNCTION__, gnb_id, RC.rrc[gnb_id], gnb_id+1, gnb_id_end);
+    memset((void *)RC.rrc[gnb_id],0,sizeof(gNB_RRC_INST));
+    configure_nrrrc(gnb_id);
+  }
+
+# if defined(ENABLE_USE_MME)
+  /* Try to register each gNB */
+  registered_gnb = 0;
+  register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end);//, gnb_properties_p);
+# else
+  /* Start L2L1 task */
+  msg_p = itti_alloc_new_message(TASK_GNB_APP, INITIALIZE_MESSAGE);
+  itti_send_msg_to_task(TASK_L2L1, INSTANCE_DEFAULT, msg_p);
+# endif
+
+  do {
+    // Wait for a message
+    itti_receive_msg (TASK_GNB_APP, &msg_p);
+
+    msg_name = ITTI_MSG_NAME (msg_p);
+    instance = ITTI_MSG_INSTANCE (msg_p);
+
+    switch (ITTI_MSG_ID(msg_p)) {
+    case TERMINATE_MESSAGE:
+      LOG_W(GNB_APP, " *** Exiting GNB_APP thread\n");
+      itti_exit_task ();
+      break;
+
+    case MESSAGE_TEST:
+      LOG_I(GNB_APP, "Received %s\n", ITTI_MSG_NAME(msg_p));
+      break;
+
+# if defined(ENABLE_USE_MME)
+
+    case S1AP_REGISTER_ENB_CNF:
+      LOG_I(GNB_APP, "[gNB %d] Received %s: associated MME %d\n", instance, msg_name,
+            S1AP_REGISTER_ENB_CNF(msg_p).nb_mme);
+
+      DevAssert(register_gnb_pending > 0);
+      register_gnb_pending--;
+
+      /* Check if at least gNB is registered with one MME */
+      if (S1AP_REGISTER_ENB_CNF(msg_p).nb_mme > 0) {
+        registered_gnb++;
+      }
+
+      /* Check if all register gNB requests have been processed */
+      if (register_gnb_pending == 0) {
+        if (registered_gnb == gnb_nb) {
+          /* If all gNB are registered, start L2L1 task */
+          MessageDef *msg_init_p;
+
+          msg_init_p = itti_alloc_new_message (TASK_GNB_APP, INITIALIZE_MESSAGE);
+          itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p);
+
+        } else {
+          uint32_t not_associated = gnb_nb - registered_gnb;
+
+          LOG_W(GNB_APP, " %d gNB %s not associated with a MME, retrying registration in %d seconds ...\n",
+                not_associated, not_associated > 1 ? "are" : "is", GNB_REGISTER_RETRY_DELAY);
+
+          /* Restart the gNB registration process in GNB_REGISTER_RETRY_DELAY seconds */
+          if (timer_setup (GNB_REGISTER_RETRY_DELAY, 0, TASK_GNB_APP, INSTANCE_DEFAULT, TIMER_ONE_SHOT,
+                           NULL, &gnb_register_retry_timer_id) < 0) {
+            LOG_E(GNB_APP, " Can not start gNB register retry timer, use \"sleep\" instead!\n");
+
+            sleep(GNB_REGISTER_RETRY_DELAY);
+            /* Restart the registration process */
+            registered_gnb = 0;
+            register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end);//, gnb_properties_p);
+          }
+        }
+      }
+
+      break;
+
+    case S1AP_DEREGISTERED_ENB_IND:
+      LOG_W(GNB_APP, "[gNB %d] Received %s: associated MME %d\n", instance, msg_name,
+            S1AP_DEREGISTERED_ENB_IND(msg_p).nb_mme);
+
+      /* TODO handle recovering of registration */
+      break;
+
+    case TIMER_HAS_EXPIRED:
+      LOG_I(GNB_APP, " Received %s: timer_id %ld\n", msg_name, TIMER_HAS_EXPIRED(msg_p).timer_id);
+
+      if (TIMER_HAS_EXPIRED (msg_p).timer_id == gnb_register_retry_timer_id) {
+        /* Restart the registration process */
+        registered_gnb = 0;
+        register_gnb_pending = gNB_app_register(gnb_id_start, gnb_id_end);//, gnb_properties_p);
+      }
+
+      break;
+# endif
+
+    default:
+      LOG_E(GNB_APP, "Received unexpected message %s\n", msg_name);
+      break;
+    }
+
+    result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
+    AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+  } while (1);
+
+#endif
+
+
+  return NULL;
+}
diff --git a/openair2/ENB_APP/gnb_app.h b/openair2/ENB_APP/gnb_app.h
new file mode 100644
index 0000000000000000000000000000000000000000..3fd33f38b62b1dfcb5bbcf9abeb1591973c8d545
--- /dev/null
+++ b/openair2/ENB_APP/gnb_app.h
@@ -0,0 +1,38 @@
+/*
+ * 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
+ */
+
+/*
+                                gnb_app.h
+                             -------------------
+  AUTHOR  : Laurent Winckel, Sebastien ROUX, Lionel GAUTHIER, Navid Nikaein
+  COMPANY : EURECOM
+  EMAIL   : Lionel.Gauthier@eurecom.fr
+*/
+
+#ifndef GNB_APP_H_
+#define GNB_APP_H_
+
+#include <stdint.h>
+
+void *gNB_app_task(void *args_p);
+
+
+#endif /* GNB_APP_H_ */
diff --git a/openair2/ENB_APP/gnb_config.c b/openair2/ENB_APP/gnb_config.c
new file mode 100644
index 0000000000000000000000000000000000000000..a52809b62c7f85bfbf2c96b9adbdcf7ae322a125
--- /dev/null
+++ b/openair2/ENB_APP/gnb_config.c
@@ -0,0 +1,2238 @@
+#include <string.h>
+#include <inttypes.h>
+
+#include "log.h"
+#include "log_extern.h"
+#include "assertions.h"
+#include "gnb_config.h"
+#include "UTIL/OTG/otg.h"
+#include "UTIL/OTG/otg_externs.h"
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+# if defined(ENABLE_USE_MME)
+#   include "s1ap_eNB.h"
+#   include "sctp_eNB_task.h"
+# endif
+#endif
+#include "sctp_default_values.h"
+// #include "SystemInformationBlockType2.h"
+// #include "LAYER2/MAC/extern.h"
+// #include "LAYER2/MAC/proto.h"
+#include "PHY/extern.h"
+#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
+#include "nfapi_vnf.h"
+#include "nfapi_pnf.h"
+
+#include "L1_paramdef.h"
+#include "MACRLC_paramdef.h"
+#include "common/config/config_userapi.h"
+#include "RRC_config_tools.h"
+#include "gnb_paramdef.h"
+
+
+int RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
+
+  int                    num_gnbs                                                      = 0;
+  int                    num_component_carriers                                        = 0;
+  int                    j,k                                                           = 0;
+  int32_t                gnb_id                                                        = 0;
+
+  int                    nb_cc                                                         = 0;
+  char*                  frame_type                                                    = NULL;
+  char*                  DL_prefix_type                                                = NULL;
+  char*                  UL_prefix_type                                                = 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                N_RB_DL                                                       = 0;
+  int32_t                nb_antenna_ports                                              = 0;
+
+  ///NR
+  //MIB
+  int32_t                MIB_subCarrierSpacingCommon                                   = 0;
+  uint32_t               MIB_ssb_SubcarrierOffset                                      = 0;
+  int32_t                MIB_dmrs_TypeA_Position                                       = 0;
+  uint32_t               pdcch_ConfigSIB1                                              = 0;
+
+  //SIB1
+  int32_t                SIB1_frequencyOffsetSSB                                       = 0; 
+  int32_t                SIB1_ssb_PeriodicityServingCell                               = 0;
+  int32_t                SIB1_ss_PBCH_BlockPower                                       = 0;
+  //NR FrequencyInfoDL
+  int32_t                absoluteFrequencySSB                                          = 0;
+  uint32_t               ssb_SubcarrierOffset                                          = 0;
+  int32_t                DL_FreqBandIndicatorNR                                        = 0;
+  int32_t                DL_absoluteFrequencyPointA                                    = 0;
+
+  //NR DL SCS-SpecificCarrier
+  uint32_t               DL_offsetToCarrier                                            = 0;
+  int32_t                DL_SCS_SubcarrierSpacing                                      = 0;
+  int32_t                DL_SCS_SpecificCarrier_k0                                     = 0;
+  uint32_t               DL_carrierBandwidth                                           = 0;
+
+  // NR BWP-DownlinkCommon
+  uint32_t               DL_locationAndBandwidth                                       = 0;
+  long                   DL_BWP_SubcarrierSpacing                                      = 0;
+  char*                  DL_BWP_prefix_type                                            = NULL;  
+
+  //NR FrequencyInfoUL
+  int32_t                UL_FreqBandIndicatorNR                                        = 0;
+  int32_t                UL_absoluteFrequencyPointA                                    = 0;
+  uint32_t               UL_additionalSpectrumEmission                                 = 0;
+  int32_t                UL_p_Max                                                      = 0;
+  int32_t                UL_frequencyShift7p5khz                                       = 0;
+
+  //NR UL SCS-SpecificCarrier
+  uint32_t               UL_offsetToCarrier                                            = 0;
+  int32_t                UL_SCS_SubcarrierSpacing                                      = 0;
+  int32_t                UL_SCS_SpecificCarrier_k0                                     = 0;
+  uint32_t               UL_carrierBandwidth                                           = 0;
+
+  // NR BWP-UplinkCommon
+  uint32_t               UL_locationAndBandwidth                                       = 0;
+  long                   UL_BWP_SubcarrierSpacing                                      = 0;
+  char*                  UL_BWP_prefix_type                                            = NULL; 
+  
+  int32_t                ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0;
+  int32_t                ServingCellConfigCommon_ssb_periodicityServingCell            = 0;
+  int32_t                ServingCellConfigCommon_dmrs_TypeA_Position                   = 0;
+  int32_t                NIA_SubcarrierSpacing                                         = 0; 
+  int32_t                ServingCellConfigCommon_ss_PBCH_BlockPower                    = 0;
+
+  //NR TDD-UL-DL-ConfigCommon
+  int32_t                referenceSubcarrierSpacing                                    = 0;
+  int32_t                dl_UL_TransmissionPeriodicity                                 = 0;
+  int32_t                nrofDownlinkSlots                                             = 0;
+  int32_t                nrofDownlinkSymbols                                           = 0;
+  int32_t                nrofUplinkSlots                                               = 0;
+  int32_t                nrofUplinkSymbols                                             = 0;
+
+  //NR RACH-ConfigCommon
+  int32_t                rach_totalNumberOfRA_Preambles                                = 0;
+  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = 0;
+  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 0;
+  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 0;
+  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 0;
+  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 0;
+  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 0;
+  uint32_t               rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 0;
+  uint32_t               rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 0;
+  uint32_t               rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 0;
+  char*                  rach_groupBconfigured                                         = NULL;
+  int32_t                rach_ra_Msg3SizeGroupA                                        = 0;
+  int32_t                rach_messagePowerOffsetGroupB                                 = 0;
+  int32_t                rach_numberOfRA_PreamblesGroupA                               = 0;
+  int32_t                rach_ra_ContentionResolutionTimer                             = 0;
+  int32_t                rsrp_ThresholdSSB                                             = 0;
+  int32_t                rsrp_ThresholdSSB_SUL                                         = 0;
+  int32_t                prach_RootSequenceIndex_choice                                = 0;
+  uint32_t               prach_RootSequenceIndex_l839                                  = 0;
+  uint32_t               prach_RootSequenceIndex_l139                                  = 0;
+  int32_t                prach_msg1_SubcarrierSpacing                                  = 0;
+  int32_t                restrictedSetConfig                                           = 0;
+  int32_t                msg3_transformPrecoding                                       = 0;
+  //ssb-perRACH-OccasionAndCB-PreamblesPerSSB not sure
+
+  //NR RACH-ConfigGeneric
+  int32_t                prach_ConfigurationIndex                                      = 0;
+  int32_t                prach_msg1_FDM                                                = 0;
+  int32_t                prach_msg1_FrequencyStart                                     = 0;
+  int32_t                zeroCorrelationZoneConfig                                     = 0;
+  int32_t                preambleReceivedTargetPower                                   = 0;
+  int32_t                preambleTransMax                                              = 0;
+  int32_t                powerRampingStep                                              = 0;
+  int32_t                ra_ResponseWindow                                             = 0;
+
+  //PUSCH-ConfigCommon
+  char*                  groupHoppingEnabledTransformPrecoding                         = NULL;
+  int32_t                msg3_DeltaPreamble                                            = 0;
+  int32_t                p0_NominalWithGrant                                           = 0;
+
+  ///PUSCH-TimeDomainResourceAllocation
+  int32_t                PUSCH_TimeDomainResourceAllocation_k2                         = 0;
+  int32_t                PUSCH_TimeDomainResourceAllocation_mappingType                = 0;
+
+  //PUCCH-ConfigCommon
+  int32_t                pucch_GroupHopping                                            = 0;
+  int32_t                p0_nominal                                                    = 0;
+
+  //PDSCH-ConfigCOmmon
+  //PDSCH-TimeDomainResourceAllocation
+  int32_t                PDSCH_TimeDomainResourceAllocation_k0                         = 0;
+  int32_t                PDSCH_TimeDomainResourceAllocation_mappingType                = 0;
+
+  //RateMatchPattern  is used to configure one rate matching pattern for PDSCH
+  int32_t                rateMatchPatternId                                            = 0;
+  int32_t                RateMatchPattern_patternType                                  = 0;
+  int32_t                symbolsInResourceBlock                                        = 0;
+  int32_t                periodicityAndPattern                                         = 0;
+  int32_t                RateMatchPattern_controlResourceSet                           = 0;
+  int32_t                RateMatchPattern_subcarrierSpacing                            = 0;
+  int32_t                RateMatchPattern_mode                                         = 0;
+
+  //PDCCH-ConfigCommon
+  int32_t                searchSpaceSIB1                                               = 0;
+  int32_t                searchSpaceOtherSystemInformation                             = 0;
+  int32_t                pagingSearchSpace                                             = 0;
+  int32_t                ra_SearchSpace                                                = 0;
+  int32_t                rach_ra_ControlResourceSet                                    = 0;
+  //NR PDCCH-ConfigCommon commonControlResourcesSets
+  int32_t                PDCCH_common_controlResourceSetId                             = 0;
+  int32_t                PDCCH_common_ControlResourceSet_duration                      = 0;
+  int32_t                PDCCH_cce_REG_MappingType                                     = 0;
+  int32_t                PDCCH_reg_BundleSize                                          = 0;
+  int32_t                PDCCH_interleaverSize                                         = 0;
+  int32_t                PDCCH_shiftIndex                                              = 0;  
+  int32_t                PDCCH_precoderGranularity                                     = 0;
+  char*                  tci_PresentInDCI                                              = NULL;
+
+  //NR PDCCH-ConfigCommon commonSearchSpaces
+  int32_t                SearchSpaceId                                                 = 0;
+  int32_t                commonSearchSpaces_controlResourceSetId                       = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl1            = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl2            = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl4            = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl5            = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl8            = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl10           = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl16           = 0;
+  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_sl20           = 0;
+  int32_t                SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
+  int32_t                SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
+  int32_t                SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
+  int32_t                SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
+  int32_t                SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
+  int32_t                SearchSpace_searchSpaceType                                   = 0;
+  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 0;
+  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 0;
+  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 0;
+  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 0;
+  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 0; 
+  int32_t                Common_dci_Format2_3_monitoringPeriodicity                    = 0;
+  int32_t                Common_dci_Format2_3_nrofPDCCH_Candidates                     = 0;
+  int32_t                ue_Specific__dci_Formats                                      = 0;
+  //NR  RateMatchPatternLTE-CRS
+  uint32_t               RateMatchPatternLTE_CRS_carrierFreqDL                         = 0;
+  int32_t                RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 0;
+  int32_t                RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 0;
+  int32_t                RateMatchPatternLTE_CRS_v_Shift                               = 0;
+  int32_t                RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 0;
+  uint32_t               RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
+  int32_t                RateMatchPatternLTE_CRS_subframeAllocation_choice             = 0;
+
+  int32_t             my_int;
+
+  paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
+  ////////// Identification parameters
+  paramdef_t GNBParams[]  = GNBPARAMS_DESC;
+  paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0};
+  ////////// Physical parameters
+  checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
+  paramdef_t CCsParams[] = CCPARAMS_DESC;
+  paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
+  
+  paramdef_t SRB1Params[] = SRB1PARAMS_DESC;  
+
+  /* get global parameters, defined outside any section in the config file */
+ 
+  config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); 
+  num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt;
+  AssertFatal (i<num_gnbs,"Failed to parse config file no %ith element in %s \n",i, GNB_CONFIG_STRING_ACTIVE_GNBS);
+  
+  #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
+
+    if (strcasecmp( *(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr), GNB_CONFIG_STRING_ASN1_VERBOSITY_NONE) == 0) {
+      asn_debug      = 0;
+      asn1_xer_print = 0;
+    } else if (strcasecmp( *(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr), GNB_CONFIG_STRING_ASN1_VERBOSITY_INFO) == 0) {
+      asn_debug      = 1;
+      asn1_xer_print = 1;
+    } else if (strcasecmp(*(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr) , GNB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING) == 0) {
+      asn_debug      = 1;
+      asn1_xer_print = 2;
+    } else {
+      asn_debug      = 0;
+      asn1_xer_print = 0;
+    }
+
+  #endif
+
+  if (num_gnbs>0) {
+    // Output a list of all gNBs. ////////// Identification parameters
+    config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); 
+
+    if (GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr == NULL) {
+    // Calculate a default gNB ID
+      # if defined(ENABLE_USE_MME)
+        uint32_t hash;
+        hash = s1ap_generate_eNB_id ();
+        gnb_id = i + (hash & 0xFFFF8);
+      # else
+        gnb_id = i;
+      # endif
+    } else {
+        gnb_id = *(GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr);
+    }
+
+    printf("NRRRC %d: Southbound Transport %s\n",i,*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr));
+
+    if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_mac") == 0) {
+  
+    } else if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "cudu") == 0) {
+      rrc->eth_params_s.local_if_name            = strdup(*(GNBParamList.paramarray[i][GNB_LOCAL_S_IF_NAME_IDX].strptr));
+      rrc->eth_params_s.my_addr                  = strdup(*(GNBParamList.paramarray[i][GNB_LOCAL_S_ADDRESS_IDX].strptr));
+      rrc->eth_params_s.remote_addr              = strdup(*(GNBParamList.paramarray[i][GNB_REMOTE_S_ADDRESS_IDX].strptr));
+      rrc->eth_params_s.my_portc                 = *(GNBParamList.paramarray[i][GNB_LOCAL_S_PORTC_IDX].uptr);
+      rrc->eth_params_s.remote_portc             = *(GNBParamList.paramarray[i][GNB_REMOTE_S_PORTC_IDX].uptr);
+      rrc->eth_params_s.my_portd                 = *(GNBParamList.paramarray[i][GNB_LOCAL_S_PORTD_IDX].uptr);
+      rrc->eth_params_s.remote_portd             = *(GNBParamList.paramarray[i][GNB_REMOTE_S_PORTD_IDX].uptr);
+      rrc->eth_params_s.transp_preference        = ETH_UDP_MODE;
+    } else { // other midhaul
+    }       
+
+    // search if in active list
+
+    for (k=0; k <num_gnbs ; k++) {
+      if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[k], *(GNBParamList.paramarray[i][GNB_GNB_NAME_IDX].strptr) )== 0) {
+        
+        char gnbpath[MAX_OPTNAME_SIZE + 8];
+
+        NRRRC_CONFIGURATION_REQ (msg_p).cell_identity     = gnb_id;
+        NRRRC_CONFIGURATION_REQ (msg_p).tac               = (uint16_t)atoi( *(GNBParamList.paramarray[i][GNB_TRACKING_AREA_CODE_IDX].strptr) );
+        NRRRC_CONFIGURATION_REQ (msg_p).mcc               = (uint16_t)atoi( *(GNBParamList.paramarray[i][GNB_MOBILE_COUNTRY_CODE_IDX].strptr) );
+        NRRRC_CONFIGURATION_REQ (msg_p).mnc               = (uint16_t)atoi( *(GNBParamList.paramarray[i][GNB_MOBILE_NETWORK_CODE_IDX].strptr) );
+        NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length  = strlen(*(GNBParamList.paramarray[i][GNB_MOBILE_NETWORK_CODE_IDX].strptr));
+        AssertFatal((NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length == 2) ||
+                    (NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length == 3),"BAD MNC DIGIT LENGTH %d",
+                     NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length);
+
+        // Parse optional physical parameters
+        sprintf(gnbpath,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k),
+        config_getlist( &CCsParamList,NULL,0,gnbpath); 
+    
+        LOG_I(NRRRC,"num component carriers %d \n", num_component_carriers); 
+
+        if ( CCsParamList.numelt> 0) {
+          
+          char ccspath[MAX_OPTNAME_SIZE*2 + 16];
+
+          for (j = 0; j < CCsParamList.numelt ;j++) {
+            
+            sprintf(ccspath,"%s.%s.[%i]",gnbpath,GNB_CONFIG_STRING_COMPONENT_CARRIERS,j);
+            config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath);        
+ 
+            nb_cc++;
+
+            // NRRRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = tdd_config;
+            // AssertFatal (tdd_config <= TDD_Config__subframeAssignment_sa6,
+            //             "Failed to parse gNB configuration file %s, gnb %d illegal tdd_config %d (should be 0-%d)!",
+            //             RC.config_file_name, i, tdd_config, TDD_Config__subframeAssignment_sa6);
+        
+            // NRRRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = tdd_config_s;
+            // AssertFatal (tdd_config_s <= TDD_Config__specialSubframePatterns_ssp8,
+            //             "Failed to parse gNB configuration file %s, gnb %d illegal tdd_config_s %d (should be 0-%d)!",
+            //             RC.config_file_name, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8);
+
+            if (!DL_prefix_type){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
+                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
+            }else if (strcmp(DL_prefix_type, "NORMAL") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = NORMAL;
+            }else if (strcmp(DL_prefix_type, "EXTENDED") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = EXTENDED;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_prefix_type choice: NORMAL or EXTENDED !\n",
+                           RC.config_file_name, i, DL_prefix_type);
+            }
+
+            if (!UL_prefix_type){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
+                           RC.config_file_name, i, GNB_CONFIG_STRING_UL_PREFIX_TYPE);
+            }else if (strcmp(UL_prefix_type, "NORMAL") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = NORMAL;
+            }else if (strcmp(UL_prefix_type, "EXTENDED") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = EXTENDED;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_prefix_type choice: NORMAL or EXTENDED !\n",
+                           RC.config_file_name, i, UL_prefix_type);
+            }            
+
+            NRRRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = eutra_band;
+            NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) downlink_frequency;
+            NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
+            NRRRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= Nid_cell;
+
+            if (Nid_cell>503) {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
+                           RC.config_file_name, i, Nid_cell);
+            }
+        
+            NRRRC_CONFIGURATION_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 gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
+                           RC.config_file_name, i, N_RB_DL);
+            }
+        
+            if (strcmp(frame_type, "FDD") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j] = FDD;
+            }else  if (strcmp(frame_type, "TDD") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j] = TDD;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
+                           RC.config_file_name, i, frame_type);
+            }
+
+            if (!prefix_type){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
+                           RC.config_file_name, i, ENB_CONFIG_STRING_PREFIX_TYPE);
+            }else if (strcmp(prefix_type, "NORMAL") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = NORMAL;
+            }else  if (strcmp(prefix_type, "EXTENDED") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = EXTENDED;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
+                           RC.config_file_name, i, prefix_type);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = eutra_band;
+            NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) downlink_frequency;
+            NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
+        
+            if (config_check_band_frequencies(j,
+              NRRRC_CONFIGURATION_REQ (msg_p).eutra_band[j],
+              NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j],
+              NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j],
+              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j])) {
+               AssertFatal(0, "error calling enb_check_band_frequencies\n");
+            }
+
+            if ((nb_antenna_ports <1) || (nb_antenna_ports > 2)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
+                           RC.config_file_name, i, nb_antenna_ports);
+            }
+            NRRRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = nb_antenna_ports;
+
+
+            ////////////////////////////////////////////////////////////////////////////////
+            //---------------------------NR--------Configuration--------------------------//
+            ////////////////////////////////////////////////////////////////////////////////
+            /////////////////////////////////MIB///////////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).MIB_subCarrierSpacingCommon[j] = MIB_subCarrierSpacingCommon;
+            if ((MIB_subCarrierSpacingCommon !=15) && (MIB_subCarrierSpacingCommon !=30) && (MIB_subCarrierSpacingCommon !=60) && (MIB_subCarrierSpacingCommon !=120)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_subCarrierSpacingCommon choice: 15,30,60,120 !\n",
+                           RC.config_file_name, i, MIB_subCarrierSpacingCommon);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).MIB_ssb_SubcarrierOffset[j] = MIB_ssb_SubcarrierOffset;
+            if ((MIB_ssb_SubcarrierOffset <0) || (MIB_ssb_SubcarrierOffset > 15)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_ssb_SubcarrierOffset choice: 1..23 !\n",
+                           RC.config_file_name, i, MIB_ssb_SubcarrierOffset);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).MIB_dmrs_TypeA_Position[j] = MIB_dmrs_TypeA_Position;
+            if ((MIB_dmrs_TypeA_Position !=2) && (MIB_dmrs_TypeA_Position !=3)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_dmrs_TypeA_Position choice:2,3 !\n",
+                           RC.config_file_name, i, MIB_dmrs_TypeA_Position);
+            }          
+
+            NRRRC_CONFIGURATION_REQ (msg_p).pdcch_ConfigSIB1[j] = pdcch_ConfigSIB1;
+            if ((pdcch_ConfigSIB1 <0) || (pdcch_ConfigSIB1 > 255)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for pdcch_ConfigSIB1 choice: 0..3279165 !\n",
+                           RC.config_file_name, i, pdcch_ConfigSIB1);
+            }
+            
+            ////////////////////////////////SIB1//////////////////////////////
+
+            if (strcmp(SIB1_frequencyOffsetSSB , "khz-5") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).SIB1_frequencyOffsetSSB[j] = -5;                    
+            }else if (strcmp(SIB1_frequencyOffsetSSB , "khz5") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).SIB1_frequencyOffsetSSB[j] = 5;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SIB1_frequencyOffsetSSB !\n",
+                           RC.config_file_name, i, SIB1_frequencyOffsetSSB);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).SIB1_ssb_PeriodicityServingCell[j] = SIB1_ssb_PeriodicityServingCell;
+            if ((SIB1_ssb_PeriodicityServingCell !=5)  && 
+                (SIB1_ssb_PeriodicityServingCell !=10) && 
+                (SIB1_ssb_PeriodicityServingCell !=20) && 
+                (SIB1_ssb_PeriodicityServingCell !=40) &&
+                (SIB1_ssb_PeriodicityServingCell !=80) &&
+                (SIB1_ssb_PeriodicityServingCell !=160)&&){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SIB1_ssb_PeriodicityServingCell choice: 5,10,20,40,80,160 !\n",
+                           RC.config_file_name, i, SIB1_ssb_PeriodicityServingCell);
+            }            
+
+            NRRRC_CONFIGURATION_REQ (msg_p).SIB1_ss_PBCH_BlockPower[j] = SIB1_ss_PBCH_BlockPower;
+            if ((SIB1_ss_PBCH_BlockPower < -60) || (SIB1_ss_PBCH_BlockPower > 50)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SIB1_ss_PBCH_BlockPower choice: -60..50 !\n",
+              RC.config_file_name, i, SIB1_ss_PBCH_BlockPower);
+            }
+
+            ////////////////////////////////NR FrequencyInfoDL//////////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).absoluteFrequencySSB[j] = absoluteFrequencySSB;
+            if ((absoluteFrequencySSB <0) || (absoluteFrequencySSB > 3279165)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for absoluteFrequencySSB choice: 0..3279165 !\n",
+                           RC.config_file_name, i, absoluteFrequencySSB);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).ssb_SubcarrierOffset[j] = ssb_SubcarrierOffset;
+            if ((ssb_SubcarrierOffset <1) || (ssb_SubcarrierOffset > 23)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ssb_SubcarrierOffset choice: 1..23 !\n",
+                           RC.config_file_name, i, ssb_SubcarrierOffset);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).DL_FreqBandIndicatorNR[j] = DL_FreqBandIndicatorNR;
+            if ((DL_FreqBandIndicatorNR <1) || (DL_FreqBandIndicatorNR > 1024)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_FreqBandIndicatorNR choice: 1..1024 !\n",
+                           RC.config_file_name, i, DL_FreqBandIndicatorNR);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).DL_absoluteFrequencyPointA[j] = DL_absoluteFrequencyPointA;
+            if ((DL_absoluteFrequencyPointA <0) || (DL_absoluteFrequencyPointA > 3279165)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_absoluteFrequencyPointA choice: 0..3279165 !\n",
+                           RC.config_file_name, i, DL_absoluteFrequencyPointA);
+            }            
+            
+
+            /////////////////////////////////NR DL SCS-SpecificCarrier///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).DL_offsetToCarrier[j] = DL_offsetToCarrier;
+            if ((DL_offsetToCarrier <0) || (DL_offsetToCarrier > 2199)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_offsetToCarrier choice: 0..11 !\n",
+                           RC.config_file_name, i, DL_offsetToCarrier);
+            }
+
+            if (strcmp(DL_SCS_SubcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_SCS_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+                           RC.config_file_name, i, DL_SCS_SubcarrierSpacing);
+            }
+
+            switch (DL_SCS_SpecificCarrier_k0) {
+              case -6:
+                NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SpecificCarrier_k0[j] =  SCS_SpecificCarrier__k0_n_6;
+                break;
+
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SpecificCarrier_k0[j] =  SCS_SpecificCarrier__k0_n0;
+                break;
+
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SpecificCarrier_k0[j] =  SCS_SpecificCarrier__k0_n6;
+                break;
+
+               default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_SCS_SpecificCarrier_k0 choice: -6,0,6 !\n",
+                             RC.config_file_name, i, DL_SCS_SpecificCarrier_k0);
+                break;
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).DL_carrierBandwidth[j] = DL_carrierBandwidth;
+            if ((DL_carrierBandwidth <1) || (DL_carrierBandwidth > 275)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_carrierBandwidth choice: 1..275 !\n",
+              RC.config_file_name, i, DL_carrierBandwidth);
+            }
+
+            /////////////////////////////////NR BWP-DownlinkCommon///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).DL_locationAndBandwidth[j] = DL_locationAndBandwidth;
+            if ((DL_locationAndBandwidth <0) || (DL_locationAndBandwidth > 37949)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_locationAndBandwidth choice: 0..11 !\n",
+              RC.config_file_name, i, DL_locationAndBandwidth);
+            }
+
+            if (strcmp(DL_BWP_SubcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_BWP_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+                           RC.config_file_name, i, DL_BWP_SubcarrierSpacing);
+            }
+
+            if (!DL_BWP_prefix_type){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
+                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
+            }else if (strcmp(DL_BWP_prefix_type, "NORMAL") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_prefix_type[j] = NORMAL;
+            }else if (strcmp(DL_BWP_prefix_type, "EXTENDED") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_prefix_type[j] = EXTENDED;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_BWP_prefix_type choice: NORMAL or EXTENDED !\n",
+                           RC.config_file_name, i, DL_BWP_prefix_type);
+            }                        
+
+            /////////////////////////////////NR FrequencyInfoUL//////////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).UL_FreqBandIndicatorNR[j] = UL_FreqBandIndicatorNR;
+            if ((UL_FreqBandIndicatorNR <1) || (UL_FreqBandIndicatorNR > 1024)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_FreqBandIndicatorNR choice: 1..1024 !\n",
+                           RC.config_file_name, i, UL_FreqBandIndicatorNR);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).UL_absoluteFrequencyPointA[j] = UL_absoluteFrequencyPointA;
+            if ((UL_absoluteFrequencyPointA <0) || (UL_absoluteFrequencyPointA > 3279165)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_absoluteFrequencyPointA choice: 0..3279165 !\n",
+                           RC.config_file_name, i, UL_absoluteFrequencyPointA);
+            }       
+
+            NRRRC_CONFIGURATION_REQ (msg_p).UL_additionalSpectrumEmission[j] = UL_additionalSpectrumEmission;
+            if ((UL_additionalSpectrumEmission <0) || (UL_additionalSpectrumEmission > 7)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_additionalSpectrumEmission choice: 0..7 !\n",
+                           RC.config_file_name, i, UL_additionalSpectrumEmission);
+            }            
+
+            NRRRC_CONFIGURATION_REQ (msg_p).UL_p_Max[j] = UL_p_Max;
+            if ((UL_p_Max <-30) || (UL_p_Max > 33)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_p_Max choice: -30..33 !\n",
+              RC.config_file_name, i, UL_p_Max);
+            }
+
+            if (strcmp(UL_frequencyShift7p5khz, "TRUE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).UL_frequencyShift7p5khz[j] = FrequencyInfoUL__frequencyShift7p5khz_true; //enum true = 0
+            }else if{
+              RRC_CONFIGURATION_REQ (msg_p).UL_frequencyShift7p5khz[j] = 1;//false               
+            } 
+
+            /////////////////////////////////NR UL SCS-SpecificCarrier///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).UL_offsetToCarrier[j] = UL_offsetToCarrier;
+            if ((UL_offsetToCarrier <0) || (UL_offsetToCarrier > 2199)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_offsetToCarrier choice: 0..11 !\n",
+              RC.config_file_name, i, UL_offsetToCarrier);
+            }
+
+            if (strcmp(UL_SCS_SubcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_SCS_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+              RC.config_file_name, i, UL_SCS_SubcarrierSpacing);
+            }
+
+            switch (UL_SCS_SpecificCarrier_k0) {
+              case -6:
+                NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SpecificCarrier_k0[j] =  SCS_SpecificCarrier__k0_n_6;
+                break;
+
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SpecificCarrier_k0[j] =  SCS_SpecificCarrier__k0_n0;
+                break;
+
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SpecificCarrier_k0[j] =  SCS_SpecificCarrier__k0_n6;
+                break;
+
+               default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_SCS_SpecificCarrier_k0 choice: -6,0,6 !\n",
+                             RC.config_file_name, i, UL_SCS_SpecificCarrier_k0);
+                break;
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).UL_carrierBandwidth[j] = UL_carrierBandwidth;
+            if ((UL_carrierBandwidth <1) || (UL_carrierBandwidth > 275)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_carrierBandwidth choice: 1..275 !\n",
+              RC.config_file_name, i, UL_carrierBandwidth);
+            }
+
+
+
+            //Not Sure the value selection
+            NRRRC_CONFIGURATION_REQ (msg_p).absoluteFrequencyPointA[j] = absoluteFrequencyPointA;
+                        
+            NRRRC_CONFIGURATION_REQ (msg_p).ControlResourceSetId[j] = ControlResourceSetId;
+            if ((ControlResourceSetId <0) || (ControlResourceSetId > 11)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ControlResourceSetId choice: 0..11 !\n",
+              RC.config_file_name, i, ControlResourceSetId);
+            }
+
+            /////////////////////////////////NR BWP-UplinkCommon///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).UL_locationAndBandwidth[j] = UL_locationAndBandwidth;
+            if ((UL_locationAndBandwidth <0) || (UL_locationAndBandwidth > 37949)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_locationAndBandwidth choice: 0..11 !\n",
+              RC.config_file_name, i, UL_locationAndBandwidth);
+            }
+
+            if (strcmp(UL_BWP_SubcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_BWP_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+                           RC.config_file_name, i, UL_BWP_SubcarrierSpacing);
+            }
+
+            if (!UL_BWP_prefix_type){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
+                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
+            }else if (strcmp(UL_BWP_prefix_type, "NORMAL") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_prefix_type[j] = NORMAL;
+            }else if (strcmp(UL_BWP_prefix_type, "EXTENDED") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_prefix_type[j] = EXTENDED;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_BWP_prefix_type choice: NORMAL or EXTENDED !\n",
+                           RC.config_file_name, i, UL_BWP_prefix_type);
+            }  
+
+            if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"shortBitmap")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap;
+            }else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"mediumBitmap")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap;
+            }else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"longBitmap")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap;
+            }else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"NOTHING")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon__ssb_PositionsInBurst_PR_NOTHING;
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for ServingCellConfigCommon_ssb_PositionsInBurst_PR choice !\n",
+                           RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR);
+            }            
+
+
+            switch (ServingCellConfigCommon_ssb_periodicityServingCell) {
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  ServingCellConfigCommon__ssb_periodicityServingCell_ms5;
+                break;
+
+              case 10:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  ServingCellConfigCommon__ssb_periodicityServingCell_ms10;
+                break;
+
+              case 20:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  ServingCellConfigCommon__ssb_periodicityServingCell_ms20;
+                break;
+              
+              case 40:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  ServingCellConfigCommon__ssb_periodicityServingCell_ms40;
+                break;
+                          
+              case 80:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  ServingCellConfigCommon__ssb_periodicityServingCell_ms80;
+                break;
+
+              case 160:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  ServingCellConfigCommon__ssb_periodicityServingCell_ms160;
+                break;
+
+               default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ServingCellConfigCommon_ssb_periodicityServingCell choice: -6,0,6 !\n",
+                             RC.config_file_name, i, ServingCellConfigCommon_ssb_periodicityServingCell);
+                break;
+            }
+
+            switch (ServingCellConfigCommon_dmrs_TypeA_Position) {
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_dmrs_TypeA_Position[j] =  ServingCellConfigCommon__dmrs_TypeA_Position_pos2;
+                break;
+
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_dmrs_TypeA_Position[j] =  ServingCellConfigCommon__dmrs_TypeA_Position_pos3;
+                break;
+
+               default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ServingCellConfigCommon_dmrs_TypeA_Position choice: -6,0,6 !\n",
+                             RC.config_file_name, i, ServingCellConfigCommon_dmrs_TypeA_Position);
+                break;
+            }
+
+            if (strcmp(NIA_SubcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(NIA_SubcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(NIA_SubcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(NIA_SubcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(NIA_SubcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for NIA_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+              RC.config_file_name, i, NIA_SubcarrierSpacing);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ss_PBCH_BlockPower[j] = ServingCellConfigCommon_ss_PBCH_BlockPower;
+            if ((ServingCellConfigCommon_ss_PBCH_BlockPower < -60) || (ServingCellConfigCommon_ss_PBCH_BlockPower > 50)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ServingCellConfigCommon_ss_PBCH_BlockPower choice: 0..11 !\n",
+              RC.config_file_name, i, ServingCellConfigCommon_ss_PBCH_BlockPower);
+            }
+
+            /////////////////////////////////NR TDD-UL-DL-ConfigCommon///////////////////////////
+            if (strcmp(referenceSubcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(referenceSubcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(referenceSubcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(referenceSubcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(referenceSubcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for referenceSubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+                  RC.config_file_name, i, referenceSubcarrierSpacing);
+            }
+
+            if (strcmp(dl_UL_TransmissionPeriodicity,"ms0p5")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms0p5;
+            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms0p625")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms0p625;
+            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms1")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms1;
+            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms1p25")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms1p25;
+            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms2")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms2;
+            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms2p5")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms2p5;
+            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms5")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms5;
+            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms10")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = TDD_UL_DL_ConfigCommon__dl_UL_TransmissionPeriodicity_ms10;    
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for dl_UL_TransmissionPeriodicity choice: minusinfinity,ms0p5,ms0p625,ms1,ms1p25,ms2,ms2p5,ms5,ms10 !\n",
+                           RC.config_file_name, i, dl_UL_TransmissionPeriodicity);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).nrofDownlinkSlots[j] = nrofDownlinkSlots;
+            if ((nrofDownlinkSlots < 0) || (nrofDownlinkSlots > 320)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofDownlinkSlots choice: 0..320 !\n",
+                           RC.config_file_name, i, nrofDownlinkSlots);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).nrofDownlinkSymbols[j] = nrofDownlinkSymbols;
+            if ((nrofDownlinkSymbols < 0) || (nrofDownlinkSymbols > 13)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofDownlinkSymbols choice: 0..13 !\n",
+                           RC.config_file_name, i, nrofDownlinkSymbols);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).nrofUplinkSlots[j] = nrofUplinkSlots;
+            if ((nrofUplinkSlots < 0) || (nrofUplinkSlots > 320)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofUplinkSlots choice: 0..320 !\n",
+                           RC.config_file_name, i, nrofUplinkSlots);
+            }
+ 
+            NRRRC_CONFIGURATION_REQ (msg_p).nrofUplinkSymbols[j] = nrofUplinkSymbols;
+            if ((nrofUplinkSymbols < 0) || (nrofUplinkSymbols > 13)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofUplinkSymbols choice: 0..13 !\n",
+                           RC.config_file_name, i, nrofUplinkSymbols);
+            }
+
+            /////////////////////////////////NR RACH-ConfigCommon///////////////////////////
+
+            NRRRC_CONFIGURATION_REQ (msg_p).rach_totalNumberOfRA_Preambles[j] = rach_totalNumberOfRA_Preambles;
+            if ((rach_totalNumberOfRA_Preambles <1) || (rach_totalNumberOfRA_Preambles>63)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_numberOfRA_Preambles choice: 1..63 !\n",
+                           RC.config_file_name, i, rach_totalNumberOfRA_Preambles);
+            }
+
+            if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"oneEighth")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth;
+              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth){
+                case 4:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n4;
+                  break;
+                case 8:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n8;
+                  break;
+                case 12:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n12;
+                  break;
+                case 16:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n16;
+                  break;
+                case 20:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n20;
+                  break;
+                case 24:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n24;
+                  break;
+                case 28:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n28;
+                  break;
+                case 32:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n32;
+                  break;
+                case 36:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n36;
+                  break;
+                case 40:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n40;
+                  break;
+                case 44:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n44;
+                  break;
+                case 48:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n48;
+                  break;
+                case 52:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n52;
+                  break;
+                case 56:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n56;
+                  break;
+                case 60:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n60;
+                  break;
+                case 64:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n64;
+                  break;
+                default:
+                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
+                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth);
+                  break;
+              }//End oneEighth
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"oneFourth")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth;
+              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth){
+                case 4:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n4;
+                  break;
+                case 8:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n8;
+                  break;
+                case 12:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n12;
+                  break;
+                case 16:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n16;
+                  break;
+                case 20:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n20;
+                  break;
+                case 24:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n24;
+                  break;
+                case 28:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n28;
+                  break;
+                case 32:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n32;
+                  break;
+                case 36:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n36;
+                  break;
+                case 40:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n40;
+                  break;
+                case 44:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n44;
+                  break;
+                case 48:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n48;
+                  break;
+                case 52:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n52;
+                  break;
+                case 56:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n56;
+                  break;
+                case 60:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n60;
+                  break;
+                case 64:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n64;
+                  break;
+                default:
+                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
+                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth);
+                  break;
+              }//End oneFourth
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"oneHalf")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf;
+              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf){
+                case 4:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n4;
+                  break;
+                case 8:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n8;
+                  break;
+                case 12:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n12;
+                  break;
+                case 16:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n16;
+                  break;
+                case 20:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n20;
+                  break;
+                case 24:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n24;
+                  break;
+                case 28:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n28;
+                  break;
+                case 32:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n32;
+                  break;
+                case 36:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n36;
+                  break;
+                case 40:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n40;
+                  break;
+                case 44:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n44;
+                  break;
+                case 48:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n48;
+                  break;
+                case 52:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n52;
+                  break;
+                case 56:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n56;
+                  break;
+                case 60:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n60;
+                  break;
+                case 64:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n64;
+                  break;
+                default:
+                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
+                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf);
+                  break;
+              }//End oneHalf
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"one")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
+              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one){
+                case 4:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n4;
+                  break;
+                case 8:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n8;
+                  break;
+                case 12:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n12;
+                  break;
+                case 16:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n16;
+                  break;
+                case 20:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n20;
+                  break;
+                case 24:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n24;
+                  break;
+                case 28:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n28;
+                  break;
+                case 32:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n32;
+                  break;
+                case 36:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n36;
+                  break;
+                case 40:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n40;
+                  break;
+                case 44:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n44;
+                  break;
+                case 48:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n48;
+                  break;
+                case 52:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n52;
+                  break;
+                case 56:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n56;
+                  break;
+                case 60:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n60;
+                  break;
+                case 64:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n64;
+                  break;
+                default:
+                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
+                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one);
+                  break;
+              }//End one
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"two")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two;
+              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one){
+                case 4:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n4;
+                  break;
+                case 8:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n8;
+                  break;
+                case 12:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n12;
+                  break;
+                case 16:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n16;
+                  break;
+                case 20:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n20;
+                  break;
+                case 24:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n24;
+                  break;
+                case 28:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n28;
+                  break;
+                case 32:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n32;
+                  break;
+                default:
+                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
+                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two);
+                  break;
+              }//End two
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"four")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four;
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four[j] = rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four;
+              if ((rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four < 1) || (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four > 16)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four choice: 1..16 !\n",
+                             RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four);
+              }//End four
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"eight")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight;
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight[j] = rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight;
+              if ((rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight < 1) || (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight > 8)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight choice: 1..8 !\n",
+                             RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight);
+              }//End eight 
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"sixteen")==0) {
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen;    
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen[j] = rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen;
+              if ((rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen < 1) || (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen > 4)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen choice: 1..4 !\n",
+                             RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen);
+              }//End sixteen
+
+            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"NOTHING")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING;    
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice: oneEighth,oneFourth,oneHalf,one,two,four,eight,sixteen !\n",
+                           RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice);
+            }
+
+            if (strcmp(rach_groupBconfigured , "ENABLE") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_groupBconfigured [j] = TRUE;
+
+              switch (rach_ra_Msg3SizeGroupA) {
+                case 56:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b56;
+                  break;
+                case 144:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b144;
+                  break;
+                case 208:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b208;
+                  break;
+                case 256:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b256;
+                  break;
+                case 282:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b282;
+                  break;
+                case 480:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b480;
+                  break;
+                case 640:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b640;
+                  break;
+                case 800:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b800;
+                  break;
+                case 1000:
+                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b1000;
+                  break;
+                default:
+                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ra_Msg3SizeGroupA choice: 56,144,208,256,282,480,640,800,1000!\n",
+                               RC.config_file_name, i, rach_ra_Msg3SizeGroupA);
+                  break;
+              }// End switch (rach_ra_Msg3SizeGroupA)
+
+              if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_minusinfinity;
+              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB0")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB0;
+              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB5")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB5;
+              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB8")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB8;
+              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB10")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB10;
+              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB12")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB12;
+              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB15")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB15;
+              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB18")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB18;
+              }else{
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n",
+                             RC.config_file_name, i, rach_messagePowerOffsetGroupB);
+              }// End if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0)
+
+              NRRRC_CONFIGURATION_REQ (msg_p).rach_numberOfRA_PreamblesGroupA[j] = rach_numberOfRA_PreamblesGroupA;
+              if ((rach_numberOfRA_PreamblesGroupA <1) || (rach_numberOfRA_PreamblesGroupA>64)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_numberOfRA_PreamblesGroupA choice: 1..63 !\n",
+                             RC.config_file_name, i, rach_numberOfRA_PreamblesGroupA);
+              }
+
+            }// End if (strcmp(rach_groupBconfigured , "ENABLE") == 0) 
+
+            switch (rach_ra_ContentionResolutionTimer) {
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf8;
+                break;
+              case 16:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf16;
+                break;
+              case 24:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf24;
+                break;
+              case 32:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf32;
+                break;
+              case 40:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf40;
+                break;
+              case 48:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf48;
+                break;
+              case 56:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf56;
+                break;
+              case 64:
+                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ra_ContentionResolutionTimer choice: 8,16,24,32,40,48,56,64!\n",
+                             RC.config_file_name, i, rach_ra_ContentionResolutionTimer);
+                break;
+            }// End switch (rach_ra_ContentionResolutionTimer)
+
+            
+            NRRRC_CONFIGURATION_REQ (msg_p).rsrp_ThresholdSSB[j] = rsrp_ThresholdSSB;
+            if ((rsrp_ThresholdSSB <0) || (rsrp_ThresholdSSB>124)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rsrp_ThresholdSSB choice: 0..124 !\n",
+                           RC.config_file_name, i, rsrp_ThresholdSSB);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).rsrp_ThresholdSSB_SUL[j] = rsrp_ThresholdSSB_SUL;
+            if ((rsrp_ThresholdSSB_SUL <0) || (rsrp_ThresholdSSB_SUL>124)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rsrp_ThresholdSSB_SUL choice: 0..124 !\n",
+                           RC.config_file_name, i, rsrp_ThresholdSSB_SUL);
+            }
+
+            if (strcmp(prach_RootSequenceIndex_choice , "l839") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_choice[j] = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839;
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_l839[j] = prach_RootSequenceIndex_l839;              
+            }else if (strcmp(prach_RootSequenceIndex_choice , "l139") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_choice[j] = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_l139[j] = prach_RootSequenceIndex_l139;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for prach_RootSequenceIndex !\n",
+                           RC.config_file_name, i, prach_RootSequenceIndex);
+            }
+
+            if (strcmp(prach_msg1_SubcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for prach_msg1_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+                           RC.config_file_name, i, prach_msg1_SubcarrierSpacing);
+            }
+
+            if (strcmp(restrictedSetConfig , "unrestrictedSet") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).restrictedSetConfig[j] = RACH_ConfigCommon__restrictedSetConfig_unrestrictedSet;                    
+            }else if (strcmp(restrictedSetConfig , "restrictedSetTypeA") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).restrictedSetConfig[j] = RACH_ConfigCommon__restrictedSetConfig_restrictedSetTypeA;
+            }else if (strcmp(restrictedSetConfig , "restrictedSetTypeB") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).restrictedSetConfig[j] = RACH_ConfigCommon__restrictedSetConfig_restrictedSetTypeB;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for restrictedSetConfig !\n",
+                           RC.config_file_name, i, restrictedSetConfig);
+            }
+
+            if (strcmp(msg3_transformPrecoding , "ENABLE") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).msg3_transformPrecoding[j] = TRUE;
+            }
+
+            ////////////////////////////////NR RACH-ConfigGeneric//////////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).prach_ConfigurationIndex[j] = prach_ConfigurationIndex;
+            if ((prach_ConfigurationIndex <0) || (prach_ConfigurationIndex>255)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for prach_ConfigurationIndex choice: 0..255 !\n",
+                           RC.config_file_name, i, prach_ConfigurationIndex);
+            }
+
+            if (strcmp(prach_msg1_FDM , "one") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = RACH_ConfigGeneric__msg1_FDM_one;                    
+            }else if (strcmp(prach_msg1_FDM , "two") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = RACH_ConfigGeneric__msg1_FDM_two;
+            }else if (strcmp(prach_msg1_FDM , "four") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = RACH_ConfigGeneric__msg1_FDM_four;
+            }else if (strcmp(prach_msg1_FDM , "eight") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = RACH_ConfigGeneric__msg1_FDM_eight;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for prach_msg1_FDM !\n",
+                           RC.config_file_name, i, prach_msg1_FDM);
+            }            
+            
+            NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FrequencyStart[j] = prach_msg1_FrequencyStart;
+            if ((prach_msg1_FrequencyStart <0) || (prach_msg1_FrequencyStart>274)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for prach_msg1_FrequencyStart choice: 0..274 !\n",
+                           RC.config_file_name, i, prach_msg1_FrequencyStart);
+            }           
+
+            NRRRC_CONFIGURATION_REQ (msg_p).zeroCorrelationZoneConfig[j] = zeroCorrelationZoneConfig;
+            if ((zeroCorrelationZoneConfig <0) || (zeroCorrelationZoneConfig>15)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for zeroCorrelationZoneConfig choice: 0..15 !\n",
+                           RC.config_file_name, i, zeroCorrelationZoneConfig);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).preambleReceivedTargetPower[j] = preambleReceivedTargetPower;
+            if ((preambleReceivedTargetPower <-200) || (preambleReceivedTargetPower>-74)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for preambleReceivedTargetPower choice: -200..-74 !\n",
+                           RC.config_file_name, i, preambleReceivedTargetPower);
+            }
+
+            switch (preambleTransMax) {
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n3;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n5;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n6;
+                break;
+              case 7:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n7;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n8;
+                break;
+              case 10:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n10;
+                break;
+              case 20:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n20;
+                break;
+              case 50:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n50;
+                break;
+              case 100:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n100;
+                break;
+              case 200:
+                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  RACH_ConfigGeneric__preambleTransMax_n200;
+                break;
+               default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200 !\n",
+                             RC.config_file_name, i, preambleTransMax);
+                break;
+            }            
+
+            if (strcmp(powerRampingStep , "dB0") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = RACH_ConfigGeneric__powerRampingStep_dB0;                    
+            }else if (strcmp(powerRampingStep , "dB2") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = RACH_ConfigGeneric__powerRampingStep_dB2;
+            }else if (strcmp(powerRampingStep , "dB4") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = RACH_ConfigGeneric__powerRampingStep_dB4;
+            }else if (strcmp(powerRampingStep , "dB6") == 0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = RACH_ConfigGeneric__powerRampingStep_dB6;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for powerRampingStep !\n",
+                           RC.config_file_name, i, powerRampingStep);
+            }
+
+            switch (ra_ResponseWindow) {
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl2;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl4;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl8;
+                break;
+              case 10:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl10;
+                break;
+              case 20:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl20;
+                break;
+              case 40:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl40;
+                break;
+              case 80:
+                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  RACH_ConfigGeneric__ra_ResponseWindow_sl80;
+                break;
+               default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ra_ResponseWindow choice: 1,2,4,8,10,20,40,80 !\n",
+                             RC.config_file_name, i, ra_ResponseWindow);
+                break;
+            }  
+
+            /////////////////////////////////NR PUSCH-ConfigCommon///////////////////////////
+            if (strcmp(groupHoppingEnabledTransformPrecoding , "ENABLE") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).groupHoppingEnabledTransformPrecoding[j] =  TRUE;
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).msg3_DeltaPreamble[j] = msg3_DeltaPreamble;
+            if ((msg3_DeltaPreamble <-1) || (msg3_DeltaPreamble>6)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for msg3_DeltaPreamble choice: -1..6 !\n",
+                           RC.config_file_name, i, msg3_DeltaPreamble);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).p0_NominalWithGrant[j] = p0_NominalWithGrant;
+            if ((p0_NominalWithGrant <-202) || (p0_NominalWithGrant>24)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for p0_NominalWithGrant choice: -202..24 !\n",
+                           RC.config_file_name, i, p0_NominalWithGrant);
+            }
+
+            /////////////////////////////////NR PUSCH-TimeDomainResourceAllocation///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).PUSCH_TimeDomainResourceAllocation_k2[j] = PUSCH_TimeDomainResourceAllocation_k2;
+            if ((PUSCH_TimeDomainResourceAllocation_k2 <0) || (PUSCH_TimeDomainResourceAllocation_k2>7)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PUSCH_TimeDomainResourceAllocation_k2 choice: 0..7 !\n",
+                           RC.config_file_name, i, PUSCH_TimeDomainResourceAllocation_k2);
+            }
+
+            if (strcmp(PUSCH_TimeDomainResourceAllocation_mappingType , "typeA") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PUSCH_TimeDomainResourceAllocation_mappingType[j] =  PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
+            }else if (strcmp(PUSCH_TimeDomainResourceAllocation_mappingType , "typeB") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PUSCH_TimeDomainResourceAllocation_mappingType[j] =  PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PUSCH_TimeDomainResourceAllocation_mappingType !\n",
+                           RC.config_file_name, i, PUSCH_TimeDomainResourceAllocation_mappingType);
+            }
+
+            /////////////////////////////////NR PUCCH-ConfigCommon///////////////////////////
+            if (strcmp(pucch_GroupHopping , "neither") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).pucch_GroupHopping[j] =  PUCCH_ConfigCommon__pucch_GroupHopping_neither;
+            }else if (strcmp(pucch_GroupHopping , "enable") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).pucch_GroupHopping[j] =  PUCCH_ConfigCommon__pucch_GroupHopping_enable;
+            }else if (strcmp(pucch_GroupHopping , "disable") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).pucch_GroupHopping[j] =  PUCCH_ConfigCommon__pucch_GroupHopping_disable;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for pucch_GroupHopping !\n",
+                           RC.config_file_name, i, pucch_GroupHopping);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).p0_nominal[j] = p0_nominal;
+            if ((p0_nominal <-202) || (p0_nominal>24)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for p0_nominal choice: -202..24 !\n",
+                           RC.config_file_name, i, p0_nominal);
+            }
+
+            //////////////////////////////////NR PDSCH-TimeDomainResourceAllocation///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).PDSCH_TimeDomainResourceAllocation_k0[j] = PDSCH_TimeDomainResourceAllocation_k0;
+            if ((PDSCH_TimeDomainResourceAllocation_k0 <1) || (PDSCH_TimeDomainResourceAllocation_k0>3)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDSCH_TimeDomainResourceAllocation_k0 choice: 0..7 !\n",
+                           RC.config_file_name, i, PDSCH_TimeDomainResourceAllocation_k0);
+            }
+
+            if (strcmp(PDSCH_TimeDomainResourceAllocation_mappingType , "typeA") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PDSCH_TimeDomainResourceAllocation_mappingType[j] =  PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+            }else if (strcmp(PDSCH_TimeDomainResourceAllocation_mappingType , "typeB") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PDSCH_TimeDomainResourceAllocation_mappingType[j] =  PDSCH_TimeDomainResourceAllocation__mappingType_typeB;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDSCH_TimeDomainResourceAllocation_mappingType !\n",
+                           RC.config_file_name, i, PDSCH_TimeDomainResourceAllocation_mappingType);
+            }
+
+            //////////////////////////////////NR RateMatchPattern///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).rateMatchPatternId[j] = rateMatchPatternId;
+            if ((rateMatchPatternId <0) || (rateMatchPatternId>3)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rateMatchPatternId choice: 0..3 !\n",
+                           RC.config_file_name, i, rateMatchPatternId);
+            }
+
+            if (strcmp(RateMatchPattern_patternType , "NOTHING") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_patternType[j] =  RateMatchPattern__patternType_PR_NOTHING;
+            }else if (strcmp(RateMatchPattern_patternType , "bitmaps") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_patternType[j] =  RateMatchPattern__patternType_PR_bitmaps;
+            }else if (strcmp(RateMatchPattern_patternType , "controlResourceSet") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_patternType[j] =  RateMatchPattern__patternType_PR_controlResourceSet;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPattern_patternType !\n",
+                           RC.config_file_name, i, RateMatchPattern_patternType);
+            }
+
+            if (strcmp(symbolsInResourceBlock , "NOTHING") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).symbolsInResourceBlock[j] =  RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_NOTHING;
+            }else if (strcmp(symbolsInResourceBlock , "oneSlot") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).symbolsInResourceBlock[j] =  RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_oneSlot;
+            }else if (strcmp(symbolsInResourceBlock , "twoSlots") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).symbolsInResourceBlock[j] =  RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_twoSlots;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for symbolsInResourceBlock !\n",
+                           RC.config_file_name, i, symbolsInResourceBlock);
+            }
+
+            switch(periodicityAndPattern){
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n2;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n5;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n8;
+                break;
+              case 10:
+                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n10;
+                break;
+              case 20:
+                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n20;
+                break;
+              case 40:
+                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n40;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for periodicityAndPattern choice: 2,4,5,8,10,20,40 !\n",
+                             RC.config_file_name, i, periodicityAndPattern);
+                break;
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_controlResourceSet[j] = RateMatchPattern_controlResourceSet;
+            if ((RateMatchPattern_controlResourceSet <0) || (RateMatchPattern_controlResourceSet>11)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPattern_controlResourceSet choice: 0..3 !\n",
+                           RC.config_file_name, i, RateMatchPattern_controlResourceSet);
+            }
+
+            if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz15")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = SubcarrierSpacing_kHz15;
+            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz30")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = SubcarrierSpacing_kHz30;
+            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz60")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = SubcarrierSpacing_kHz60;
+            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz120")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = SubcarrierSpacing_kHz120;
+            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz240")==0) {
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = SubcarrierSpacing_kHz240;
+            }else { 
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for RateMatchPattern_subcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
+                           RC.config_file_name, i, RateMatchPattern_subcarrierSpacing);
+            }            
+            
+            if (strcmp(RateMatchPattern_mode , "dynamic") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_mode[j] =  RateMatchPattern__mode_dynamic;
+            }else if (strcmp(RateMatchPattern_mode , "semiStatic") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_mode[j] =  RateMatchPattern__mode_semiStatic;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPattern_mode !\n",
+                           RC.config_file_name, i, RateMatchPattern_mode);
+            }
+
+            //////////////////////////////////NR PDCCH-ConfigCommon///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).searchSpaceSIB1[j] = searchSpaceSIB1;
+            if ((searchSpaceSIB1 <0) || (searchSpaceSIB1>39)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for searchSpaceSIB1 choice: 0..39 !\n",
+                           RC.config_file_name, i, searchSpaceSIB1);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).searchSpaceOtherSystemInformation[j] = searchSpaceOtherSystemInformation;
+            if ((searchSpaceOtherSystemInformation <0) || (searchSpaceOtherSystemInformation>39)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for searchSpaceOtherSystemInformation choice: 0..39 !\n",
+                           RC.config_file_name, i, searchSpaceOtherSystemInformation);
+            }            
+
+            NRRRC_CONFIGURATION_REQ (msg_p).pagingSearchSpace[j] = pagingSearchSpace;
+            if ((pagingSearchSpace <0) || (pagingSearchSpace>39)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for pagingSearchSpace choice: 0..39 !\n",
+                           RC.config_file_name, i, pagingSearchSpace);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).ra_SearchSpace[j] = ra_SearchSpace;
+            if ((ra_SearchSpace <0) || (ra_SearchSpace>39)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ra_SearchSpace choice: 0..39 !\n",
+                           RC.config_file_name, i, ra_SearchSpace);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ControlResourceSet[j] = rach_ra_ControlResourceSet;
+            if ((rach_ra_ControlResourceSet <0) || (rach_ra_ControlResourceSet>11)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ra_ControlResourceSet choice: 0..11 !\n",
+                           RC.config_file_name, i, rach_ra_ControlResourceSet);
+            }
+
+            //////////////////////////////////NR PDCCH commonControlResourcesSets///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_common_controlResourceSetId[j] = PDCCH_common_controlResourceSetId;
+            if ((PDCCH_common_controlResourceSetId <0) || (PDCCH_common_controlResourceSetId>11)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_common_controlResourceSetId choice: 0..11 !\n",
+                           RC.config_file_name, i, PDCCH_common_controlResourceSetId);
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_common_ControlResourceSet_duration[j] = PDCCH_common_ControlResourceSet_duration;
+            if ((PDCCH_common_ControlResourceSet_duration <0) || (PDCCH_common_ControlResourceSet_duration>3)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_common_ControlResourceSet_duration choice: 0..11 !\n",
+                           RC.config_file_name, i, PDCCH_common_ControlResourceSet_duration);
+            }            
+            
+            if (strcmp(PDCCH_cce_REG_MappingType , "NOTHING") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_cce_REG_MappingType[j] =  ControlResourceSet__cce_REG_MappingType_PR_NOTHING;
+            }else if (strcmp(PDCCH_cce_REG_MappingType , "interleaved") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_cce_REG_MappingType[j] =  ControlResourceSet__cce_REG_MappingType_PR_interleaved;
+            }else if (strcmp(PDCCH_cce_REG_MappingType , "nonInterleaved") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_cce_REG_MappingType[j] =  ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_cce_REG_MappingType !\n",
+                           RC.config_file_name, i, PDCCH_cce_REG_MappingType);
+            }
+
+            switch(PDCCH_reg_BundleSize){
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_reg_BundleSize[j] =  ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_reg_BundleSize[j] =  ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n3;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_reg_BundleSize[j] =  ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_reg_BundleSize choice: 2,3,6 !\n",
+                             RC.config_file_name, i, PDCCH_reg_BundleSize);
+                break;
+            }            
+
+            switch(PDCCH_interleaverSize){
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_interleaverSize[j] =  ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_interleaverSize[j] =  ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n3;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_interleaverSize[j] =  ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_interleaverSize choice: 2,3,6 !\n",
+                             RC.config_file_name, i, PDCCH_interleaverSize);
+                break;
+            }               
+
+            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_shiftIndex[j] = PDCCH_shiftIndex;
+            if ((PDCCH_shiftIndex <0) || (PDCCH_shiftIndex>274)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_shiftIndex choice: 0..274 !\n",
+                           RC.config_file_name, i, PDCCH_shiftIndex);
+            }
+
+            if (strcmp(PDCCH_precoderGranularity , "sameAsREG-bundle") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_precoderGranularity[j] =  ControlResourceSet__precoderGranularity_sameAsREG_bundle;
+            }else if (strcmp(PDCCH_precoderGranularity , "allContiguousRBs") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_precoderGranularity[j] =  ControlResourceSet__precoderGranularity_allContiguousRBs;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_precoderGranularity !\n",
+                           RC.config_file_name, i, PDCCH_precoderGranularity);
+            }            
+
+            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_TCI_StateId[j] = PDCCH_TCI_StateId;
+            if ((PDCCH_TCI_StateId <0) || (PDCCH_TCI_StateId>63)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_TCI_StateId choice: 0..63 !\n",
+                           RC.config_file_name, i, PDCCH_TCI_StateId);
+            }
+
+            if (strcmp(tci_PresentInDCI , "ENABLE") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).tci_PresentInDCI[j] = TRUE;
+            }
+
+            //////////////////////////////////NR PDCCH commonSearchSpaces///////////////////////////
+            NRRRC_CONFIGURATION_REQ (msg_p).SearchSpaceId[j] = SearchSpaceId;
+            if ((SearchSpaceId <0) || (SearchSpaceId>39)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpaceId choice: 0..39 !\n",
+                           RC.config_file_name, i, SearchSpaceId);
+            }            
+
+            NRRRC_CONFIGURATION_REQ (msg_p).commonSearchSpaces_controlResourceSetId[j] = commonSearchSpaces_controlResourceSetId;
+            if ((commonSearchSpaces_controlResourceSetId <0) || (commonSearchSpaces_controlResourceSetId>11)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for commonSearchSpaces_controlResourceSetId choice: 0..11 !\n",
+                           RC.config_file_name, i, commonSearchSpaces_controlResourceSetId);
+            }
+
+            if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl1") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl1[j] = NULL;                 
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl2") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2;
+              
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl2[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_sl2;
+              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_sl2 <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_sl2>1)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_sl2 choice: 0..1 !\n",
+                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_sl2);
+              }   
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl4") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4;
+            
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl4[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_sl4;
+              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_sl4 <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_sl4>3)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_sl4 choice: 0..3 !\n",
+                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_sl4);
+              }                 
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl5") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5;
+            
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl5[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_sl5;
+              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_sl5 <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_sl5>4)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_sl5 choice: 0..4 !\n",
+                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_sl5);
+              }   
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl8") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8;
+            
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl8[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_sl8;
+              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_sl8 <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_sl8>7)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_sl8 choice: 0..7 !\n",
+                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_sl8);
+              }   
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl10") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10;
+            
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl10[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_sl10;
+              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_sl10 <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_sl10>9)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_sl10 choice: 0..9 !\n",
+                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_sl10);
+              } 
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl16") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16;
+            
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl16[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_sl16;
+              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_sl16 <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_sl16>15)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_sl16 choice: 0..15 !\n",
+                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_sl16);
+              } 
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl20") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20;
+            
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_sl20[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_sl20;
+              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_sl20 <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_sl20>19)){
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_sl20 choice: 0..19 !\n",
+                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_sl20);
+              } 
+
+            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "UNABLE") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  SearchSpace__monitoringSlotPeriodicityAndOffset_PR_NOTHING;
+            
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_choice !\n",
+                           RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_choice);
+            }// End if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl1")
+
+            
+            switch(SearchSpace_nrofCandidates_aggregationLevel1){
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n0;
+                break;
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n3;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n5;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n6;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  SearchSpace__nrofCandidates__aggregationLevel1_n8;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel1 choice: 0,1,2,3,4,5,6,8 !\n",
+                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel1);
+                break;
+            }  
+
+            switch(SearchSpace_nrofCandidates_aggregationLevel2){
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n0;
+                break;
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n3;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n5;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n6;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  SearchSpace__nrofCandidates__aggregationLevel2_n8;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel2 choice: 0,1,2,3,4,5,6,8 !\n",
+                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel2);
+                break;
+            }  
+
+            switch(SearchSpace_nrofCandidates_aggregationLevel4){
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n0;
+                break;
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n3;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n5;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n6;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  SearchSpace__nrofCandidates__aggregationLevel4_n8;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel4 choice: 0,1,2,3,4,5,6,8 !\n",
+                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel4);
+                break;
+            }
+
+            switch(SearchSpace_nrofCandidates_aggregationLevel8){
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n0;
+                break;
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n3;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n5;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n6;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  SearchSpace__nrofCandidates__aggregationLevel8_n8;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel8 choice: 0,1,2,3,4,5,6,8 !\n",
+                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel8);
+                break;
+            }
+
+            switch(SearchSpace_nrofCandidates_aggregationLevel16){
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n0;
+                break;
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n3;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n5;
+                break;
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n6;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  SearchSpace__nrofCandidates__aggregationLevel16_n8;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel16 choice: 0,1,2,3,4,5,6,8 !\n",
+                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel16);
+                break;
+            }
+
+            if (strcmp(SearchSpace_searchSpaceType , "NOTHING") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_searchSpaceType[j] =  SearchSpace__searchSpaceType_PR_NOTHING;
+            }else if (strcmp(SearchSpace_searchSpaceType , "common") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_searchSpaceType[j] =  SearchSpace__searchSpaceType_PR_common;
+            }else if (strcmp(SearchSpace_searchSpaceType , "ue_Specific") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_searchSpaceType[j] =  SearchSpace__searchSpaceType_PR_ue_Specific;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_searchSpaceType !\n",
+                           RC.config_file_name, i, SearchSpace_searchSpaceType);
+            }
+
+            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel1_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel1_n2;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 choice: 1,2 !\n",
+                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1);
+                break;
+            }
+
+            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel2_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel2_n2;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 choice: 1,2 !\n",
+                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2);
+                break;
+            }
+
+            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel4_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel4_n2;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 choice: 1,2 !\n",
+                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4);
+                break;
+            }
+
+            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel8_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel8_n2;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 choice: 1,2 !\n",
+                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8);
+                break;
+            }
+
+            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel16_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[j] =  SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel16_n2;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 choice: 1,2 !\n",
+                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16);
+                break;
+            }
+
+            switch(Common_dci_Format2_3_monitoringPeriodicity){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n2;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n5;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n8;
+                break;
+              case 10:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n10;
+                break;
+              case 16:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n16;
+                break;
+              case 20:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__monitoringPeriodicity_n20;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_3_monitoringPeriodicity choice: 1,2,4,5,8,10,16,20 !\n",
+                             RC.config_file_name, i, Common_dci_Format2_3_monitoringPeriodicity);
+                break;
+            }
+
+            switch(Common_dci_Format2_3_nrofPDCCH_Candidates){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_nrofPDCCH_Candidates[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__nrofPDCCH_Candidates_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_nrofPDCCH_Candidates[j] =  SearchSpace__searchSpaceType__common__dci_Format2_3__nrofPDCCH_Candidates_n2;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_3_nrofPDCCH_Candidates choice: 1,2 !\n",
+                             RC.config_file_name, i, Common_dci_Format2_3_nrofPDCCH_Candidates);
+                break;
+            }
+
+            if (strcmp(ue_Specific__dci_Formats , "formats0-0-And-1-0") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).ue_Specific__dci_Formats[j] =  SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0;
+            }else if (strcmp(ue_Specific__dci_Formats , "formats0-1-And-1-1") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).ue_Specific__dci_Formats[j] =  SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ue_Specific__dci_Formats !\n",
+                           RC.config_file_name, i, ue_Specific__dci_Formats);
+            }
+
+            //////////////////////////////////NR RateMatchPatternLTE-CRS///////////////////////////
+
+            switch(RateMatchPatternLTE_CRS_carrierBandwidthDL){
+              case 6:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  RateMatchPatternLTE_CRS__carrierBandwidthDL_n6;
+                break;
+              case 15:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  RateMatchPatternLTE_CRS__carrierBandwidthDL_n15;
+                break;
+              case 25:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  RateMatchPatternLTE_CRS__carrierBandwidthDL_n25;
+                break;
+              case 50:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  RateMatchPatternLTE_CRS__carrierBandwidthDL_n50;
+                break;
+              case 75:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  RateMatchPatternLTE_CRS__carrierBandwidthDL_n75;
+                break;
+              case 100:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  RateMatchPatternLTE_CRS__carrierBandwidthDL_n100;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_carrierBandwidthDL choice: 6,15,25,50,75,100 !\n",
+                             RC.config_file_name, i, RateMatchPatternLTE_CRS_carrierBandwidthDL);
+                break;
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] = RateMatchPatternLTE_CRS_carrierBandwidthDL;
+            if ((RateMatchPatternLTE_CRS_carrierBandwidthDL <0) || (RateMatchPatternLTE_CRS_carrierBandwidthDL>16383)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_carrierBandwidthDL choice: 0..16383 !\n",
+                           RC.config_file_name, i, RateMatchPatternLTE_CRS_carrierBandwidthDL);
+            }
+
+            switch(RateMatchPatternLTE_CRS_nrofCRS_Ports){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_nrofCRS_Ports[j] =  RateMatchPatternLTE_CRS__nrofCRS_Ports_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_nrofCRS_Ports[j] =  RateMatchPatternLTE_CRS__nrofCRS_Ports_n2;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_nrofCRS_Ports[j] =  RateMatchPatternLTE_CRS__nrofCRS_Ports_n4;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_nrofCRS_Ports choice: 1,2,4 !\n",
+                             RC.config_file_name, i, RateMatchPatternLTE_CRS_nrofCRS_Ports);
+                break;
+            }
+
+            switch(RateMatchPatternLTE_CRS_v_Shift){
+              case 0:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  RateMatchPatternLTE_CRS__v_Shift_n0;
+                break;
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  RateMatchPatternLTE_CRS__v_Shift_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  RateMatchPatternLTE_CRS__v_Shift_n2;
+                break;
+              case 3:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  RateMatchPatternLTE_CRS__v_Shift_n3;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  RateMatchPatternLTE_CRS__v_Shift_n4;
+                break;
+              case 5:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  RateMatchPatternLTE_CRS__v_Shift_n5;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_v_Shift choice: 0,1,2,3,4,5 !\n",
+                             RC.config_file_name, i, RateMatchPatternLTE_CRS_v_Shift);
+                break;
+            }
+
+            switch(RateMatchPatternLTE_CRS_radioframeAllocationPeriod){
+              case 1:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n1;
+                break;
+              case 2:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n2;
+                break;
+              case 4:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
+                break;
+              case 8:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n8;
+                break;
+              case 16:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n16;
+                break;
+              case 32:
+                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n32;
+                break;
+              default:
+                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_radioframeAllocationPeriod choice: 1,2,4,8,16,32 !\n",
+                             RC.config_file_name, i, RateMatchPatternLTE_CRS_radioframeAllocationPeriod);
+                break;
+            }
+
+            NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationOffset[j] = RateMatchPatternLTE_CRS_radioframeAllocationOffset;
+            if ((RateMatchPatternLTE_CRS_radioframeAllocationOffset <0) || (RateMatchPatternLTE_CRS_radioframeAllocationOffset>7)){
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_radioframeAllocationOffset choice: 0..7 !\n",
+                           RC.config_file_name, i, RateMatchPatternLTE_CRS_radioframeAllocationOffset);
+            }
+
+            if (strcmp(RateMatchPatternLTE_CRS_subframeAllocation_choice , "oneFrame") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_subframeAllocation_choice[j] =  EUTRA_MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
+            }else if (strcmp(RateMatchPatternLTE_CRS_subframeAllocation_choice , "fourFrames") == 0){
+              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_subframeAllocation_choice[j] =  EUTRA_MBSFN_SubframeConfig__subframeAllocation_PR_fourFrames;
+            }else {
+              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_subframeAllocation_choice !\n",
+                           RC.config_file_name, i, RateMatchPatternLTE_CRS_subframeAllocation_choice);
+            }
+
+
+          }//End for (j = 0; j < CCsParamList.numelt ;j++)
+
+        }//End if ( CCsParamList.numelt> 0) 
+
+      }//End for (k=0; k <num_gnbs ; k++)
+
+    }//End for (k=0; k <num_gnbs ; k++)
+
+
+  }//End if (num_gnbs>0)
+
+
+}//End RCconfig_NRRRC function
+
+void NRRCConfig(void) {
+
+  // paramlist_def_t MACRLCParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0};
+  // paramlist_def_t L1ParamList = {CONFIG_STRING_L1_LIST,NULL,0};
+  // paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0};
+  paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
+  paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
+  
+  char aprefix[MAX_OPTNAME_SIZE*2 + 8];  
+  
+
+
+/* get global parameters, defined outside any section in the config file */
+ 
+  printf("Getting GNBSParams\n");
+ 
+  config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); 
+  RC.nb_nr_inst = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt;
+ 
+  if (RC.nb_nr_inst > 0) {
+    RC.nb_CC = (int *)malloc((1+RC.nb_nr_inst)*sizeof(int));
+    for (int i=0;i<RC.nb_nr_inst;i++) {
+      sprintf(aprefix,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,i);
+      config_getlist( &CCsParamList,NULL,0, aprefix);
+      RC.nb_CC[i]   = CCsParamList.numelt;
+    }
+  }
+
+/*    
+	// Get num MACRLC instances
+    config_getlist( &MACRLCParamList,NULL,0, NULL);
+    RC.nb_macrlc_inst  = MACRLCParamList.numelt;
+    // Get num L1 instances
+    config_getlist( &L1ParamList,NULL,0, NULL);
+    RC.nb_L1_inst = L1ParamList.numelt;
+
+    // Get num RU instances
+    config_getlist( &RUParamList,NULL,0, NULL);  
+    RC.nb_RU     = RUParamList.numelt; 
+ */
+ 
+
+}
diff --git a/openair2/ENB_APP/gnb_config.h b/openair2/ENB_APP/gnb_config.h
new file mode 100644
index 0000000000000000000000000000000000000000..179f7ac03d6b390fa6a46c46a21e4968e5b3c2d8
--- /dev/null
+++ b/openair2/ENB_APP/gnb_config.h
@@ -0,0 +1,110 @@
+/*
+ * 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
+ */
+
+/*
+                                gnb_config.h
+                             -------------------
+  AUTHOR  : Lionel GAUTHIER, Navid Nikaein, Laurent Winckel
+  COMPANY : EURECOM
+  EMAIL   : Lionel.Gauthier@eurecom.fr, navid.nikaein@eurecom.fr
+*/
+
+#ifndef GNB_CONFIG_H_
+#define GNB_CONFIG_H_
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <libconfig.h>
+
+#include "commonDef.h"
+#include "platform_types.h"
+#include "platform_constants.h"
+#include "PHY/impl_defs_lte.h"
+#include "PHY/defs.h"
+#include "s1ap_messages_types.h"
+//#ifdef CMAKER
+//#include "SystemInformationBlockType2.h"
+//#include "rrc_messages_types.h"
+//#else
+//#include "RRC/LITE/MESSAGES/SystemInformationBlockType2.h"
+//#endif
+#include "intertask_interface_types.h"
+#include "RRC/NR/defs_NR.h"
+
+#define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\
+            struct in_addr inp;\
+            if ( inet_aton(AdDr_StR, &inp ) < 0 ) {\
+                AssertFatal (0, MeSsAgE);\
+            } else {\
+                NwBo = inp.s_addr;\
+            }\
+        } while (0);
+
+/** @defgroup _enb_app ENB APP 
+ * @ingroup _oai2
+ * @{
+ */
+
+// Hard to find a defined value for max enb...
+#define MAX_ENB 16
+
+/*
+typedef struct mme_ip_address_s {
+  unsigned  ipv4:1;
+  unsigned  ipv6:1;
+  unsigned  active:1;
+  char     *ipv4_address;
+  char     *ipv6_address;
+} mme_ip_address_t;
+
+typedef struct ru_config_s {
+  // indicates if local or remote rf is used (1 == LOCAL)
+  unsigned  local_rf:1;
+  // indicates if UDP socket is used
+  unsigned  udp:1;
+  // indicates if RAW socket is used
+  unsigned  raw:1;
+  char      *ru_if_name;
+  char     *local_address;
+  char     *remote_address;
+  uint16_t  local_port;
+  uint16_t  remote_port;
+  uint8_t   udpif4p5;
+  uint8_t   rawif4p5;
+  uint8_t   rawif5_mobipass;
+  uint8_t   if_compress;
+} ru_config_t;
+*/
+//extern void RCconfig_RU(void);
+//extern void RCconfig_flexran(void);
+//extern void RCconfig_L1(void);
+//extern void RCconfig_macrlc(void);
+//extern int  RCconfig_gtpu(void );
+extern void NRRCConfig(void);
+
+//void                          enb_config_display(void);
+//void                          ru_config_display(void);
+
+int RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc);
+//int RCconfig_S1(MessageDef *msg_p, uint32_t i);
+
+#endif /* GNB_CONFIG_H_ */
+/** @} */
diff --git a/openair2/ENB_APP/gnb_paramdef.h b/openair2/ENB_APP/gnb_paramdef.h
new file mode 100644
index 0000000000000000000000000000000000000000..96a18fa2ea134d14cbbe2dfa081c6578888695a4
--- /dev/null
+++ b/openair2/ENB_APP/gnb_paramdef.h
@@ -0,0 +1,705 @@
+/*
+ * 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/GNB_APP/gnb_paramdef.f
+ * \brief definition of configuration parameters for all eNodeB modules 
+ * \author Francois TABURET
+ * \date 2017
+ * \version 0.1
+ * \company NOKIA BellLabs France
+ * \email: francois.taburet@nokia-bell-labs.com
+ * \note
+ * \warning
+ */
+
+#include "common/config/config_paramdesc.h"
+#include "NRRRC_paramsvalues.h"
+
+
+#define GNB_CONFIG_STRING_CC_NODE_FUNCTION        "node_function"
+#define GNB_CONFIG_STRING_CC_NODE_TIMING          "node_timing"   
+#define GNB_CONFIG_STRING_CC_NODE_SYNCH_REF       "node_synch_ref"   
+
+
+// OTG config per GNB-UE DL
+#define GNB_CONF_STRING_OTG_CONFIG                "otg_config"
+#define GNB_CONF_STRING_OTG_UE_ID                 "ue_id"
+#define GNB_CONF_STRING_OTG_APP_TYPE              "app_type"
+#define GNB_CONF_STRING_OTG_BG_TRAFFIC            "bg_traffic"
+
+#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
+extern int asn_debug;
+extern int asn1_xer_print;
+#endif
+
+#ifdef LIBCONFIG_LONG
+#define libconfig_int long
+#else
+#define libconfig_int int
+#endif
+
+typedef enum {
+  RU     = 0,
+  L1     = 1,
+  L2     = 2,
+  L3     = 3,
+  S1     = 4,
+  lastel = 5
+} NRRC_config_functions_t;
+
+#define CONFIG_STRING_ACTIVE_RUS                  "Active_RUs"
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+/*    RUs  configuration section name */
+#define CONFIG_STRING_RU_LIST                     "RUs"
+#define CONFIG_STRING_RU_CONFIG                   "ru_config"
+
+/*    RUs configuration parameters name   */
+#define CONFIG_STRING_RU_LOCAL_IF_NAME            "local_if_name"
+#define CONFIG_STRING_RU_LOCAL_ADDRESS            "local_address"
+#define CONFIG_STRING_RU_REMOTE_ADDRESS           "remote_address"
+#define CONFIG_STRING_RU_LOCAL_PORTC              "local_portc"
+#define CONFIG_STRING_RU_REMOTE_PORTC             "remote_portc"
+#define CONFIG_STRING_RU_LOCAL_PORTD              "local_portd"
+#define CONFIG_STRING_RU_REMOTE_PORTD             "remote_portd"
+#define CONFIG_STRING_RU_LOCAL_RF                 "local_rf"
+#define CONFIG_STRING_RU_TRANSPORT_PREFERENCE     "tr_preference"
+#define CONFIG_STRING_RU_BAND_LIST                "bands"
+#define CONFIG_STRING_RU_GNB_LIST                 "gNB_instances"
+#define CONFIG_STRING_RU_NB_TX                    "nb_tx"
+#define CONFIG_STRING_RU_NB_RX                    "nb_rx"
+#define CONFIG_STRING_RU_ATT_TX                   "att_tx"
+#define CONFIG_STRING_RU_ATT_RX                   "att_rx"
+#define CONFIG_STRING_RU_MAX_RS_EPRE              "max_pdschReferenceSignalPower"
+#define CONFIG_STRING_RU_MAX_RXGAIN               "max_rxgain"
+#define CONFIG_STRING_RU_IF_COMPRESSION           "if_compression"
+#define CONFIG_STRING_RU_NBIOTRRC_LIST            "NbIoT_RRC_instances"
+
+#define RU_LOCAL_IF_NAME_IDX          0
+#define RU_LOCAL_ADDRESS_IDX          1
+#define RU_REMOTE_ADDRESS_IDX         2
+#define RU_LOCAL_PORTC_IDX            3
+#define RU_REMOTE_PORTC_IDX           4
+#define RU_LOCAL_PORTD_IDX            5
+#define RU_REMOTE_PORTD_IDX           6
+#define RU_TRANSPORT_PREFERENCE_IDX   7
+#define RU_LOCAL_RF_IDX               8
+#define RU_NB_TX_IDX                  9
+#define RU_NB_RX_IDX                  10
+#define RU_MAX_RS_EPRE_IDX            11
+#define RU_MAX_RXGAIN_IDX             12
+#define RU_BAND_LIST_IDX              13
+#define RU_GNB_LIST_IDX               14
+#define RU_ATT_TX_IDX                 15
+#define RU_ATT_RX_IDX                 16
+#define RU_NBIOTRRC_LIST_IDX          17
+
+
+
+/*-----------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            RU configuration parameters                                                                  */
+/*   optname                                   helpstr   paramflags    XXXptr        defXXXval                   type           numelt     */
+/*-----------------------------------------------------------------------------------------------------------------------------------------*/
+#define RUPARAMS_DESC { \
+{CONFIG_STRING_RU_LOCAL_IF_NAME,            	 NULL,       0,       strptr:NULL,     defstrval:"lo",  	TYPE_STRING,	  0}, \
+{CONFIG_STRING_RU_LOCAL_ADDRESS,            	 NULL,       0,       strptr:NULL,     defstrval:"127.0.0.2",	TYPE_STRING,	  0}, \
+{CONFIG_STRING_RU_REMOTE_ADDRESS,           	 NULL,       0,       strptr:NULL,     defstrval:"127.0.0.1",	TYPE_STRING,	  0}, \
+{CONFIG_STRING_RU_LOCAL_PORTC,              	 NULL,       0,       uptr:NULL,       defuintval:50000,	TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_REMOTE_PORTC,             	 NULL,       0,       uptr:NULL,       defuintval:50000,	TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_LOCAL_PORTD,              	 NULL,       0,       uptr:NULL,       defuintval:50001,	TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_REMOTE_PORTD,             	 NULL,       0,       uptr:NULL,       defuintval:50001,	TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_TRANSPORT_PREFERENCE,     	 NULL,       0,       strptr:NULL,     defstrval:"udp_if5",	TYPE_STRING,	  0}, \
+{CONFIG_STRING_RU_LOCAL_RF,                 	 NULL,       0,       strptr:NULL,     defstrval:"yes", 	TYPE_STRING,	  0}, \
+{CONFIG_STRING_RU_NB_TX,                    	 NULL,       0,       uptr:NULL,       defuintval:1,		TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_NB_RX,                    	 NULL,       0,       uptr:NULL,       defuintval:1,		TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_MAX_RS_EPRE,              	 NULL,       0,       iptr:NULL,       defintval:-29,		TYPE_INT,	  0}, \
+{CONFIG_STRING_RU_MAX_RXGAIN,               	 NULL,       0,       iptr:NULL,       defintval:120,		TYPE_INT,	  0}, \
+{CONFIG_STRING_RU_BAND_LIST,                	 NULL,       0,       uptr:NULL,       defintarrayval:DEFBANDS, TYPE_INTARRAY,    1}, \
+{CONFIG_STRING_RU_GNB_LIST,                 	 NULL,       0,       uptr:NULL,       defintarrayval:DEFGNBS,  TYPE_INTARRAY,    1}, \
+{CONFIG_STRING_RU_ATT_TX,                   	 NULL,       0,       uptr:NULL,       defintval:0,		TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_ATT_RX,                   	 NULL,       0,       uptr:NULL,       defintval:0,		TYPE_UINT,	  0}, \
+{CONFIG_STRING_RU_NBIOTRRC_LIST,               NULL,       0,       uptr:NULL,       defintarrayval:DEFGNBS,  TYPE_INTARRAY,    1}, \
+}
+
+/*---------------------------------------------------------------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------------------------------------------------------------------*/
+/* value definitions for ASN1 verbosity parameter */
+#define GNB_CONFIG_STRING_ASN1_VERBOSITY_NONE              "none"
+#define GNB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING          "annoying"
+#define GNB_CONFIG_STRING_ASN1_VERBOSITY_INFO              "info"
+ 
+
+/* global parameters, not under a specific section   */
+#define GNB_CONFIG_STRING_ASN1_VERBOSITY                   "Asn1_verbosity"
+#define GNB_CONFIG_STRING_ACTIVE_GNBS                      "Active_gNBs"
+/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            global configuration parameters                                                                                   */
+/*   optname                                   helpstr   paramflags    XXXptr        defXXXval                                        type           numelt     */
+/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+#define GNBSPARAMS_DESC {                                                                                             \
+{GNB_CONFIG_STRING_ASN1_VERBOSITY,             NULL,     0,        uptr:NULL,   defstrval:GNB_CONFIG_STRING_ASN1_VERBOSITY_NONE,   TYPE_STRING,      0},   \
+{GNB_CONFIG_STRING_ACTIVE_GNBS,                NULL,     0,        uptr:NULL,   defstrval:NULL, 				   TYPE_STRINGLIST,  0}    \
+}
+#define GNB_ASN1_VERBOSITY_IDX                     0
+#define GNB_ACTIVE_GNBS_IDX                        1
+
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+
+
+/* cell configuration parameters names */
+#define GNB_CONFIG_STRING_GNB_ID                        "gNB_ID"
+#define GNB_CONFIG_STRING_CELL_TYPE                     "cell_type"
+#define GNB_CONFIG_STRING_GNB_NAME                      "gNB_name"
+#define GNB_CONFIG_STRING_TRACKING_AREA_CODE            "tracking_area_code"
+#define GNB_CONFIG_STRING_MOBILE_COUNTRY_CODE           "mobile_country_code"
+#define GNB_CONFIG_STRING_MOBILE_NETWORK_CODE           "mobile_network_code"
+#define GNB_CONFIG_STRING_TRANSPORT_S_PREFERENCE        "tr_s_preference"
+#define GNB_CONFIG_STRING_LOCAL_S_IF_NAME               "local_s_if_name"
+#define GNB_CONFIG_STRING_LOCAL_S_ADDRESS               "local_s_address"
+#define GNB_CONFIG_STRING_REMOTE_S_ADDRESS              "remote_s_address"
+#define GNB_CONFIG_STRING_LOCAL_S_PORTC                 "local_s_portc"
+#define GNB_CONFIG_STRING_REMOTE_S_PORTC                "remote_s_portc"
+#define GNB_CONFIG_STRING_LOCAL_S_PORTD                 "local_s_portd"
+#define GNB_CONFIG_STRING_REMOTE_S_PORTD                "remote_s_portd"
+
+/*-----------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            cell configuration parameters                                                                */
+/*   optname                                   helpstr   paramflags    XXXptr        defXXXval                   type           numelt     */
+/*-----------------------------------------------------------------------------------------------------------------------------------------*/
+#define GNBPARAMS_DESC {\
+{GNB_CONFIG_STRING_GNB_ID,                       NULL,   0,            uptr:NULL,   defintval:0,                 TYPE_UINT,      0},  \
+{GNB_CONFIG_STRING_CELL_TYPE,                    NULL,   0,            strptr:NULL, defstrval:"CELL_MACRO_GNB",  TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_GNB_NAME,                     NULL,   0,            strptr:NULL, defstrval:"OAIgNodeB",       TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_TRACKING_AREA_CODE,           NULL,   0,            strptr:NULL, defstrval:"0",               TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_MOBILE_COUNTRY_CODE,          NULL,   0,            strptr:NULL, defstrval:"0",               TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_MOBILE_NETWORK_CODE,          NULL,   0,            strptr:NULL, defstrval:"0",               TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_TRANSPORT_S_PREFERENCE,       NULL,   0,            strptr:NULL, defstrval:"local_mac",       TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_LOCAL_S_IF_NAME,              NULL,   0,            strptr:NULL, defstrval:"lo",              TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_LOCAL_S_ADDRESS,              NULL,   0,            strptr:NULL, defstrval:"127.0.0.1",       TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_REMOTE_S_ADDRESS,             NULL,   0,            strptr:NULL, defstrval:"127.0.0.2",       TYPE_STRING,    0},  \
+{GNB_CONFIG_STRING_LOCAL_S_PORTC,                NULL,   0,            uptr:NULL,   defuintval:50000,            TYPE_UINT,      0},  \
+{GNB_CONFIG_STRING_REMOTE_S_PORTC,               NULL,   0,            uptr:NULL,   defuintval:50000,            TYPE_UINT,      0},  \
+{GNB_CONFIG_STRING_LOCAL_S_PORTD,                NULL,   0,            uptr:NULL,   defuintval:50001,            TYPE_UINT,      0},  \
+{GNB_CONFIG_STRING_REMOTE_S_PORTD,               NULL,   0,            uptr:NULL,   defuintval:50001,            TYPE_UINT,      0},  \
+}															     	
+#define GNB_GNB_ID_IDX                  0
+#define GNB_CELL_TYPE_IDX               1
+#define GNB_GNB_NAME_IDX                2
+#define GNB_TRACKING_AREA_CODE_IDX      3
+#define GNB_MOBILE_COUNTRY_CODE_IDX     4
+#define GNB_MOBILE_NETWORK_CODE_IDX     5
+#define GNB_TRANSPORT_S_PREFERENCE_IDX  6
+#define GNB_LOCAL_S_IF_NAME_IDX         7
+#define GNB_LOCAL_S_ADDRESS_IDX         8
+#define GNB_REMOTE_S_ADDRESS_IDX        9
+#define GNB_LOCAL_S_PORTC_IDX           10
+#define GNB_REMOTE_S_PORTC_IDX          11
+#define GNB_LOCAL_S_PORTD_IDX           12
+#define GNB_REMOTE_S_PORTD_IDX          13
+/*-------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------------------------------------------------------------------------------*/		  
+
+
+/* component carries configuration parameters name */
+
+#define GNB_CONFIG_STRING_NB_ANT_PORTS                                                 "nb_antenna_ports"
+#define GNB_CONFIG_STRING_NB_ANT_TX                                                    "nb_antennas_tx"
+#define GNB_CONFIG_STRING_NB_ANT_RX                                                    "nb_antennas_rx"
+#define GNB_CONFIG_STRING_TX_GAIN                                                      "tx_gain"
+#define GNB_CONFIG_STRING_RX_GAIN                                                      "rx_gain"
+
+  ///NR
+  //MIB
+#define GNB_CONFIG_STRING_MIB_SUBCARRIERSPACINGCOMMON                                  "MIB_subCarrierSpacingCommon"
+#define GNB_CONFIG_STRING_MIB_SSB_SUBCARRIEROFFSET                                     "MIB_ssb_SubcarrierOffset"
+#define GNB_CONFIG_STRING_MIB_DMRS_TYPEA_POSITION                                      "MIB_dmrs_TypeA_Position"
+#define GNB_CONFIG_STRING_PDCCH_CONFIGSIB1                                             "pdcch_ConfigSIB1"
+
+  //SIB1
+#define GNB_CONFIG_STRING_SIB1_FREQUENCYOFFSETSSB                                      "SIB1_frequencyOffsetSSB"
+#define GNB_CONFIG_STRING_SIB1_SSB_PERIODICITYSERVINGCELL                              "SIB1_ssb_PeriodicityServingCell"
+#define GNB_CONFIG_STRING_SIB1_SS_PBCH_BLOCKPOWER                                      "SIB1_ss_PBCH_BlockPower"
+  //NR FREQUENCYINFODL
+#define GNB_CONFIG_STRING_ABSOLUTEFREQUENCYSSB                                         "absoluteFrequencySSB"
+#define GNB_CONFIG_STRING_SSB_SUBCARRIEROFFSET                                         "SubcarrierSpacing"
+#define GNB_CONFIG_STRING_DL_FREQBANDINDICATORNR                                       "DL_FreqBandIndicatorNR"
+#define GNB_CONFIG_STRING_DL_ABSOLUTEFREQUENCYPOINTA                                   "DL_absoluteFrequencyPointA"
+
+  //NR DL SCS-SPECIFICCARRIER
+#define GNB_CONFIG_STRING_DL_OFFSETTOCARRIER                                           "DL_offsetToCarrier"
+#define GNB_CONFIG_STRING_DL_SCS_SUBCARRIERSPACING                                     "DL_SCS_SubcarrierSpacing"
+#define GNB_CONFIG_STRING_DL_SCS_SPECIFICCARRIER_K0                                    "DL_SCS_SpecificCarrier_k0"
+#define GNB_CONFIG_STRING_DL_CARRIERBANDWIDTH                                          "DL_carrierBandwidth"
+
+  // NR BWP-DOWNLINKCOMMON
+#define GNB_CONFIG_STRING_DL_LOCATIONANDBANDWIDTH                                      "DL_locationAndBandwidth"
+#define GNB_CONFIG_STRING_DL_BWP_SUBCARRIERSPACING                                     "DL_BWP_SubcarrierSpacing"
+#define GNB_CONFIG_STRING_DL_BWP_PREFIX_TYPE                                           "DL_BWP_prefix_type"
+
+  //NR FREQUENCYINFOUL
+#define GNB_CONFIG_STRING_UL_FREQBANDINDICATORNR                                       "UL_FreqBandIndicatorNR"
+#define GNB_CONFIG_STRING_UL_ABSOLUTEFREQUENCYPOINTA                                   "UL_absoluteFrequencyPointA"
+#define GNB_CONFIG_STRING_UL_ADDITIONALSPECTRUMEMISSION                                "UL_additionalSpectrumEmission"
+#define GNB_CONFIG_STRING_UL_P_MAX                                                     "UL_p_Max"
+#define GNB_CONFIG_STRING_UL_FREQUENCYSHIFT7P5KHZ                                      "UL_frequencyShift7p5khz"
+
+  //NR UL SCS-SPECIFICCARRIER
+#define GNB_CONFIG_STRING_UL_OFFSETTOCARRIER                                           "UL_offsetToCarrier"
+#define GNB_CONFIG_STRING_UL_SCS_SUBCARRIERSPACING                                     "UL_SCS_SubcarrierSpacing"
+#define GNB_CONFIG_STRING_UL_SCS_SPECIFICCARRIER_K0                                    "UL_SCS_SpecificCarrier_k0"
+#define GNB_CONFIG_STRING_UL_CARRIERBANDWIDTH                                          "UL_carrierBandwidth"
+
+  // NR BWP-UPLINKCOMMON
+#define GNB_CONFIG_STRING_UL_LOCATIONANDBANDWIDTH                                      "UL_locationAndBandwidth"
+#define GNB_CONFIG_STRING_UL_BWP_SUBCARRIERSPACING                                     "UL_BWP_SubcarrierSpacing"
+#define GNB_CONFIG_STRING_UL_BWP_PREFIX_TYPE                                           "UL_BWP_prefix_type"
+
+#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR              "ServingCellConfigCommon_ssb_PositionsInBurst_PR"
+#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL           "ServingCellConfigCommon_ssb_periodicityServingCell"
+#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION                  "ServingCellConfigCommon_dmrs_TypeA_Position"
+#define GNB_CONFIG_STRING_NIA_SUBCARRIERSPACING                                        "NIA_SubcarrierSpacing"
+#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SS_PBCH_BLOCKPOWER                   "ServingCellConfigCommon_ss_PBCH_BlockPower"
+
+
+  //NR TDD-UL-DL-CONFIGCOMMON
+#define GNB_CONFIG_STRING_REFERENCESUBCARRIERSPACING                                   "referenceSubcarrierSpacing"
+#define GNB_CONFIG_STRING_DL_UL_TRANSMISSIONPERIODICITY                                "dl_UL_TransmissionPeriodicity"
+#define GNB_CONFIG_STRING_NROFDOWNLINKSLOTS                                            "nrofDownlinkSlots"
+#define GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS                                          "nrofDownlinkSymbols"
+#define GNB_CONFIG_STRING_NROFUPLINKSLOTS                                              "nrofUplinkSlots"
+#define GNB_CONFIG_STRING_NROFUPLINKSYMBOLS                                            "nrofUplinkSymbols"
+
+  //NR RACH-CONFIGCOMMON
+#define GNB_CONFIG_STRING_RACH_TOTALNUMBEROFRA_PREAMBLES                               "rach_totalNumberOfRA_Preambles"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_CHOICE        "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEEIGHTH     "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEFOURTH     "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEHALF       "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONE           "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_TWO           "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_FOUR          "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_EIGHT         "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight"
+#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_SIXTEEN       "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen"
+#define GNB_CONFIG_STRING_RACH_GROUPBCONFIGURED                                        "rach_groupBconfigured"
+#define GNB_CONFIG_STRING_RACH_RA_MSG3SIZEGROUPA                                       "rach_ra_Msg3SizeGroupA"
+#define GNB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB                                "rach_messagePowerOffsetGroupB"
+#define GNB_CONFIG_STRING_RACH_NUMBEROFRA_PREAMBLESGROUPA                              "rach_numberOfRA_PreamblesGroupA"
+#define GNB_CONFIG_STRING_RACH_RA_CONTENTIONRESOLUTIONTIMER                            "rach_ra_ContentionResolutionTimer"
+#define GNB_CONFIG_STRING_RSRP_THRESHOLDSSB                                            "rsrp_ThresholdSSB"
+#define GNB_CONFIG_STRING_RSRP_THRESHOLDSSB_SUL                                        "rsrp_ThresholdSSB_SUL"
+#define GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_CHOICE                               "prach_RootSequenceIndex_choice"
+#define GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L839                                 "prach_RootSequenceIndex_l839"
+#define GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L139                                 "prach_RootSequenceIndex_l139"
+#define GNB_CONFIG_STRING_PRACH_MSG1_SUBCARRIERSPACING                                 "prach_msg1_SubcarrierSpacing"
+#define GNB_CONFIG_STRING_RESTRICTEDSETCONFIG                                          "restrictedSetConfig"
+#define GNB_CONFIG_STRING_MSG3_TRANSFORMPRECODING                                      "msg3_transformPrecoding"
+  //SSB-PERRACH-OCCASIONANDCB-PREAMBLESPERSSB NOT SURE
+
+  //NR RACH-CONFIGGENERIC
+#define GNB_CONFIG_STRING_PRACH_CONFIGURATIONINDEX                                     "prach_ConfigurationIndex"
+#define GNB_CONFIG_STRING_PRACH_MSG1_FDM                                               "prach_msg1_FDM"
+#define GNB_CONFIG_STRING_PRACH_MSG1_FREQUENCYSTART                                    "prach_msg1_FrequencyStart"
+#define GNB_CONFIG_STRING_ZEROCORRELATIONZONECONFIG                                    "zeroCorrelationZoneConfig"
+#define GNB_CONFIG_STRING_PREAMBLERECEIVEDTARGETPOWER                                  "preambleReceivedTargetPower"
+#define GNB_CONFIG_STRING_PREAMBLETRANSMAX                                             "preambleTransMax"
+#define GNB_CONFIG_STRING_POWERRAMPINGSTEP                                             "powerRampingStep"
+#define GNB_CONFIG_STRING_RA_RESPONSEWINDOW                                            "ra_ResponseWindow"
+
+  //PUSCH-CONFIGCOMMON
+#define GNB_CONFIG_STRING_GROUPHOPPINGENABLEDTRANSFORMPRECODING                        "groupHoppingEnabledTransformPrecoding"
+#define GNB_CONFIG_STRING_MSG3_DELTAPREAMBLE                                           "msg3_DeltaPreamble"
+#define GNB_CONFIG_STRING_P0_NOMINALWITHGRANT                                          "p0_NominalWithGrant"
+
+  ///PUSCH-TIMEDOMAINRESOURCEALLOCATION
+#define GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_K2                        "PUSCH_TimeDomainResourceAllocation_k2"
+#define GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE               "PUSCH_TimeDomainResourceAllocation_mappingType"
+
+  //PUCCH-CONFIGCOMMON
+#define GNB_CONFIG_STRING_PUCCH_GROUPHOPPING                                           "pucch_GroupHopping"
+#define GNB_CONFIG_STRING_P0_NOMINAL                                                   "p0_nominal"
+
+  //PDSCH-CONFIGCOMMON
+  //PDSCH-TIMEDOMAINRESOURCEALLOCATION
+#define GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_K0                        "PDSCH_TimeDomainResourceAllocation_k0"
+#define GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE               "PDSCH_TimeDomainResourceAllocation_mappingType"
+
+  //RATEMATCHPATTERN  IS USED TO CONFIGURE ONE RATE MATCHING PATTERN FOR PDSCH
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNID                                           "rateMatchPatternId"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERN_PATTERNTYPE                                 "RateMatchPattern_patternType"
+#define GNB_CONFIG_STRING_SYMBOLSINRESOURCEBLOCK                                       "symbolsInResourceBlock"
+#define GNB_CONFIG_STRING_PERIODICITYANDPATTERN                                        "periodicityAndPattern"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERN_CONTROLRESOURCESET                          "RateMatchPattern_controlResourceSet"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERN_SUBCARRIERSPACING                           "RateMatchPattern_subcarrierSpacing"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERN_MODE                                        "RateMatchPattern_mode"
+
+  //PDCCH-CONFIGCOMMON
+#define GNB_CONFIG_STRING_SEARCHSPACESIB1                                              "searchSpaceSIB1"
+#define GNB_CONFIG_STRING_SEARCHSPACEOTHERSYSTEMINFORMATION                            "searchSpaceOtherSystemInformation"
+#define GNB_CONFIG_STRING_PAGINGSEARCHSPACE                                            "pagingSearchSpace"
+#define GNB_CONFIG_STRING_RA_SEARCHSPACE                                               "ra_SearchSpace"
+#define GNB_CONFIG_STRING_RACH_RA_CONTROLRESOURCESET                                   "rach_ra_ControlResourceSet"
+  //NR PDCCH-CONFIGCOMMON COMMONCONTROLRESOURCESSETS
+#define GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESETID                            "PDCCH_common_controlResourceSetId"
+#define GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESET_DURATION                     "PDCCH_common_ControlResourceSet_duration"
+#define GNB_CONFIG_STRING_PDCCH_CCE_REG_MAPPINGTYPE                                    "PDCCH_cce_REG_MappingType"
+#define GNB_CONFIG_STRING_PDCCH_REG_BUNDLESIZE                                         "PDCCH_reg_BundleSize"
+#define GNB_CONFIG_STRING_PDCCH_INTERLEAVERSIZE                                        "PDCCH_interleaverSize"
+#define GNB_CONFIG_STRING_PDCCH_SHIFTINDEX                                             "PDCCH_shiftIndex"
+#define GNB_CONFIG_STRING_PDCCH_PRECODERGRANULARITY                                    "PDCCH_precoderGranularity"
+#define GNB_CONFIG_STRING_PDCCH_TCI_STATEID                                            "PDCCH_TCI_StateId"
+#define GNB_CONFIG_STRING_TCI_PRESENTINDCI                                             "tci_PresentInDCI"
+
+  //NR PDCCH-ConfigCommon commonSearchSpaces
+#define GNB_CONFIG_STRING_SEARCHSPACEID                                                "SearchSpaceId"
+#define GNB_CONFIG_STRING_COMMONSEARCHSPACES_CONTROLRESOURCESETID                      "commonSearchSpaces_controlResourceSetId"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_CHOICE        "SearchSpace_monitoringSlotPeriodicityAndOffset_choice"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL1           "SearchSpace_monitoringSlotPeriodicityAndOffset_sl1"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL2           "SearchSpace_monitoringSlotPeriodicityAndOffset_sl2"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL4           "SearchSpace_monitoringSlotPeriodicityAndOffset_sl4"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL5           "SearchSpace_monitoringSlotPeriodicityAndOffset_sl5"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL8           "SearchSpace_monitoringSlotPeriodicityAndOffset_sl8"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL10          "SearchSpace_monitoringSlotPeriodicityAndOffset_sl10"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL16          "SearchSpace_monitoringSlotPeriodicityAndOffset_sl16"
+#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL20          "SearchSpace_monitoringSlotPeriodicityAndOffset_sl20"
+#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL1                 "SearchSpace_nrofCandidates_aggregationLevel1"
+#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL2                 "SearchSpace_nrofCandidates_aggregationLevel2"
+#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL4                 "SearchSpace_nrofCandidates_aggregationLevel4"
+#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL8                 "SearchSpace_nrofCandidates_aggregationLevel8"
+#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL16                "SearchSpace_nrofCandidates_aggregationLevel16"
+#define GNB_CONFIG_STRING_SEARCHSPACE_SEARCHSPACETYPE                                  "SearchSpace_searchSpaceType"
+#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL1    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1"
+#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL2    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2"
+#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL4    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4"
+#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL8    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8"
+#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL16   "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16"
+#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_MONITORINGPERIODICITY                   "Common_dci_Format2_3_monitoringPeriodicity"
+#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_NROFPDCCH_CANDIDATES                    "Common_dci_Format2_3_nrofPDCCH_Candidates"
+#define GNB_CONFIG_STRING_UE_SPECIFIC__DCI_FORMATS                                     "ue_Specific__dci_Formats"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERFREQDL                        "RateMatchPatternLTE_CRS_carrierFreqDL"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERBANDWIDTHDL                   "RateMatchPatternLTE_CRS_carrierBandwidthDL"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_NROFCRS_PORTS                        "RateMatchPatternLTE_CRS_nrofCRS_Ports"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_V_SHIFT                              "RateMatchPatternLTE_CRS_v_Shift"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONPERIOD           "RateMatchPatternLTE_CRS_radioframeAllocationPeriod"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONOFFSET           "RateMatchPatternLTE_CRS_radioframeAllocationOffset"
+#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_SUBFRAMEALLOCATION_CHOICE            "RateMatchPatternLTE_CRS_subframeAllocation_choice"
+
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                                                             component carriers configuration parameters                                                                                                                           */
+/*   optname                                                                        helpstr   paramflags    XXXptr                                                                  defXXXval                    type         numelt  checked_param  */
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+#define NRCCPARAMS_DESC { \
+{GNB_CONFIG_STRING_FRAME_TYPE,                                                       NULL,        0,        strptr:&frame_type,                                                     defstrval:"FDD",           TYPE_STRING,     0},  \
+{GNB_CONFIG_STRING_DL_prefix_type,                                                   NULL,        0,        strptr:&DL_prefix_type,                                                 defstrval:"NORMAL",        TYPE_STRING,     0},  \
+{GNB_CONFIG_STRING_UL_prefix_type,                                                   NULL,        0,        strptr:&UL_prefix_type,                                                 defstrval:"NORMAL",        TYPE_STRING,     0},  \
+{GNB_CONFIG_STRING_EUTRA_BAND,                                                       NULL,        0,        iptr:&eutra_band,                                                       defintval:7,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DOWNLINK_FREQUENCY,                                               NULL,        0,        i64ptr:(int64_t *)&downlink_frequency,                                  defint64val:2680000000,    TYPE_UINT64,     0},  \
+{GNB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET,                                          NULL,        0,        iptr:&uplink_frequency_offset,                                          defintval:-120000000,      TYPE_INT,        0},  \
+{GNB_CONFIG_STRING_NID_CELL,                                                         NULL,        0,        iptr:&Nid_cell,                                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_N_RB_DL,                                                          NULL,        0,        iptr:&N_RB_DL,                                                          defintval:25,              TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_NB_ANT_PORTS,                                                     NULL,        0,        iptr:&nb_antenna_ports,                                                 defintval:1,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_MIB_SUBCARRIERSPACINGCOMMON,                                      NULL,        0,        iptr:&MIB_subCarrierSpacingCommon,                                      defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_MIB_SSB_SUBCARRIEROFFSET,                                         NULL,        0,        iptr:&MIB_ssb_SubcarrierOffset,                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_MIB_DMRS_TYPEA_POSITION,                                          NULL,        0,        iptr:&MIB_dmrs_TypeA_Position,                                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_CONFIGSIB1,                                                 NULL,        0,        iptr:&pdcch_ConfigSIB1,                                                 defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SIB1_FREQUENCYOFFSETSSB,                                          NULL,        0,        iptr:&SIB1_frequencyOffsetSSB,                                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SIB1_SSB_PERIODICITYSERVINGCELL,                                  NULL,        0,        iptr:&SIB1_ssb_PeriodicityServingCell,                                  defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SIB1_SS_PBCH_BLOCKPOWER,                                          NULL,        0,        iptr:&SIB1_ss_PBCH_BlockPower,                                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_ABSOLUTEFREQUENCYSSB,                                             NULL,        0,        iptr:&absoluteFrequencySSB,                                             defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SSB_SUBCARRIEROFFSET,                                             NULL,        0,        iptr:&ssb_SubcarrierOffset,                                             defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_FREQBANDINDICATORNR,                                           NULL,        0,        iptr:&DL_FreqBandIndicatorNR,                                           defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_ABSOLUTEFREQUENCYPOINTA,                                       NULL,        0,        iptr:&DL_absoluteFrequencyPointA,                                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_OFFSETTOCARRIER,                                               NULL,        0,        iptr:&DL_offsetToCarrier,                                               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_SCS_SUBCARRIERSPACING,                                         NULL,        0,        iptr:&DL_SCS_SubcarrierSpacing,                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_SCS_SPECIFICCARRIER_K0,                                        NULL,        0,        iptr:&DL_SCS_SpecificCarrier_k0,                                        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_CARRIERBANDWIDTH,                                              NULL,        0,        iptr:&DL_carrierBandwidth,                                              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_LOCATIONANDBANDWIDTH,                                          NULL,        0,        iptr:&DL_locationAndBandwidth,                                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_BWP_SUBCARRIERSPACING,                                         NULL,        0,        iptr:&DL_BWP_SubcarrierSpacing,                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_BWP_PREFIX_TYPE,                                               NULL,        0,        iptr:&DL_BWP_prefix_type,                                               defintval:0,               TYPE_STRING,     0},  \
+{GNB_CONFIG_STRING_UL_FREQBANDINDICATORNR,                                           NULL,        0,        iptr:&UL_FreqBandIndicatorNR,                                           defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_ABSOLUTEFREQUENCYPOINTA,                                       NULL,        0,        iptr:&UL_absoluteFrequencyPointA,                                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_ADDITIONALSPECTRUMEMISSION,                                    NULL,        0,        iptr:&UL_additionalSpectrumEmission,                                    defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_P_MAX,                                                         NULL,        0,        iptr:&UL_p_Max,                                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_FREQUENCYSHIFT7P5KHZ,                                          NULL,        0,        iptr:&UL_frequencyShift7p5khz,                                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_OFFSETTOCARRIER,                                               NULL,        0,        iptr:&UL_offsetToCarrier,                                               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_SCS_SUBCARRIERSPACING,                                         NULL,        0,        iptr:&UL_SCS_SubcarrierSpacing,                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_SCS_SPECIFICCARRIER_K0,                                        NULL,        0,        iptr:&UL_SCS_SpecificCarrier_k0,                                        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_CARRIERBANDWIDTH,                                              NULL,        0,        iptr:&UL_carrierBandwidth,                                              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_LOCATIONANDBANDWIDTH,                                          NULL,        0,        iptr:&UL_locationAndBandwidth,                                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_BWP_SUBCARRIERSPACING,                                         NULL,        0,        iptr:&UL_BWP_SubcarrierSpacing,                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UL_BWP_PREFIX_TYPE,                                               NULL,        0,        iptr:&UL_BWP_prefix_type,                                               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR,                  NULL,        0,        iptr:&ServingCellConfigCommon_ssb_PositionsInBurst_PR,                  defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL,               NULL,        0,        iptr:&ServingCellConfigCommon_ssb_periodicityServingCell,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION,                      NULL,        0,        iptr:&ServingCellConfigCommon_dmrs_TypeA_Position,                      defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_NIA_SUBCARRIERSPACING,                                            NULL,        0,        iptr:&NIA_SubcarrierSpacing,                                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SS_PBCH_BLOCKPOWER,                       NULL,        0,        iptr:&ServingCellConfigCommon_ss_PBCH_BlockPower,                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_REFERENCESUBCARRIERSPACING,                                       NULL,        0,        iptr:&referenceSubcarrierSpacing,                                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_DL_UL_TRANSMISSIONPERIODICITY,                                    NULL,        0,        iptr:&dl_UL_TransmissionPeriodicity,                                    defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_NROFDOWNLINKSLOTS,                                                NULL,        0,        iptr:&nrofDownlinkSlots,                                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS,                                              NULL,        0,        iptr:&nrofDownlinkSymbols,                                              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_NROFUPLINKSLOTS,                                                  NULL,        0,        iptr:&nrofUplinkSlots,                                                  defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_NROFUPLINKSYMBOLS,                                                NULL,        0,        iptr:&nrofUplinkSymbols,                                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_TOTALNUMBEROFRA_PREAMBLES,                                   NULL,        0,        iptr:&rach_totalNumberOfRA_Preambles,                                   defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_CHOICE,            NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEEIGHTH,         NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth,         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEFOURTH,         NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth,         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEHALF,           NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf,           defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONE,               NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_TWO,               NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_FOUR,              NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four,              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_EIGHT,             NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight,             defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_SIXTEEN,           NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen,           defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_GROUPBCONFIGURED,                                            NULL,        0,        iptr:&rach_groupBconfigured,                                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_RA_MSG3SIZEGROUPA,                                           NULL,        0,        iptr:&rach_ra_Msg3SizeGroupA,                                           defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB,                                    NULL,        0,        iptr:&rach_messagePowerOffsetGroupB,                                    defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_NUMBEROFRA_PREAMBLESGROUPA,                                  NULL,        0,        iptr:&rach_numberOfRA_PreamblesGroupA,                                  defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_RA_CONTENTIONRESOLUTIONTIMER,                                NULL,        0,        iptr:&rach_ra_ContentionResolutionTimer,                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RSRP_THRESHOLDSSB,                                                NULL,        0,        iptr:&rsrp_ThresholdSSB,                                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RSRP_THRESHOLDSSB_SUL,                                            NULL,        0,        iptr:&rsrp_ThresholdSSB_SUL,                                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_CHOICE,                                   NULL,        0,        iptr:&prach_RootSequenceIndex_choice,                                   defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L839,                                     NULL,        0,        iptr:&prach_RootSequenceIndex_l839,                                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L139,                                     NULL,        0,        iptr:&prach_RootSequenceIndex_l139,                                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PRACH_MSG1_SUBCARRIERSPACING,                                     NULL,        0,        iptr:&prach_msg1_SubcarrierSpacing,                                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RESTRICTEDSETCONFIG,                                              NULL,        0,        iptr:&restrictedSetConfig,                                              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_MSG3_TRANSFORMPRECODING,                                          NULL,        0,        iptr:&msg3_transformPrecoding,                                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PRACH_CONFIGURATIONINDEX,                                         NULL,        0,        iptr:&prach_ConfigurationIndex,                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PRACH_MSG1_FDM,                                                   NULL,        0,        iptr:&prach_msg1_FDM,                                                   defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PRACH_MSG1_FREQUENCYSTART,                                        NULL,        0,        iptr:&prach_msg1_FrequencyStart,                                        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_ZEROCORRELATIONZONECONFIG,                                        NULL,        0,        iptr:&zeroCorrelationZoneConfig,                                        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PREAMBLERECEIVEDTARGETPOWER,                                      NULL,        0,        iptr:&preambleReceivedTargetPower,                                      defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PREAMBLETRANSMAX,                                                 NULL,        0,        iptr:&preambleTransMax,                                                 defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_POWERRAMPINGSTEP,                                                 NULL,        0,        iptr:&powerRampingStep,                                                 defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RA_RESPONSEWINDOW,                                                NULL,        0,        iptr:&ra_ResponseWindow,                                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_GROUPHOPPINGENABLEDTRANSFORMPRECODING,                            NULL,        0,        iptr:&groupHoppingEnabledTransformPrecoding,                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_MSG3_DELTAPREAMBLE,                                               NULL,        0,        iptr:&msg3_DeltaPreamble,                                               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_P0_NOMINALWITHGRANT,                                              NULL,        0,        iptr:&p0_NominalWithGrant,                                              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_K2,                            NULL,        0,        iptr:&PUSCH_TimeDomainResourceAllocation_k2,                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE,                   NULL,        0,        iptr:&PUSCH_TimeDomainResourceAllocation_mappingType,                   defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PUCCH_GROUPHOPPING,                                               NULL,        0,        iptr:&pucch_GroupHopping,                                               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_P0_NOMINAL,                                                       NULL,        0,        iptr:&p0_nominal,                                                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_K0,                            NULL,        0,        iptr:&PDSCH_TimeDomainResourceAllocation_k0,                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE,                   NULL,        0,        iptr:&PDSCH_TimeDomainResourceAllocation_mappingType,                   defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNID,                                               NULL,        0,        iptr:&rateMatchPatternId,                                               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERN_PATTERNTYPE,                                     NULL,        0,        iptr:&RateMatchPattern_patternType,                                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SYMBOLSINRESOURCEBLOCK,                                           NULL,        0,        iptr:&symbolsInResourceBlock,                                           defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PERIODICITYANDPATTERN,                                            NULL,        0,        iptr:&periodicityAndPattern,                                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERN_CONTROLRESOURCESET,                              NULL,        0,        iptr:&RateMatchPattern_controlResourceSet,                              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERN_SUBCARRIERSPACING,                               NULL,        0,        iptr:&RateMatchPattern_subcarrierSpacing,                               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERN_MODE,                                            NULL,        0,        iptr:&RateMatchPattern_mode,                                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACESIB1,                                                  NULL,        0,        iptr:&searchSpaceSIB1,                                                  defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACEOTHERSYSTEMINFORMATION,                                NULL,        0,        iptr:&searchSpaceOtherSystemInformation,                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PAGINGSEARCHSPACE,                                                NULL,        0,        iptr:&pagingSearchSpace,                                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RA_SEARCHSPACE,                                                   NULL,        0,        iptr:&ra_SearchSpace,                                                   defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RACH_RA_CONTROLRESOURCESET,                                       NULL,        0,        iptr:&rach_ra_ControlResourceSet,                                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESETID,                                NULL,        0,        iptr:&PDCCH_common_controlResourceSetId,                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESET_DURATION,                         NULL,        0,        iptr:&PDCCH_common_ControlResourceSet_duration,                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_CCE_REG_MAPPINGTYPE,                                        NULL,        0,        iptr:&PDCCH_cce_REG_MappingType,                                        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_REG_BUNDLESIZE,                                             NULL,        0,        iptr:&PDCCH_reg_BundleSize,                                             defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_INTERLEAVERSIZE,                                            NULL,        0,        iptr:&PDCCH_interleaverSize,                                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_SHIFTINDEX,                                                 NULL,        0,        iptr:&PDCCH_shiftIndex,                                                 defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_PRECODERGRANULARITY,                                        NULL,        0,        iptr:&PDCCH_precoderGranularity,                                        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_PDCCH_TCI_STATEID,                                                NULL,        0,        iptr:&PDCCH_TCI_StateId,                                                defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_TCI_PRESENTINDCI,                                                 NULL,        0,        iptr:&tci_PresentInDCI,                                                 defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACEID,                                                    NULL,        0,        iptr:&SearchSpaceId,                                                    defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMONSEARCHSPACES_CONTROLRESOURCESETID,                          NULL,        0,        iptr:&commonSearchSpaces_controlResourceSetId,                          defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_CHOICE,            NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_choice,            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL1,               NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl1,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL2,               NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl2,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL4,               NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl4,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL5,               NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl5,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL8,               NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl8,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL10,              NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl10,              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL16,              NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl16,              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL20,              NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_sl20,              defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL1,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel1,                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL2,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel2,                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL4,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel4,                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL8,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel8,                     defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL16,                    NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel16,                    defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_SEARCHSPACE_SEARCHSPACETYPE,                                      NULL,        0,        iptr:&SearchSpace_searchSpaceType,                                      defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL1,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1,        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL2,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2,        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL4,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4,        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL8,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8,        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL16,       NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16,       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_MONITORINGPERIODICITY,                       NULL,        0,        iptr:&Common_dci_Format2_3_monitoringPeriodicity,                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_NROFPDCCH_CANDIDATES,                        NULL,        0,        iptr:&Common_dci_Format2_3_nrofPDCCH_Candidates,                        defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_UE_SPECIFIC__DCI_FORMATS,                                         NULL,        0,        iptr:&ue_Specific__dci_Formats,                                         defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERFREQDL,                            NULL,        0,        iptr:&RateMatchPatternLTE_CRS_carrierFreqDL,                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERBANDWIDTHDL,                       NULL,        0,        iptr:&RateMatchPatternLTE_CRS_carrierBandwidthDL,                       defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_NROFCRS_PORTS,                            NULL,        0,        iptr:&RateMatchPatternLTE_CRS_nrofCRS_Ports,                            defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_V_SHIFT,                                  NULL,        0,        iptr:&RateMatchPatternLTE_CRS_v_Shift,                                  defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONPERIOD,               NULL,        0,        iptr:&RateMatchPatternLTE_CRS_radioframeAllocationPeriod,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONOFFSET,               NULL,        0,        iptr:&RateMatchPatternLTE_CRS_radioframeAllocationOffset,               defintval:0,               TYPE_UINT,       0},  \
+{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_SUBFRAMEALLOCATION_CHOICE,                NULL,        0,        iptr:&RateMatchPatternLTE_CRS_subframeAllocation_choice,                defintval:0,               TYPE_UINT,       0},  \
+}
+
+
+/* component carries configuration parameters name */
+#define ENB_CONFIG_FRAME_TYPE_IDX                             0             
+#define ENB_CONFIG_DL_PREFIX_TYPE_IDX                            1
+#define ENB_CONFIG_UL_PREFIX_TYPE_IDX                            1
+#define ENB_CONFIG_EUTRA_BAND_IDX                             2
+#define ENB_CONFIG_DOWNLINK_FREQUENCY_IDX                     3
+#define ENB_CONFIG_UPLINK_FREQUENCY_OFFSET_IDX                4
+#define ENB_CONFIG_NID_CELL_IDX                               5
+#define ENB_CONFIG_N_RB_DL_IDX                                6
+#define GNB_CONFIG_NB_ANT_PORTS_IDX                                                 
+#define GNB_CONFIG_NB_ANT_TX_IDX                                                    
+#define GNB_CONFIG_NB_ANT_RX_IDX                                                   
+#define GNB_CONFIG_TX_GAIN_IDX                                                      
+#define GNB_CONFIG_RX_GAIN_IDX
+#define GNB_CONFIG_MIB_SUBCARRIERSPACINGCOMMON_IDX
+#define GNB_CONFIG_MIB_SSB_SUBCARRIEROFFSET_IDX 
+#define GNB_CONFIG_MIB_DMRS_TYPEA_POSITION_IDX
+#define GNB_CONFIG_PDCCH_CONFIGSIB1_IDX
+#define GNB_CONFIG_SIB1_FREQUENCYOFFSETSSB_IDX
+#define GNB_CONFIG_SIB1_SSB_PERIODICITYSERVINGCELL_IDX
+#define GNB_CONFIG_SIB1_SS_PBCH_BLOCKPOWER_IDX                                                   
+#define GNB_CONFIG_ABSOLUTEFREQUENCYSSB_IDX                                         
+#define GNB_CONFIG_SSB_SUBCARRIEROFFSET_IDX                                         
+#define GNB_CONFIG_DL_FREQBANDINDICATORNR_IDX                                       
+#define GNB_CONFIG_DL_ABSOLUTEFREQUENCYPOINTA_IDX                                   
+#define GNB_CONFIG_DL_OFFSETTOCARRIER_IDX                                           
+#define GNB_CONFIG_DL_SUBCARRIERSPACING_IDX                                         
+#define GNB_CONFIG_DL_SCS_SPECIFICCARRIER_K0_IDX                                    
+#define GNB_CONFIG_DL_CARRIERBANDWIDTH_IDX                                          
+#define GNB_CONFIG_DL_LOCATIONANDBANDWIDTH_IDX
+#define GNB_CONFIG_DL_BWP_SUBCARRIERSPACING_IDX
+#define GNB_CONFIG_DL_BWP_PREFIX_TYPE_IDX                                      
+#define GNB_CONFIG_UL_FREQBANDINDICATORNR_IDX                                       
+#define GNB_CONFIG_UL_ABSOLUTEFREQUENCYPOINTA_IDX 
+#define GNB_CONFIG_UL_ADDITIONALSPECTRUMEMISSION_IDX;                                  
+#define GNB_CONFIG_UL_P_MAX_IDX                                        
+#define GNB_CONFIG_UL_FREQUENCYSHIFT7P5KHZ_IDX                                         
+#define GNB_CONFIG_UL_OFFSETTOCARRIER_IDX                                           
+#define GNB_CONFIG_UL_SCS_SUBCARRIERSPACING_IDX                                         
+#define GNB_CONFIG_UL_SCS_SPECIFICCARRIER_K0_IDX                                    
+#define GNB_CONFIG_UL_CARRIERBANDWIDTH_IDX                                          
+#define GNB_CONFIG_UL_LOCATIONANDBANDWIDTH_IDX
+#define GNB_CONFIG_UL_BWP_SUBCARRIERSPACING_IDX
+#define GNB_CONFIG_UL_BWP_PREFIX_TYPE_IDX
+#define GNB_CONFIG_SUBCARRIERSPACINGCOMMON_IDX
+#define GNB_CONFIG_PDCCH_CONFIGSIB1_IDX
+#define GNB_CONFIG_FREQUENCYOFFSETSSB_IDX
+#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR_IDX                                      
+#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL_IDX                                  
+#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION_IDX                                          
+#define GNB_CONFIG_NIA_SUBCARRIERSPACING_IDX                                        
+#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_SS_PBCH_BLOCKPOWER_IDX                                           
+#define GNB_CONFIG_REFERENCESUBCARRIERSPACING_IDX                                   
+#define GNB_CONFIG_DL_UL_TRANSMISSIONPERIODICITY_IDX                                
+#define GNB_CONFIG_NROFDOWNLINKSLOTS_IDX                                            
+#define GNB_CONFIG_NROFDOWNLINKSYMBOLS_IDX                                          
+#define GNB_CONFIG_NROFUPLINKSLOTS_IDX                                              
+#define GNB_CONFIG_NROFUPLINKSYMBOLS_IDX                                            
+#define GNB_CONFIG_RACH_TOTALNUMBEROFRA_PREAMBLES_IDX                               
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_CHOICE_IDX        
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEEIGHTH_IDX     
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEFOURTH_IDX     
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEHALF_IDX       
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONE_IDX         
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_TWO_IDX           
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_FOUR_IDX          
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_EIGHT_IDX         
+#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_SIXTEEN_IDX       
+#define GNB_CONFIG_RACH_GROUPBCONFIGURED_IDX                                        
+#define GNB_CONFIG_RACH_RA_MSG3SIZEGROUPA_IDX                                       
+#define GNB_CONFIG_RACH_MESSAGEPOWEROFFSETGROUPB_IDX                                
+#define GNB_CONFIG_RACH_NUMBEROFRA_PREAMBLESGROUPA_IDX                              
+#define GNB_CONFIG_RACH_RA_CONTENTIONRESOLUTIONTIMER_IDX                           
+#define GNB_CONFIG_RSRP_THRESHOLDSSB_IDX                                            
+#define GNB_CONFIG_RSRP_THRESHOLDSSB_SUL_IDX                                        
+#define GNB_CONFIG_PRACH_ROOTSEQUENCEINDEX_CHOICE_IDX                               
+#define GNB_CONFIG_PRACH_ROOTSEQUENCEINDEX_L839_IDX                                
+#define GNB_CONFIG_PRACH_ROOTSEQUENCEINDEX_L139_IDX                                 
+#define GNB_CONFIG_PRACH_MSG1_SUBCARRIERSPACING_IDX                                
+#define GNB_CONFIG_RESTRICTEDSETCONFIG_IDX                                          
+#define GNB_CONFIG_MSG3_TRANSFORMPRECODING_IDX                                      
+#define GNB_CONFIG_PRACH_CONFIGURATIONINDEX_IDX                                    
+#define GNB_CONFIG_PRACH_MSG1_FDM_IDX                                              
+#define GNB_CONFIG_PRACH_MSG1_FREQUENCYSTART_IDX                                    
+#define GNB_CONFIG_ZEROCORRELATIONZONECONFIG_IDX                                    
+#define GNB_CONFIG_PREAMBLERECEIVEDTARGETPOWER_IDX                                  
+#define GNB_CONFIG_PREAMBLETRANSMAX_IDX                                            
+#define GNB_CONFIG_POWERRAMPINGSTEP_IDX                                             
+#define GNB_CONFIG_RA_RESPONSEWINDOW_IDX                                            
+#define GNB_CONFIG_GROUPHOPPINGENABLEDTRANSFORMPRECODING_IDX                        
+#define GNB_CONFIG_MSG3_DELTAPREAMBLE_IDX                                          
+#define GNB_CONFIG_P0_NOMINALWITHGRANT_IDX                                          
+#define GNB_CONFIG_PUSCH_TIMEDOMAINRESOURCEALLOCATION_K2_IDX                        
+#define GNB_CONFIG_PUSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE_IDX               
+#define GNB_CONFIG_PUCCH_GROUPHOPPING_IDX                                           
+#define GNB_CONFIG_P0_NOMINAL_IDX                                                 
+#define GNB_CONFIG_PDSCH_TIMEDOMAINRESOURCEALLOCATION_K0_IDX                        
+#define GNB_CONFIG_PDSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE_IDX               
+#define GNB_CONFIG_RATEMATCHPATTERNID_IDX                                           
+#define GNB_CONFIG_RATEMATCHPATTERN_PATTERNTYPE_IDX                                 
+#define GNB_CONFIG_SYMBOLSINRESOURCEBLOCK_IDX                                       
+#define GNB_CONFIG_PERIODICITYANDPATTERN_IDX                                        
+#define GNB_CONFIG_RATEMATCHPATTERN_CONTROLRESOURCESET_IDX                          
+#define GNB_CONFIG_RATEMATCHPATTERN_SUBCARRIERSPACING_IDX                           
+#define GNB_CONFIG_RATEMATCHPATTERN_MODE_IDX                                        
+#define GNB_CONFIG_SEARCHSPACESIB1_IDX                                              
+#define GNB_CONFIG_SEARCHSPACEOTHERSYSTEMINFORMATION_IDX                            
+#define GNB_CONFIG_PAGINGSEARCHSPACE_IDX                                            
+#define GNB_CONFIG_RA_SEARCHSPACE_IDX                                               
+#define GNB_CONFIG_RACH_RA_CONTROLRESOURCESET_IDX                                  
+#define GNB_CONFIG_PDCCH_COMMON_CONTROLRESOURCESETID_IDX                            
+#define GNB_CONFIG_PDCCH_COMMON_CONTROLRESOURCESET_DURATION_IDX                     
+#define GNB_CONFIG_PDCCH_CCE_REG_MAPPINGTYPE_IDX                                    
+#define GNB_CONFIG_PDCCH_REG_BUNDLESIZE_IDX                                        
+#define GNB_CONFIG_PDCCH_INTERLEAVERSIZE_IDX                                        
+#define GNB_CONFIG_PDCCH_SHIFTINDEX_IDX                                             
+#define GNB_CONFIG_PDCCH_PRECODERGRANULARITY_IDX
+#define GNB_CONFIG_PDCCH_TCI_STATEID_IDX
+#define GNB_CONFIG_TCI_PRESENTINDCI_IDX                                             
+#define GNB_CONFIG_SEARCHSPACEID_IDX                                                
+#define GNB_CONFIG_COMMONSEARCHSPACES_CONTROLRESOURCESETID_IDX                      
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_CHOICE_IDX        
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL1_IDX           
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL2_IDX           
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL4_IDX           
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL5_IDX           
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL8_IDX           
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL10_IDX         
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL16_IDX          
+#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_SL20_IDX          
+#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL1_IDX                 
+#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL2_IDX                 
+#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL4_IDX                 
+#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL8_IDX                 
+#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL16_IDX                
+#define GNB_CONFIG_SEARCHSPACE_SEARCHSPACETYPE_IDX                                  
+#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL1_IDX   
+#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL2_IDX   
+#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL4_IDX    
+#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL8_IDX    
+#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL16_IDX   
+#define GNB_CONFIG_COMMON_DCI_FORMAT2_3_MONITORINGPERIODICITY_IDX                   
+#define GNB_CONFIG_COMMON_DCI_FORMAT2_3_NROFPDCCH_CANDIDATES_IDX                   
+#define GNB_CONFIG_UE_SPECIFIC__DCI_FORMATS_IDX                                     
+#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_CARRIERFREQDL_IDX 
+#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_CARRIERBANDWIDTHDL_IDX 
+#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_NROFCRS_PORTS_IDX 
+#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_V_SHIFT_IDX 
+#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONPERIOD_IDX 
+#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONOFFSET_IDX 
+#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_SUBFRAMEALLOCATION_CHOICE_IDX 
\ No newline at end of file
diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c
new file mode 100644
index 0000000000000000000000000000000000000000..c699ad5232b8761475644a3a677965e1e78913b3
--- /dev/null
+++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c
@@ -0,0 +1,126 @@
+
+/*
+ * 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 config.c
+ * \brief UE and eNB configuration performed by RRC or as a consequence of RRC procedures
+ * \author  Navid Nikaein and Raymond Knopp
+ * \date 2010 - 2014
+ * \version 0.1
+ * \email: navid.nikaein@eurecom.fr
+ * @ingroup _mac
+
+ */
+
+int
+nr_rrc_mac_config_req_ue(
+    module_id_t Mod_idP,
+	int CC_idP,
+	uint8_t eNB_index,
+    MAC_CellGroupConfig_t *mac_cell_group_config,
+    PhysicalCellGroupConfig_t *phy_cell_group_config,
+    SpCellConfig_t *spcell_config){
+
+    NR_UE_MAC_INST *mac = get_mac_inst(Mod_idP);
+
+    ServingCellConfig_t *serving_cell_config = spcell_config->spCellConfigDedicated;
+//  TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc.
+
+    if(mac_cell_group_config != (MAC_CellGroupConfig_t *)0){
+        if(mac_cell_group_config->drx_Config != (drx_Config_t *)0 ){
+            mac->drx_Config = mac_cell_group_config->drx_Config;
+        }
+
+        if(mac_cell_group_config->SchedulingRequestConfig != (SchedulingRequestConfig_t *)0 ){
+            mac->SchedulingRequestConfig = mac_cell_group_config->SchedulingRequestConfig;
+        }
+
+        if(mac_cell_group_config->BSR_Config != (BSR_Config_t *)0 ){
+            mac->BSR_Config = mac_cell_group_config->BSR_Config;
+        }
+
+        if(mac_cell_group_config->TAG_Config != (TAG_Config_t *)0 ){
+            mac->TAG_Config = mac_cell_group_config->TAG_Config;
+        }
+
+        if(mac_cell_group_config->phr_Config != (phr_Config_t *)0 ){
+            mac->phr_Config = mac_cell_group_config->phr_Config;
+        }
+
+        if(mac_cell_group_config->cs_RNTI != (cs_RNTI_t *)0 ){
+            mac->cs_RNTI = mac_cell_group_config->cs_RNTI;
+        }
+    }
+    
+    if(phy_cell_group_config != (PhysicalCellGroupConfig_t *)0){
+        config_phy(phy_cell_group_config, NULL);
+    }
+
+    if(serving_cell_config_config != (SpCellConfig_t *)0){
+        config_phy(NULL, spcell_config);
+        mac->servCellIndex = spcell_config->servCellIndex;
+    }
+
+
+    if(serving_cell_config != (spCellConfigDedicated_t *)0){
+        if(serving_cell_config->tdd_UL_DL_ConfigurationDedicated != (TDD_UL_DL_ConfigDedicated_t *)0){
+            mac->tdd_UL_DL_ConfigurationDedicated = serving_cell_config->tdd_UL_DL_ConfigurationDedicated;
+        }
+        
+        if(spcell_config->initialDownlinkBWP != (BWP_DownlinkDedicated_t *)0){
+            mac->init_DL_BWP = spcell_config->initialDownlinkBWP;
+        }
+        
+        //  storage list of DL BWP config. TODO should be modify to maintain(add/release) a list inside MAC instance, this implementation just use for one-shot RRC configuration setting.
+        if(spcell_config->downlinkBWP_ToAddModList != (struct ServingCellConfig__downlinkBWP_ToAddModList *)0){
+            mac->BWP_Downlink_list = spcell_config->downlinkBWP_ToAddModList->list;
+            mac->BWP_Downlink_count = spcell_config->downlinkBWP_ToAddModList->count;
+        }
+        
+        if(spcell_config->bwp_InactivityTimer != (long *)0){
+            mac->bwp_InactivityTimer = spcell_config->bwp_InactivityTimer;
+        } 
+
+        if(spcell_config->defaultDownlinkBWP_Id != (BWP_Id_t *)0){
+            mac->defaultDownlinkBWP_Id = spcell_config->defaultDownlinkBWP_Id;
+        }
+
+        if(spcell_config->pdsch_ServingCellConfig != (PDSCH_ServingCellConfig_t *)0){
+            mac->pdsch_ServingCellConfig = spcell_config->pdsch_ServingCellConfig;
+        }
+
+        if(spcell_config->csi_MeasConfig != (CSI_MeasConfig_t *)0){
+            mac->csi_MeasConfig = spcell_config->csi_MeasConfig;
+        }
+
+        spcell_config->tag_Id = spcell_config.tag_Id;
+    }
+
+    //scell config not yet
+
+
+
+
+
+
+
+    return (0);
+}
diff --git a/openair2/LAYER2/NR_MAC_UE/defs.h b/openair2/LAYER2/NR_MAC_UE/defs.h
new file mode 100644
index 0000000000000000000000000000000000000000..e7329616b7fca0654f0c98e2f051c6b76786131f
--- /dev/null
+++ b/openair2/LAYER2/NR_MAC_UE/defs.h
@@ -0,0 +1,108 @@
+/*
+ * 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__
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.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"
+
+
+/*!\brief Top level UE MAC structure */
+typedef struct {
+    
+    ////  MAC config
+    drx_Config_t *drx_config;
+    SchedulingRequestConfig_t *SchedulingRequestConfig;
+    BSR_Config_t *BSR_Config;
+    TAG_Config_t *TAG_Config;
+    phr_Config_t *phr_Config;
+    cs_RNTI_t *cs_RNTI;
+    ServCellIndex_t *servCellIndex;
+
+    ////  Serving cell config
+    TDD_UL_DL_ConfigDedicated_t *tdd_UL_DL_ConfigurationDedicated;
+    //  init DL BWP
+    BWP_DownlinkDedicated_t *init_DL_BWP;
+    //  DL BWP list, not default one
+    BWP_Downlink_t **BWP_Downlink_list;
+    int BWP_Downlink_count;
+    //BWP_Id_t *firstActiveDownlinkBWP_Id;
+    long *bwp_InactivityTimer;
+    BWP_Id_t *defaultDownlinkBWP_Id;
+    //struct UplinkConfig *uplinkConfig;
+    //struct UplinkConfig *supplementaryUplink;
+    PDSCH_ServingCellConfig_t *pdsch_ServingCellConfig;
+    CSI_MeasConfig_t *csi_MeasConfig;
+    //SRS_CarrierSwitching_t *carrierSwitching;
+    //long *sCellDeactivationTimer /* OPTIONAL */;
+    //struct CrossCarrierSchedulingConfig *crossCarrierSchedulingConfig   /* OPTIONAL */;
+    TAG_Id_t tag_Id;
+    //long *ue_BeamLockFunction    /* OPTIONAL */;
+    //long *pathlossReferenceLinking   /* OPTIONAL */;    
+
+} UE_MAC_INST;
+#include "proto.h"
+/*@}*/
+#endif /*__LAYER2_MAC_DEFS_H__ */
diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..a1c3688fc485f293702905317a016cca180a09d9
--- /dev/null
+++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
@@ -0,0 +1,55 @@
+/*
+ * 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 main.c
+ * \brief top init of Layer 2
+ * \author  Navid Nikaein and Raymond Knopp
+ * \date 2010 - 2014
+ * \version 1.0
+ * \email: navid.nikaein@eurecom.fr
+ * @ingroup _mac
+
+ */
+
+#include "defs.h"
+#include "proto.h"
+#include "extern.h"
+#include "assertions.h"
+
+static NR_UE_MAC_INST_t *nr_ue_mac_inst; 
+
+int
+nr_l2_init_ue(void)
+{
+    LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n");
+
+    LOG_I(MAC, "[MAIN] init UE MAC functions \n");
+    
+    //init mac here
+    nr_ue_mac_inst = (NR_UE_MAC_INST_t *)malloc(sizeof(NR_UE_MAC_INST_t)*NB_NR_UE_MAC_INST);
+    
+
+    return (1);
+}
+
+NR_UE_MAC_INST_t *get_mac_inst(Module_id_t Mod_idP){
+    return &nr_ue_mac_inst[(int)Mod_idP];
+}
diff --git a/openair2/LAYER2/NR_MAC_UE/vars.c b/openair2/LAYER2/NR_MAC_UE/vars.c
new file mode 100644
index 0000000000000000000000000000000000000000..300917b3c1f06619f4670fa4f54056e86ae7b275
--- /dev/null
+++ b/openair2/LAYER2/NR_MAC_UE/vars.c
@@ -0,0 +1,34 @@
+/*
+ * 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 vars.h
+* \brief mac vars
+* \author  Navid Nikaein and Raymond Knopp
+* \date 2010 - 2014
+* \version 1.0
+* \email navid.nikaein@eurecom.fr
+* @ingroup _mac
+
+*/
+
+UE_MAC_INST_t UE_mac_inst;	//[NB_MODULE_MAX];
+
+
diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/openair2/NR_PHY_INTERFACE/IF_Module.h b/openair2/NR_PHY_INTERFACE/IF_Module.h
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/openair2/NR_UE_PHY_INTERFACE/IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/IF_Module.c
new file mode 100644
index 0000000000000000000000000000000000000000..d0b8e5755858bbaf3ac64711016a8debce09b04c
--- /dev/null
+++ b/openair2/NR_UE_PHY_INTERFACE/IF_Module.c
@@ -0,0 +1,647 @@
+#include "openair1/PHY/defs.h"
+#include "openair2/PHY_INTERFACE/IF_Module.h"
+#include "openair1/PHY/extern.h"
+#include "LAYER2/MAC/extern.h"
+#include "LAYER2/MAC/proto.h"
+#include "common/ran_context.h"
+
+#define MAX_IF_MODULES 100
+
+IF_Module_t *if_inst[MAX_IF_MODULES];
+Sched_Rsp_t Sched_INFO[MAX_IF_MODULES][MAX_NUM_CCs];
+
+extern int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind);
+extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind);
+extern int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *cqi_ind);
+extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind);
+extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind);
+extern uint8_t nfapi_mode;
+extern uint16_t sf_ahead;
+
+void handle_rach(UL_IND_t *UL_info) {
+  int i;
+
+  if (UL_info->rach_ind.rach_indication_body.number_of_preambles>0) {
+
+    AssertFatal(UL_info->rach_ind.rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n");
+    UL_info->rach_ind.rach_indication_body.number_of_preambles=0;
+    LOG_D(MAC,"UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->subframe, NFAPI_SFNSF2DEC(UL_info->rach_ind.sfn_sf));
+    initiate_ra_proc(UL_info->module_id,
+		     UL_info->CC_id,
+		     NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf),
+		     NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf),
+		     UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
+		     UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
+		     UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti
+#ifdef Rel14
+		     ,0
+#endif
+		     );
+  }
+
+#ifdef Rel14
+  if (UL_info->rach_ind_br.rach_indication_body.number_of_preambles>0) {
+
+    AssertFatal(UL_info->rach_ind_br.rach_indication_body.number_of_preambles<5,"More than 4 preambles not supported\n");
+    for (i=0;i<UL_info->rach_ind_br.rach_indication_body.number_of_preambles;i++) {
+      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);
+      initiate_ra_proc(UL_info->module_id,
+		       UL_info->CC_id,
+		       UL_info->frame,
+		       UL_info->subframe,
+		       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.preamble,
+		       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.timing_advance,
+		       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.rnti,
+		       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type);
+    }
+    UL_info->rach_ind_br.rach_indication_body.number_of_preambles=0;
+  }
+#endif
+}
+
+void handle_sr(UL_IND_t *UL_info) {
+
+  int i;
+
+  if (nfapi_mode == 1)  // PNF
+  {
+    if (UL_info->sr_ind.sr_indication_body.number_of_srs>0)
+    {
+      oai_nfapi_sr_indication(&UL_info->sr_ind);
+    }
+  }
+  else
+  {
+    for (i=0;i<UL_info->sr_ind.sr_indication_body.number_of_srs;i++)
+      SR_indication(UL_info->module_id,
+          UL_info->CC_id,
+          UL_info->frame,
+          UL_info->subframe,
+          UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].rx_ue_information.rnti,
+          UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].ul_cqi_information.ul_cqi);
+  }
+
+  UL_info->sr_ind.sr_indication_body.number_of_srs=0;
+}
+
+void handle_cqi(UL_IND_t *UL_info) {
+
+  int i;
+
+  if (nfapi_mode == 1)
+  {
+    if (UL_info->cqi_ind.number_of_cqis>0)
+    {
+      LOG_D(PHY,"UL_info->cqi_ind.number_of_cqis:%d\n", UL_info->cqi_ind.number_of_cqis);
+      nfapi_cqi_indication_t ind;
+
+      ind.header.message_id = NFAPI_RX_CQI_INDICATION;
+      ind.sfn_sf = UL_info->frame<<4 | UL_info->subframe;
+      ind.cqi_indication_body = UL_info->cqi_ind;
+
+      oai_nfapi_cqi_indication(&ind);
+
+      UL_info->cqi_ind.number_of_cqis=0;
+    }
+  }
+  else
+  {
+    for (i=0;i<UL_info->cqi_ind.number_of_cqis;i++) 
+      cqi_indication(UL_info->module_id,
+          UL_info->CC_id,
+          UL_info->frame,
+          UL_info->subframe,
+          UL_info->cqi_ind.cqi_pdu_list[i].rx_ue_information.rnti,
+          &UL_info->cqi_ind.cqi_pdu_list[i].cqi_indication_rel9,
+          UL_info->cqi_ind.cqi_raw_pdu_list[i].pdu,
+          &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information);
+
+    UL_info->cqi_ind.number_of_cqis=0;
+  }
+}
+
+void handle_harq(UL_IND_t *UL_info) {
+
+  int i;
+
+  if (nfapi_mode == 1 && UL_info->harq_ind.harq_indication_body.number_of_harqs>0) // PNF
+  {
+    //LOG_D(PHY, "UL_info->harq_ind.harq_indication_body.number_of_harqs:%d Send to VNF\n", UL_info->harq_ind.harq_indication_body.number_of_harqs);
+
+    int retval = oai_nfapi_harq_indication(&UL_info->harq_ind);
+
+    if (retval!=0)
+    {
+      LOG_E(PHY, "Failed to encode NFAPI HARQ_IND retval:%d\n", retval);
+    }
+
+    UL_info->harq_ind.harq_indication_body.number_of_harqs = 0;
+  }
+  else
+  {
+    for (i=0;i<UL_info->harq_ind.harq_indication_body.number_of_harqs;i++)
+      harq_indication(UL_info->module_id,
+          UL_info->CC_id,
+          NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf),
+          NFAPI_SFNSF2SF(UL_info->harq_ind.sfn_sf),
+          &UL_info->harq_ind.harq_indication_body.harq_pdu_list[i]);
+
+    UL_info->harq_ind.harq_indication_body.number_of_harqs=0;
+  }
+}
+
+void handle_ulsch(UL_IND_t *UL_info) {
+
+  int i,j;
+
+  if(nfapi_mode == 1)
+  {
+    if (UL_info->crc_ind.crc_indication_body.number_of_crcs>0)
+    {
+      //LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf));
+
+      oai_nfapi_crc_indication(&UL_info->crc_ind);
+
+      UL_info->crc_ind.crc_indication_body.number_of_crcs = 0;
+    }
+
+    if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0)
+    {
+      //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
+      oai_nfapi_rx_ind(&UL_info->rx_ind);
+      UL_info->rx_ind.rx_indication_body.number_of_pdus = 0;
+    }
+  }
+  else
+  {
+    if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) {
+      for (i=0;i<UL_info->rx_ind.rx_indication_body.number_of_pdus;i++) {
+        for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) {
+          // find crc_indication j corresponding rx_indication i
+          LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti, i, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti);
+          if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti ==
+              UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti) {
+            LOG_D(PHY, "UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].crc_indication_rel8.crc_flag:%d\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag);
+            if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication
+              LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->subframe);
+              rx_sdu(UL_info->module_id,
+                  UL_info->CC_id,
+                  NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
+                  NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
+                  (uint8_t *)NULL,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
+            }
+            else {
+              LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->subframe);
+              rx_sdu(UL_info->module_id,
+                  UL_info->CC_id,
+                  NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
+                  NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
+                  UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
+            }
+            break;
+          } //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti ==
+          //    UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti)
+        } //    for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++)
+      } //   for (i=0;i<UL_info->rx_ind.number_of_pdus;i++)
+      UL_info->crc_ind.crc_indication_body.number_of_crcs=0;
+      UL_info->rx_ind.rx_indication_body.number_of_pdus = 0;
+    } // UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->subframe && UL_info->crc_ind.crc_indication_body.number_of_crcs>0
+    else if (UL_info->rx_ind.rx_indication_body.number_of_pdus!=0 || UL_info->crc_ind.crc_indication_body.number_of_crcs!=0) {
+      LOG_E(PHY,"hoping not to have mis-match between CRC ind and RX ind - hopefully the missing message is coming shortly rx_ind:%d(SFN/SF:%05d) crc_ind:%d(SFN/SF:%05d) UL_info(SFN/SF):%04d%d\n",
+          UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf),
+          UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf),
+          UL_info->frame, UL_info->subframe);
+    }
+  }
+}
+
+/****************************************************************************/
+/* debug utility functions begin                                            */
+/****************************************************************************/
+
+//#define DUMP_FAPI
+
+#ifdef DUMP_FAPI
+
+#define C do { size = 0; put(0); } while (0)
+#define A(...) do { char t[4096]; sprintf(t, __VA_ARGS__); append_string(t); } while (0)
+
+#if 0
+
+/* eats lots of ms at startup, disrupts realtime */
+static char *s;
+static int size;
+static int maxsize;
+
+static void put(char x)
+{
+  if (size == maxsize) {
+    maxsize += 32768;
+    s = realloc(s, maxsize); if (s == NULL) abort();
+  }
+  s[size++] = x;
+}
+
+#else
+
+/* eats nothing at startup, but fixed size */
+#define SMAX 65536
+static char s[SMAX];
+static int size;
+static int maxsize = SMAX;
+
+static void put(char x)
+{
+  if (size == maxsize) { printf("incrase SMAX\n"); exit(1); }
+  s[size++] = x;
+}
+
+#endif
+
+static void append_string(char *t)
+{
+  size--;
+  while (*t) put(*t++);
+  put(0);
+}
+
+static void dump_ul(UL_IND_t *u)
+{
+  int i;
+
+  C;
+  A("XXXX UL  mod %d CC %d f.sf %d.%d\n",
+    u->module_id, u->CC_id, u->frame, u->subframe);
+
+  A("XXXX     harq_ind %d\n", u->harq_ind.harq_indication_body.number_of_harqs);
+      for (i = 0; i < u->harq_ind.harq_indication_body.number_of_harqs; i++) {
+        nfapi_harq_indication_pdu_t *v = &u->harq_ind.harq_indication_body.harq_pdu_list[i];
+  A("XXXX         harq ind %d\n", i);
+  A("XXXX         rnti %d\n", v->rx_ue_information.rnti);
+  A("XXXX         tb1 %d tb2 %d\n", v->harq_indication_fdd_rel8.harq_tb1,
+                                    v->harq_indication_fdd_rel8.harq_tb2);
+  A("XXXX         number_of_ack_nack %d\n",
+                          v->harq_indication_fdd_rel9.number_of_ack_nack);
+  A("XXXX             harq[0] = %d\n",
+                                    v->harq_indication_fdd_rel9.harq_tb_n[0]);
+  A("XXXX harq        ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi,
+                                           v->ul_cqi_information.channel);
+      }
+
+  A("XXXX     crc_ind  %d\n", u->crc_ind.crc_indication_body.number_of_crcs);
+
+  A("XXXX     sr_ind   %d\n", u->sr_ind.sr_indication_body.number_of_srs);
+
+  A("XXXX     cqi_ind  %d\n", u->cqi_ind.number_of_cqis);
+      for (i = 0; i < u->cqi_ind.number_of_cqis; i++) {
+        nfapi_cqi_indication_pdu_t *v = &u->cqi_ind.cqi_pdu_list[i];
+  A("XXXX         cqi ind %d\n", i);
+  A("XXXX cqi         ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi,
+                                               v->ul_cqi_information.channel);
+      }
+
+  A("XXXX     rach_ind %d\n", u->rach_ind.rach_indication_body.number_of_preambles);
+
+  A("XXXX     rx_ind   %d\n", u->rx_ind.rx_indication_body.number_of_pdus);
+      for (i = 0; i < u->rx_ind.rx_indication_body.number_of_pdus; i++) {
+        nfapi_rx_indication_pdu_t *v = &u->rx_ind.rx_indication_body.rx_pdu_list[i];
+  A("XXXX         rx ind %d\n", i);
+  A("XXXX             timing_advance %d\n",
+                                    v->rx_indication_rel8.timing_advance);
+  A("XXXX rx          ul_cqi %d\n", v->rx_indication_rel8.ul_cqi);
+      }
+
+  LOG_I(PHY, "XXXX UL\nXXXX UL\n%s", s);
+}
+
+static char *DL_PDU_TYPE(int x)
+{
+  switch (x) {
+  case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: return "NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE";
+  case NFAPI_DL_CONFIG_BCH_PDU_TYPE: return "NFAPI_DL_CONFIG_BCH_PDU_TYPE";
+  case NFAPI_DL_CONFIG_MCH_PDU_TYPE: return "NFAPI_DL_CONFIG_MCH_PDU_TYPE";
+  case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: return "NFAPI_DL_CONFIG_DLSCH_PDU_TYPE";
+  case NFAPI_DL_CONFIG_PCH_PDU_TYPE: return "NFAPI_DL_CONFIG_PCH_PDU_TYPE";
+  case NFAPI_DL_CONFIG_PRS_PDU_TYPE: return "NFAPI_DL_CONFIG_PRS_PDU_TYPE";
+  case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: return "NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE";
+  case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: return "NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE";
+  case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: return "NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE";
+  case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NBCH_PDU_TYPE";
+  case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE";
+  case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE";
+  }
+  return "UNKNOWN";
+}
+
+static char *UL_PDU_TYPE(int x)
+{
+  switch (x) {
+  case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_PDU_TYPE";
+  case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE";
+  case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE";
+  case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE";
+  case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE";
+  case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE";
+  case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE";
+  case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE";
+  case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE";
+  case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE";
+  case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE";
+  case NFAPI_UL_CONFIG_SRS_PDU_TYPE: return "NFAPI_UL_CONFIG_SRS_PDU_TYPE";
+  case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE: return "NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE";
+  case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE";
+  case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE";
+  case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE";
+  case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE: return "NFAPI_UL_CONFIG_NULSCH_PDU_TYPE";
+  case NFAPI_UL_CONFIG_NRACH_PDU_TYPE: return "NFAPI_UL_CONFIG_NRACH_PDU_TYPE";
+  }
+  return "UNKNOWN";
+}
+
+static char *HI_DCI0_PDU_TYPE(int x)
+{
+  switch (x) {
+  case NFAPI_HI_DCI0_HI_PDU_TYPE: return "NFAPI_HI_DCI0_HI_PDU_TYPE";
+  case NFAPI_HI_DCI0_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_DCI_PDU_TYPE";
+  case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE";
+  case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE";
+  case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE";
+  }
+  return "UNKNOWN";
+}
+
+static void dump_dl(Sched_Rsp_t *d)
+{
+  int i;
+
+  C;
+  A("XXXX DL  mod %d CC %d f.sf %d.%d\n",
+    d->module_id, d->CC_id, d->frame, d->subframe);
+
+      if (d->DL_req != NULL) {
+        nfapi_dl_config_request_body_t *v=&d->DL_req->dl_config_request_body;
+        nfapi_dl_config_request_pdu_t *p = v->dl_config_pdu_list;
+  A("XXXX     DL_req sfnsf %d\n", d->DL_req->sfn_sf);
+  A("XXXX     PDCCH size   %d\n", v->number_pdcch_ofdm_symbols);
+  A("XXXX     DCIs         %d\n", v->number_dci);
+  A("XXXX     PDUs         %d\n", v->number_pdu);
+  A("XXXX     rntis        %d\n", v->number_pdsch_rnti);
+  A("XXXX     pcfich power %d\n", v->transmission_power_pcfich);
+        for (i = 0; i < v->number_pdu; i++) {
+  A("XXXX         pdu %d\n", i);
+  A("XXXX             type %d %s\n", p[i].pdu_type, DL_PDU_TYPE(p[i].pdu_type));
+          switch (p[i].pdu_type) {
+          case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: {
+            nfapi_dl_config_dci_dl_pdu_rel8_t *q =
+                &p[i].dci_dl_pdu.dci_dl_pdu_rel8;
+  A("XXXX                 dci format %d\n", q->dci_format);
+  A("XXXX                 cce idx    %d\n", q->cce_idx);
+  A("XXXX                 agg lvl    %d\n", q->aggregation_level);
+  A("XXXX                 rnti       %d\n", q->rnti);
+  A("XXXX                 rb coding  %8.8x\n", q->resource_block_coding);
+  A("XXXX                 mcs_1      %d\n", q->mcs_1);
+  A("XXXX                 rv_1       %d\n", q->redundancy_version_1);
+  A("XXXX                 ndi_1      %d\n", q->new_data_indicator_1);
+  A("XXXX                 harq pid   %d\n", q->harq_process);
+  A("XXXX                 tpc        %d\n", q->tpc);
+  A("XXXX                 tbs idx    %d\n", q->transport_block_size_index);
+  A("XXXX                 dl pow off %d\n", q->downlink_power_offset);
+  A("XXXX                 rnti type  %d\n", q->rnti_type);
+  A("XXXX                 xmit pow   %d\n", q->transmission_power);
+            break;
+          }
+          case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: {
+            nfapi_dl_config_dlsch_pdu_rel8_t *q =
+                &p[i].dlsch_pdu.dlsch_pdu_rel8;
+  A("XXXX                 pdu_index %d\n", q->pdu_index);
+  A("XXXX                 rnti      %d\n", q->rnti);
+  A("XXXX                 rv        %d\n", q->redundancy_version);
+  A("XXXX                 mcs       %d\n", q->modulation);
+  A("XXXX                 pa        %d\n", q->pa);
+            break;
+          }}
+        }
+      }
+
+      if (d->HI_DCI0_req != NULL) {
+        nfapi_hi_dci0_request_body_t *v=&d->HI_DCI0_req->hi_dci0_request_body;
+  A("XXXX up  HI_DCI0_req sfnsf %d (%d.%d)\n", d->HI_DCI0_req->sfn_sf,
+    d->HI_DCI0_req->sfn_sf/16, d->HI_DCI0_req->sfn_sf%16);
+  A("XXXX up     sfnsf %d\n", v->sfnsf);
+  A("XXXX up     DCIs  %d\n", v->number_of_dci);
+  A("XXXX up     HIs   %d\n", v->number_of_hi);
+        for (i = 0; i < v->number_of_dci + v->number_of_hi; i++) {
+          nfapi_hi_dci0_request_pdu_t *p = &v->hi_dci0_pdu_list[i];
+  A("XXXX up      pdu %d\n", i);
+  A("XXXX up          type %d %s\n",p->pdu_type,HI_DCI0_PDU_TYPE(p->pdu_type));
+          if (p->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) {
+            nfapi_hi_dci0_dci_pdu_rel8_t *q = &p->dci_pdu.dci_pdu_rel8;
+  A("XXXX up          dci_format           %d\n", q->dci_format);
+  A("XXXX up          cce_index            %d\n", q->cce_index);
+  A("XXXX up          aggregation_level    %d\n", q->aggregation_level);
+  A("XXXX up          rnti                 %d\n", q->rnti);
+  A("XXXX up          rb start             %d\n", q->resource_block_start);
+  A("XXXX up          # rb                 %d\n", q->number_of_resource_block);
+  A("XXXX up          mcs_1                %d\n", q->mcs_1);
+  A("XXXX up          cshift_2_for_drms    %d\n", q->cyclic_shift_2_for_drms);
+  A("XXXX up          freq hop enabled     %d\n", q->frequency_hopping_enabled_flag);
+  A("XXXX up          fre hop bits         %d\n", q->frequency_hopping_bits);
+  A("XXXX up          NDI_1                %d\n", q->new_data_indication_1);
+  A("XXXX up          tx_antenna_seleciton %d\n", q->ue_tx_antenna_seleciton);
+  A("XXXX up          tpc                  %d\n", q->tpc);
+  A("XXXX up          cqi_csi_request      %d\n", q->cqi_csi_request);
+  A("XXXX up          ul_index             %d\n", q->ul_index);
+  A("XXXX up          dl_assignment_index  %d\n", q->dl_assignment_index);
+  A("XXXX up          tpc_bitmap           %d\n", q->tpc_bitmap);
+  A("XXXX up          transmission_power   %d\n", q->transmission_power);
+          }
+          if (p->pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) {
+            nfapi_hi_dci0_hi_pdu_rel8_t *q = &p->hi_pdu.hi_pdu_rel8;
+  A("XXXX up          rb start    %d\n", q->resource_block_start);
+  A("XXXX up          cs2_drms    %d\n", q->cyclic_shift_2_for_drms);
+  A("XXXX up          ack         %d\n", q->hi_value);
+  A("XXXX up          i_phich     %d\n", q->i_phich);
+  A("XXXX up          power       %d\n", q->transmission_power);
+          }
+        }
+      }
+
+      if (d->UL_req != NULL) {
+        nfapi_ul_config_request_body_t *v=&d->UL_req->ul_config_request_body;
+  A("XXXX     UL_req sfnsf %d (%d.%d)\n", d->UL_req->sfn_sf,
+    d->UL_req->sfn_sf/16, d->UL_req->sfn_sf%16);
+  A("XXXX     PDUs         %d\n", v->number_of_pdus);
+  A("XXXX     ra freq      %d\n", v->rach_prach_frequency_resources);
+  A("XXXX     srs?         %d\n", v->srs_present);
+        for (i = 0; i < v->number_of_pdus; i++) {
+          nfapi_ul_config_request_pdu_t *p = &v->ul_config_pdu_list[i];
+  A("XXXX         pdu %d\n", i);
+  A("XXXX             type %d %s\n", p->pdu_type, UL_PDU_TYPE(p->pdu_type));
+          switch(p->pdu_type) {
+          case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: {
+            nfapi_ul_config_uci_harq_pdu *q = &p->uci_harq_pdu;
+            nfapi_ul_config_harq_information_rel9_fdd_t *h =
+                &q->harq_information.harq_information_rel9_fdd;
+  A("XXXX                 rnti          %d\n",
+    q->ue_information.ue_information_rel8.rnti);
+  A("XXXX                 harq size     %d\n", h->harq_size);
+  A("XXXX                 ack_nack_mode %d\n", h->ack_nack_mode);
+  A("XXXX                 # pucch res   %d\n", h->number_of_pucch_resources);
+  A("XXXX                 n_pucch_1_0   %d\n", h->n_pucch_1_0);
+  A("XXXX                 n_pucch_1_1   %d\n", h->n_pucch_1_1);
+  A("XXXX                 n_pucch_1_2   %d\n", h->n_pucch_1_2);
+  A("XXXX                 n_pucch_1_3   %d\n", h->n_pucch_1_3);
+            break;
+          }
+          case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: {
+            nfapi_ul_config_uci_sr_pdu *q = &p->uci_sr_pdu;
+            nfapi_ul_config_sr_information_rel8_t *h =
+                &q->sr_information.sr_information_rel8;
+  A("XXXX                 rnti          %d\n",
+    q->ue_information.ue_information_rel8.rnti);
+  A("XXXX                 pucch_index   %d\n", h->pucch_index);
+          }}
+        }
+      }
+
+  LOG_I(PHY, "XXXX DL\nXXXX DL\n%s", s);
+}
+
+#undef C
+#undef A
+
+#endif /* DUMP_FAPI */
+
+/****************************************************************************/
+/* debug utility functions end                                              */
+/****************************************************************************/
+
+void UL_indication(UL_IND_t *UL_info)
+{
+
+  AssertFatal(UL_info!=NULL,"UL_INFO is null\n");
+
+#ifdef DUMP_FAPI
+  dump_ul(UL_info);
+#endif
+
+  module_id_t  module_id   = UL_info->module_id;
+  int          CC_id       = UL_info->CC_id;
+  Sched_Rsp_t  *sched_info = &Sched_INFO[module_id][CC_id];
+  IF_Module_t  *ifi        = if_inst[module_id];
+  eNB_MAC_INST *mac        = RC.mac[module_id];
+
+  LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rx_ind:%d harqs:%d crcs:%d cqis:%d preambles:%d sr_ind:%d]\n",
+        UL_info->frame,UL_info->subframe,
+        module_id,CC_id,
+        UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs);
+
+  if (nfapi_mode != 1)
+  {
+    if (ifi->CC_mask==0) {
+      ifi->current_frame    = UL_info->frame;
+      ifi->current_subframe = UL_info->subframe;
+    }
+    else {
+      AssertFatal(UL_info->frame != ifi->current_frame,"CC_mask %x is not full and frame has changed\n",ifi->CC_mask);
+      AssertFatal(UL_info->subframe != ifi->current_subframe,"CC_mask %x is not full and subframe has changed\n",ifi->CC_mask);
+    }
+    ifi->CC_mask |= (1<<CC_id);
+  }
+
+
+  // clear DL/UL info for new scheduling round
+  clear_nfapi_information(RC.mac[module_id],CC_id,
+			  UL_info->frame,UL_info->subframe);
+
+  handle_rach(UL_info);
+
+  handle_sr(UL_info);
+
+  handle_cqi(UL_info);
+
+  handle_harq(UL_info);
+
+  // clear HI prior to handling ULSCH
+  mac->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi                     = 0;
+  
+  handle_ulsch(UL_info);
+
+  if (nfapi_mode != 1)
+  {
+    if (ifi->CC_mask == ((1<<MAX_NUM_CCs)-1)) {
+
+      eNB_dlsch_ulsch_scheduler(module_id,
+          (UL_info->frame+((UL_info->subframe>(9-sf_ahead))?1:0)) % 1024,
+          (UL_info->subframe+sf_ahead)%10);
+
+      ifi->CC_mask            = 0;
+
+      sched_info->module_id   = module_id;
+      sched_info->CC_id       = CC_id;
+      sched_info->frame       = (UL_info->frame + ((UL_info->subframe>(9-sf_ahead)) ? 1 : 0)) % 1024;
+      sched_info->subframe    = (UL_info->subframe+sf_ahead)%10;
+      sched_info->DL_req      = &mac->DL_req[CC_id];
+      sched_info->HI_DCI0_req = &mac->HI_DCI0_req[CC_id];
+      if ((mac->common_channels[CC_id].tdd_Config==NULL) ||
+          (is_UL_sf(&mac->common_channels[CC_id],(sched_info->subframe+sf_ahead)%10)>0))
+        sched_info->UL_req      = &mac->UL_req[CC_id];
+      else
+        sched_info->UL_req      = NULL;
+
+      sched_info->TX_req      = &mac->TX_req[CC_id];
+
+#ifdef DUMP_FAPI
+      dump_dl(sched_info);
+#endif
+
+      if (ifi->schedule_response)
+      {
+        AssertFatal(ifi->schedule_response!=NULL,
+            "schedule_response is null (mod %d, cc %d)\n",
+            module_id,
+            CC_id);
+        ifi->schedule_response(sched_info);
+      }
+
+      LOG_D(PHY,"Schedule_response: SFN_SF:%d%d dl_pdus:%d\n",sched_info->frame,sched_info->subframe,sched_info->DL_req->dl_config_request_body.number_pdu);
+    }
+  }
+}
+
+IF_Module_t *IF_Module_init(int Mod_id){
+
+  AssertFatal(Mod_id<MAX_MODULES,"Asking for Module %d > %d\n",Mod_id,MAX_IF_MODULES);
+
+  LOG_D(PHY,"Installing callbacks for IF_Module - UL_indication\n");
+
+  if (if_inst[Mod_id]==NULL) {
+    if_inst[Mod_id] = (IF_Module_t*)malloc(sizeof(IF_Module_t));
+    memset((void*)if_inst[Mod_id],0,sizeof(IF_Module_t));
+
+    if_inst[Mod_id]->CC_mask=0;
+    if_inst[Mod_id]->UL_indication = UL_indication;
+
+    AssertFatal(pthread_mutex_init(&if_inst[Mod_id]->if_mutex,NULL)==0,
+        "allocation of if_inst[%d]->if_mutex fails\n",Mod_id);
+  }
+  return if_inst[Mod_id];
+}
+
+void IF_Module_kill(int Mod_id) {
+
+  AssertFatal(Mod_id>MAX_MODULES,"Asking for Module %d > %d\n",Mod_id,MAX_IF_MODULES);
+  if (if_inst[Mod_id]!=NULL) free(if_inst[Mod_id]);
+
+}
diff --git a/openair2/NR_UE_PHY_INTERFACE/IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/IF_Module.h
new file mode 100644
index 0000000000000000000000000000000000000000..3b1c88dda03b5857f99c40a3a724b1a072a469e5
--- /dev/null
+++ b/openair2/NR_UE_PHY_INTERFACE/IF_Module.h
@@ -0,0 +1,142 @@
+/*
+ * 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/PHY_INTERFACE/IF_Module.h
+* \brief data structures for PHY/MAC interface modules
+* \author EURECOM/NTUST
+* \date 2017
+* \version 0.1
+* \company Eurecom
+* \email: raymond.knopp@eurecom.fr
+* \note
+* \warning
+*/
+#ifndef __IF_MODULE__H__
+#define __IF_MODULE__H__
+
+
+#include <stdint.h>
+#include "openair1/PHY/LTE_TRANSPORT/defs.h"
+#include "nfapi_interface.h"
+
+
+#define MAX_NUM_DL_PDU 100
+#define MAX_NUM_UL_PDU 100
+#define MAX_NUM_HI_DCI0_PDU 100
+#define MAX_NUM_TX_REQUEST_PDU 100
+
+#define MAX_NUM_HARQ_IND 100
+#define MAX_NUM_CRC_IND 100
+#define MAX_NUM_SR_IND 100
+#define MAX_NUM_CQI_IND 100
+#define MAX_NUM_RACH_IND 100
+#define MAX_NUM_SRS_IND 100
+
+typedef struct{
+  /// Module ID
+  module_id_t module_id;
+  /// CC ID
+  int CC_id;
+  /// frame 
+  frame_t frame;
+  /// subframe
+  sub_frame_t subframe;
+
+  /// harq indication list
+  nfapi_harq_indication_t harq_ind;
+
+  /// crc indication list
+  nfapi_crc_indication_t crc_ind;
+
+  /// SR indication list
+  nfapi_sr_indication_t sr_ind;
+
+  /// CQI indication list
+  nfapi_cqi_indication_body_t cqi_ind;
+
+  /// RACH indication list
+  nfapi_rach_indication_t rach_ind;
+
+#ifdef Rel14
+  /// RACH indication list for BR UEs
+  nfapi_rach_indication_t rach_ind_br;
+#endif
+
+  /// SRS indication list
+  nfapi_srs_indication_body_t srs_ind;
+
+  /// RX indication
+  nfapi_rx_indication_t rx_ind;
+
+} UL_IND_t;
+
+// Downlink subframe P7
+
+
+typedef struct{
+  /// Module ID
+  module_id_t module_id; 
+  /// CC ID
+  uint8_t CC_id;
+  /// frame
+  frame_t frame;
+  /// subframe
+  sub_frame_t subframe;
+  /// nFAPI DL Config Request
+  nfapi_dl_config_request_t *DL_req;
+  /// nFAPI UL Config Request
+  nfapi_ul_config_request_t *UL_req;
+  /// nFAPI HI_DCI Request
+  nfapi_hi_dci0_request_t *HI_DCI0_req;
+  /// Pointers to DL SDUs
+  nfapi_tx_request_t *TX_req;
+}Sched_Rsp_t;
+
+typedef struct {
+    uint8_t Mod_id;
+    int CC_id;
+    nfapi_config_request_t *cfg;
+}PHY_Config_t;
+
+typedef struct IF_Module_s{
+//define the function pointer
+  void (*UL_indication)(UL_IND_t *UL_INFO);
+  void (*schedule_response)(Sched_Rsp_t *Sched_INFO);
+  void (*PHY_config_req)(PHY_Config_t* config_INFO);
+  uint32_t CC_mask;
+  uint16_t current_frame;
+  uint8_t current_subframe;
+  pthread_mutex_t if_mutex;
+}IF_Module_t;
+
+/*Initial */
+IF_Module_t *IF_Module_init(int Mod_id);
+void IF_Module_kill(int Mod_id);
+
+/*Interface for uplink, transmitting the Preamble(list), ULSCH SDU, NAK, Tick (trigger scheduler)
+ */
+void UL_indication(UL_IND_t *UL_INFO);
+
+/*Interface for Downlink, transmitting the DLSCH SDU, DCI SDU*/
+void Schedule_Response(Sched_Rsp_t *Sched_INFO);
+
+#endif
+
diff --git a/openair2/NR_UE_PHY_INTERFACE/defs.h b/openair2/NR_UE_PHY_INTERFACE/defs.h
new file mode 100644
index 0000000000000000000000000000000000000000..deb07443f18fcddf3a1555821fece15ca0acd7c4
--- /dev/null
+++ b/openair2/NR_UE_PHY_INTERFACE/defs.h
@@ -0,0 +1,373 @@
+/*
+ * 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_INTERFACE/defs.h
+* \brief mac phy interface primitives
+* \author Raymond Knopp and Navid Nikaein
+* \date 2011
+* \version 0.5
+* \mail navid.nikaein@eurecom.fr or openair_tech@eurecom.fr
+*/
+
+#ifndef __MAC_PHY_PRIMITIVES_H__
+#    define __MAC_PHY_PRIMITIVES_H__
+
+#include "LAYER2/MAC/defs.h"
+
+
+#define MAX_NUMBER_OF_MAC_INSTANCES 16
+
+#define NULL_PDU 255
+#define DCI 0
+#define DLSCH 1
+#define ULSCH 2
+
+#define mac_exit_wrapper(sTRING)                                                            \
+do {                                                                                        \
+    char temp[300];                                                                         \
+    snprintf(temp, sizeof(temp), "%s in file "__FILE__" at line %d\n", sTRING, __LINE__);   \
+    mac_xface->macphy_exit(temp);                                                           \
+} while(0)
+
+/** @defgroup _phy_if MAC-PHY interface
+ * @ingroup _oai2
+ * @{
+ */
+/*! \brief MACPHY Interface */
+/*
+typedef struct {
+  /// Pointer function that initializes L2
+  int (*macphy_init)(int eMBMS_active, char *uecap_xer, uint8_t CBA_active,uint8_t HO_active);
+
+  /// Pointer function that stops the low-level scheduler due an exit condition
+  void (*macphy_exit)(const char *);
+
+  // eNB functions
+  /// Invoke dlsch/ulsch scheduling procedure for new subframe
+  void (*eNB_dlsch_ulsch_scheduler)(module_id_t Mod_id,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP);//, int calibration_flag);
+
+  /// Fill random access response sdu, passing timing advance
+  uint16_t (*fill_rar)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t *dlsch_buffer,uint16_t N_RB_UL, uint8_t input_buffer_length);
+
+  /// Initiate the RA procedure upon reception (hypothetical) of a valid preamble
+  void (*initiate_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframe,uint8_t f_id);
+
+  /// cancel an ongoing RA procedure
+  void (*cancel_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble);
+
+  /// Inform MAC layer that an uplink is scheduled for Msg3 in given subframe.
+  /// This is used so that the MAC scheduler marks as busy the RBs used by the Msg3.
+  void (*set_msg3_subframe)(module_id_t Mod_id,
+                            int CC_id,
+                            int frame,
+                            int subframe,
+                            int rnti,
+                            int Msg3_frame,
+                            int Msg3_subframe);
+
+  /// Get DCI for current subframe from MAC
+  DCI_PDU* (*get_dci_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe);
+
+  /// Get DLSCH sdu for particular RNTI and Transport block index
+  uint8_t* (*get_dlsch_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,uint8_t TB_index);
+
+  /// Send ULSCH sdu to MAC for given rnti
+  void (*rx_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP, sub_frame_t sub_frameP,rnti_t rnti, uint8_t *sdu,uint16_t sdu_len, int harq_pid,uint8_t *msg3_flag);
+
+  /// Indicate failure to synch to external source
+  void (*mrbch_phy_sync_failure) (module_id_t Mod_id,frame_t frameP, uint8_t free_eNB_index);
+
+  /// Indicate Scheduling Request from UE
+  void (*SR_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe);
+  /// Indicate UL Failure to eNodeB MAC
+  void (*UL_failure_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe);
+
+  /// Configure Common PHY parameters from SIB1
+  void (*phy_config_mib_eNB)(module_id_t Mod_id,int CC_id,
+			     int eutra_band,
+			     int N_RB_DL,
+			     PHICH_Config_t *phich_Config,
+			     int Nid_cell,
+			     int Ncp,
+			     int p_eNB,
+			     uint32_t      dl_CarrierFreq,
+			     uint32_t      ul_CarrierFreq);
+
+  /// Configure Common PHY parameters from SIB1
+  void (*phy_config_sib1_eNB)(module_id_t Mod_id,int CC_id,
+                              TDD_Config_t *tdd_config,
+                              uint8_t SIwindowsize,
+                              uint16_t SIperiod);
+
+  /// Configure Common PHY parameters from SIB2
+  void (*phy_config_sib2_eNB)(module_id_t Mod_id, int CC_id,
+                              RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
+                              ARFCN_ValueEUTRA_t *ul_CArrierFreq,
+                              long *ul_Bandwidth,
+                              AdditionalSpectrumEmission_t *additionalSpectrumEmission,
+                              struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList);
+
+#if defined(Rel10) || defined(Rel14)
+  /// Configure Common PHY parameters from SIB13
+  void (*phy_config_sib13_eNB)(module_id_t Mod_id,int CC_id, int mbsfn_Area_idx,
+                               long mbsfn_AreaId_r9);
+
+  void (*phy_config_dedicated_scell_eNB)(uint8_t Mod_id,
+                                         uint16_t rnti,
+                                         SCellToAddMod_r10_t *sCellToAddMod_r10,
+                                         int CC_id);
+#endif
+
+  /// PHY-Config-Dedicated eNB
+  void (*phy_config_dedicated_eNB)(module_id_t Mod_id,int CC_id,rnti_t rnti,
+                                   struct PhysicalConfigDedicated *physicalConfigDedicated);
+
+#if defined(Rel10) || defined(Rel14)
+  /// Get MCH sdu and corresponding MCS for particular MBSFN subframe
+  MCH_PDU* (*get_mch_sdu)(module_id_t Mod_id, int CC_id, frame_t frameP,sub_frame_t subframe);
+#endif
+  // configure the cba rnti at the physical layer
+  void (*phy_config_cba_rnti)(module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, uint16_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups);
+  /// get delta mcs for fast UL AMC
+  int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs);
+
+  int (*mac_phy_remove_ue)(module_id_t Mod_idP,rnti_t rntiP);
+  /// UE functions
+
+  /// reset the ue phy
+  void (*phy_reset_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
+
+  /// Indicate loss of synchronization of PBCH for this eNB to MAC layer
+  void (*out_of_sync_ind)(module_id_t Mod_id,frame_t frameP,uint16_t eNB_index);
+
+  ///  Send a received SI sdu
+  void (*ue_decode_si)(module_id_t Mod_id,int CC_id,frame_t frameP, uint8_t CH_index, void *pdu, uint16_t len);
+
+  ///  Send a received Paging sdu
+  void (*ue_decode_p)(module_id_t Mod_id,int CC_id,frame_t frameP, uint8_t CH_index, void *pdu, uint16_t len);
+
+  /// Send a received DLSCH sdu to MAC
+  void (*ue_send_sdu)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,sub_frame_t subframe,uint8_t *sdu,uint16_t sdu_len,uint8_t CH_index);
+
+#if defined(Rel10) || defined(Rel14)
+  /// Send a received MCH sdu to MAC
+  void (*ue_send_mch_sdu)(module_id_t Mod_id,uint8_t CC_id, frame_t frameP,uint8_t *sdu,uint16_t sdu_len,uint8_t eNB_index,uint8_t sync_area);
+
+  /// Function to check if UE PHY needs to decode MCH for MAC
+  /// get the sync area id, and return MCS value if need to decode, otherwise -1
+  int (*ue_query_mch)(module_id_t Mod_id, uint8_t CC_id,frame_t frameP,sub_frame_t subframe,uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active);
+#endif
+
+  /// Retrieve ULSCH sdu from MAC
+  void (*ue_get_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe, uint8_t CH_index,uint8_t *ulsch_buffer,uint16_t buflen,uint8_t *access_mode);
+
+  /// Retrieve RRCConnectionReq from MAC
+  PRACH_RESOURCES_t* (*ue_get_rach)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t Msg3_flag,sub_frame_t subframe);
+
+  /// Process Random-Access Response
+  uint16_t (*ue_process_rar)(module_id_t Mod_id,int CC_id,frame_t frameP, uint16_t ra_rnti, uint8_t *dlsch_buffer, uint16_t *t_crnti,uint8_t preamble_index, uint8_t* selected_rar_buffer);
+
+  /// Get SR payload (0,1) from UE MAC
+  uint32_t (*ue_get_SR)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe);
+
+  /// Indicate synchronization with valid PBCH
+  void (*dl_phy_sync_success) (module_id_t Mod_id,frame_t frameP, uint8_t CH_index,uint8_t first_sync);
+
+  /// Only calls the PDCP for now
+  UE_L2_STATE_t (*ue_scheduler)(module_id_t Mod_id, frame_t rxFrameP,sub_frame_t rxSubframe, frame_t txFrameP,sub_frame_t txSubframe, lte_subframe_t direction, uint8_t eNB_id, int CC_id);
+
+  /// PHY-Config-Dedicated UE
+  void (*phy_config_dedicated_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index,
+                                  struct PhysicalConfigDedicated *physicalConfigDedicated);
+
+  /// PHY-Config-harq UE
+  void (*phy_config_harq_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index,
+                             uint16_t max_harq_tx);
+  /// Configure Common PHY parameters from SIB1
+  void (*phy_config_sib1_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index,
+                             TDD_Config_t *tdd_config,
+                             uint8_t SIwindowsize,
+                             uint16_t SIperiod);
+
+  /// Configure Common PHY parameters from SIB2
+  void (*phy_config_sib2_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index,
+                             RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
+                             ARFCN_ValueEUTRA_t *ul_CArrierFreq,
+                             long *ul_Bandwidth,
+                             AdditionalSpectrumEmission_t *additionalSpectrumEmission,
+                             struct MBSFN_SubframeConfigList  *mbsfn_SubframeConfigList);
+
+#if defined(Rel10) || defined(Rel14)
+  /// Configure Common PHY parameters from SIB13
+  void (*phy_config_sib13_ue)(uint8_t Mod_id,int CC_id, uint8_t eNB_index,int mbsfn_Area_idx,
+                              long mbsfn_AreaId_r9);
+
+  void (*phy_config_dedicated_scell_ue)(uint8_t Mod_id,
+                                        uint8_t eNB_index,
+                                        SCellToAddMod_r10_t *sCellToAddMod_r10,
+                                        int CC_id);
+#endif
+  /// Configure Common PHY parameters from mobilityControlInfo
+  void (*phy_config_afterHO_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t CH_index,
+                                MobilityControlInfo_t *mobilityControlInfo,
+                                uint8_t ho_failed);
+
+  /// Function to indicate failure of contention resolution or RA procedure
+  void (*ra_failed)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index);
+
+  /// Function to indicate success of contention resolution or RA procedure
+  void (*ra_succeeded)(module_id_t Mod_id,uint8_t CC_id, uint8_t eNB_index);
+
+  /// Function to indicate the transmission of msg1/rach to MAC
+  void (*Msg1_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id);
+
+  /// Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer
+  void (*Msg3_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id);
+
+  /// Function to pass inter-cell measurement parameters to PHY (cell Ids)
+  void (*phy_config_meas_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,uint32_t *adj_cell_id);
+
+  // PHY Helper Functions
+
+  /// RIV computation from PHY
+  uint16_t (*computeRIV)(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs);
+
+  /// Downlink TBS table lookup from PHY
+  uint32_t (*get_TBS_DL)(uint8_t mcs, uint16_t nb_rb);
+
+  /// Uplink TBS table lookup from PHY
+  uint32_t (*get_TBS_UL)(uint8_t mcs, uint16_t nb_rb);
+
+  /// Function to retrieve the HARQ round index for a particular UL/DLSCH and harq_pid
+  int (*get_ue_active_harq_pid)(module_id_t Mod_id, uint8_t CC_id,rnti_t rnti, int frame, uint8_t subframe, uint8_t *harq_pid, uint8_t *round, uint8_t ul_flag);
+
+  /// Function to retrieve number of CCE
+  uint16_t (*get_nCCE_max)(module_id_t Mod_id,uint8_t  CC_id,int num_pdcch_symbols,int subframe);
+
+
+  int (*get_nCCE_offset)(int *CCE_table,
+                         const unsigned char L,
+                         const int nCCE,
+                         const int common_dci,
+                         const unsigned short rnti,
+                         const unsigned char subframe);
+
+  /// Function to retrieve number of PRB in an rb_alloc
+  uint32_t (*get_nb_rb)(uint8_t ra_header, uint32_t rb_alloc, int n_rb_dl);
+
+  /// Function to convert VRB to PRB for distributed allocation
+  uint32_t (*get_prb)(int N_RB_DL,int odd_slot,int vrb,int Ngap);
+
+  /// Function to retrieve transmission mode for UE
+  uint8_t (*get_transmission_mode)(module_id_t Mod_id,uint8_t CC_id,rnti_t rnti);
+
+  /// Function to retrieve rb_alloc bitmap from dci rballoc field and VRB type
+  uint32_t (*get_rballoc)(vrb_t vrb_type, uint16_t rb_alloc_dci);
+
+  /// Function for UE MAC to retrieve current PHY connectivity mode (PRACH,RA_RESPONSE,PUSCH)
+  UE_MODE_t (*get_ue_mode)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index);
+
+  /// Function for UE MAC to retrieve measured Path Loss
+  int16_t (*get_PL)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
+
+  /// Function for UE MAC to retrieve the rssi
+  uint32_t (*get_RSSI)(uint8_t Mod_id,uint8_t CC_id);
+
+  /// Function for UE MAC to retrieve the total gain
+  uint32_t (*get_rx_total_gain_dB)(uint8_t Mod_id,uint8_t CC_id);
+
+  /// Function for UE MAC to retrieve the number of adjustent cells
+  uint8_t (*get_n_adj_cells)(uint8_t Mod_id,uint8_t CC_id);
+
+  /// Function for UE MAC to retrieve RSRP/RSRQ measurements
+  uint32_t (*get_RSRP)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
+
+  /// Function for UE MAC to retrieve RSRP/RSRQ measurements
+  uint32_t (*get_RSRQ)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
+
+  /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements
+  uint8_t (*set_RSRP_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp);
+
+  /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements
+  uint8_t (*set_RSRQ_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp);
+
+  /// Function for UE/eNB MAC to retrieve number of PRACH in TDD
+  uint8_t (*get_num_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms);
+
+  /// Function for UE/eNB MAC to retrieve f_id of particular PRACH resource in TDD
+  uint8_t (*get_fid_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms,uint8_t tdd_map_index);
+
+  /// Function for eNB MAC to retrieve subframe direction
+  lte_subframe_t (*get_subframe_direction)(module_id_t Mod_id, uint8_t CC_id, uint8_t subframe);
+
+  // MAC Helper functions
+  /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (Po_NOMINAL_PUSCH parameter)
+  int8_t (*get_Po_NOMINAL_PUSCH)(module_id_t Mod_id,uint8_t  CC_id);
+
+  /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (deltaP_rampup parameter)
+  int8_t (*get_deltaP_rampup)(module_id_t Mod_id,uint8_t CC_id);
+
+  /// Function for UE/PHY to compute PHR
+  int8_t (*get_PHR)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index);
+
+  /// Function for UE to process the timing advance command
+  void (*process_timing_advance)(module_id_t Mod_id,uint8_t CC_id, int16_t timing_advance);
+  
+  /// Function for MAC to get the UE stats from the PHY   
+  LTE_eNB_UE_stats* (*get_eNB_UE_stats)(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti);
+
+  /// get the frame parameters from the PHY
+  LTE_DL_FRAME_PARMS* (*get_lte_frame_parms)(module_id_t Mod_id, uint8_t CC_id);
+  
+  /// get the Multiuser mimo mode
+  MU_MIMO_mode* (*get_mu_mimo_mode) (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti);
+
+  /// get the delta TF for Uplink Power Control Calculation
+  int16_t (*get_hundred_times_delta_TF) (module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid);
+  /// get target PUSCH received power 
+  int16_t (*get_target_pusch_rx_power) (module_id_t module_idP, uint8_t CC_id);
+  /// get target PUSCH received power 
+  int16_t (*get_target_pucch_rx_power) (module_id_t module_idP, uint8_t CC_id);
+
+  unsigned char is_cluster_head;
+  unsigned char is_primary_cluster_head;
+  unsigned char is_secondary_cluster_head;
+  unsigned char cluster_head_index;
+
+  /// PHY Frame Configuration
+  LTE_DL_FRAME_PARMS *frame_parms;
+
+  uint8_t (*get_prach_prb_offset)(LTE_DL_FRAME_PARMS *frame_parms, uint8_t tdd_mapindex, uint16_t Nf); 
+
+  int (*is_prach_subframe)(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe);
+
+  /// ICIC algos
+  uint8_t (*get_SB_size)(uint8_t n_rb_dl);
+  ///end ALU's algo
+
+} MAC_xface;
+
+*/
+
+#endif
+
+
+/** @} */
diff --git a/openair2/NR_UE_PHY_INTERFACE/extern.h b/openair2/NR_UE_PHY_INTERFACE/extern.h
new file mode 100644
index 0000000000000000000000000000000000000000..b87fa42fe41ae930bce6b0d03abfea34bb20c0b8
--- /dev/null
+++ b/openair2/NR_UE_PHY_INTERFACE/extern.h
@@ -0,0 +1,27 @@
+/*
+ * 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
+ */
+
+#ifndef __PHY_INTERFACE_EXTERN_H__
+#define __PHY_INTERFACE_EXTERN_H__
+
+
+
+#endif
diff --git a/openair2/NR_UE_PHY_INTERFACE/mac_phy_primitives.c b/openair2/NR_UE_PHY_INTERFACE/mac_phy_primitives.c
new file mode 100644
index 0000000000000000000000000000000000000000..06e06d096dc53caf0066bbdd26f6546dd5f7f9ee
--- /dev/null
+++ b/openair2/NR_UE_PHY_INTERFACE/mac_phy_primitives.c
@@ -0,0 +1,283 @@
+/*
+ * 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
+ */
+
+/*________________________mac_phy_primitives.c________________________
+
+ Authors : Hicham Anouar, Raymond Knopp
+ Company : EURECOM
+ Emails  : anouar@eurecom.fr,  knopp@eurecom.fr
+________________________________________________________________*/
+
+
+//#include "openair_extern.h"
+
+#ifdef MAC_CONTEXT
+#include "LAYER2/MAC/defs.h"
+#include "LAYER2/MAC/extern.h"
+//#include "extern.h"
+#include "defs.h"
+#endif //MAC_CONTEXT
+
+
+//#define DEBUG_UE_DECODE_SACH
+//#define DEBUG_NODEB_DECODE_SACH
+
+#ifdef PHY_CONTEXT
+#ifdef PHY_EMUL
+#include "extern.h"
+#include "SIMULATION/simulation_defs.h"
+#else //PHY_EMUL
+#include "MAC_INTERFACE/extern.h"
+#endif //PHY_EMUL
+
+void clear_macphy_data_req(unsigned char Mod_id)
+{
+  //msg("CLEAR DATA_REQ\n");
+  unsigned char i;
+
+  Macphy_req_table[Mod_id].Macphy_req_cnt = 0;
+
+  for (i=0; i<NB_REQ_MAX; i++)
+    Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active = 0;
+}
+
+/*
+unsigned char phy_resources_compare(PHY_RESOURCES *Phy1,PHY_RESOURCES* Phy2 ){
+
+  if(Phy1->Time_alloc==Phy2->Time_alloc && Phy1->Freq_alloc==Phy2->Freq_alloc)// && Phy1->Coding_fmt==Phy2->Coding_fmt && Phy1->Seq_index==Phy2->Seq_index)
+    return 1;
+  else
+    return 0;
+
+}
+*/
+
+MACPHY_DATA_REQ_TABLE_ENTRY* find_data_req_entry(unsigned char Mod_id,MACPHY_REQ_ENTRY_KEY *Search_key)
+{
+
+  unsigned char i;
+
+  //msg("[MAC_PHY]MAC_PHY_REQUEST_CNT=%d\n",Macphy_req_table.Macphy_req_cnt);
+  if (Macphy_req_table[Mod_id].Macphy_req_cnt > 0) {
+#ifdef DEBUG_PHY
+    //    msg("[MACPHY_FIND_REQ] SEARCH KEY=%d\n",Search_key->Key_type);
+#endif //DEBUG_PHY
+    //msg("[MACPHY_FIND_REQ] SEARCH KEY=%d, NB_REQ_MAX=%d\n",Search_key->Key_type,NB_REQ_MAX);
+
+    switch(Search_key->Key_type) {
+    case PDU_TYPE_KEY:
+      for(i=0; i<NB_REQ_MAX; i++) {
+        if ( (Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Pdu_type==Search_key->Key.Pdu_type) &&
+             (Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1) ) {
+          //msg("[MACPHY_FIND] MACPHY_req_table_entry=%p,idx=%d,Phy_resources %p",       &Macphy_req_table.Macphy_req_table_entry[i],i,Macphy_req_table.Macphy_req_table_entry[i].Macphy_data_req.Phy_Resources_Entry);
+          return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i]);
+        }
+      }
+
+      break;
+      /*
+      case LCHAN_KEY:
+      for(i=0;i<NB_REQ_MAX;i++){
+      if ((Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Lchan_id.Index==Search_key->Key.Lchan_id->Index) &&
+      (Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1) )
+      return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i]);
+      }
+      break;
+
+      case PHY_RESOURCES_KEY:
+      for(i=0;i<NB_REQ_MAX;i++){
+      if(Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1)
+      if ( ( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Time_alloc ==
+        Search_key->Key.Phy_resources.Time_alloc )
+         &&( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Freq_alloc ==
+       Search_key->Key.Phy_resources.Freq_alloc )
+         &&( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.CH_index ==
+      Search_key->CH_index )
+         && ( Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Direction == RX))
+      return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i]);
+      }
+      break;
+      */
+    }
+  }
+
+#ifndef PHY_EMUL
+  //  msg("[PHY][PHY_MAC] Frame %d : No data request\n",mac_xface->frame);
+#endif //PHY_EMUL
+
+
+  return (MACPHY_DATA_REQ_TABLE_ENTRY*)0;
+
+}
+
+
+
+
+
+
+void print_active_requests(unsigned char Mod_id)
+{
+
+  int i;
+  msg("_________________________INST %d , FRAME %d ACTIVE_REQUESTS_________________\n",Mod_id,mac_xface->frame);
+
+  for (i=0; i<NB_REQ_MAX; i++) {
+
+    if (Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Active == 1) {
+      msg("[MACPHY][DATA][REQ] Request %d: Direction %d, Pdu_type %d\n",
+          i,
+          Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Direction,
+          Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Pdu_type);
+      //    Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Lchan_id.Index);
+      //    Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources,
+      //    Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Time_alloc,
+      //    Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Phy_resources->Freq_alloc);
+      //if(Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Pdu_type==RACH)
+      //msg("[RACH_REQ] Rach_pdu %p, Payload %p\n",Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Dir.Req_rx.Pdu.Rach_pdu,
+      //    Macphy_req_table[Mod_id].Macphy_req_table_entry[i].Macphy_data_req.Dir.Req_rx.Pdu.Rach_pdu->Rach_payload);
+
+    }
+  }
+}
+
+
+/*___________________________________________________________________________________________________*/
+#define RCNT Macphy_req_table[Mod_id].Macphy_req_cnt
+
+MACPHY_DATA_REQ *new_macphy_data_req(unsigned char Mod_id)
+{
+  /*___________________________________________________________________________________________________*/
+  unsigned char i;
+
+
+
+  for (i=0; i<NB_REQ_MAX; i++) {
+    if (Macphy_req_table[Mod_id].Macphy_req_table_entry[(i)%NB_REQ_MAX].Active == 0) {
+      Macphy_req_table[Mod_id].Macphy_req_table_entry[(i)%NB_REQ_MAX].Active = 1;
+      RCNT = (RCNT + 1)%NB_REQ_MAX;
+      //            msg("[MAC_PHY]NEW MAC_REQUEST_CNT=%d,frame %d, Module %d, entry %d \n",Macphy_req_table[Mod_id].Macphy_req_cnt,mac_xface->frame,Mod_id,i);
+      //        Macphy_req_table[Mod_id].Macphy_req_table_entry[i%NB_REQ_MAX].Macphy_data_req.Phy_resources=(PHY_RESOURCES*)malloc16(sizeof(PHY_RESOURCES));
+      return(&Macphy_req_table[Mod_id].Macphy_req_table_entry[i%NB_REQ_MAX].Macphy_data_req);
+    }
+  }
+
+  msg("[OPENAIR][MAC][ERROR] frame %d: No more DATA_REQ !!!!\n",mac_xface->frame);
+
+  print_active_requests(Mod_id);
+  mac_xface->macphy_exit("new_macphy_data_req: no more DATA_REQ");
+  //rt_sleep(nano2count(2000));
+
+  return((MACPHY_DATA_REQ*)0);
+}
+
+
+#endif //PHY_CONTEXT
+
+#ifdef MAC_CONTEXT
+#include "LAYER2/MAC/extern.h"
+
+// Function called by PHY to indicate available data/measurements for MAC
+
+/*___________________________________________________________________________________________________*/
+void macphy_data_ind(unsigned char Mod_id,unsigned char Pdu_type,void *pdu,unsigned short rnti)
+{
+  /*___________________________________________________________________________________________________*/
+  //msg("[OPENAIR][MACPHY] Calling mac_resp In\n");
+
+  int i;
+
+  //  if (Req_rx->crc_status[0]!= -1) {  //CRC_STATUS
+
+  // msg("[OPENAIR][MACPHY] Calling mac_indicate In\n");
+  //     Req_rx->Meas.UL_meas=&UL_meas[Mod_id];
+  //   Req_rx->Meas.DL_meas=&DL_meas[Mod_id];
+
+  switch (Pdu_type) {
+  case ULSCH:
+
+    //        msg("[OPENAIR][MACPHY] Received RACH, Sending to MAC\n");
+    nodeb_decode_ulsch(Mod_id,(ULSCH_PDU *)pdu,rnti);
+
+    break;
+
+  case DLSCH:
+#ifdef DEBUG_UE_DECODE_SACH
+    msg("[MAC][UE][MAC_PHY] TTI %d Inst %d\n",mac_xface->frame,Mod_id);
+#endif
+
+    //      ue_decode_dlsch(Mod_id-NB_CH_INST,
+    //          (DLSCH_PDU *)pdu,rnti);
+
+    break;
+
+  default:
+    break;
+  }
+
+  //    msg("Freeing Req %p\n",Macphy_data_req_table_entry);
+  //  }
+
+}
+
+
+
+
+
+/*PHY_RESOURCES_TABLE_ENTRY *new_phy_resources() {
+
+
+  unsigned char i;
+
+  //msg("[OPENAIR][PHY][MAC Interface] New Phy Resource, cnt %d\n",Phy_resources_table.Phy_resources_cnt);
+
+  for (i=0;i<NB_PHY_RESOURCES_MAX;i++){
+
+    if (Phy_resources_table.Phy_resources_table_entry[(i+Phy_resources_table.Phy_resources_cnt+1)%NB_PHY_RESOURCES_MAX].Active == 0) {
+      Phy_resources_table.Phy_resources_table_entry[(i+Phy_resources_table.Phy_resources_cnt+1)%NB_PHY_RESOURCES_MAX].Active = 1;
+      Phy_resources_table.Phy_resources_cnt = (Phy_resources_table.Phy_resources_cnt + 1)%NB_PHY_RESOURCES_MAX;
+      //  msg("[OPENAIR][PHY][MAC Interface] NEW PHY_RESOURCES: Taking index %d\n\n",(i+Phy_resources_table.Phy_resources_cnt+1)%NB_PHY_RESOURCES_MAX);
+
+      return(&Phy_resources_table.Phy_resources_table_entry[(i+Phy_resources_table.Phy_resources_cnt)%NB_PHY_RESOURCES_MAX]);
+    }
+  }
+  msg("[OPENAIR][MAC][ERROR] No more PHY_RESOURCES !!!!\n");
+  exit(-1);
+}
+*/
+
+#endif //MAC_CONTEXT
+
+
+// Measurements, etc ..
+
+//short phy_resource_cnt = 0, macphy_data_req_cnt = 0, macphy_data_ind_cnt = 0;
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/openair2/NR_UE_PHY_INTERFACE/mac_phy_primitives.h b/openair2/NR_UE_PHY_INTERFACE/mac_phy_primitives.h
new file mode 100644
index 0000000000000000000000000000000000000000..889cb503dca1d91088401f20c8ee963433512e35
--- /dev/null
+++ b/openair2/NR_UE_PHY_INTERFACE/mac_phy_primitives.h
@@ -0,0 +1,232 @@
+/*
+ * 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
+ */
+
+/*________________________mac_phy_primitives.h________________________
+
+ Authors : Hicham Anouar, Raymond Knopp
+ Company : EURECOM
+ Emails  : anouar@eurecom.fr,  knopp@eurecom.fr
+________________________________________________________________*/
+
+
+#ifndef __MAC_PHY_PRIMITIVES_H__
+#    define __MAC_PHY_PRIMITIVES_H__
+
+#include "../LAYER2/MAC/defs.h"
+
+
+/**@defgroup _mac_phy_primitives_ MAC Layer Primitives for Communications with PHY
+ *@ingroup w3g4f_mac_layer_
+ *@{
+
+This subclause describes the primitives for communications between the MAC and PHY sub-layers.
+
+The primitives for dynamic MAC-PHY PDU exchange (Transport channel interface) are:
+
+- MACPHY_DATA_REQ: transfers or requests a PDU from PHY.  The data is passed along with the dynamic PHY transmission
+format (coding and modulation, time/freq/space resource allocation)
+
+- MACPHY_DATA_IND: Function call (by PHY) to deliver a new PDU and corresponding measurements to MAC.  This implicitly confirms the MACPHY_DATA_REQ by
+filling the fields of the request (TX or RX) with the data and measurements.
+
+One primitive is used for semi-static configuration (during logical channel establishment)
+relaying the puncturing/repetition patterns for HARQ:
+
+- MACPHY_CONFIG_SACH_HARQ_REQ (still to be defined...)
+
+The primitive for static (re)configuration is:
+- MACPHY_CONFIG_REQ : This primitive transports the initial configuration during the setup phase of equipment, both for CH and UE.
+Static configuration is used during the initialization phase of the equipment.  For a CH, it is done prior to any communication.  For a UE, some
+structures may be set after receiving configuration information from the network via the BCCH/CCCH.
+*/
+
+
+
+
+/*! \brief MACPHY-DATA-REQ_RX structure is used to request transfer a new PDU from PHY corresponding to a particular transport channel*/
+typedef struct {
+  int crc_status[MAX_NUMBER_TB_PER_LCHAN];                   /*!< This field indicates the CRC status of the PDU upon reception from PHY*/
+  unsigned char num_tb;                /*!< This field indicates the number of transport blocks to be received*/
+  unsigned short tb_size_bytes;        /*!< This field indicates the number of bytes per transpor block*/
+  unsigned int Active_process_map;   /*!< HARQ indicator for active processes*/
+  union {
+    CHBCH_PDU   *Chbch_pdu;        /*!< This is a pointer to CHBCH data*/
+    DL_SACH_PDU *DL_sach_pdu;      /*!< This is a pointer to DL_SACH data*/
+    UL_SACH_PDU *UL_sach_pdu;      /*!< This is a pointer to UL_SACH data*/
+    RACH_PDU    *Rach_pdu;         /*!< This is a pointer to RACH data*/
+    MRBCH_PDU   *Mrbch_pdu;        /*!< This is a pointer to MRBCH data*/
+  } Pdu;
+  union {
+    DL_MEAS *DL_meas;   /*!< This is an array of pointers to the current measurements of DL quality at UE (indexed by CH_id) */
+    UL_MEAS *UL_meas;   /*!< This is an array of pointers to the current measurements of UL quality at Node-B (indexed by user_id) */
+  } Meas;
+} MACPHY_DATA_REQ_RX;
+
+
+/*! \brief MACPHY-DATA-REQ_TX structure is used to transfer a new PDU to PHY corresponding to a particular transport channel*/
+typedef struct {
+  unsigned char num_tb;             /*!< This field indicates the number of transport blocks to be received*/
+  unsigned short tb_size_bytes;     /*!< This field indicates the number of bytes per transpor block*/
+  unsigned int Active_process_map;   /*!< HARQ indicator for active processes*/
+  unsigned int New_process_map;      /*!< HARQ indicator for new processes*/
+  //  unsigned char round_indices_tx;
+  union {
+    CHBCH_PDU   *Chbch_pdu;      /*!< pointer to CHBCH data */
+    DL_SACH_PDU DL_sach_pdu;    /*!< pointer to DL_SACH data*/
+    UL_SACH_PDU UL_sach_pdu;    /*!< pointer to UL_SACH data*/
+    RACH_PDU Rach_pdu;  //H.A   /*!< pointer to RACH data */
+    MRBCH_PDU   *Mrbch_pdu;     /*!< pointer to MRBCH data */
+  } Pdu;
+} MACPHY_DATA_REQ_TX;
+
+/*! \brief MACPHY-DATA-REQ primitive is used to transfer a new PDU to PHY corresponding to a particular transport channel*/
+typedef struct {
+  unsigned char Direction;
+  unsigned char Pdu_type;                 /*!< This field indicates the type of PDU requested */
+  LCHAN_ID      Lchan_id;                 /*!< This field indicates the flow id of the PDU */
+  PHY_RESOURCES *Phy_resources;           /*!< This field indicates to PHY the physical resources */
+  unsigned int format_flag;               /*!< This field indicates to PHY something about a SACH, e.g. presense of SACCH*/
+  union {
+    MACPHY_DATA_REQ_RX Req_rx;            /*!< This field contains the request corresponding to an RX resource*/
+    MACPHY_DATA_REQ_TX Req_tx;            /*!< This field contains the request corresponding to a TX resource*/
+  } Dir;
+} MACPHY_DATA_REQ;
+
+/*!\fn void macphy_data_ind(unsigned char Mod_id,MACPHY_DATA_REQ_RX *Req_rx,unsigned char Pdu_type,unsigned short Index);
+\brief MACPHY_DATA_IND function call.  Called by PHY to upload PDU and measurements in response to a MACPHY_DATA_REQ_RX.
+@param Mod_id MAC instance ID (only useful if multiple MAC instances run in the same machine)
+@param Req_rx Pointer to MACPHY_DTA_REQ_RX received previously
+@param Pdu_type Type of PDU (redundant!)
+@param Index CH Index for CH, UEid for UE
+*/
+void macphy_data_ind(unsigned char Mod_id,
+                     MACPHY_DATA_REQ_RX *Req_rx,
+                     unsigned char Pdu_type,
+                     unsigned short Index);
+
+/*! \brief MACPHY-CONFIG-REQ primitive is used to configure a new instance of OpenAirInterface (static configuration) during initialization*/
+typedef struct {
+  PHY_FRAMING Phy_framing;   /*!< Framing Configuration*/
+  PHY_CHSCH Phy_chsch[8];    /*!< CHSCH Static Configuration*/
+  PHY_CHBCH Phy_chbch;       /*!< CHBCH Static Configuration*/
+  PHY_SCH   Phy_sch[8];      /*!< SCH Static Configuration*/
+  PHY_SACH  Phy_sach;        /*!< SACH Statuc Configuration*/
+} MACPHY_CONFIG_REQ;
+
+/*! \brief MACPHY-CONFIG-SACH-HARQ-REQ primitive is used to configure a new SACH transport channel (dynamic configuration) during logical channel establishment*/
+//typedef struct {
+//  LCHAN_ID Lchan_id;             /*!< This is the identifier of the SACH, which should simply be the logical channel id*/
+//  HARQ_PARAMS Harq_params;           /*!< This is the set of HARQ parameters corresponding to the QoS description of the logical channel*/
+//} MACPHY_CONFIG_SACH_HARQ_REQ;
+
+/** @} */
+
+#define MAX_NUMBER_OF_MAC_INSTANCES 16
+
+#define NULL_PDU 255
+#define CHBCH 0
+#define DL_SACH 1
+#define UL_SACH 2
+#define UL_SACCH_SACH 3
+#define RACH 4
+#define MRBCH 5
+
+
+#define NUMBER_OF_SUBBANDS 64
+#define LCHAN_KEY 0
+#define PDU_TYPE_KEY 1
+#define PHY_RESOURCES_KEY 2
+
+typedef struct Macphy_req_entry_key {
+  unsigned char Key_type;
+  union {
+    LCHAN_ID *Lchan_id;  //SACH, EMULATION
+    unsigned char Pdu_type;//CHBCH, RACH, EMULATION
+    PHY_RESOURCES Phy_resources;//REAL PHY
+  } Key;
+} MACPHY_REQ_ENTRY_KEY;
+
+/** @ingroup _PHY_TRANSPORT_CHANNEL_PROCEDURES_
+ * @{
+\var typedef struct Macphy_data_req_table_entry {
+  MACPHY_DATA_REQ Macphy_data_req;
+  unsigned char Active;
+} MACPHY_DATA_REQ_TABLE_ENTRY;
+\brief An entry in the MACPHY_DATA_REQ Table.
+*/
+
+typedef struct Macphy_data_req_table_entry {
+  /// The MACPHY_DATA_REQ Structure itself
+  MACPHY_DATA_REQ Macphy_data_req;
+  /// Active flag.  Active=1 means that the REQ is pending.
+  unsigned char Active;
+} MACPHY_DATA_REQ_TABLE_ENTRY;
+
+/*!\var typedef struct  {
+  MACPHY_DATA_REQ_TABLE_ENTRY *Macphy_req_table_entry;
+  unsigned int Macphy_req_cnt;
+} MACPHY_DATA_REQ_TABLE
+\brief The MACPHY_DATA_REQ interface between MAC and PHY.  This table stores the pending requests from MAC which are serviced by PHY.  The pointer Macphy_req_table_entry points
+to an array of idle reqests allocated during initialization of the MAC-layer.
+*/
+
+typedef struct  {
+  /// Pointer to a MACPHY_DATA_REQ
+  MACPHY_DATA_REQ_TABLE_ENTRY *Macphy_req_table_entry;
+  /// Number of active requests
+  unsigned int Macphy_req_cnt;
+} MACPHY_DATA_REQ_TABLE;
+
+/** @} */
+
+/*typedef struct Tx_Phy_Pdu{                              //H.A
+  PHY_RESOURCES *Phy_resources;
+  MACPHY_DATA_IND *Macphy_data_ind;
+}T_PHY_PDU;
+
+typedef struct Rx_Phy_Pdu{                              //H.A
+  PHY_RESOURCES *Phy_resources;
+  char *Phy_payload;
+  }RX_PHY_PDU;*/
+
+
+typedef struct GRANTED_LCHAN_TABLE_ENTRY {
+  PHY_RESOURCES *Phy_resources;
+  LCHAN_ID Lchan_id;
+} GRANTED_LCHAN_TABLE_ENTRY;
+
+void clear_macphy_data_req(uint8_t);
+//void clean_macphy_interface(void);
+unsigned char phy_resources_compare(PHY_RESOURCES *,PHY_RESOURCES*);
+MACPHY_DATA_REQ_TABLE_ENTRY* find_data_req_entry(uint8_t,MACPHY_REQ_ENTRY_KEY*);
+void print_active_requests(uint8_t);
+void mac_process_meas_ul(uint8_t Mod_id,UL_MEAS *UL_meas, uint16_t Index);
+void mac_process_meas_dl(uint8_t Mod_id,DL_MEAS *DL_meas, uint16_t Index);
+
+
+
+
+MACPHY_DATA_REQ *new_macphy_data_req(uint8_t);
+//PHY_RESOURCES_TABLE_ENTRY *new_phy_resources(void);
+//MACPHY_DATA_IND *new_macphy_data_ind(void);
+#endif
+
+
diff --git a/openair2/NR_UE_PHY_INTERFACE/vars.h b/openair2/NR_UE_PHY_INTERFACE/vars.h
new file mode 100644
index 0000000000000000000000000000000000000000..566f4347b6e5e264ff19a5a28193b1c96258ab97
--- /dev/null
+++ b/openair2/NR_UE_PHY_INTERFACE/vars.h
@@ -0,0 +1,44 @@
+/*
+ * 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
+ */
+
+#ifndef __PHY_INTERFACE_VARS_H__
+#define __PHY_INTERFACE_VARS_H__
+
+//#include "SIMULATION/PHY_EMULATION/spec_defs.h"
+#include "defs.h"
+
+#ifdef PHY_EMUL
+#include "SIMULATION/PHY_EMULATION/DEVICE_DRIVER/defs.h"
+#include "SIMULATION/simulation_defs.h"
+#endif
+
+
+unsigned int mac_debug;
+
+//MAC_xface *mac_xface;
+
+//MACPHY_PARAMS MACPHY_params;
+
+unsigned int mac_registered;
+
+
+#endif
+
diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c
index b21cf77f4df76d15d10938cabeacca0c9ae3924c..59de459f674218510ee35ca1c7d6fef5b76fec8f 100644
--- a/openair2/RRC/LTE/L2_interface.c
+++ b/openair2/RRC/LTE/L2_interface.c
@@ -57,7 +57,7 @@ mac_rrc_data_req(
   const frame_t     frameP,
   const rb_id_t     Srb_id,
   const uint8_t     Nb_tb,
-  uint8_t*    const buffer_pP,
+  uint8_t    *const buffer_pP,
   const uint8_t     mbsfn_sync_area
 )
 //--------------------------------------------------------------------------
@@ -66,286 +66,262 @@ mac_rrc_data_req(
   SRB_INFO *Srb_info;
   uint8_t Sdu_size                = 0;
   uint8_t sfn                     = (uint8_t)((frameP>>2)&0xff);
-
-
 #ifdef DEBUG_RRC
   int i;
   LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id);
 #endif
-
   eNB_RRC_INST *rrc;
   rrc_eNB_carrier_data_t *carrier;
   BCCH_BCH_Message_t *mib;
+  rrc     = RC.rrc[Mod_idP];
+  carrier = &rrc->carrier[0];
+  mib     = &carrier->mib;
 
+  if((Srb_id & RAB_OFFSET) == BCCH) {
+    if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) {
+      return 0;
+    }
 
-    rrc     = RC.rrc[Mod_idP];
-    carrier = &rrc->carrier[0];
-    mib     = &carrier->mib;
-
-    if((Srb_id & RAB_OFFSET) == BCCH) {
-      if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) {
-        return 0;
-      }
-
-      // All even frames transmit SIB in SF 5
-      AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255, 
-		  "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP);
-
-      if ((frameP%2) == 0) {
-        memcpy(&buffer_pP[0],
-               RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
-               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
+    // All even frames transmit SIB in SF 5
+    AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255,
+                "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP);
 
+    if ((frameP%2) == 0) {
+      memcpy(&buffer_pP[0],
+             RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
+             RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
 #if 0 //defined(ENABLE_ITTI)
-        {
-          MessageDef *message_p;
-          int sib1_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1;
-          int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
-
-          if (sib1_size > sdu_size) {
-            LOG_E(RRC, "SIB1 SDU larger than BCCH SDU buffer size (%d, %d)", sib1_size, sdu_size);
-            sib1_size = sdu_size;
-          }
-
-          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ);
-          RRC_MAC_BCCH_DATA_REQ (message_p).frame    = frameP;
-          RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib1_size;
-          memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
-          memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
-                  RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
-                  sib1_size);
-          RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
-
-          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
-        }
-#endif
-
-#ifdef DEBUG_RRC
-        LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP);
+      {
+        MessageDef *message_p;
+        int sib1_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1;
+        int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
 
-        for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1; i++) {
-          LOG_T(RRC,"%x.",buffer_pP[i]);
+        if (sib1_size > sdu_size) {
+          LOG_E(RRC, "SIB1 SDU larger than BCCH SDU buffer size (%d, %d)", sib1_size, sdu_size);
+          sib1_size = sdu_size;
         }
 
-        LOG_T(RRC,"\n");
+        message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ);
+        RRC_MAC_BCCH_DATA_REQ (message_p).frame    = frameP;
+        RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib1_size;
+        memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
+        memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
+                RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
+                sib1_size);
+        RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
+        itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+      }
 #endif
+#ifdef DEBUG_RRC
+      LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP);
 
-        return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
-      } // All RFN mod 8 transmit SIB2-3 in SF 5
-      else if ((frameP%8) == 1) {
-        memcpy(&buffer_pP[0],
-               RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
-               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
+      for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1; i++) {
+        LOG_T(RRC,"%x.",buffer_pP[i]);
+      }
 
-#if 0 //defined(ENABLE_ITTI)
-        {
-          MessageDef *message_p;
-          int sib23_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23;
-          int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
-
-          if (sib23_size > sdu_size) {
-            LOG_E(RRC, "SIB23 SDU larger than BCCH SDU buffer size (%d, %d)", sib23_size, sdu_size);
-            sib23_size = sdu_size;
-          }
-
-          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ);
-          RRC_MAC_BCCH_DATA_REQ (message_p).frame = frameP;
-          RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib23_size;
-          memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
-          memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
-                  RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
-                  sib23_size);
-          RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
-
-          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
-        }
+      LOG_T(RRC,"\n");
 #endif
+      return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
+    } // All RFN mod 8 transmit SIB2-3 in SF 5
+    else if ((frameP%8) == 1) {
+      memcpy(&buffer_pP[0],
+             RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
+             RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
+#if 0 //defined(ENABLE_ITTI)
+      {
+        MessageDef *message_p;
+        int sib23_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23;
+        int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
 
-#ifdef DEBUG_RRC
-        LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP);
-
-        for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23; i++) {
-          LOG_T(RRC,"%x.",buffer_pP[i]);
+        if (sib23_size > sdu_size) {
+          LOG_E(RRC, "SIB23 SDU larger than BCCH SDU buffer size (%d, %d)", sib23_size, sdu_size);
+          sib23_size = sdu_size;
         }
 
-        LOG_T(RRC,"\n");
-#endif
-        return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
-      } else {
-        return(0);
+        message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ);
+        RRC_MAC_BCCH_DATA_REQ (message_p).frame = frameP;
+        RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib23_size;
+        memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
+        memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
+                RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
+                sib23_size);
+        RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
+        itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
       }
-    }
-    if( (Srb_id & RAB_OFFSET ) == MIBCH) {
-
-        mib->message.systemFrameNumber.buf = &sfn;
-	enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message,
-					 (void*)mib,
-					 carrier->MIB,
-					 24);
-	LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded);
-	buffer_pP[0]=carrier->MIB[0];
-	buffer_pP[1]=carrier->MIB[1];
-	buffer_pP[2]=carrier->MIB[2];
-	AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
-		     enc_rval.failed_type->name, enc_rval.encoded);
-	return(3);
-    }
-
-    if( (Srb_id & RAB_OFFSET ) == CCCH) {
-      LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id);
+#endif
+#ifdef DEBUG_RRC
+      LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP);
 
-      if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) {
-        LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP);
-        return -1;
+      for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23; i++) {
+        LOG_T(RRC,"%x.",buffer_pP[i]);
       }
 
-      Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0;
-
-      // check if data is there for MAC
-      if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer
-        LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload);
-
-#if 0 // defined(ENABLE_ITTI)
-        {
-          MessageDef *message_p;
-          int ccch_size = Srb_info->Tx_buffer.payload_size;
-          int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu);
-
-          if (ccch_size > sdu_size) {
-            LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", ccch_size, sdu_size);
-            ccch_size = sdu_size;
-          }
-
-          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_CCCH_DATA_REQ);
-          RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP;
-          RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size;
-          memset (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, 0, CCCH_SDU_SIZE);
-          memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, Srb_info->Tx_buffer.Payload, ccch_size);
-          RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index;
-
-          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
-        }
+      LOG_T(RRC,"\n");
 #endif
+      return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
+    } else {
+      return(0);
+    }
+  }
 
-        memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size);
-        Sdu_size = Srb_info->Tx_buffer.payload_size;
-        Srb_info->Tx_buffer.payload_size=0;
-      }
+  if( (Srb_id & RAB_OFFSET ) == MIBCH) {
+    mib->message.systemFrameNumber.buf = &sfn;
+    enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message,
+                                     NULL,
+                                     (void *)mib,
+                                     carrier->MIB,
+                                     24);
+    LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded);
+    buffer_pP[0]=carrier->MIB[0];
+    buffer_pP[1]=carrier->MIB[1];
+    buffer_pP[2]=carrier->MIB[2];
+    AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
+                 enc_rval.failed_type->name, enc_rval.encoded);
+    return(3);
+  }
+
+  if( (Srb_id & RAB_OFFSET ) == CCCH) {
+    LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id);
 
-      return (Sdu_size);
+    if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) {
+      LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP);
+      return -1;
     }
 
-    if( (Srb_id & RAB_OFFSET ) == PCCH) {
-      LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id);
+    Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0;
 
-      // check if data is there for MAC
-      if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer
-        LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area],
-               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]);
+    // check if data is there for MAC
+    if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer
+      LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload);
+#if 0 // defined(ENABLE_ITTI)
+      {
+        MessageDef *message_p;
+        int ccch_size = Srb_info->Tx_buffer.payload_size;
+        int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu);
 
-#if 0 //defined(ENABLE_ITTI)
-        {
-          MessageDef *message_p;
-          int pcch_size = RC.rrc[Mod_idP]->arrier[CC_id].sizeof_paging[mbsfn_sync_area];
-          int sdu_size = sizeof(RRC_MAC_PCCH_DATA_REQ (message_p).sdu);
-
-          if (pcch_size > sdu_size) {
-            LOG_E(RRC, "SDU larger than PCCH SDU buffer size (%d, %d)", pcch_size, sdu_size);
-            pcch_size = sdu_size;
-          }
-
-          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_PCCH_DATA_REQ);
-          RRC_MAC_PCCH_DATA_REQ (message_p).frame = frameP;
-          RRC_MAC_PCCH_DATA_REQ (message_p).sdu_size = pcch_size;
-          memset (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, 0, PCCH_SDU_SIZE);
-          memcpy (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], pcch_size);
-          RRC_MAC_PCCH_DATA_REQ (message_p).enb_index = eNB_index;
-
-          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+        if (ccch_size > sdu_size) {
+          LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", ccch_size, sdu_size);
+          ccch_size = sdu_size;
         }
-#endif
 
-        memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]);
-        Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area];
-        RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0;
+        message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_CCCH_DATA_REQ);
+        RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP;
+        RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size;
+        memset (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, 0, CCCH_SDU_SIZE);
+        memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, Srb_info->Tx_buffer.Payload, ccch_size);
+        RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index;
+        itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
       }
-
-      return (Sdu_size);
+#endif
+      memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size);
+      Sdu_size = Srb_info->Tx_buffer.payload_size;
+      Srb_info->Tx_buffer.payload_size=0;
     }
 
-#if defined(Rel10) || defined(Rel14)
-
-    if((Srb_id & RAB_OFFSET) == MCCH) {
-      if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) {
-        return 0;  // this parameter is set in function init_mcch in rrc_eNB.c
-      }
+    return (Sdu_size);
+  }
 
+  if( (Srb_id & RAB_OFFSET ) == PCCH) {
+    LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id);
 
-#if 0 // defined(ENABLE_ITTI)
+    // check if data is there for MAC
+    if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer
+      LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area],
+            RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]);
+#if 0 //defined(ENABLE_ITTI)
       {
         MessageDef *message_p;
-        int mcch_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area];
-        int sdu_size = sizeof(RRC_MAC_MCCH_DATA_REQ (message_p).sdu);
+        int pcch_size = RC.rrc[Mod_idP]->arrier[CC_id].sizeof_paging[mbsfn_sync_area];
+        int sdu_size = sizeof(RRC_MAC_PCCH_DATA_REQ (message_p).sdu);
 
-        if (mcch_size > sdu_size) {
-          LOG_E(RRC, "SDU larger than MCCH SDU buffer size (%d, %d)", mcch_size, sdu_size);
-          mcch_size = sdu_size;
+        if (pcch_size > sdu_size) {
+          LOG_E(RRC, "SDU larger than PCCH SDU buffer size (%d, %d)", pcch_size, sdu_size);
+          pcch_size = sdu_size;
         }
 
-        message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_MCCH_DATA_REQ);
-        RRC_MAC_MCCH_DATA_REQ (message_p).frame = frameP;
-        RRC_MAC_MCCH_DATA_REQ (message_p).sdu_size = mcch_size;
-        memset (RRC_MAC_MCCH_DATA_REQ (message_p).sdu, 0, MCCH_SDU_SIZE);
-        memcpy (RRC_MAC_MCCH_DATA_REQ (message_p).sdu,
-                RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
-                mcch_size);
-        RRC_MAC_MCCH_DATA_REQ (message_p).enb_index = eNB_index;
-        RRC_MAC_MCCH_DATA_REQ (message_p).mbsfn_sync_area = mbsfn_sync_area;
-
+        message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_PCCH_DATA_REQ);
+        RRC_MAC_PCCH_DATA_REQ (message_p).frame = frameP;
+        RRC_MAC_PCCH_DATA_REQ (message_p).sdu_size = pcch_size;
+        memset (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, 0, PCCH_SDU_SIZE);
+        memcpy (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], pcch_size);
+        RRC_MAC_PCCH_DATA_REQ (message_p).enb_index = eNB_index;
         itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
       }
 #endif
+      memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]);
+      Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area];
+      RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0;
+    }
 
-      memcpy(&buffer_pP[0],
-             RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
-             RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
+    return (Sdu_size);
+  }
 
-#ifdef DEBUG_RRC
-      LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP);
+#if defined(Rel10) || defined(Rel14)
 
-      for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) {
-        LOG_T(RRC,"%x.",buffer_pP[i]);
+  if((Srb_id & RAB_OFFSET) == MCCH) {
+    if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) {
+      return 0;  // this parameter is set in function init_mcch in rrc_eNB.c
+    }
+
+#if 0 // defined(ENABLE_ITTI)
+    {
+      MessageDef *message_p;
+      int mcch_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area];
+      int sdu_size = sizeof(RRC_MAC_MCCH_DATA_REQ (message_p).sdu);
+
+      if (mcch_size > sdu_size) {
+        LOG_E(RRC, "SDU larger than MCCH SDU buffer size (%d, %d)", mcch_size, sdu_size);
+        mcch_size = sdu_size;
       }
 
-      LOG_T(RRC,"\n");
+      message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_MCCH_DATA_REQ);
+      RRC_MAC_MCCH_DATA_REQ (message_p).frame = frameP;
+      RRC_MAC_MCCH_DATA_REQ (message_p).sdu_size = mcch_size;
+      memset (RRC_MAC_MCCH_DATA_REQ (message_p).sdu, 0, MCCH_SDU_SIZE);
+      memcpy (RRC_MAC_MCCH_DATA_REQ (message_p).sdu,
+              RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
+              mcch_size);
+      RRC_MAC_MCCH_DATA_REQ (message_p).enb_index = eNB_index;
+      RRC_MAC_MCCH_DATA_REQ (message_p).mbsfn_sync_area = mbsfn_sync_area;
+      itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+    }
 #endif
+    memcpy(&buffer_pP[0],
+           RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
+           RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
+#ifdef DEBUG_RRC
+    LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP);
 
-      return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
-      //      }
-      //else
-      //return(0);
+    for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) {
+      LOG_T(RRC,"%x.",buffer_pP[i]);
     }
 
-#endif //Rel10 || Rel14
+    LOG_T(RRC,"\n");
+#endif
+    return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
+    //      }
+    //else
+    //return(0);
+  }
 
+#endif //Rel10 || Rel14
 #ifdef Rel14
-    if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR){
-        memcpy(&buffer_pP[0],
-               RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR,
-               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
-        return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
-    }
-
-    if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR){ // First SI message with SIB2/3
-        memcpy(&buffer_pP[0],
-               RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR,
-               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR);
-        return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR);
-    }
 
-#endif
+  if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR) {
+    memcpy(&buffer_pP[0],
+           RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR,
+           RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
+    return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
+  }
 
+  if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR) { // First SI message with SIB2/3
+    memcpy(&buffer_pP[0],
+           RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR,
+           RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR);
+    return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR);
+  }
 
+#endif
   return(0);
 }
 
@@ -358,7 +334,7 @@ mac_rrc_data_ind(
   const sub_frame_t     sub_frameP,
   const rnti_t          rntiP,
   const rb_id_t         srb_idP,
-  const uint8_t*        sduP,
+  const uint8_t        *sduP,
   const sdu_size_t      sdu_lenP,
   const uint8_t         mbsfn_sync_areaP
 )
@@ -367,54 +343,48 @@ mac_rrc_data_ind(
   SRB_INFO *Srb_info;
   protocol_ctxt_t ctxt;
   sdu_size_t      sdu_size = 0;
-
   /* for no gcc warnings */
   (void)sdu_size;
-
   /*
   int si_window;
    */
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, rntiP, frameP, sub_frameP,0);
-
-    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);
-    
+  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);
 #if 0 //defined(ENABLE_ITTI)
-    {
-      MessageDef *message_p;
-      int msg_sdu_size = sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu);
-
-      if (sdu_lenP > msg_sdu_size) {
-        LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_lenP, msg_sdu_size);
-        sdu_size = msg_sdu_size;
-      } else {
-        sdu_size = sdu_lenP;
-      }
-
-      message_p = itti_alloc_new_message (TASK_MAC_ENB, RRC_MAC_CCCH_DATA_IND);
-      RRC_MAC_CCCH_DATA_IND (message_p).frame     = frameP;
-      RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frameP;
-      RRC_MAC_CCCH_DATA_IND (message_p).rnti      = rntiP;
-      RRC_MAC_CCCH_DATA_IND (message_p).sdu_size  = sdu_size;
-      RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
-      memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
-      memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, sduP, sdu_size);
-      LOG_D(RRC,"[eNB %d] Sending message to RRC task\n",module_idP);
-      itti_send_msg_to_task (TASK_RRC_ENB, ctxt.instance, message_p);
+  {
+    MessageDef *message_p;
+    int msg_sdu_size = sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu);
+
+    if (sdu_lenP > msg_sdu_size) {
+      LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_lenP, msg_sdu_size);
+      sdu_size = msg_sdu_size;
+    } else {
+      sdu_size = sdu_lenP;
     }
+
+    message_p = itti_alloc_new_message (TASK_MAC_ENB, RRC_MAC_CCCH_DATA_IND);
+    RRC_MAC_CCCH_DATA_IND (message_p).frame     = frameP;
+    RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frameP;
+    RRC_MAC_CCCH_DATA_IND (message_p).rnti      = rntiP;
+    RRC_MAC_CCCH_DATA_IND (message_p).sdu_size  = sdu_size;
+    RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
+    memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
+    memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, sduP, sdu_size);
+    LOG_D(RRC,"[eNB %d] Sending message to RRC task\n",module_idP);
+    itti_send_msg_to_task (TASK_RRC_ENB, ctxt.instance, message_p);
+  }
 #else
 
-    //    msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id);
-    if (sdu_lenP > 0) {
-      memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP);
-      Srb_info->Rx_buffer.payload_size = sdu_lenP;
-      rrc_eNB_decode_ccch(&ctxt, Srb_info, CC_id);
-    }
+  //    msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id);
+  if (sdu_lenP > 0) {
+    memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP);
+    Srb_info->Rx_buffer.payload_size = sdu_lenP;
+    rrc_eNB_decode_ccch(&ctxt, Srb_info, CC_id);
+  }
 
 #endif
-
   return(0);
-
 }
 
 //------------------------------------------------------------------------------
@@ -425,7 +395,7 @@ mac_eNB_get_rrc_status(
 )
 //------------------------------------------------------------------------------
 {
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
                    RC.rrc[Mod_idP],
                    rntiP);
@@ -438,60 +408,64 @@ mac_eNB_get_rrc_status(
 }
 
 void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
-			    const int CC_idP,
-			    const frame_t frameP,
-			    const sub_frame_t subframeP,
-			    const rnti_t rntiP)
+                            const int CC_idP,
+                            const frame_t frameP,
+                            const sub_frame_t subframeP,
+                            const rnti_t rntiP)
 {
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
                    RC.rrc[Mod_instP],
                    rntiP);
 
   if (ue_context_p != NULL) {
     LOG_I(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP);
+
     if(ue_context_p->ue_context.ul_failure_timer == 0)
       ue_context_p->ue_context.ul_failure_timer=1;
   }
   else {
     LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP);
   }
+
   if (rrc_agent_registered[Mod_instP]) {
     agent_rrc_xface[Mod_instP]->flexran_agent_notify_ue_state_change(Mod_instP,
-								     rntiP,
-								     PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
+        rntiP,
+        PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
   }
-//  rrc_mac_remove_ue(Mod_instP,rntiP);
+
+  //  rrc_mac_remove_ue(Mod_instP,rntiP);
 }
 
 void mac_eNB_rrc_uplane_failure(const module_id_t Mod_instP,
-                const int CC_idP,
-                const frame_t frameP,
-                const sub_frame_t subframeP,
-                const rnti_t rntiP)
+                                const int CC_idP,
+                                const frame_t frameP,
+                                const sub_frame_t subframeP,
+                                const rnti_t rntiP)
 {
-    struct rrc_eNB_ue_context_s* ue_context_p = NULL;
-    ue_context_p = rrc_eNB_get_ue_context(
-                     RC.rrc[Mod_instP],
-                     rntiP);
-    if (ue_context_p != NULL) {
-      LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP);
-
-      if(ue_context_p->ue_context.ul_failure_timer == 0)
-          ue_context_p->ue_context.ul_failure_timer=19999;
-    }
-    else {
-      LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP);
-    }
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
+  ue_context_p = rrc_eNB_get_ue_context(
+                   RC.rrc[Mod_instP],
+                   rntiP);
+
+  if (ue_context_p != NULL) {
+    LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP);
+
+    if(ue_context_p->ue_context.ul_failure_timer == 0)
+      ue_context_p->ue_context.ul_failure_timer=19999;
+  }
+  else {
+    LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP);
+  }
 }
 
-void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, 
-			    const int CC_idP, 
-			    const frame_t frameP,
-			    const sub_frame_t subframeP,
-			    const rnti_t rntiP)
+void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP,
+                            const int CC_idP,
+                            const frame_t frameP,
+                            const sub_frame_t subframeP,
+                            const rnti_t rntiP)
 {
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
                    RC.rrc[Mod_instP],
                    rntiP);
diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c
index 6c7e6e4ead7764a610fed45211cb7a252326584e..4aefb12b832e938b51edde69a002bf689ad97eaf 100644
--- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c
@@ -137,11 +137,9 @@ int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, voi
 {
   asn_enc_rval_t er;
   xer_sprint_string_t string_buffer;
-
   string_buffer.string = string;
   string_buffer.string_size = string_size;
   string_buffer.string_index = 0;
-
   er = xer_encode(td, sptr, XER_F_BASIC, xer__print2s, &string_buffer);
 
   if (er.encoded < 0) {
@@ -179,40 +177,40 @@ uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId)
 
 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)
 {
-
   asn_enc_rval_t enc_rval;
   BCCH_BCH_Message_t *mib=&carrier->mib ;
   uint8_t sfn = (uint8_t)((frame>>2)&0xff);
   uint16_t *spare= calloc(1, sizeof(uint16_t));
+
   if (spare == NULL) abort();
 
   switch (N_RB_DL) {
+    case 6:
+      mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
+      break;
 
-  case 6:
-    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
-    break;
+    case 15:
+      mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15;
+      break;
 
-  case 15:
-    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15;
-    break;
+    case 25:
+      mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25;
+      break;
 
-  case 25:
-    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25;
-    break;
+    case 50:
+      mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50;
+      break;
 
-  case 50:
-    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50;
-    break;
+    case 75:
+      mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75;
+      break;
 
-  case 75:
-    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75;
-    break;
+    case 100:
+      mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100;
+      break;
 
-  case 100:
-    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100;
-    break;
-  default:
-    AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL);
+    default:
+      AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL);
   }
 
   AssertFatal(phich_Resource <= PHICH_Config__phich_Resource_two,"Illegal phich_Resource\n");
@@ -220,11 +218,10 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich
   AssertFatal(phich_duration <= PHICH_Config__phich_Duration_extended,"Illegal phich_Duration\n");
   mib->message.phich_Config.phich_Duration = phich_duration;
   LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x,sfn %x\n",
-         (uint32_t)mib->message.dl_Bandwidth,
-         (uint32_t)phich_duration,
-         (uint32_t)phich_Resource,
-         (uint32_t)sfn);
-
+        (uint32_t)mib->message.dl_Bandwidth,
+        (uint32_t)phich_duration,
+        (uint32_t)phich_Resource,
+        (uint32_t)sfn);
   mib->message.systemFrameNumber.buf = &sfn;
   mib->message.systemFrameNumber.size = 1;
   mib->message.systemFrameNumber.bits_unused=0;
@@ -237,17 +234,17 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich
   mib->message.spare.bits_unused = 3;  // This makes a spare of 5 bits
   mib->message.schedulingInfoSIB1_BR_r13 = 0; // turn off eMTC
 #endif
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message,
-                                   (void*)mib,
+                                   NULL,
+                                   (void *)mib,
                                    carrier->MIB,
                                    24);
   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)
+  #if defined(ENABLE_ITTI)
+  # if !defined(DISABLE_XER_SPRINT)
   {
     char        message_string[20000];
     size_t      message_string_size;
@@ -262,8 +259,8 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich
       itti_send_msg_to_task(TASK_UNKNOWN, enb_module_idP, msg_p);
     }
   }
-# endif
-#endif
+  # endif
+  #endif
   */
   if (enc_rval.encoded==-1) {
     return(-1);
@@ -273,43 +270,32 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich
 }
 
 uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
-		int Mod_id,int CC_id
+                int Mod_id,int CC_id
 #if defined(ENABLE_ITTI)
                 , RrcConfigurationReq *configuration
 #endif
                )
 {
-
   //  SystemInformation_t systemInformation;
   PLMN_IdentityInfo_t PLMN_identity_info;
   MCC_MNC_Digit_t dummy_mcc[3],dummy_mnc[3];
   asn_enc_rval_t enc_rval;
   SchedulingInfo_t schedulingInfo;
   SIB_Type_t sib_type;
-
   uint8_t *buffer                      = carrier->SIB1;
   BCCH_DL_SCH_Message_t *bcch_message  = &carrier->siblock1;
   SystemInformationBlockType1_t **sib1 = &carrier->sib1;
-
-  
   memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t));
   bcch_message->message.present = BCCH_DL_SCH_MessageType_PR_c1;
   bcch_message->message.choice.c1.present = 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,sizeof(PLMN_IdentityInfo_t));
   memset(&schedulingInfo,0,sizeof(SchedulingInfo_t));
   memset(&sib_type,0,sizeof(SIB_Type_t));
-
-
-
   PLMN_identity_info.plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
   memset(PLMN_identity_info.plmn_Identity.mcc,0,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
-
   asn_set_empty(&PLMN_identity_info.plmn_Identity.mcc->list);//.size=0;
-
 #if defined(ENABLE_ITTI)
   dummy_mcc[0] = (configuration->mcc / 100) % 10;
   dummy_mcc[1] = (configuration->mcc / 10) % 10;
@@ -322,7 +308,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
   ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[0]);
   ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[1]);
   ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[2]);
-
   PLMN_identity_info.plmn_Identity.mnc.list.size=0;
   PLMN_identity_info.plmn_Identity.mnc.list.count=0;
 #if defined(ENABLE_ITTI)
@@ -357,10 +342,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
 
   //assign_enum(&PLMN_identity_info.cellReservedForOperatorUse,PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved);
   PLMN_identity_info.cellReservedForOperatorUse=PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
-
   ASN_SEQUENCE_ADD(&(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list,&PLMN_identity_info);
-
-
   // 16 bits
   (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf = MALLOC(2);
 #if defined(ENABLE_ITTI)
@@ -372,7 +354,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
 #endif
   (*sib1)->cellAccessRelatedInfo.trackingAreaCode.size=2;
   (*sib1)->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0;
-
   // 28 bits
   (*sib1)->cellAccessRelatedInfo.cellIdentity.buf = MALLOC(8);
 #if defined(ENABLE_ITTI)
@@ -388,14 +369,11 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
 #endif
   (*sib1)->cellAccessRelatedInfo.cellIdentity.size=4;
   (*sib1)->cellAccessRelatedInfo.cellIdentity.bits_unused=4;
-
   //  assign_enum(&(*sib1)->cellAccessRelatedInfo.cellBarred,SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred);
   (*sib1)->cellAccessRelatedInfo.cellBarred=SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred;
-
   //  assign_enum(&(*sib1)->cellAccessRelatedInfo.intraFreqReselection,SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed);
   (*sib1)->cellAccessRelatedInfo.intraFreqReselection=SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_notAllowed;
   (*sib1)->cellAccessRelatedInfo.csg_Indication=0;
-
   (*sib1)->cellSelectionInfo.q_RxLevMin=-65;
   (*sib1)->cellSelectionInfo.q_RxLevMinOffset=NULL;
   //(*sib1)->p_Max = CALLOC(1, sizeof(P_Max_t));
@@ -406,52 +384,45 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
 #else
     7;
 #endif
-
   schedulingInfo.si_Periodicity=SchedulingInfo__si_Periodicity_rf8;
-
   // This is for SIB2/3
   sib_type=SIB_Type_sibType3;
   ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type);
   ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo);
-
   //  ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,NULL);
-
 #if defined(ENABLE_ITTI)
 
   if (configuration->frame_type[CC_id] == TDD)
 #endif
   {
     (*sib1)->tdd_Config =                             CALLOC(1,sizeof(struct TDD_Config));
-
     (*sib1)->tdd_Config->subframeAssignment =
 #if defined(ENABLE_ITTI)
       configuration->tdd_config[CC_id];
 #else
       3;
 #endif
-
     (*sib1)->tdd_Config->specialSubframePatterns =
 #if defined(ENABLE_ITTI)
       configuration->tdd_config_s[CC_id];
 #else
-    0;
+      0;
 #endif
   }
 
   (*sib1)->si_WindowLength=SystemInformationBlockType1__si_WindowLength_ms20;
   (*sib1)->systemInfoValueTag=0;
   //  (*sib1).nonCriticalExtension = calloc(1,sizeof(*(*sib1).nonCriticalExtension));
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message);
+  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_DL_SCH_Message,
-                                   (void*)bcch_message,
+                                   NULL,
+                                   (void *)bcch_message,
                                    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)
   {
@@ -460,7 +431,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
@@ -469,7 +439,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
   }
 # endif
 #endif
-
   LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
 
   if (enc_rval.encoded==-1) {
@@ -495,7 +464,6 @@ uint8_t do_SIB23(uint8_t Mod_id,
   struct 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;
   BCCH_DL_SCH_Message_t             *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation;
   SystemInformationBlockType2_t     **sib2        = &RC.rrc[Mod_id]->carrier[CC_id].sib2;
@@ -531,13 +499,10 @@ uint8_t do_SIB23(uint8_t Mod_id,
   sib3_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
   memset(sib2_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
   memset(sib3_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
-
   sib2_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2;
   sib3_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3;
-
   *sib2 = &sib2_part->choice.sib2;
   *sib3 = &sib3_part->choice.sib3;
-
 #if defined(Rel10) || defined(Rel14)
 
   if (MBMS_flag > 0) {
@@ -548,9 +513,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
   }
 
 #endif
-
   // sib2
-
   (*sib2)->ac_BarringInfo = NULL;
 #if defined(Rel10) || defined(Rel14)
 #if 0
@@ -561,9 +524,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib2)->ext1 = NULL;
   (*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.preamblesGroupAConfig                        = NULL;
 
@@ -586,17 +547,14 @@ uint8_t do_SIB23(uint8_t Mod_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];
-
   // PCCH-Config
   (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle
     = configuration->pcch_defaultPagingCycle[CC_id];
   (*sib2)->radioResourceConfigCommon.pcch_Config.nB
     = configuration->pcch_nB[CC_id];
-
   // PRACH-Config
   (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex
     = configuration->prach_root[CC_id];
@@ -608,13 +566,11 @@ uint8_t do_SIB23(uint8_t Mod_id,
     = configuration->prach_zero_correlation[CC_id];
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset
     = configuration->prach_freq_offset[CC_id];
-
   // PDSCH-Config
   (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower
     = configuration->pdsch_referenceSignalPower[CC_id];
   (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b
     = configuration->pdsch_p_b[CC_id];
-
   // PUSCH-Config
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB
     = configuration->pusch_n_SB[CC_id];
@@ -632,9 +588,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
     = configuration->pusch_sequenceHoppingEnabled[CC_id];
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift
     = configuration->pusch_nDMRS1[CC_id];
-
   // PUCCH-Config
-
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift
     = configuration->pucch_delta_shift[CC_id];
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI
@@ -664,6 +618,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
     } else {
       (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts = NULL;
     }
+
     RC.rrc[Mod_id]->srs_enable[CC_id] = 1;
   } else {
     RC.rrc[Mod_id]->srs_enable[CC_id] = 0;
@@ -672,7 +627,6 @@ uint8_t do_SIB23(uint8_t Mod_id,
   }
 
   // uplinkPowerControlCommon
-
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH
     = configuration->pusch_p0_Nominal[CC_id];
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH
@@ -693,9 +647,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
     = configuration->msg3_delta_Preamble[CC_id];
   (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength
     = configuration->ul_CyclicPrefixLength[CC_id];
-
   // UE Timers and Constants
-
   (*sib2)->ue_TimersAndConstants.t300
     = configuration->ue_TimersAndConstants_t300[CC_id];
   (*sib2)->ue_TimersAndConstants.t301
@@ -708,7 +660,6 @@ uint8_t do_SIB23(uint8_t Mod_id,
     = configuration->ue_TimersAndConstants_t311[CC_id];
   (*sib2)->ue_TimersAndConstants.n311
     = configuration->ue_TimersAndConstants_n311[CC_id];
-
 #else
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles=RACH_ConfigCommon__preambleInfo__numberOfRA_Preambles_n64;
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL;
@@ -720,27 +671,20 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer=
     RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48;
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = 4;
-
   // BCCH-Config
   (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff=BCCH_Config__modificationPeriodCoeff_n2;
-
   // PCCH-Config
   (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = PCCH_Config__defaultPagingCycle_rf128;
   (*sib2)->radioResourceConfigCommon.pcch_Config.nB=PCCH_Config__nB_oneT;
-
   // PRACH-Config
   (*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;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset = 2;
-
   // PDSCH-Config
   (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower=0;  // corresponds to 24.7 dBm 5 MHz/ 27.7 10 MHz/ 30.7 20 MHz
-
-
   (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0;
-
   // PUSCH-Config
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB=1;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode=PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
@@ -750,55 +694,35 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH=0;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled=0;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift=0;
-
   // PUCCH-Config
-
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift=PUCCH_ConfigCommon__deltaPUCCH_Shift_ds1;
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI = 1;
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = 0;
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = 32;
-
-
   (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=SoundingRS_UL_ConfigCommon_PR_release;
   (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0;
-
   // uplinkPowerControlCommon
-
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH = -108;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH = -108;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha=UplinkPowerControlCommon__alpha_al1;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1=DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b=DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
-
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2=DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
-
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a=DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
-
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b=DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
-
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 = 6;
-
   (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength=UL_CyclicPrefixLength_len1;
-
   (*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;
   (*sib2)->freqInfo.ul_Bandwidth = NULL;
   //  (*sib2)->mbsfn_SubframeConfigList = NULL;
-
 #if defined(Rel10) || defined(Rel14)
 
   if (MBMS_flag > 0) {
@@ -806,37 +730,29 @@ uint8_t do_SIB23(uint8_t Mod_id,
     MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig1;
     (*sib2)->mbsfn_SubframeConfigList = CALLOC(1,sizeof(struct MBSFN_SubframeConfigList));
     MBSFNSubframeConfigList = (*sib2)->mbsfn_SubframeConfigList;
-
     sib2_mbsfn_SubframeConfig1= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig1));
-    memset((void*)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1));
-
+    memset((void *)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1));
     sib2_mbsfn_SubframeConfig1->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
     sib2_mbsfn_SubframeConfig1->radioframeAllocationOffset= 1;
     sib2_mbsfn_SubframeConfig1->subframeAllocation.present= MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
     sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf= MALLOC(1);
     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 ) {
       LOG_I(RRC,"Adding MBSFN subframe Configuration 2 to SIB2\n");
       MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig2;
       sib2_mbsfn_SubframeConfig2= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig2));
-      memset((void*)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2));
-
+      memset((void *)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2));
       sib2_mbsfn_SubframeConfig2->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
       sib2_mbsfn_SubframeConfig2->radioframeAllocationOffset= 1;
       sib2_mbsfn_SubframeConfig2->subframeAllocation.present= MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
       sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf= MALLOC(1);
       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);
     }
   }
@@ -844,9 +760,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
 #else // no MBMS transmission
   (*sib2)->mbsfn_SubframeConfigList = NULL;
 #endif
-
   (*sib2)->timeAlignmentTimerCommon=TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120;
-
   /// (*SIB3)
 #if defined(Rel10) || defined(Rel14)
   (*sib3)->ext1 = NULL;
@@ -858,21 +772,16 @@ uint8_t do_SIB23(uint8_t Mod_id,
 #endif
 #endif
   (*sib3)->cellReselectionInfoCommon.q_Hyst=SystemInformationBlockType3__cellReselectionInfoCommon__q_Hyst_dB4;
-
   (*sib3)->cellReselectionInfoCommon.speedStateReselectionPars=NULL;
-
   (*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));
   *(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = 31;
   (*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth=CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth));
-
   *(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth = AllowedMeasBandwidth_mbw6;
-
   (*sib3)->intraFreqCellReselectionInfo.presenceAntennaPort1 = 0;
   (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.buf = CALLOC(8,1);
   (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.size = 1;
@@ -880,7 +789,6 @@ 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 SpeedStateScaleFactors *)NULL;
-
   // SIB13
   // fill in all elements of SIB13 if present
 #if defined(Rel10) || defined(Rel14)
@@ -890,7 +798,6 @@ uint8_t do_SIB23(uint8_t Mod_id,
     (*sib13)->notificationConfig_r9.notificationRepetitionCoeff_r9= MBMS_NotificationConfig_r9__notificationRepetitionCoeff_r9_n2;
     (*sib13)->notificationConfig_r9.notificationOffset_r9= 0;
     (*sib13)->notificationConfig_r9.notificationSF_Index_r9= 1;
-
     //  MBSFN-AreaInfoList
     MBSFNArea_list= &(*sib13)->mbsfn_AreaInfoList_r9;//CALLOC(1,sizeof(*MBSFNArea_list));
     memset(MBSFNArea_list,0,sizeof(*MBSFNArea_list));
@@ -905,14 +812,9 @@ uint8_t do_SIB23(uint8_t Mod_id,
     //  Subframe Allocation Info
     MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1);
     MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
-
     MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x20<<2;  // FDD: SF1
-    
-
     MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
-
     MBSFN_Area1->mcch_Config_r9.signallingMCS_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7;
-
     ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area1);
 
     //MBSFN Area 2: currently only activated for eMBMS relaying
@@ -928,12 +830,8 @@ uint8_t do_SIB23(uint8_t Mod_id,
       MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1);
       MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
       MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
-
       MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x04<<2;  // FDD: SF6
-     
-
       MBSFN_Area2->mcch_Config_r9.signallingMCS_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7;
-
       ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area2);
     }
 
@@ -941,18 +839,13 @@ uint8_t do_SIB23(uint8_t Mod_id,
   }
 
 #endif
-
   bcch_message->message.present = BCCH_DL_SCH_MessageType_PR_c1;
   bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType__c1_PR_systemInformation;
-
   /*  memcpy((void*)&bcch_message.message.choice.c1.choice.systemInformation,
    (void*)systemInformation,
    sizeof(SystemInformation_t));*/
-
   bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = 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;
   ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,
@@ -966,19 +859,16 @@ uint8_t do_SIB23(uint8_t Mod_id,
   }
 
 #endif
-
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message);
+  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_DL_SCH_Message,
-                                   (void*)bcch_message,
+                                   NULL,
+                                   (void *)bcch_message,
                                    buffer,
                                    900);
   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)
   {
@@ -987,17 +877,14 @@ uint8_t do_SIB23(uint8_t Mod_id,
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_D(RRC,"[eNB] SystemInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
 
   if (enc_rval.encoded==-1) {
@@ -1010,21 +897,15 @@ uint8_t do_SIB23(uint8_t Mod_id,
 
 uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv)
 {
-
   asn_enc_rval_t enc_rval;
   uint8_t buf[5],buf2=0;
   uint8_t ecause=0;
-
   UL_CCCH_Message_t ul_ccch_msg;
-
   RRCConnectionRequest_t *rrcConnectionRequest;
-
   memset((void *)&ul_ccch_msg,0,sizeof(UL_CCCH_Message_t));
-
   ul_ccch_msg.message.present           = UL_CCCH_MessageType_PR_c1;
   ul_ccch_msg.message.choice.c1.present = UL_CCCH_MessageType__c1_PR_rrcConnectionRequest;
   rrcConnectionRequest          = &ul_ccch_msg.message.choice.c1.choice.rrcConnectionRequest;
-
   rrcConnectionRequest->criticalExtensions.present = RRCConnectionRequest__criticalExtensions_PR_rrcConnectionRequest_r8;
 
   if (1) {
@@ -1053,19 +934,16 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv)
   }
 
   rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.establishmentCause = EstablishmentCause_mo_Signalling; //EstablishmentCause_mo_Data;
-
   rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.buf = &buf2;
   rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.size=1;
   rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.bits_unused = 7;
-
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_UL_CCCH_Message,
-                                   (void*)&ul_ccch_msg,
+                                   NULL,
+                                   (void *)&ul_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)
   {
@@ -1074,50 +952,37 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv)
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_CCCH_Message, (void *) &ul_ccch_msg)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_CCCH, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_ul_ccch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_ul_ccch.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_D(RRC,"[UE] RRCConnectionRequest Encoded %zd bits (%zd bytes), ecause %d\n",enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
-
   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;
-
   UL_DCCH_Message_t ul_dcch_msg;
-
   RRCConnectionSetupComplete_t *rrcConnectionSetupComplete;
-
   memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
-
   ul_dcch_msg.message.present           = UL_DCCH_MessageType_PR_c1;
   ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete;
   rrcConnectionSetupComplete            = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionSetupComplete;
-
   rrcConnectionSetupComplete->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionSetupComplete->criticalExtensions.present = RRCConnectionSetupComplete__criticalExtensions_PR_c1;
   rrcConnectionSetupComplete->criticalExtensions.choice.c1.present = RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8;
-
   rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension=CALLOC(1,
       sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension));
 
   if(usim_test == 0)
-      rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 2;
+    rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 2;
   else
-      rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 1;
+    rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 1;
 
   rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME =
     NULL;//calloc(1,sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME));
@@ -1132,21 +997,19 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin
   memset(&rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.dedicatedInfoNAS,0,sizeof(OCTET_STRING_t));
   OCTET_STRING_fromBuf(&rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.dedicatedInfoNAS,
                        dedicatedInfoNAS, dedicatedInfoNASLength);
-
   /*
     rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.buf = calloc(1,1);
     rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.buf[0] = 0x98;
     rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.size=1;
     rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.bits_unused=0;
   */
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message,
-                                   (void*)&ul_dcch_msg,
+                                   NULL,
+                                   (void *)&ul_dcch_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)
   {
@@ -1155,58 +1018,45 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_D(RRC,"RRCConnectionSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
-
   return((enc_rval.encoded+7)/8);
-
 }
 
 //------------------------------------------------------------------------------
 uint8_t
 do_RRCConnectionReconfigurationComplete(
-  const protocol_ctxt_t* const ctxt_pP,
-  uint8_t* buffer,
+  const protocol_ctxt_t *const ctxt_pP,
+  uint8_t *buffer,
   const uint8_t Transaction_id
 )
 //------------------------------------------------------------------------------
 {
-
-
   asn_enc_rval_t enc_rval;
-
   UL_DCCH_Message_t ul_dcch_msg;
-
   RRCConnectionReconfigurationComplete_t *rrcConnectionReconfigurationComplete;
-
   memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
-
   ul_dcch_msg.message.present                     = UL_DCCH_MessageType_PR_c1;
   ul_dcch_msg.message.choice.c1.present           = UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete;
   rrcConnectionReconfigurationComplete            = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionReconfigurationComplete;
-
   rrcConnectionReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionReconfigurationComplete->criticalExtensions.present =
     RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8;
   rrcConnectionReconfigurationComplete->criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.nonCriticalExtension=NULL;
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message,
-                                   (void*)&ul_dcch_msg,
+                                   NULL,
+                                   (void *)&ul_dcch_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)
   {
@@ -1215,19 +1065,15 @@ do_RRCConnectionReconfigurationComplete(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_D(RRC,"RRCConnectionReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
-
   return((enc_rval.encoded+7)/8);
 }
 
@@ -1235,38 +1081,32 @@ do_RRCConnectionReconfigurationComplete(
 //------------------------------------------------------------------------------
 uint8_t
 do_RRCConnectionSetup(
-  const protocol_ctxt_t*     const ctxt_pP,
-  rrc_eNB_ue_context_t*      const ue_context_pP,
+  const protocol_ctxt_t     *const ctxt_pP,
+  rrc_eNB_ue_context_t      *const ue_context_pP,
   int                        CC_id,
-  uint8_t*                   const buffer,
+  uint8_t                   *const buffer,
   const uint8_t              transmission_mode,
   const uint8_t              Transaction_id,
   SRB_ToAddModList_t  **SRB_configList,
   struct PhysicalConfigDedicated  **physicalConfigDedicated)
 {
-
   asn_enc_rval_t enc_rval;
   uint8_t ecause=0;
   eNB_RRC_INST *rrc               = RC.rrc[ctxt_pP->module_id];
   rrc_eNB_carrier_data_t *carrier = &rrc->carrier[CC_id];
- 
-  long* logicalchannelgroup = NULL;
-  struct SRB_ToAddMod* SRB1_config = NULL;
-  struct SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL;
-  struct SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL;
-  struct LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL;
-
+  long *logicalchannelgroup = NULL;
+  struct SRB_ToAddMod *SRB1_config = NULL;
+  struct SRB_ToAddMod__rlc_Config *SRB1_rlc_config = NULL;
+  struct SRB_ToAddMod__logicalChannelConfig *SRB1_lchan_config = NULL;
+  struct LogicalChannelConfig__ul_SpecificParameters *SRB1_ul_SpecificParameters = NULL;
 #ifdef CBA
-  struct PUSCH_CBAConfigDedicated_vlola*  pusch_CBAConfigDedicated_vlola = NULL;
-  long* betaOffset_CBA_Index = NULL;
-  long* cShift_CBA = NULL;
+  struct PUSCH_CBAConfigDedicated_vlola  *pusch_CBAConfigDedicated_vlola = NULL;
+  long *betaOffset_CBA_Index = NULL;
+  long *cShift_CBA = NULL;
 #endif
-  PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL;
-
+  PhysicalConfigDedicated_t *physicalConfigDedicated2 = NULL;
   DL_CCCH_Message_t dl_ccch_msg;
-
-  RRCConnectionSetup_t* rrcConnectionSetup = NULL;
-
+  RRCConnectionSetup_t *rrcConnectionSetup = NULL;
   memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t));
   dl_ccch_msg.message.present           = DL_CCCH_MessageType_PR_c1;
   dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionSetup;
@@ -1281,14 +1121,11 @@ do_RRCConnectionSetup(
   }
 
   *SRB_configList = CALLOC(1,sizeof(SRB_ToAddModList_t));
-
   /// 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;
-
   SRB1_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
   SRB1_rlc_config->choice.explicitValue.present=RLC_Config_PR_am;
 #if defined(ENABLE_ITTI)
@@ -1298,44 +1135,31 @@ do_RRCConnectionSetup(
   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 
+#else
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms20;;
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = PollPDU_p4;;
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte         = PollByte_kBinfinity;
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8;
   SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering     = T_Reordering_ms35;
   SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms0;
-#endif 
-
+#endif
   SRB1_lchan_config = CALLOC(1,sizeof(*SRB1_lchan_config));
   SRB1_config->logicalChannelConfig   = SRB1_lchan_config;
-
   SRB1_lchan_config->present = 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=LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
-
   //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50);
   SRB1_ul_SpecificParameters->bucketSizeDuration=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));
@@ -1343,10 +1167,12 @@ do_RRCConnectionSetup(
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH));
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH));
   physicalConfigDedicated2->cqi_ReportConfig              = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
+
   if (rrc->srs_enable[CC_id]==1)
     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));
 
@@ -1374,7 +1200,6 @@ do_RRCConnectionSetup(
   physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_ACK_Index = 0; // 2.00
   physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_RI_Index  = 0; // 1.25
   physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_CQI_Index = 8; // 2.25
-
   // UplinkPowerControlDedicated
   physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUSCH = 0; // 0 dB
   //assign_enum(&physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled,
@@ -1387,9 +1212,7 @@ do_RRCConnectionSetup(
       sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient));
   //  assign_enum(physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient,FilterCoefficient_fc4); // fc4 dB
   *physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient=FilterCoefficient_fc4; // fc4 dB
-
   // TPC-PDCCH-Config
-
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->present=TPC_PDCCH_Config_PR_setup;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.present = TPC_Index_PR_indexOfFormat3;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1;
@@ -1398,7 +1221,6 @@ do_RRCConnectionSetup(
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0]=0x12;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused=0;
-
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present=TPC_PDCCH_Config_PR_setup;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.present = TPC_Index_PR_indexOfFormat3;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1;
@@ -1407,9 +1229,7 @@ do_RRCConnectionSetup(
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0]=0x22;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused=0;
-
   // CQI ReportConfig
-
   physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic));
 #if defined(Rel10) || defined(Rel14)
   *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic= CQI_ReportModeAperiodic_rm30;
@@ -1418,65 +1238,68 @@ do_RRCConnectionSetup(
 #endif
   physicalConfigDedicated2->cqi_ReportConfig->nomPDSCH_RS_EPRE_Offset = 0; // 0 dB
   //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=NULL;
-  
   physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic));
   physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present =  CQI_ReportPeriodic_PR_release;
-    /*
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present =  CQI_ReportPeriodic_PR_setup;
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0;  // n2_pucch
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0;  // Icqi/pmi
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI;  // subband CQI
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4;
-
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL;
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0;
-    */
+  /*
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present =  CQI_ReportPeriodic_PR_setup;
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0;  // n2_pucch
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0;  // Icqi/pmi
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI;  // subband CQI
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4;
+
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL;
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0;
+  */
 
   //soundingRS-UL-ConfigDedicated
   if (rrc->srs_enable[CC_id]==1) {
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup;
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth =
-                                                             SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0;
+      SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0;
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth =
-          SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0;
+      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
-	  == 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 %zd. Expect undefined behaviour!\n",
-		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);
+          == 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 %zd. Expect undefined behaviour!\n",
+                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
-	  == 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 %zd and %zd. Expect undefined behaviour!\n",
-		carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig,
-		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);
+          == 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 %zd and %zd. Expect undefined behaviour!\n",
+                carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig,
+                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 %zd, TransmissionComb %zd\n",ue_context_pP->local_uid,
-	  physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex,
-	  physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb);
 
+    LOG_W(RRC,"local UID %d, srs ConfigIndex %zd, TransmissionComb %zd\n",ue_context_pP->local_uid,
+          physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex,
+          physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb);
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift=
-          SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0;
+      SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0;
   }
 
-
   //AntennaInfoDedicated
   physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo));
   physicalConfigDedicated2->antennaInfo->present = PhysicalConfigDedicated__antennaInfo_PR_explicitValue;
@@ -1484,53 +1307,51 @@ do_RRCConnectionSetup(
   //     AntennaInfoDedicated__transmissionMode_tm2);
 
   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=     AntennaInfoDedicated__transmissionMode_tm1;
-    break;
-
-  case 2:
-    physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     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;
-    */
-  }
+    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=     AntennaInfoDedicated__transmissionMode_tm1;
+      break;
+
+    case 2:
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     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 = AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release;
   physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0;
-
   // SchedulingRequestConfig
-
   physicalConfigDedicated2->schedulingRequestConfig->present = SchedulingRequestConfig_PR_setup;
   physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid;
 
@@ -1538,24 +1359,24 @@ do_RRCConnectionSetup(
     physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5+(ue_context_pP->local_uid%10);  // Isr = 5 (every 10 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;
+      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;
     }
   }
 
@@ -1563,7 +1384,6 @@ do_RRCConnectionSetup(
   //SchedulingRequestConfig__setup__dsr_TransMax_n4);
   //  assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4;
   physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4;
-
   rrcConnectionSetup->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionSetup->criticalExtensions.present = RRCConnectionSetup__criticalExtensions_PR_c1;
   rrcConnectionSetup->criticalExtensions.choice.c1.present =RRCConnectionSetup__criticalExtensions__c1_PR_rrcConnectionSetup_r8 ;
@@ -1582,18 +1402,16 @@ do_RRCConnectionSetup(
   physicalConfigDedicated2->pusch_CBAConfigDedicated_vlola->cShift_CBA=cShift_CBA;
   rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.sps_CBA_ConfigList_vlola = NULL;
 #endif
-
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void *)&dl_ccch_msg);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message,
-                                   (void*)&dl_ccch_msg,
+                                   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)
   {
@@ -1602,34 +1420,29 @@ do_RRCConnectionSetup(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_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
-
   LOG_D(RRC,"RRCConnectionSetup Encoded %zd bits (%zd bytes), ecause %d\n",
         enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
-
   //  FREEMEM(SRB_list);
   //  free(SRB1_config);
   //  free(SRB1_rlc_config);
   //  free(SRB1_lchan_config);
   //  free(SRB1_ul_SpecificParameters);
-
   return((enc_rval.encoded+7)/8);
 }
 
 //------------------------------------------------------------------------------
 uint8_t
 do_SecurityModeCommand(
-  const protocol_ctxt_t* const ctxt_pP,
-  uint8_t* const buffer,
+  const protocol_ctxt_t *const ctxt_pP,
+  uint8_t *const buffer,
   const uint8_t Transaction_id,
   const uint8_t cipheringAlgorithm,
   const uint8_t integrityProtAlgorithm
@@ -1638,15 +1451,11 @@ do_SecurityModeCommand(
 {
   DL_DCCH_Message_t dl_dcch_msg;
   asn_enc_rval_t enc_rval;
-
   memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
-
   dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
   dl_dcch_msg.message.choice.c1.present = 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 = SecurityModeCommand__criticalExtensions_PR_c1;
-
   dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present =
     SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8;
   // the two following information could be based on the mod_id
@@ -1654,17 +1463,16 @@ do_SecurityModeCommand(
     = (CipheringAlgorithm_r12_t)cipheringAlgorithm;
   dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm
     = (e_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm;
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message, (void*)&dl_dcch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message, (void *)&dl_dcch_msg);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message,
-                                   (void*)&dl_dcch_msg,
+                                   NULL,
+                                   (void *)&dl_dcch_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)
   {
@@ -1673,17 +1481,14 @@ do_SecurityModeCommand(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_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_D(RRC,"[eNB %d] securityModeCommand for UE %x Encoded %zd bits (%zd bytes)\n",
         ctxt_pP->module_id,
         ctxt_pP->rnti,
@@ -1705,42 +1510,35 @@ do_SecurityModeCommand(
 //------------------------------------------------------------------------------
 uint8_t
 do_UECapabilityEnquiry(
-  const protocol_ctxt_t* const ctxt_pP,
-  uint8_t*               const buffer,
+  const protocol_ctxt_t *const ctxt_pP,
+  uint8_t               *const buffer,
   const uint8_t                Transaction_id
 )
 //------------------------------------------------------------------------------
 {
-
   DL_DCCH_Message_t dl_dcch_msg;
-
   RAT_Type_t rat=RAT_Type_eutra;
   asn_enc_rval_t enc_rval;
-
   memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
-
   dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
   dl_dcch_msg.message.choice.c1.present = 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 = UECapabilityEnquiry__criticalExtensions_PR_c1;
   dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present =
     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);
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message, (void*)&dl_dcch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message, (void *)&dl_dcch_msg);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message,
-                                   (void*)&dl_dcch_msg,
+                                   NULL,
+                                   (void *)&dl_dcch_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)
   {
@@ -1749,17 +1547,14 @@ do_UECapabilityEnquiry(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_DCCH_Message, (void *) &dl_dcch_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
-
   LOG_D(RRC,"[eNB %d] UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n",
         ctxt_pP->module_id,
         ctxt_pP->rnti,
@@ -1779,7 +1574,7 @@ do_UECapabilityEnquiry(
 //------------------------------------------------------------------------------
 uint16_t
 do_RRCConnectionReconfiguration(
-  const protocol_ctxt_t*        const ctxt_pP,
+  const protocol_ctxt_t        *const ctxt_pP,
   uint8_t                            *buffer,
   uint8_t                             Transaction_id,
   SRB_ToAddModList_t                 *SRB_list,
@@ -1806,24 +1601,17 @@ do_RRCConnectionReconfiguration(
 )
 //------------------------------------------------------------------------------
 {
-
   asn_enc_rval_t enc_rval;
-
   DL_DCCH_Message_t dl_dcch_msg;
   RRCConnectionReconfiguration_t *rrcConnectionReconfiguration;
-
-
   memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
-
   dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
   dl_dcch_msg.message.choice.c1.present = DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration;
   rrcConnectionReconfiguration          = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionReconfiguration;
-
   // RRCConnectionReconfiguration
   rrcConnectionReconfiguration->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionReconfiguration->criticalExtensions.present = RRCConnectionReconfiguration__criticalExtensions_PR_c1;
   rrcConnectionReconfiguration->criticalExtensions.choice.c1.present =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;
@@ -1850,9 +1638,8 @@ do_RRCConnectionReconfiguration(
   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,
+    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;
@@ -1884,27 +1671,24 @@ do_RRCConnectionReconfiguration(
   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,
+    memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void *)mobilityInfo,
            sizeof(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_DL_DCCH_Message,
-                                   (void*)&dl_dcch_msg,
+                                   NULL,
+                                   (void *)&dl_dcch_msg,
                                    buffer,
                                    RRC_BUF_SIZE);
   AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %zd)!\n",
                enc_rval.failed_type->name, enc_rval.encoded);
-
 #ifdef XER_PRINT
-  xer_fprint(stdout,&asn_DEF_DL_DCCH_Message,(void*)&dl_dcch_msg);
+  xer_fprint(stdout,&asn_DEF_DL_DCCH_Message,(void *)&dl_dcch_msg);
 #endif
-
 #if defined(ENABLE_ITTI)
 # if !defined(DISABLE_XER_SPRINT)
   {
@@ -1913,67 +1697,58 @@ do_RRCConnectionReconfiguration(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_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 %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
   // for (i=0;i<30;i++)
   //    msg("%x.",buffer[i]);
   // msg("\n");
-
-
   return((enc_rval.encoded+7)/8);
 }
 
 //------------------------------------------------------------------------------
 uint8_t
 do_RRCConnectionReestablishment(
-  const protocol_ctxt_t*     const ctxt_pP,
-  rrc_eNB_ue_context_t*      const ue_context_pP,
+  const protocol_ctxt_t     *const ctxt_pP,
+  rrc_eNB_ue_context_t      *const ue_context_pP,
   int                              CC_id,
-  uint8_t*                   const buffer,
+  uint8_t                   *const buffer,
   const uint8_t                    transmission_mode,
   const uint8_t                    Transaction_id,
   SRB_ToAddModList_t               **SRB_configList,
   struct PhysicalConfigDedicated   **physicalConfigDedicated)
 {
   asn_enc_rval_t enc_rval;
-
-  long* logicalchannelgroup = NULL;
-  struct SRB_ToAddMod* SRB1_config = NULL;
-  struct SRB_ToAddMod* SRB2_config = NULL;
-  struct SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL;
-  struct SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL;
-  struct LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL;
+  long *logicalchannelgroup = NULL;
+  struct SRB_ToAddMod *SRB1_config = NULL;
+  struct SRB_ToAddMod *SRB2_config = NULL;
+  struct SRB_ToAddMod__rlc_Config *SRB1_rlc_config = NULL;
+  struct SRB_ToAddMod__logicalChannelConfig *SRB1_lchan_config = NULL;
+  struct LogicalChannelConfig__ul_SpecificParameters *SRB1_ul_SpecificParameters = NULL;
   eNB_RRC_INST *rrc               = RC.rrc[ctxt_pP->module_id];
-
 #ifdef CBA
-  struct PUSCH_CBAConfigDedicated_vlola* pusch_CBAConfigDedicated_vlola = NULL;
-  long* betaOffset_CBA_Index = NULL;
-  long* cShift_CBA = NULL;
+  struct PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola = NULL;
+  long *betaOffset_CBA_Index = NULL;
+  long *cShift_CBA = NULL;
 #endif
-  PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL;
-
+  PhysicalConfigDedicated_t *physicalConfigDedicated2 = NULL;
   DL_CCCH_Message_t dl_ccch_msg;
-
-  RRCConnectionReestablishment_t* rrcConnectionReestablishment = NULL;
-
+  RRCConnectionReestablishment_t *rrcConnectionReestablishment = NULL;
   int i = 0;
   SRB_ToAddModList_t **SRB_configList2 = NULL;
   SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[Transaction_id];
+
   if (*SRB_configList2) {
     free(*SRB_configList2);
   }
-  *SRB_configList2 = CALLOC(1, sizeof(SRB_ToAddModList_t));
 
+  *SRB_configList2 = CALLOC(1, sizeof(SRB_ToAddModList_t));
   memset((void *)&dl_ccch_msg, 0, sizeof(DL_CCCH_Message_t));
   dl_ccch_msg.message.present           = DL_CCCH_MessageType_PR_c1;
   dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment;
@@ -1982,15 +1757,15 @@ do_RRCConnectionReestablishment(
   // RRCConnectionReestablishment
   // Configure SRB1
 
-
   // get old configuration of SRB2
   if (*SRB_configList != NULL) {
     for (i = 0; (i < (*SRB_configList)->list.count) && (i < 3); i++) {
       LOG_D(RRC, "(*SRB_configList)->list.array[%d]->srb_Identity=%ld\n",
-          i, (*SRB_configList)->list.array[i]->srb_Identity);
-      if ((*SRB_configList)->list.array[i]->srb_Identity == 2 ){
+            i, (*SRB_configList)->list.array[i]->srb_Identity);
+
+      if ((*SRB_configList)->list.array[i]->srb_Identity == 2 ) {
         SRB2_config = (*SRB_configList)->list.array[i];
-      } else if ((*SRB_configList)->list.array[i]->srb_Identity == 1 ){
+      } else if ((*SRB_configList)->list.array[i]->srb_Identity == 1 ) {
         SRB1_config = (*SRB_configList)->list.array[i];
       }
     }
@@ -2001,44 +1776,36 @@ do_RRCConnectionReestablishment(
     LOG_W(RRC,"SRB1 configuration does not exist in SRB configuration list, use default\n");
     /// 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;
-
     SRB1_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
     SRB1_rlc_config->choice.explicitValue.present=RLC_Config_PR_am;
-  #if defined(ENABLE_ITTI)
+#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
+#else
     SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms20;;
     SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = PollPDU_p4;;
     SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte         = PollByte_kBinfinity;
     SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8;
     SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering     = T_Reordering_ms35;
     SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms0;
-  #endif
-
+#endif
     SRB1_lchan_config = CALLOC(1, sizeof(*SRB1_lchan_config));
     SRB1_config->logicalChannelConfig = SRB1_lchan_config;
-
     SRB1_lchan_config->present = 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=LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
-
     //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50);
     SRB1_ul_SpecificParameters->bucketSizeDuration=LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
     logicalchannelgroup = CALLOC(1, sizeof(long));
     *logicalchannelgroup = 0;
     SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup;
@@ -2055,11 +1822,8 @@ do_RRCConnectionReestablishment(
   }
 
   *SRB_configList = CALLOC(1, sizeof(SRB_ToAddModList_t));
-
   ASN_SEQUENCE_ADD(&(*SRB_configList)->list,SRB1_config);
-
   physicalConfigDedicated2 = *physicalConfigDedicated;
-
   rrcConnectionReestablishment->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionReestablishment->criticalExtensions.present = RRCConnectionReestablishment__criticalExtensions_PR_c1;
   rrcConnectionReestablishment->criticalExtensions.choice.c1.present = RRCConnectionReestablishment__criticalExtensions__c1_PR_rrcConnectionReestablishment_r8;
@@ -2069,27 +1833,28 @@ do_RRCConnectionReestablishment(
   rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.sps_Config = NULL;
   rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.physicalConfigDedicated = physicalConfigDedicated2;
   rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.mac_MainConfig = NULL;
-
   uint8_t KeNB_star[32] = { 0 };
   uint16_t pci = rrc->carrier[CC_id].physCellId;
   uint32_t earfcn_dl = (uint32_t)freq_to_arfcn10(RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band,
-                  rrc->carrier[CC_id].dl_CarrierFreq);
+                       rrc->carrier[CC_id].dl_CarrierFreq);
   bool     is_rel8_only = true;
+
   if (earfcn_dl > 65535) {
     is_rel8_only = false;
   }
 
   LOG_D(RRC, "pci=%d, eutra_band=%d, downlink_frequency=%d, earfcn_dl=%u, is_rel8_only=%s\n",
-      pci,
-      RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band,
-      rrc->carrier[CC_id].dl_CarrierFreq,
-      earfcn_dl,
-      is_rel8_only == true ? "true": "false");
+        pci,
+        RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band,
+        rrc->carrier[CC_id].dl_CarrierFreq,
+        earfcn_dl,
+        is_rel8_only == true ? "true": "false");
 #if defined(ENABLE_SECURITY)
+
   if (ue_context_pP->ue_context.nh_ncc >= 0) {
     derive_keNB_star(ue_context_pP->ue_context.nh, pci, earfcn_dl, is_rel8_only, KeNB_star);
     rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = ue_context_pP->ue_context.nh_ncc;
-  } else { // first HO 
+  } else { // first HO
     derive_keNB_star (ue_context_pP->ue_context.kenb, pci, earfcn_dl, is_rel8_only, KeNB_star);
     // LG: really 1
     rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0;
@@ -2101,19 +1866,17 @@ do_RRCConnectionReestablishment(
 #else
   rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0;
 #endif
-
   rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nonCriticalExtension = NULL;
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void *)&dl_ccch_msg);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message,
-                                   (void*)&dl_ccch_msg,
+                                   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)
   {
@@ -2122,22 +1885,18 @@ do_RRCConnectionReestablishment(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_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,"RRCConnectionReestablishment Encoded %zd bits (%zd bytes)\n",
         enc_rval.encoded,(enc_rval.encoded+7)/8);
 #endif
-
   return((enc_rval.encoded+7)/8);
 }
 
@@ -2145,33 +1904,28 @@ do_RRCConnectionReestablishment(
 uint8_t
 do_RRCConnectionReestablishmentReject(
   uint8_t                    Mod_id,
-  uint8_t*                   const buffer)
+  uint8_t                   *const buffer)
 //------------------------------------------------------------------------------
 {
-
   asn_enc_rval_t enc_rval;
-
   DL_CCCH_Message_t dl_ccch_msg;
   RRCConnectionReestablishmentReject_t *rrcConnectionReestablishmentReject;
-
   memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t));
   dl_ccch_msg.message.present           = DL_CCCH_MessageType_PR_c1;
   dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject;
   rrcConnectionReestablishmentReject    = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReestablishmentReject;
-
   // RRCConnectionReestablishmentReject
   rrcConnectionReestablishmentReject->criticalExtensions.present = RRCConnectionReestablishmentReject__criticalExtensions_PR_rrcConnectionReestablishmentReject_r8;
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void *)&dl_ccch_msg);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message,
-                                   (void*)&dl_ccch_msg,
+                                   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)
   {
@@ -2180,20 +1934,16 @@ do_RRCConnectionReestablishmentReject(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_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, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_D(RRC,"RRCConnectionReestablishmentReject Encoded %zd bits (%zd bytes)\n",
         enc_rval.encoded,(enc_rval.encoded+7)/8);
-
   return((enc_rval.encoded+7)/8);
 }
 
@@ -2201,36 +1951,31 @@ do_RRCConnectionReestablishmentReject(
 uint8_t
 do_RRCConnectionReject(
   uint8_t                    Mod_id,
-  uint8_t*                   const buffer)
+  uint8_t                   *const buffer)
 //------------------------------------------------------------------------------
 {
-
   asn_enc_rval_t enc_rval;
-
   DL_CCCH_Message_t dl_ccch_msg;
   RRCConnectionReject_t *rrcConnectionReject;
-
   memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t));
   dl_ccch_msg.message.present           = DL_CCCH_MessageType_PR_c1;
   dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionReject;
   rrcConnectionReject                   = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReject;
-
   // RRCConnectionReject
   rrcConnectionReject->criticalExtensions.present = RRCConnectionReject__criticalExtensions_PR_c1;
   rrcConnectionReject->criticalExtensions.choice.c1.present = RRCConnectionReject__criticalExtensions__c1_PR_rrcConnectionReject_r8;
   /* let's put a wait time of 1s for the moment */
   rrcConnectionReject->criticalExtensions.choice.c1.choice.rrcConnectionReject_r8.waitTime = 1;
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void *)&dl_ccch_msg);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message,
-                                   (void*)&dl_ccch_msg,
+                                   NULL,
+                                   (void *)&dl_ccch_msg,
                                    buffer,
                                    100);
   AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %ld)!\n",
                enc_rval.failed_type->name, enc_rval.encoded);
-
 #if defined(ENABLE_ITTI)
 # if !defined(DISABLE_XER_SPRINT)
   {
@@ -2239,20 +1984,16 @@ do_RRCConnectionReject(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_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, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_D(RRC,"RRCConnectionReject Encoded %zd bits (%zd bytes)\n",
         enc_rval.encoded,(enc_rval.encoded+7)/8);
-
   return((enc_rval.encoded+7)/8);
 }
 
@@ -2261,36 +2002,27 @@ uint8_t do_RRCConnectionRelease(
   uint8_t                            *buffer,
   uint8_t                             Transaction_id)
 {
-
   asn_enc_rval_t enc_rval;
-
   DL_DCCH_Message_t dl_dcch_msg;
   RRCConnectionRelease_t *rrcConnectionRelease;
-
-
   memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
-
   dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
   dl_dcch_msg.message.choice.c1.present = DL_DCCH_MessageType__c1_PR_rrcConnectionRelease;
   rrcConnectionRelease                  = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionRelease;
-
   // RRCConnectionRelease
   rrcConnectionRelease->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionRelease->criticalExtensions.present = RRCConnectionRelease__criticalExtensions_PR_c1;
   rrcConnectionRelease->criticalExtensions.choice.c1.present =RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8 ;
-
   rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause = ReleaseCause_other;
   rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.redirectedCarrierInfo = NULL;
   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_DL_DCCH_Message,
-                                   (void*)&dl_dcch_msg,
+                                   NULL,
+                                   (void *)&dl_dcch_msg,
                                    buffer,
                                    RRC_BUF_SIZE);
-
   return((enc_rval.encoded+7)/8);
 }
 
@@ -2304,7 +2036,6 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
                            MCCH_Message_t *mcch_message,
                            MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration)
 {
-
   asn_enc_rval_t enc_rval;
   MBSFN_SubframeConfig_t *mbsfn_SubframeConfig1;
   PMCH_Info_r9_t *pmch_Info_1;
@@ -2312,17 +2043,13 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
   // MBMS_SessionInfo_r9_t *mbms_Session_2;
   eNB_RRC_INST *rrc               = RC.rrc[Mod_id];
   rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0];
- 
-
   memset(mcch_message,0,sizeof(MCCH_Message_t));
   mcch_message->message.present = MCCH_MessageType_PR_c1;
   mcch_message->message.choice.c1.present = MCCH_MessageType__c1_PR_mbsfnAreaConfiguration_r9;
   *mbsfnAreaConfiguration = &mcch_message->message.choice.c1.choice.mbsfnAreaConfiguration_r9;
-
   // Common Subframe Allocation (CommonSF-Alloc-r9)
-
   mbsfn_SubframeConfig1= CALLOC(1,sizeof(*mbsfn_SubframeConfig1));
-  memset((void*)mbsfn_SubframeConfig1,0,sizeof(*mbsfn_SubframeConfig1));
+  memset((void *)mbsfn_SubframeConfig1,0,sizeof(*mbsfn_SubframeConfig1));
   //
   mbsfn_SubframeConfig1->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
   mbsfn_SubframeConfig1->radioframeAllocationOffset= 1;
@@ -2333,36 +2060,33 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
 
   // CURRENTLY WE ARE SUPPORITNG ONLY ONE sf ALLOCATION
   switch (sync_area) {
-  case 0:
-    if (carrier->sib1->tdd_Config != NULL) {// pattern 001110 for TDD
-      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused.
-    } else { //111000
-      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2;
-    }
+    case 0:
+      if (carrier->sib1->tdd_Config != NULL) {// pattern 001110 for TDD
+        mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused.
+      } else { //111000
+        mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2;
+      }
 
-    break;
+      break;
 
-  case 1:
-    if (carrier->sib1->tdd_Config != NULL) {
-      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused.
-    } else { // 000111
-      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2;
-    }
+    case 1:
+      if (carrier->sib1->tdd_Config != NULL) {
+        mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused.
+      } else { // 000111
+        mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2;
+      }
 
-  default :
-    break;
+    default :
+      break;
   }
 
   ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->commonSF_Alloc_r9.list,mbsfn_SubframeConfig1);
-
   //  commonSF-AllocPeriod-r9
   (*mbsfnAreaConfiguration)->commonSF_AllocPeriod_r9= MBSFNAreaConfiguration_r9__commonSF_AllocPeriod_r9_rf16;
-
   // PMCHs Information List (PMCH-InfoList-r9)
   // PMCH_1  Config
   pmch_Info_1 = CALLOC(1,sizeof(PMCH_Info_r9_t));
-  memset((void*)pmch_Info_1,0,sizeof(PMCH_Info_r9_t));
-
+  memset((void *)pmch_Info_1,0,sizeof(PMCH_Info_r9_t));
   /*
    * take the value of last mbsfn subframe in this CSA period because there is only one PMCH in this mbsfn area
    * Note: this has to be set based on the subframeAllocation and CSA
@@ -2370,7 +2094,6 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
   pmch_Info_1->pmch_Config_r9.sf_AllocEnd_r9= 3;
   pmch_Info_1->pmch_Config_r9.dataMCS_r9= 7;
   pmch_Info_1->pmch_Config_r9.mch_SchedulingPeriod_r9= PMCH_Config_r9__mch_SchedulingPeriod_r9_rf16;
-
   // MBMSs-SessionInfoList-r9
   //  pmch_Info_1->mbms_SessionInfoList_r9 = CALLOC(1,sizeof(struct MBMS_SessionInfoList_r9));
   //  Session 1
@@ -2381,7 +2104,7 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
   mbms_Session_1->tmgi_r9.plmn_Id_r9.choice.plmn_Index_r9= 1;
   // Service ID
   memset(&mbms_Session_1->tmgi_r9.serviceId_r9,0,sizeof(OCTET_STRING_t));// need to check
-  OCTET_STRING_fromBuf(&mbms_Session_1->tmgi_r9.serviceId_r9,(const char*)&TMGI[2],3);
+  OCTET_STRING_fromBuf(&mbms_Session_1->tmgi_r9.serviceId_r9,(const char *)&TMGI[2],3);
   // Session ID is still missing here, it can be used as an rab id or mrb id
   mbms_Session_1->sessionId_r9 = CALLOC(1,sizeof(OCTET_STRING_t));
   mbms_Session_1->sessionId_r9->buf= MALLOC(1);
@@ -2390,7 +2113,6 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
   // Logical Channel ID
   mbms_Session_1->logicalChannelIdentity_r9= MTCH;
   ASN_SEQUENCE_ADD(&pmch_Info_1->mbms_SessionInfoList_r9.list,mbms_Session_1);
-
   /*    //  Session 2
   //mbms_Session_2 = CALLOC(1,sizeof(MBMS_SessionInfo_r9_t));
   memset(mbms_Session_2,0,sizeof(MBMS_SessionInfo_r9_t));
@@ -2409,17 +2131,16 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
   ASN_SEQUENCE_ADD(&pmch_Info_1->mbms_SessionInfoList_r9.list,mbms_Session_2);
   */
   ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->pmch_InfoList_r9.list,pmch_Info_1);
-
 #ifdef XER_PRINT
-  xer_fprint(stdout,&asn_DEF_MCCH_Message,(void*)mcch_message);
+  xer_fprint(stdout,&asn_DEF_MCCH_Message,(void *)mcch_message);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_MCCH_Message,
-                                   (void*)mcch_message,
+                                   NULL,
+                                   (void *)mcch_message,
                                    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)
   {
@@ -2428,17 +2149,14 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_MCCH_Message, (void *) &mcch_message)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_MCCH, message_string_size);
       msg_p->ittiMsg.rrc_dl_mcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_dl_mcch.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_D(RRC,"[eNB] MCCH Message Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
 
   if (enc_rval.encoded==-1) {
@@ -2452,22 +2170,16 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
 
 uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t)
 {
-
   asn_enc_rval_t enc_rval;
-
   UL_DCCH_Message_t ul_dcch_msg;
-
   MeasurementReport_t  *measurementReport;
-
   ul_dcch_msg.message.present                     = UL_DCCH_MessageType_PR_c1;
   ul_dcch_msg.message.choice.c1.present           = UL_DCCH_MessageType__c1_PR_measurementReport;
   measurementReport            = &ul_dcch_msg.message.choice.c1.choice.measurementReport;
-
   measurementReport->criticalExtensions.present=MeasurementReport__criticalExtensions_PR_c1;
   measurementReport->criticalExtensions.choice.c1.present=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 defined(Rel10) || defined(Rel14)
   measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrpResult=rsrp_s;
@@ -2479,24 +2191,17 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_
   measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells=CALLOC(1,
       sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells));
   measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->present=MeasResults__measResultNeighCells_PR_measResultListEUTRA;
-
   MeasResultListEUTRA_t  *measResultListEUTRA2;
   measResultListEUTRA2 = CALLOC(1,sizeof(*measResultListEUTRA2));
-
   struct MeasResultEUTRA *measresulteutra2;
   measresulteutra2 = CALLOC(1,sizeof(*measresulteutra2));
   measresulteutra2->physCellId=phy_id;//1;
-
   struct MeasResultEUTRA__cgi_Info *measresult_cgi2;
   measresult_cgi2 = CALLOC(1,sizeof(*measresult_cgi2));
-
   memset(&measresult_cgi2->cellGlobalId.plmn_Identity,0,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity));
-
   // measresult_cgi2->cellGlobalId.plmn_Identity.mcc=CALLOC(1,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity.mcc));
   measresult_cgi2->cellGlobalId.plmn_Identity.mcc = CALLOC(1, sizeof(*measresult_cgi2->cellGlobalId.plmn_Identity.mcc));
-
   asn_set_empty(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list);//.size=0;
-
   MCC_MNC_Digit_t dummy;
   dummy=2;
   ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy);
@@ -2504,14 +2209,12 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_
   ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy);
   dummy=2;
   ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy);
-
   measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.size=0;
   measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.count=0;
   dummy=8;
   ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy);
   dummy=0;
   ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy);
-
   measresult_cgi2->cellGlobalId.cellIdentity.buf=MALLOC(8);
   measresult_cgi2->cellGlobalId.cellIdentity.buf[0]=0x01;
   measresult_cgi2->cellGlobalId.cellIdentity.buf[1]=0x48;
@@ -2519,39 +2222,27 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_
   measresult_cgi2->cellGlobalId.cellIdentity.buf[3]=0x03;
   measresult_cgi2->cellGlobalId.cellIdentity.size=4;
   measresult_cgi2->cellGlobalId.cellIdentity.bits_unused=4;
-
   measresult_cgi2->trackingAreaCode.buf = MALLOC(2);
   measresult_cgi2->trackingAreaCode.buf[0]=0x00;
   measresult_cgi2->trackingAreaCode.buf[1]=0x10;
   measresult_cgi2->trackingAreaCode.size=2;
   measresult_cgi2->trackingAreaCode.bits_unused=0;
-
-
   measresulteutra2->cgi_Info=measresult_cgi2;
-
   struct MeasResultEUTRA__measResult meas2;
   //    int rsrp_va=10;
-
   meas2.rsrpResult=&(rsrp_t);
   //&rsrp_va;
   meas2.rsrqResult=&(rsrq_t);
-
   measresulteutra2->measResult=meas2;
-
   ASN_SEQUENCE_ADD(&measResultListEUTRA2->list,measresulteutra2);
-
   measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->choice.measResultListEUTRA=*(measResultListEUTRA2);
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message,
-                                   (void*)&ul_dcch_msg,
+                                   NULL,
+                                   (void *)&ul_dcch_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)
   {
@@ -2560,30 +2251,23 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, 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, NB_eNB_INST + Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   printf("Measurement Report Encoded %zu bits (%zu bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
-
   return((enc_rval.encoded+7)/8);
 }
 
 uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer)
 {
   ssize_t encoded;
-
   DL_DCCH_Message_t dl_dcch_msg;
-
   memset(&dl_dcch_msg, 0, sizeof(DL_DCCH_Message_t));
-
   dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
   dl_dcch_msg.message.choice.c1.present = DL_DCCH_MessageType__c1_PR_dlInformationTransfer;
   dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.rrc_TransactionIdentifier = transaction_id;
@@ -2593,12 +2277,10 @@ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t trans
     DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS;
   dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length;
   dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer;
-
-  encoded = uper_encode_to_new_buffer (&asn_DEF_DL_DCCH_Message, NULL, (void*) &dl_dcch_msg, (void **) buffer);
-
+  encoded = uper_encode_to_new_buffer (&asn_DEF_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **) buffer);
   /*
-#if defined(ENABLE_ITTI)
-# if !defined(DISABLE_XER_SPRINT)
+  #if defined(ENABLE_ITTI)
+  # if !defined(DISABLE_XER_SPRINT)
   {
     char        message_string[10000];
     size_t      message_string_size;
@@ -2613,10 +2295,9 @@ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t trans
       itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
     }
   }
-# endif
-#endif
+  # endif
+  #endif
   */
-
   return encoded;
 }
 
@@ -2624,20 +2305,15 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin
 {
   LOG_D(RRC, "[eNB %d] do_Paging start\n", Mod_id);
   asn_enc_rval_t enc_rval;
-
   PCCH_Message_t pcch_msg;
   PagingRecord_t *paging_record_p;
   int j;
-
   pcch_msg.message.present           = PCCH_MessageType_PR_c1;
   pcch_msg.message.choice.c1.present = PCCH_MessageType__c1_PR_paging;
-
   pcch_msg.message.choice.c1.choice.paging.pagingRecordList = CALLOC(1,sizeof(*pcch_msg.message.choice.c1.choice.paging.pagingRecordList));
-
   pcch_msg.message.choice.c1.choice.paging.systemInfoModification = NULL;
   pcch_msg.message.choice.c1.choice.paging.etws_Indication = NULL;
   pcch_msg.message.choice.c1.choice.paging.nonCriticalExtension = NULL;
-
   asn_set_empty(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list);
   pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count = 0;
 
@@ -2655,10 +2331,11 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin
                              &paging_record_p->ue_Identity.choice.s_TMSI.mmec);
     paging_record_p->ue_Identity.choice.s_TMSI.mmec.bits_unused = 0;
     M_TMSI_TO_OCTET_STRING(ue_paging_identity.choice.s_tmsi.m_tmsi,
-                             &paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI);
+                           &paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI);
     paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI.bits_unused = 0;
   } else if (ue_paging_identity.presenceMask == UE_PAGING_IDENTITY_imsi) {
     IMSI_Digit_t imsi_digit[21];
+
     for (j = 0; j< ue_paging_identity.choice.imsi.length; j++) {  /* IMSI size */
       imsi_digit[j] = (IMSI_Digit_t)ue_paging_identity.choice.imsi.buffer[j];
       ASN_SEQUENCE_ADD(&paging_record_p->ue_Identity.choice.imsi.list, &imsi_digit[j]);
@@ -2671,30 +2348,25 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin
   } else {
     paging_record_p->cn_Domain = PagingRecord__cn_Domain_cs;
   }
+
   /* add to list */
   ASN_SEQUENCE_ADD(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list, paging_record_p);
   LOG_D(RRC, "[eNB %d] do_Paging paging_record: cn_Domain %ld, ue_paging_identity.presenceMask %d, PagingRecordList.count %d\n",
-          Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count);
-
-  enc_rval = uper_encode_to_buffer(&asn_DEF_PCCH_Message, (void*)&pcch_msg, buffer, RRC_BUF_SIZE);
-
+        Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count);
+  enc_rval = uper_encode_to_buffer(&asn_DEF_PCCH_Message, NULL, (void *)&pcch_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_PCCH_Message, (void*)&pcch_msg);
+  xer_fprint(stdout, &asn_DEF_PCCH_Message, (void *)&pcch_msg);
 #endif
-
   return((enc_rval.encoded+7)/8);
 }
 
 uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer)
 {
   ssize_t encoded;
-
   UL_DCCH_Message_t ul_dcch_msg;
-
   memset(&ul_dcch_msg, 0, sizeof(UL_DCCH_Message_t));
-
   ul_dcch_msg.message.present           = UL_DCCH_MessageType_PR_c1;
   ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_ulInformationTransfer;
   ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.present = ULInformationTransfer__criticalExtensions_PR_c1;
@@ -2703,9 +2375,7 @@ uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t
     ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS;
   ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length;
   ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer;
-
-  encoded = uper_encode_to_new_buffer (&asn_DEF_UL_DCCH_Message, NULL, (void*) &ul_dcch_msg, (void **) buffer);
-
+  encoded = uper_encode_to_new_buffer (&asn_DEF_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, (void **) buffer);
   return encoded;
 }
 
@@ -2715,21 +2385,15 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
   static SupportedBandEUTRA_t Bandlist[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
   static InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
   static BandInfoEUTRA_t BandInfoEUTRA[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
-
   asn_enc_rval_t enc_rval;
   asn_dec_rval_t dec_rval;
-
   long maxNumberROHC_ContextSessions = PDCP_Parameters__maxNumberROHC_ContextSessions_cs16;
   int i;
-
   UE_EUTRA_Capability_t *UE_EUTRA_Capability;
   char UE_EUTRA_Capability_xer[8192];
   size_t size;
-
   LOG_I(RRC,"Allocating %zu bytes for UE_EUTRA_Capability\n",sizeof(*UE_EUTRA_Capability));
-
   UE_EUTRA_Capability = CALLOC(1, sizeof(*UE_EUTRA_Capability));
-
   assert(UE_EUTRA_Capability);
 
   if (!UE_EUTRA_Capability_xer_fname)  {
@@ -2741,10 +2405,8 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
     Bandlist[2].halfDuplex = 0;
     Bandlist[3].bandEUTRA  = 38;  // UL/DL 2570-2620, TDD
     Bandlist[3].halfDuplex = 0;
-
-    memset((void*)InterFreqBandInfo, 0, sizeof(InterFreqBandInfo));
-    memset((void*)BandInfoEUTRA, 0, sizeof(BandInfoEUTRA));
-
+    memset((void *)InterFreqBandInfo, 0, sizeof(InterFreqBandInfo));
+    memset((void *)BandInfoEUTRA, 0, sizeof(BandInfoEUTRA));
     InterFreqBandInfo[0][0].interFreqNeedForGaps = 0;
     InterFreqBandInfo[0][1].interFreqNeedForGaps = 1;
     InterFreqBandInfo[0][2].interFreqNeedForGaps = 1;
@@ -2761,8 +2423,6 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
     InterFreqBandInfo[3][1].interFreqNeedForGaps = 1;
     InterFreqBandInfo[3][2].interFreqNeedForGaps = 1;
     InterFreqBandInfo[3][3].interFreqNeedForGaps = 0;
-
-
     UE_EUTRA_Capability->accessStratumRelease = 0;//AccessStratumRelease_rel8;
     UE_EUTRA_Capability->ue_Category          = 4;
     UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0001=0;
@@ -2774,41 +2434,34 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
     UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0102=0;
     UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0103=0;
     UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0104=0;
-
     UE_EUTRA_Capability->pdcp_Parameters.maxNumberROHC_ContextSessions = &maxNumberROHC_ContextSessions;
-
     UE_EUTRA_Capability->phyLayerParameters.ue_TxAntennaSelectionSupported = 0;
     UE_EUTRA_Capability->phyLayerParameters.ue_SpecificRefSigsSupported    = 0;
     UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count                          = 0;
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[0]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[1]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[2]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[3]);
-
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[0]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[1]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[2]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[3]);
-
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][0]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][1]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][2]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][3]);
-
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][0]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][1]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][2]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][3]);
-
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][0]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][1]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][2]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][3]);
-
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][0]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][1]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][2]);
-    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][3]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[3]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[3]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][3]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][3]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][3]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][3]);
 
     // UE_EUTRA_Capability->measParameters.bandListEUTRA.list.count                         = 0;  // no measurements on other bands
     // UE_EUTRA_Capability->featureGroupIndicators  // null
@@ -2828,8 +2481,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
 
     // UE_EUTRA_Capability->interRAT_Parameters     // null
   } else {
-
-    FILE* f = fopen(UE_EUTRA_Capability_xer_fname, "r");
+    FILE *f = fopen(UE_EUTRA_Capability_xer_fname, "r");
     assert(f);
     size = fread(UE_EUTRA_Capability_xer, 1, sizeof UE_EUTRA_Capability_xer, f);
     fclose(f);
@@ -2840,7 +2492,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
       return(NULL);
     }
 
-    dec_rval = xer_decode(0, &asn_DEF_UE_EUTRA_Capability, (void*)UE_EUTRA_Capability, UE_EUTRA_Capability_xer, size);
+    dec_rval = xer_decode(0, &asn_DEF_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability, UE_EUTRA_Capability_xer, size);
     assert(dec_rval.code == RC_OK);
   }
 
@@ -2849,20 +2501,18 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
   xer_fprint(stdout,&asn_DEF_UE_EUTRA_Capability,(void *)UE_EUTRA_Capability);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_UE_EUTRA_Capability,
-                                   (void*)UE_EUTRA_Capability,
+                                   NULL,
+                                   (void *)UE_EUTRA_Capability,
                                    &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);
-
 #if defined(ENABLE_ITTI)
 # if defined(DISABLE_XER_SPRINT)
   {
     MessageDef *msg_p;
-
     msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_UE_EUTRA_CAPABILITY);
     memcpy (&msg_p->ittiMsg, (void *) UE_EUTRA_Capability, sizeof(RrcUeEutraCapability));
-
     itti_send_msg_to_task (TASK_UNKNOWN, NB_eNB_INST, msg_p);
   }
 # else
@@ -2872,17 +2522,14 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UE_EUTRA_CAPABILITY, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_ue_eutra_capability.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_ue_eutra_capability.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, msg_p);
     }
   }
 # endif
 #endif
-
   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);
@@ -2897,7 +2544,6 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
     LOG_D(PHY, "[RRC]UE Capability encoded, %s\n", sdu);
     free(sdu);
   }
-
   return(&UECapability);
 }
 
diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c
index 2d91828861c4e4c07a92f12677abf3c2a9d224ae..303b9172c10c9daa9870bb140ed921a2c1f9749f 100644
--- a/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c
+++ b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c
@@ -78,14 +78,13 @@
 
 /*do_MIB_NB_NB_IoT*/
 uint8_t do_MIB_NB_IoT(
-		rrc_eNB_carrier_data_NB_IoT_t *carrier,
-		uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
-		uint32_t frame,
-    uint32_t hyper_frame)
+  rrc_eNB_carrier_data_NB_IoT_t *carrier,
+  uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
+  uint32_t frame,
+  uint32_t hyper_frame)
 {
   asn_enc_rval_t enc_rval;
   BCCH_BCH_Message_NB_t *mib_NB_IoT = &(carrier->mib_NB_IoT);
-
   /*
    * systemFrameNumber-MSB: (TS 36.331 pag 576)
    * define the 4 MSB of the SFN (10 bits). The last significant 6 bits will be acquired implicitly by decoding the NPBCH
@@ -98,45 +97,39 @@ uint8_t do_MIB_NB_IoT(
    *
    * NOTE: in OAI never modify the SIB messages!!??
    */
-
   //XXX check if correct the bit assignment
   uint8_t sfn_MSB = (uint8_t)((frame>>6) & 0x0f); // all the 4 bits are set to 1
   uint8_t hsfn_LSB = (uint8_t)(hyper_frame & 0x03); //2 bits set to 1 (0x3 = 0011)
   uint16_t spare=0; //11 bits --> use uint16
-
   mib_NB_IoT->message.systemFrameNumber_MSB_r13.buf = &sfn_MSB;
   mib_NB_IoT->message.systemFrameNumber_MSB_r13.size = 1; //if expressed in byte
   mib_NB_IoT->message.systemFrameNumber_MSB_r13.bits_unused = 4; //is byte based (so how many bits you don't use of the 8 bits of a bite
-
   mib_NB_IoT->message.hyperSFN_LSB_r13.buf= &hsfn_LSB;
   mib_NB_IoT->message.hyperSFN_LSB_r13.size= 1;
   mib_NB_IoT->message.hyperSFN_LSB_r13.bits_unused = 6;
-
   //XXX to be set??
   mib_NB_IoT->message.spare.buf = (uint8_t *)&spare;
   mib_NB_IoT->message.spare.size = 2;
   mib_NB_IoT->message.spare.bits_unused = 5;
-
   //decide how to set it
   mib_NB_IoT->message.schedulingInfoSIB1_r13 =11; //see TS 36.213-->tables 16.4.1.3-3 ecc...
   mib_NB_IoT->message.systemInfoValueTag_r13= 0;
   mib_NB_IoT->message.ab_Enabled_r13 = 0;
-
   //to be decided
   mib_NB_IoT->message.operationModeInfo_r13.present = MasterInformationBlock_NB__operationModeInfo_r13_PR_inband_SamePCI_r13;
   mib_NB_IoT->message.operationModeInfo_r13.choice.inband_SamePCI_r13.eutra_CRS_SequenceInfo_r13 = 0;
-
   printf("[MIB] Initialization of frame information,sfn_MSB %x, hsfn_LSB %x\n",
          (uint32_t)sfn_MSB,
-		 (uint32_t)hsfn_LSB);
-
+         (uint32_t)hsfn_LSB);
   enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message_NB,
-                                   (void*)mib_NB_IoT,
+                                   NULL,
+                                   (void *)mib_NB_IoT,
                                    carrier->MIB_NB_IoT,
                                    100);
+
   if(enc_rval.encoded <= 0) {
-      LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+    LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
   }
 
   if (enc_rval.encoded==-1) {
@@ -144,63 +137,48 @@ uint8_t do_MIB_NB_IoT(
   }
 
   return((enc_rval.encoded+7)/8);
-
 }
 
 /*do_SIB1_NB*/
 uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
-				rrc_eNB_carrier_data_NB_IoT_t *carrier,
-                NbIoTRrcConfigurationReq *configuration,
-				uint32_t frame
-               )
+                       rrc_eNB_carrier_data_NB_IoT_t *carrier,
+                       NbIoTRrcConfigurationReq *configuration,
+                       uint32_t frame
+                      )
 {
   BCCH_DL_SCH_Message_NB_t *bcch_message= &(carrier->siblock1_NB_IoT);
   SystemInformationBlockType1_NB_t **sib1_NB_IoT= &(carrier->sib1_NB_IoT);
-  
-
   asn_enc_rval_t enc_rval;
-
   PLMN_IdentityInfo_NB_r13_t PLMN_identity_info_NB_IoT;
   MCC_MNC_Digit_t dummy_mcc[3],dummy_mnc[3];
   SchedulingInfo_NB_r13_t *schedulingInfo_NB_IoT;
   SIB_Type_NB_r13_t *sib_type_NB_IoT;
-
-
-  long* attachWithoutPDN_Connectivity = NULL;
+  long *attachWithoutPDN_Connectivity = NULL;
   attachWithoutPDN_Connectivity = CALLOC(1,sizeof(long));
   long *nrs_CRS_PowerOffset=NULL;
   nrs_CRS_PowerOffset = CALLOC(1, sizeof(long));
   long *eutraControlRegionSize=NULL; //this parameter should be set only if we are considering in-band operating mode (samePCI or differentPCI)
-   eutraControlRegionSize = CALLOC(1,sizeof(long));
+  eutraControlRegionSize = CALLOC(1,sizeof(long));
   long systemInfoValueTagSI = 0;
-
   memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_NB_t));
   bcch_message->message.present = BCCH_DL_SCH_MessageType_NB_PR_c1;
   bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType_NB__c1_PR_systemInformationBlockType1_r13;
-
   //allocation
   *sib1_NB_IoT = &bcch_message->message.choice.c1.choice.systemInformationBlockType1_r13;
-
-
   /*TS 36.331 v14.2.0 pag 589
    * hyperSFN-MSB
    * Indicates the 8 most significant bits of the hyper-SFN. Together with the hyper-LSB in MIB-NB the complete HSFN is build up
    */
   //FIXME see if correct
   uint8_t hyperSFN_MSB = (uint8_t) ((frame>>2)& 0xff);
-
   //XXX to be checked
   (*sib1_NB_IoT)->hyperSFN_MSB_r13.buf = &hyperSFN_MSB;
   (*sib1_NB_IoT)->hyperSFN_MSB_r13.size = 1;
   (*sib1_NB_IoT)->hyperSFN_MSB_r13.bits_unused = 0;
-
   memset(&PLMN_identity_info_NB_IoT,0,sizeof(PLMN_IdentityInfo_NB_r13_t));
-
   PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc = CALLOC(1,sizeof(*PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc));
   memset(PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc,0,sizeof(*PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc));
-
   asn_set_empty(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list);//.size=0;
-
   //left as it is???
 #if defined(ENABLE_ITTI)
   dummy_mcc[0] = (configuration->mcc / 100) % 10;
@@ -214,11 +192,8 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
   ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list,&dummy_mcc[0]);
   ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list,&dummy_mcc[1]);
   ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list,&dummy_mcc[2]);
-
   PLMN_identity_info_NB_IoT.plmn_Identity_r13.mnc.list.size=0;
   PLMN_identity_info_NB_IoT.plmn_Identity_r13.mnc.list.count=0;
-
-
 #if defined(ENABLE_ITTI)
 
   if (configuration->mnc >= 100) {
@@ -251,15 +226,11 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
 
   //still set to "notReserved" as in the previous case
   PLMN_identity_info_NB_IoT.cellReservedForOperatorUse_r13=PLMN_IdentityInfo_NB_r13__cellReservedForOperatorUse_r13_notReserved;
-
   *attachWithoutPDN_Connectivity = 0;
   PLMN_identity_info_NB_IoT.attachWithoutPDN_Connectivity_r13 = attachWithoutPDN_Connectivity;
-
   ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.plmn_IdentityList_r13.list,&PLMN_identity_info_NB_IoT);
-
   // 16 bits = 2 byte
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.buf = MALLOC(2); //MALLOC works in byte
-
   //lefts as it is?
 #if defined(ENABLE_ITTI)
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.buf[0] = (configuration->tac >> 8) & 0xff;
@@ -270,7 +241,6 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
 #endif
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.size=2;
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.bits_unused=0;
-
   // 28 bits --> i have to use 32 bits = 4 byte
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf = MALLOC(8); // why allocate 8 byte?
 #if defined(ENABLE_ITTI)
@@ -286,20 +256,14 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
 #endif
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.size=4;
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.bits_unused=4;
-
   //Still set to "notBarred" as in the previous case
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellBarred_r13=SystemInformationBlockType1_NB__cellAccessRelatedInfo_r13__cellBarred_r13_notBarred;
-
   //Still Set to "notAllowed" like in the previous case
   (*sib1_NB_IoT)->cellAccessRelatedInfo_r13.intraFreqReselection_r13=SystemInformationBlockType1_NB__cellAccessRelatedInfo_r13__intraFreqReselection_r13_notAllowed;
-
-
   (*sib1_NB_IoT)->cellSelectionInfo_r13.q_RxLevMin_r13=-65; //which value?? TS 36.331 V14.2.1 pag. 589
   (*sib1_NB_IoT)->cellSelectionInfo_r13.q_QualMin_r13 = 0; //FIXME new parameter for SIB1-NB, not present in SIB1 (for cell reselection but if not used the UE should apply the default value)
-
   (*sib1_NB_IoT)->p_Max_r13 = CALLOC(1, sizeof(P_Max_t));
   *((*sib1_NB_IoT)->p_Max_r13) = 23;
-
   //FIXME
   (*sib1_NB_IoT)->freqBandIndicator_r13 =
 #if defined(ENABLE_ITTI)
@@ -307,70 +271,54 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
 #else
     5; //if not configured we use band 5 (UL: 824 MHz - 849MHz / DL: 869 MHz - 894 MHz  FDD mode)
 #endif
-
-    //OPTIONAL new parameters, to be used?
-      /*
-       * freqBandInfo_r13
-       * multiBandInfoList_r13
-       * nrs_CRS_PowerOffset_r13
-       * sib1_NB_IoT->downlinkBitmap_r13.choice.subframePattern10_r13 =(is a BIT_STRING)
-       */
-
-
-   (*sib1_NB_IoT)->downlinkBitmap_r13 = CALLOC(1, sizeof(struct DL_Bitmap_NB_r13));
-   ((*sib1_NB_IoT)->downlinkBitmap_r13)->present= DL_Bitmap_NB_r13_PR_NOTHING;
-
-   *eutraControlRegionSize = 1;
-   (*sib1_NB_IoT)->eutraControlRegionSize_r13 = eutraControlRegionSize;
-
-
-   *nrs_CRS_PowerOffset= 0;
-   (*sib1_NB_IoT)->nrs_CRS_PowerOffset_r13 = nrs_CRS_PowerOffset;
-
-   schedulingInfo_NB_IoT = (SchedulingInfo_NB_r13_t*) malloc (3*sizeof(SchedulingInfo_NB_r13_t));
-   sib_type_NB_IoT = (SIB_Type_NB_r13_t *) malloc (3*sizeof(SIB_Type_NB_r13_t));
-
+  //OPTIONAL new parameters, to be used?
+  /*
+   * freqBandInfo_r13
+   * multiBandInfoList_r13
+   * nrs_CRS_PowerOffset_r13
+   * sib1_NB_IoT->downlinkBitmap_r13.choice.subframePattern10_r13 =(is a BIT_STRING)
+   */
+  (*sib1_NB_IoT)->downlinkBitmap_r13 = CALLOC(1, sizeof(struct DL_Bitmap_NB_r13));
+  ((*sib1_NB_IoT)->downlinkBitmap_r13)->present= DL_Bitmap_NB_r13_PR_NOTHING;
+  *eutraControlRegionSize = 1;
+  (*sib1_NB_IoT)->eutraControlRegionSize_r13 = eutraControlRegionSize;
+  *nrs_CRS_PowerOffset= 0;
+  (*sib1_NB_IoT)->nrs_CRS_PowerOffset_r13 = nrs_CRS_PowerOffset;
+  schedulingInfo_NB_IoT = (SchedulingInfo_NB_r13_t *) malloc (3*sizeof(SchedulingInfo_NB_r13_t));
+  sib_type_NB_IoT = (SIB_Type_NB_r13_t *) malloc (3*sizeof(SIB_Type_NB_r13_t));
   memset(&schedulingInfo_NB_IoT[0],0,sizeof(SchedulingInfo_NB_r13_t));
   memset(&schedulingInfo_NB_IoT[1],0,sizeof(SchedulingInfo_NB_r13_t));
-  memset(&schedulingInfo_NB_IoT[2],0,sizeof(SchedulingInfo_NB_r13_t));    
+  memset(&schedulingInfo_NB_IoT[2],0,sizeof(SchedulingInfo_NB_r13_t));
   memset(&sib_type_NB_IoT[0],0,sizeof(SIB_Type_NB_r13_t));
   memset(&sib_type_NB_IoT[1],0,sizeof(SIB_Type_NB_r13_t));
   memset(&sib_type_NB_IoT[2],0,sizeof(SIB_Type_NB_r13_t));
-
-
   // Now, follow the scheduler SIB configuration
   // There is only one sib2+sib3 common setting
   schedulingInfo_NB_IoT[0].si_Periodicity_r13=SchedulingInfo_NB_r13__si_Periodicity_r13_rf4096;
   schedulingInfo_NB_IoT[0].si_RepetitionPattern_r13=SchedulingInfo_NB_r13__si_RepetitionPattern_r13_every2ndRF; //This Indicates the starting radio frames within the SI window used for SI message transmission.
   schedulingInfo_NB_IoT[0].si_TB_r13= SchedulingInfo_NB_r13__si_TB_r13_b680;//208 bits
-  
-
   // This is for SIB2/3
   /*SIB3 --> There is no mapping information of SIB2 since it is always present
     *  in the first SystemInformation message
     * listed in the schedulingInfoList list.
     * */
   sib_type_NB_IoT[0]=SIB_Type_NB_r13_sibType3_NB_r13;
-
   ASN_SEQUENCE_ADD(&schedulingInfo_NB_IoT[0].sib_MappingInfo_r13.list,&sib_type_NB_IoT[0]);
   ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->schedulingInfoList_r13.list,&schedulingInfo_NB_IoT[0]);
-
   //printf("[ASN Debug] SI P: %ld\n",(*sib1_NB_IoT)->schedulingInfoList_r13.list.array[0]->si_Periodicity_r13);
-
 #if defined(ENABLE_ITTI)
 
   if (configuration->frame_type == TDD)
 #endif
   {
-	//FIXME in NB-IoT mandatory to be FDD --> so must give an error
-	  LOG_E(RRC,"[NB-IoT %d] Frame Type is TDD --> not supported by NB-IoT, exiting\n", Mod_id); //correct?
-	  exit(-1);
+    //FIXME in NB-IoT mandatory to be FDD --> so must give an error
+    LOG_E(RRC,"[NB-IoT %d] Frame Type is TDD --> not supported by NB-IoT, exiting\n", Mod_id); //correct?
+    exit(-1);
   }
 
   //FIXME which value chose for the following parameter
   (*sib1_NB_IoT)->si_WindowLength_r13=SystemInformationBlockType1_NB__si_WindowLength_r13_ms160;
   (*sib1_NB_IoT)->si_RadioFrameOffset_r13= 0;
-
   /*In Nb-IoT change/update of specific SI message can additionally be indicated by a SI message specific value tag
    * systemInfoValueTagSI (there is no SystemInfoValueTag in SIB1-NB but only in MIB-NB)
    *contained in systemInfoValueTagList_r13
@@ -379,24 +327,20 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
   (*sib1_NB_IoT)->systemInfoValueTagList_r13 = CALLOC(1, sizeof(struct SystemInfoValueTagList_NB_r13));
   asn_set_empty(&(*sib1_NB_IoT)->systemInfoValueTagList_r13->list);
   ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->systemInfoValueTagList_r13->list,&systemInfoValueTagSI);
-
-
 #ifdef XER_PRINT //generate xml files
-  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message_NB, (void*)bcch_message);
+  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message_NB, (void *)bcch_message);
 #endif
-
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_DL_SCH_Message_NB,
-                                   (void*)bcch_message,
+                                   NULL,
+                                   (void *)bcch_message,
                                    carrier->SIB1_NB_IoT,
                                    100);
 
-  if (enc_rval.encoded > 0){ 
-       LOG_F(RRC,"ASN1 message encoding failed (%s, %lu)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+  if (enc_rval.encoded > 0) {
+    LOG_F(RRC,"ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
   }
 
-
 #ifdef USER_MODE
   LOG_D(RRC,"[NB-IoT] SystemInformationBlockType1-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
 #endif
@@ -417,30 +361,23 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
 {
   struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member *sib2_NB_part;
   struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member *sib3_NB_part;
-
   BCCH_DL_SCH_Message_NB_t *bcch_message = &(carrier->systemInformation_NB_IoT); //is the systeminformation-->BCCH_DL_SCH_Message_NB
   SystemInformationBlockType2_NB_r13_t *sib2_NB_IoT;
   SystemInformationBlockType3_NB_r13_t *sib3_NB_IoT;
-
   asn_enc_rval_t enc_rval;
   RACH_Info_NB_r13_t rach_Info_NB_IoT;
   NPRACH_Parameters_NB_r13_t *nprach_parameters;
-
   //optional
   long *connEstFailOffset = NULL;
   connEstFailOffset = CALLOC(1, sizeof(long));
-
-//  RSRP_ThresholdsNPRACH_InfoList_NB_r13_t *rsrp_ThresholdsPrachInfoList;
-//  RSRP_Range_t rsrp_range;
-
+  //  RSRP_ThresholdsNPRACH_InfoList_NB_r13_t *rsrp_ThresholdsPrachInfoList;
+  //  RSRP_Range_t rsrp_range;
   ACK_NACK_NumRepetitions_NB_r13_t ack_nack_repetition;
   struct NPUSCH_ConfigCommon_NB_r13__dmrs_Config_r13 *dmrs_config;
-  struct DL_GapConfig_NB_r13	*dl_Gap;
-
+  struct DL_GapConfig_NB_r13  *dl_Gap;
   long *srs_SubframeConfig;
   srs_SubframeConfig= CALLOC(1, sizeof(long));
 
-
   if (bcch_message) {
     memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_NB_t));
   } else {
@@ -449,84 +386,64 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
   }
 
   //before schould be allocated memory somewhere?
-//  if (!carrier->sib2_NB_IoT) {
-//    LOG_E(RRC,"[NB-IoT %d] sib2_NB_IoT is null, exiting\n", Mod_id);
-//    exit(-1);
-//  }
-//
-//  if (!carrier->sib3_NB_IoT) {
-//    LOG_E(RRC,"[NB-IoT %d] sib3_NB_IoT is null, exiting\n", Mod_id);
-//    exit(-1);
-//  }
-
-
+  //  if (!carrier->sib2_NB_IoT) {
+  //    LOG_E(RRC,"[NB-IoT %d] sib2_NB_IoT is null, exiting\n", Mod_id);
+  //    exit(-1);
+  //  }
+  //
+  //  if (!carrier->sib3_NB_IoT) {
+  //    LOG_E(RRC,"[NB-IoT %d] sib3_NB_IoT is null, exiting\n", Mod_id);
+  //    exit(-1);
+  //  }
   LOG_I(RRC,"[NB-IoT %d] Configuration SIB2/3\n", Mod_id);
-
   sib2_NB_part = CALLOC(1,sizeof(struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
   sib3_NB_part = CALLOC(1,sizeof(struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
   memset(sib2_NB_part,0,sizeof(struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
   memset(sib3_NB_part,0,sizeof(struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
-
   sib2_NB_part->present = SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_PR_sib2_r13;
   sib3_NB_part->present = SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_PR_sib3_r13;
-
   //may bug if not correct allocation of memory
   carrier->sib2_NB_IoT = &sib2_NB_part->choice.sib2_r13;
   carrier->sib3_NB_IoT = &sib3_NB_part->choice.sib3_r13;
   sib2_NB_IoT = carrier->sib2_NB_IoT;
   sib3_NB_IoT = carrier->sib3_NB_IoT;
-
   nprach_parameters = (NPRACH_Parameters_NB_r13_t *) malloc (3*sizeof(NPRACH_Parameters_NB_r13_t));
-
   memset(&nprach_parameters[0],0,sizeof(NPRACH_Parameters_NB_r13_t));
   memset(&nprach_parameters[1],0,sizeof(NPRACH_Parameters_NB_r13_t));
   memset(&nprach_parameters[2],0,sizeof(NPRACH_Parameters_NB_r13_t));
-
-/// SIB2-NB-----------------------------------------
-
+  /// SIB2-NB-----------------------------------------
   //Barring is manage by ab-Enabled in MIB-NB (but is not a struct as ac-BarringInfo in LTE legacy)
-
   //RACH Config. Common--------------------------------------------------------------
   sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.preambleTransMax_CE_r13 =
-   		  configuration->rach_preambleTransMax_CE_NB;
+    configuration->rach_preambleTransMax_CE_NB;
   sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.powerRampingParameters_r13.powerRampingStep =
-	configuration->rach_powerRampingStep_NB;
+    configuration->rach_powerRampingStep_NB;
   sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.powerRampingParameters_r13.preambleInitialReceivedTargetPower =
     configuration->rach_preambleInitialReceivedTargetPower_NB;
-
   rach_Info_NB_IoT.ra_ResponseWindowSize_r13 = configuration->rach_raResponseWindowSize_NB;
   rach_Info_NB_IoT.mac_ContentionResolutionTimer_r13 = configuration-> rach_macContentionResolutionTimer_NB;
   //rach_infoList max size = maxNPRACH-Resources-NB-r13 = 3
   ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.rach_InfoList_r13.list,&rach_Info_NB_IoT);
-
   //TS 36.331 pag 614 --> if not present the value to infinity sould be used
   *connEstFailOffset = 0;
-  
   sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.connEstFailOffset_r13 = connEstFailOffset; /*OPTIONAL*/
-
-
   // BCCH-Config-NB-IoT----------------------------------------------------------------
   sib2_NB_IoT->radioResourceConfigCommon_r13.bcch_Config_r13.modificationPeriodCoeff_r13
     = configuration->bcch_modificationPeriodCoeff_NB;
-
   // PCCH-Config-NB-IoT-----------------------------------------------------------------
   sib2_NB_IoT->radioResourceConfigCommon_r13.pcch_Config_r13.defaultPagingCycle_r13
     = configuration->pcch_defaultPagingCycle_NB;
   sib2_NB_IoT->radioResourceConfigCommon_r13.pcch_Config_r13.nB_r13 = configuration->pcch_nB_NB;
   sib2_NB_IoT->radioResourceConfigCommon_r13.pcch_Config_r13.npdcch_NumRepetitionPaging_r13 = configuration-> pcch_npdcch_NumRepetitionPaging_NB;
-
   //NPRACH-Config-NB-IoT-----------------------------------------------------------------
-
-  sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.rsrp_ThresholdsPrachInfoList_r13 = NULL; 
+  sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.rsrp_ThresholdsPrachInfoList_r13 = NULL;
   sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_CP_Length_r13 = configuration->nprach_CP_Length;
   /*OPTIONAL*/
-//   =CALLOC(1, sizeof(struct RSRP_ThresholdsNPRACH_InfoList_NB_r13)); //fatto uguale dopo
-//   rsrp_ThresholdsPrachInfoList = sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.rsrp_ThresholdsPrachInfoList_r13;
-//   rsrp_range = configuration->nprach_rsrp_range_NB;
-//   ASN_SEQUENCE_ADD(&rsrp_ThresholdsPrachInfoList->list,rsrp_range);
-
+  //   =CALLOC(1, sizeof(struct RSRP_ThresholdsNPRACH_InfoList_NB_r13)); //fatto uguale dopo
+  //   rsrp_ThresholdsPrachInfoList = sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.rsrp_ThresholdsPrachInfoList_r13;
+  //   rsrp_range = configuration->nprach_rsrp_range_NB;
+  //   ASN_SEQUENCE_ADD(&rsrp_ThresholdsPrachInfoList->list,rsrp_range);
   // According configuration to set the 3 CE level configuration setting
-
   nprach_parameters[0].nprach_Periodicity_r13               = configuration->nprach_Periodicity[0];
   nprach_parameters[0].nprach_StartTime_r13                 = configuration->nprach_StartTime[0];
   nprach_parameters[0].nprach_SubcarrierOffset_r13          = configuration->nprach_SubcarrierOffset[0];
@@ -537,7 +454,6 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
   nprach_parameters[0].npdcch_NumRepetitions_RA_r13         = configuration->npdcch_NumRepetitions_RA[0];
   nprach_parameters[0].npdcch_StartSF_CSS_RA_r13            = configuration->npdcch_StartSF_CSS_RA[0];
   nprach_parameters[0].npdcch_Offset_RA_r13                 = configuration->npdcch_Offset_RA[0];
-
   nprach_parameters[1].nprach_Periodicity_r13               = configuration->nprach_Periodicity[1];
   nprach_parameters[1].nprach_StartTime_r13                 = configuration->nprach_StartTime[1];
   nprach_parameters[1].nprach_SubcarrierOffset_r13          = configuration->nprach_SubcarrierOffset[1];
@@ -548,7 +464,6 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
   nprach_parameters[1].npdcch_NumRepetitions_RA_r13         = configuration->npdcch_NumRepetitions_RA[1];
   nprach_parameters[1].npdcch_StartSF_CSS_RA_r13            = configuration->npdcch_StartSF_CSS_RA[1];
   nprach_parameters[1].npdcch_Offset_RA_r13                 = configuration->npdcch_Offset_RA[1];
-
   nprach_parameters[2].nprach_Periodicity_r13               = configuration->nprach_Periodicity[2];
   nprach_parameters[2].nprach_StartTime_r13                 = configuration->nprach_StartTime[2];
   nprach_parameters[2].nprach_SubcarrierOffset_r13          = configuration->nprach_SubcarrierOffset[2];
@@ -559,40 +474,29 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
   nprach_parameters[2].npdcch_NumRepetitions_RA_r13         = configuration->npdcch_NumRepetitions_RA[2];
   nprach_parameters[2].npdcch_StartSF_CSS_RA_r13            = configuration->npdcch_StartSF_CSS_RA[2];
   nprach_parameters[2].npdcch_Offset_RA_r13                 = configuration->npdcch_Offset_RA[2];
-
-
   //nprach_parameterList have a max size of 3 possible nprach configuration (see maxNPRACH_Resources_NB_r13)
   ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_ParametersList_r13.list,&nprach_parameters[0]);
   ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_ParametersList_r13.list,&nprach_parameters[1]);
   ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_ParametersList_r13.list,&nprach_parameters[2]);
-  
   // NPDSCH-Config NB-IOT
   sib2_NB_IoT->radioResourceConfigCommon_r13.npdsch_ConfigCommon_r13.nrs_Power_r13= configuration->npdsch_nrs_Power;
-
-
   //NPUSCH-Config NB-IoT----------------------------------------------------------------
   //list of size 3 (see maxNPRACH_Resources_NB_r13)
   ack_nack_repetition = configuration-> npusch_ack_nack_numRepetitions_NB; //is an enumerative
-  ASN_SEQUENCE_ADD(&(sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.ack_NACK_NumRepetitions_Msg4_r13.list) ,&ack_nack_repetition);
-
+  ASN_SEQUENCE_ADD(&(sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.ack_NACK_NumRepetitions_Msg4_r13.list),&ack_nack_repetition);
   *srs_SubframeConfig = configuration->npusch_srs_SubframeConfig_NB;
   sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.srs_SubframeConfig_r13= srs_SubframeConfig; /*OPTIONAL*/
-
-
   /*OPTIONAL*/
   dmrs_config = CALLOC(1,sizeof(struct NPUSCH_ConfigCommon_NB_r13__dmrs_Config_r13));
   dmrs_config->threeTone_CyclicShift_r13 = configuration->npusch_threeTone_CyclicShift_r13;
   dmrs_config->sixTone_CyclicShift_r13 = configuration->npusch_sixTone_CyclicShift_r13;
-
   /*OPTIONAL
    * -define the base sequence for a DMRS sequence in a cell with multi tone transmission (3,6,12) see TS 36.331 NPUSCH-Config-NB
    * -if not defined will be calculated based on the cellID once we configure the phy layer (rrc_mac_config_req) through the config_sib2 */
   dmrs_config->threeTone_BaseSequence_r13 = NULL;
   dmrs_config->sixTone_BaseSequence_r13 = NULL;
   dmrs_config->twelveTone_BaseSequence_r13 = NULL;
-
   sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.dmrs_Config_r13 = dmrs_config;
-
   //ulReferenceSignalsNPUSCH
   /*Reference Signal (RS) for UL in NB-IoT is called DRS (Demodulation Reference Signal)
    * sequence-group hopping can be enabled or disabled by means of the cell-specific parameter groupHoppingEnabled_r13
@@ -601,22 +505,17 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
    */
   sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.ul_ReferenceSignalsNPUSCH_r13.groupHoppingEnabled_r13= configuration->npusch_groupHoppingEnabled;
   sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.ul_ReferenceSignalsNPUSCH_r13.groupAssignmentNPUSCH_r13 =configuration->npusch_groupAssignmentNPUSCH_r13;
-
-
   //dl_GAP---------------------------------------------------------------------------------/*OPTIONAL*/
   dl_Gap = CALLOC(1,sizeof(struct DL_GapConfig_NB_r13));
   dl_Gap->dl_GapDurationCoeff_r13= configuration-> dl_GapDurationCoeff_NB;
   dl_Gap->dl_GapPeriodicity_r13= configuration->dl_GapPeriodicity_NB;
   dl_Gap->dl_GapThreshold_r13= configuration->dl_GapThreshold_NB;
   sib2_NB_IoT->radioResourceConfigCommon_r13.dl_Gap_r13 = dl_Gap;
-
-
   // uplinkPowerControlCommon - NB-IoT------------------------------------------------------
   sib2_NB_IoT->radioResourceConfigCommon_r13.uplinkPowerControlCommon_r13.p0_NominalNPUSCH_r13 = configuration->npusch_p0_NominalNPUSCH;
   sib2_NB_IoT->radioResourceConfigCommon_r13.uplinkPowerControlCommon_r13.deltaPreambleMsg3_r13 = configuration->deltaPreambleMsg3;
   sib2_NB_IoT->radioResourceConfigCommon_r13.uplinkPowerControlCommon_r13.alpha_r13 = configuration->npusch_alpha;
   //no deltaFlist_PUCCH and no UL cyclic prefix
-
   // UE Timers and Constants -NB-IoT--------------------------------------------------------
   sib2_NB_IoT->ue_TimersAndConstants_r13.t300_r13 = configuration-> ue_TimersAndConstants_t300_NB;
   sib2_NB_IoT->ue_TimersAndConstants_r13.t301_r13 = configuration-> ue_TimersAndConstants_t301_NB;
@@ -624,60 +523,45 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
   sib2_NB_IoT->ue_TimersAndConstants_r13.t311_r13 = configuration-> ue_TimersAndConstants_t311_NB;
   sib2_NB_IoT->ue_TimersAndConstants_r13.n310_r13 = configuration-> ue_TimersAndConstants_n310_NB;
   sib2_NB_IoT->ue_TimersAndConstants_r13.n311_r13 = configuration-> ue_TimersAndConstants_n311_NB;
-
   //other SIB2-NB Parameters--------------------------------------------------------------------------------
   sib2_NB_IoT->freqInfo_r13.additionalSpectrumEmission_r13 = 1;
   sib2_NB_IoT->freqInfo_r13.ul_CarrierFreq_r13 = NULL; /*OPTIONAL*/
-
   sib2_NB_IoT->timeAlignmentTimerCommon_r13=TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120;
-
   /*OPTIONAL*/
   sib2_NB_IoT->multiBandInfoList_r13 = NULL;
-
-/// SIB3-NB-------------------------------------------------------
-
+  /// SIB3-NB-------------------------------------------------------
   sib3_NB_IoT->cellReselectionInfoCommon_r13.q_Hyst_r13=SystemInformationBlockType3_NB_r13__cellReselectionInfoCommon_r13__q_Hyst_r13_dB4;
   sib3_NB_IoT->cellReselectionServingFreqInfo_r13.s_NonIntraSearch_r13=0; //or define in configuration?
-
   sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_RxLevMin_r13 = -70;
   //new
   sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_QualMin_r13 = CALLOC(1,sizeof(*sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_QualMin_r13));
   *(sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_QualMin_r13)= 10; //a caso
-
   sib3_NB_IoT->intraFreqCellReselectionInfo_r13.p_Max_r13 = NULL;
   sib3_NB_IoT->intraFreqCellReselectionInfo_r13.s_IntraSearchP_r13 = 31; // s_intraSearch --> s_intraSearchP!!! (they call in a different way)
   sib3_NB_IoT->intraFreqCellReselectionInfo_r13.t_Reselection_r13=1;
-
   //how to manage?
   sib3_NB_IoT->freqBandInfo_r13 = NULL;
   sib3_NB_IoT->multiBandInfoList_r13 = NULL;
-
-
-///BCCH message (generate the SI message)
+  ///BCCH message (generate the SI message)
   bcch_message->message.present = BCCH_DL_SCH_MessageType_NB_PR_c1;
   bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType_NB__c1_PR_systemInformation_r13;
-
   bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.present = SystemInformation_NB__criticalExtensions_PR_systemInformation_r13;
   bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.choice.systemInformation_r13.sib_TypeAndInfo_r13.list.count=0;
-
   ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.choice.systemInformation_r13.sib_TypeAndInfo_r13.list,
                    sib2_NB_part);
   ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.choice.systemInformation_r13.sib_TypeAndInfo_r13.list,
                    sib3_NB_part);
-
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message_NB, (void*)bcch_message);
+  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message_NB, (void *)bcch_message);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_DL_SCH_Message_NB,
-                                   (void*)bcch_message,
+                                   NULL,
+                                   (void *)bcch_message,
                                    carrier->SIB23_NB_IoT,
                                    900);
-//  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
-//               enc_rval.failed_type->name, enc_rval.encoded);
-
-//#if defined(ENABLE_ITTI).....
-
-
+  //  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
+  //               enc_rval.failed_type->name, enc_rval.encoded);
+  //#if defined(ENABLE_ITTI).....
 #ifdef USER_MODE
   LOG_D(RRC,"[NB-IoT] SystemInformation-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
 #endif
@@ -689,268 +573,222 @@ uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
 
   carrier->sib2_NB_IoT = sib2_NB_IoT;
   carrier->sib3_NB_IoT = sib3_NB_IoT;
-
   return((enc_rval.encoded+7)/8);
 }
 
 /*do_RRCConnectionSetup_NB_IoT--> the aim is to establish SRB1 and SRB1bis(implicitly)*/
 uint8_t do_RRCConnectionSetup_NB_IoT(
-  const protocol_ctxt_t*     const ctxt_pP,
-  rrc_eNB_ue_context_NB_IoT_t*      const ue_context_pP,
+  const protocol_ctxt_t     *const ctxt_pP,
+  rrc_eNB_ue_context_NB_IoT_t      *const ue_context_pP,
   int                              CC_id,
-  uint8_t*                   const buffer, //Srb0.Tx_buffer.Payload
+  uint8_t                   *const buffer, //Srb0.Tx_buffer.Payload
   const uint8_t                    Transaction_id,
-  const NB_IoT_DL_FRAME_PARMS* const frame_parms, // maybe not used
-  SRB_ToAddModList_NB_r13_t**             SRB_configList_NB_IoT, //for both SRB1bis and SRB1
-  struct PhysicalConfigDedicated_NB_r13** physicalConfigDedicated_NB_IoT
+  const NB_IoT_DL_FRAME_PARMS *const frame_parms, // maybe not used
+  SRB_ToAddModList_NB_r13_t             **SRB_configList_NB_IoT, //for both SRB1bis and SRB1
+  struct PhysicalConfigDedicated_NB_r13 **physicalConfigDedicated_NB_IoT
 )
 
 {
+  asn_enc_rval_t enc_rval;
+  //MP:logical channel group not defined for Nb-IoT
+  //MP: logical channel priority pag 605 (is 1 for SRB1 and for SRB1bis should be the same)
+  //long* prioritySRB1 = NULL;
+  long *prioritySRB1bis = NULL;
+  BOOLEAN_t *logicalChannelSR_Prohibit =NULL; //pag 605
+  BOOLEAN_t *npusch_AllSymbols= NULL;
+  // struct SRB_ToAddMod_NB_r13* SRB1_config_NB = NULL;
+  // struct SRB_ToAddMod_NB_r13__rlc_Config_r13* SRB1_rlc_config_NB = NULL;
+  // struct SRB_ToAddMod_NB_r13__logicalChannelConfig_r13* SRB1_lchan_config_NB = NULL;
+  struct SRB_ToAddMod_NB_r13 *SRB1bis_config_NB_IoT = NULL;
+  struct SRB_ToAddMod_NB_r13__rlc_Config_r13 *SRB1bis_rlc_config_NB_IoT = NULL;
+  struct SRB_ToAddMod_NB_r13__logicalChannelConfig_r13 *SRB1bis_lchan_config_NB_IoT = NULL;
+  //No UL_specific parameters for NB-IoT in LogicalChanelConfig-NB
+  PhysicalConfigDedicated_NB_r13_t *physicalConfigDedicated2_NB_IoT = NULL;
+  DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
+  RRCConnectionSetup_NB_t *rrcConnectionSetup_NB_IoT = NULL;
+  memset((void *)&dl_ccch_msg_NB_IoT,0,sizeof(DL_CCCH_Message_NB_t));
+  dl_ccch_msg_NB_IoT.message.present = DL_CCCH_MessageType_NB_PR_c1;
+  dl_ccch_msg_NB_IoT.message.choice.c1.present = DL_CCCH_MessageType_NB__c1_PR_rrcConnectionSetup_r13;
+  rrcConnectionSetup_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionSetup_r13;
 
- asn_enc_rval_t enc_rval;
-
-
- //MP:logical channel group not defined for Nb-IoT
-
- //MP: logical channel priority pag 605 (is 1 for SRB1 and for SRB1bis should be the same)
- //long* prioritySRB1 = NULL;
- long* prioritySRB1bis = NULL;
- BOOLEAN_t* logicalChannelSR_Prohibit =NULL; //pag 605
- BOOLEAN_t* npusch_AllSymbols= NULL;
-
-// struct SRB_ToAddMod_NB_r13* SRB1_config_NB = NULL;
-// struct SRB_ToAddMod_NB_r13__rlc_Config_r13* SRB1_rlc_config_NB = NULL;
-// struct SRB_ToAddMod_NB_r13__logicalChannelConfig_r13* SRB1_lchan_config_NB = NULL;
-
- struct SRB_ToAddMod_NB_r13* SRB1bis_config_NB_IoT = NULL;
- struct SRB_ToAddMod_NB_r13__rlc_Config_r13* SRB1bis_rlc_config_NB_IoT = NULL;
- struct SRB_ToAddMod_NB_r13__logicalChannelConfig_r13* SRB1bis_lchan_config_NB_IoT = NULL;
-
- //No UL_specific parameters for NB-IoT in LogicalChanelConfig-NB
-
- PhysicalConfigDedicated_NB_r13_t* physicalConfigDedicated2_NB_IoT = NULL;
- DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
- RRCConnectionSetup_NB_t* rrcConnectionSetup_NB_IoT = NULL;
-
- memset((void *)&dl_ccch_msg_NB_IoT,0,sizeof(DL_CCCH_Message_NB_t));
- dl_ccch_msg_NB_IoT.message.present = DL_CCCH_MessageType_NB_PR_c1;
- dl_ccch_msg_NB_IoT.message.choice.c1.present = DL_CCCH_MessageType_NB__c1_PR_rrcConnectionSetup_r13;
- rrcConnectionSetup_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionSetup_r13;
-
-
- if (*SRB_configList_NB_IoT) {
-   free(*SRB_configList_NB_IoT);
- }
- *SRB_configList_NB_IoT = CALLOC(1,sizeof(SRB_ToAddModList_NB_r13_t));
-
-/// SRB1--------------------
- {
-// SRB1_config_NB = CALLOC(1,sizeof(*SRB1_config_NB));
-//
-// //no srb_Identity in SRB_ToAddMod_NB
-//
-// SRB1_rlc_config_NB = CALLOC(1,sizeof(*SRB1_rlc_config_NB));
-// SRB1_config_NB->rlc_Config_r13   = SRB1_rlc_config_NB;
-//
-// SRB1_rlc_config_NB->present = SRB_ToAddMod_NB_r13__rlc_Config_r13_PR_explicitValue;
-// SRB1_rlc_config_NB->choice.explicitValue.present=RLC_Config_NB_r13_PR_am;//the only possible in NB_IoT
-//
-//// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = enb_properties.properties[ctxt_pP->module_id]->srb1_timer_poll_retransmit_r13;
-//// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = enb_properties.properties[ctxt_pP->module_id]->srb1_max_retx_threshold_r13;
-//// //(musT be disabled--> SRB1 config pag 640 specs )
-//// SRB1_rlc_config_NB->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 =NULL;
-//
-//
-// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = T_PollRetransmit_NB_r13_ms25000;
-// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = UL_AM_RLC_NB_r13__maxRetxThreshold_r13_t8;
-// //(musT be disabled--> SRB1 config pag 640 specs )
-// SRB1_rlc_config_NB->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 = NULL;
-//
-// SRB1_lchan_config_NB = CALLOC(1,sizeof(*SRB1_lchan_config_NB));
-// SRB1_config_NB->logicalChannelConfig_r13  = SRB1_lchan_config_NB;
-//
-// SRB1_lchan_config_NB->present = SRB_ToAddMod_NB_r13__logicalChannelConfig_r13_PR_explicitValue;
-//
-//
-// prioritySRB1 = CALLOC(1, sizeof(long));
-// *prioritySRB1 = 1;
-// SRB1_lchan_config_NB->choice.explicitValue.priority_r13 = prioritySRB1;
-//
-// logicalChannelSR_Prohibit = CALLOC(1, sizeof(BOOLEAN_t));
-// *logicalChannelSR_Prohibit = 1;
-// //schould be set to TRUE (specs pag 641)
-// SRB1_lchan_config_NB->choice.explicitValue.logicalChannelSR_Prohibit_r13 = logicalChannelSR_Prohibit;
-//
-// //ADD SRB1
-// ASN_SEQUENCE_ADD(&(*SRB_configList_NB_IoT)->list,SRB1_config_NB);
- }
-
-///SRB1bis (The configuration for SRB1 and SRB1bis is the same) the only difference is the logical channel identity = 3 but not set here
-
-		 SRB1bis_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_config_NB_IoT));
-
-		 //no srb_Identity in SRB_ToAddMod_NB
-		 SRB1bis_rlc_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_rlc_config_NB_IoT));
-		 SRB1bis_config_NB_IoT->rlc_Config_r13   = SRB1bis_rlc_config_NB_IoT;
-
-		 SRB1bis_rlc_config_NB_IoT->present = SRB_ToAddMod_NB_r13__rlc_Config_r13_PR_explicitValue;
-		 SRB1bis_rlc_config_NB_IoT->choice.explicitValue.present=RLC_Config_NB_r13_PR_am;//MP: the only possible RLC config in NB_IoT
-
-		 SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = T_PollRetransmit_NB_r13_ms25000;
-		 SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = UL_AM_RLC_NB_r13__maxRetxThreshold_r13_t8;
-		 //(musT be disabled--> SRB1 config pag 640 specs )
-		 SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 =NULL;
-
-		 SRB1bis_lchan_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_lchan_config_NB_IoT));
-		 SRB1bis_config_NB_IoT->logicalChannelConfig_r13  = SRB1bis_lchan_config_NB_IoT;
-
-		 SRB1bis_lchan_config_NB_IoT->present = SRB_ToAddMod_NB_r13__logicalChannelConfig_r13_PR_explicitValue;
-
-		 prioritySRB1bis = CALLOC(1, sizeof(long));
-		 *prioritySRB1bis = 1; //same as SRB1?
-		 SRB1bis_lchan_config_NB_IoT->choice.explicitValue.priority_r13 = prioritySRB1bis;
-
-		 logicalChannelSR_Prohibit = CALLOC(1, sizeof(BOOLEAN_t));
-		 *logicalChannelSR_Prohibit = 1; //schould be set to TRUE (specs pag 641)
-		 SRB1bis_lchan_config_NB_IoT->choice.explicitValue.logicalChannelSR_Prohibit_r13 = logicalChannelSR_Prohibit;
-
-		 //ADD SRB1bis
-		 //MP: Actually there is no way to distinguish SRB1 and SRB1bis once put in the list
-		 //MP: SRB_ToAddModList_NB_r13_t size = 1
-		 ASN_SEQUENCE_ADD(&(*SRB_configList_NB_IoT)->list,SRB1bis_config_NB_IoT);
-
-
- // PhysicalConfigDedicated (NPDCCH, NPUSCH, CarrierConfig, UplinkPowerControl)
-
- physicalConfigDedicated2_NB_IoT = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT));
- *physicalConfigDedicated_NB_IoT = physicalConfigDedicated2_NB_IoT;
-
- physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13= CALLOC(1, sizeof(*physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13));
- physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13));
- physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13));
- physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13));
-
- //no tpc, no cqi and no pucch, no pdsch, no soundingRS, no AntennaInfo, no scheduling request config
-
- /*
-  * NB-IoT supports the operation with either one or two antenna ports, AP0 and AP1.
-  * For the latter case, Space Frequency Block Coding (SFBC) is applied.
-  * Once selected, the same transmission scheme applies to NPBCH, NPDCCH, and NPDSCH.
-  * */
-
- //FIXME: MP: CarrierConfigDedicated check the set values ----------------------------------------------
+  if (*SRB_configList_NB_IoT) {
+    free(*SRB_configList_NB_IoT);
+  }
 
+  *SRB_configList_NB_IoT = CALLOC(1,sizeof(SRB_ToAddModList_NB_r13_t));
+  /// SRB1--------------------
+  {
+    // SRB1_config_NB = CALLOC(1,sizeof(*SRB1_config_NB));
+    //
+    // //no srb_Identity in SRB_ToAddMod_NB
+    //
+    // SRB1_rlc_config_NB = CALLOC(1,sizeof(*SRB1_rlc_config_NB));
+    // SRB1_config_NB->rlc_Config_r13   = SRB1_rlc_config_NB;
+    //
+    // SRB1_rlc_config_NB->present = SRB_ToAddMod_NB_r13__rlc_Config_r13_PR_explicitValue;
+    // SRB1_rlc_config_NB->choice.explicitValue.present=RLC_Config_NB_r13_PR_am;//the only possible in NB_IoT
+    //
+    //// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = enb_properties.properties[ctxt_pP->module_id]->srb1_timer_poll_retransmit_r13;
+    //// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = enb_properties.properties[ctxt_pP->module_id]->srb1_max_retx_threshold_r13;
+    //// //(musT be disabled--> SRB1 config pag 640 specs )
+    //// SRB1_rlc_config_NB->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 =NULL;
+    //
+    //
+    // SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = T_PollRetransmit_NB_r13_ms25000;
+    // SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = UL_AM_RLC_NB_r13__maxRetxThreshold_r13_t8;
+    // //(musT be disabled--> SRB1 config pag 640 specs )
+    // SRB1_rlc_config_NB->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 = NULL;
+    //
+    // SRB1_lchan_config_NB = CALLOC(1,sizeof(*SRB1_lchan_config_NB));
+    // SRB1_config_NB->logicalChannelConfig_r13  = SRB1_lchan_config_NB;
+    //
+    // SRB1_lchan_config_NB->present = SRB_ToAddMod_NB_r13__logicalChannelConfig_r13_PR_explicitValue;
+    //
+    //
+    // prioritySRB1 = CALLOC(1, sizeof(long));
+    // *prioritySRB1 = 1;
+    // SRB1_lchan_config_NB->choice.explicitValue.priority_r13 = prioritySRB1;
+    //
+    // logicalChannelSR_Prohibit = CALLOC(1, sizeof(BOOLEAN_t));
+    // *logicalChannelSR_Prohibit = 1;
+    // //schould be set to TRUE (specs pag 641)
+    // SRB1_lchan_config_NB->choice.explicitValue.logicalChannelSR_Prohibit_r13 = logicalChannelSR_Prohibit;
+    //
+    // //ADD SRB1
+    // ASN_SEQUENCE_ADD(&(*SRB_configList_NB_IoT)->list,SRB1_config_NB);
+  }
+  ///SRB1bis (The configuration for SRB1 and SRB1bis is the same) the only difference is the logical channel identity = 3 but not set here
+  SRB1bis_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_config_NB_IoT));
+  //no srb_Identity in SRB_ToAddMod_NB
+  SRB1bis_rlc_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_rlc_config_NB_IoT));
+  SRB1bis_config_NB_IoT->rlc_Config_r13   = SRB1bis_rlc_config_NB_IoT;
+  SRB1bis_rlc_config_NB_IoT->present = SRB_ToAddMod_NB_r13__rlc_Config_r13_PR_explicitValue;
+  SRB1bis_rlc_config_NB_IoT->choice.explicitValue.present=RLC_Config_NB_r13_PR_am;//MP: the only possible RLC config in NB_IoT
+  SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = T_PollRetransmit_NB_r13_ms25000;
+  SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = UL_AM_RLC_NB_r13__maxRetxThreshold_r13_t8;
+  //(musT be disabled--> SRB1 config pag 640 specs )
+  SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 =NULL;
+  SRB1bis_lchan_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_lchan_config_NB_IoT));
+  SRB1bis_config_NB_IoT->logicalChannelConfig_r13  = SRB1bis_lchan_config_NB_IoT;
+  SRB1bis_lchan_config_NB_IoT->present = SRB_ToAddMod_NB_r13__logicalChannelConfig_r13_PR_explicitValue;
+  prioritySRB1bis = CALLOC(1, sizeof(long));
+  *prioritySRB1bis = 1; //same as SRB1?
+  SRB1bis_lchan_config_NB_IoT->choice.explicitValue.priority_r13 = prioritySRB1bis;
+  logicalChannelSR_Prohibit = CALLOC(1, sizeof(BOOLEAN_t));
+  *logicalChannelSR_Prohibit = 1; //schould be set to TRUE (specs pag 641)
+  SRB1bis_lchan_config_NB_IoT->choice.explicitValue.logicalChannelSR_Prohibit_r13 = logicalChannelSR_Prohibit;
+  //ADD SRB1bis
+  //MP: Actually there is no way to distinguish SRB1 and SRB1bis once put in the list
+  //MP: SRB_ToAddModList_NB_r13_t size = 1
+  ASN_SEQUENCE_ADD(&(*SRB_configList_NB_IoT)->list,SRB1bis_config_NB_IoT);
+  // PhysicalConfigDedicated (NPDCCH, NPUSCH, CarrierConfig, UplinkPowerControl)
+  physicalConfigDedicated2_NB_IoT = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT));
+  *physicalConfigDedicated_NB_IoT = physicalConfigDedicated2_NB_IoT;
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13= CALLOC(1, sizeof(*physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13));
+  physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13));
+  physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13));
+  physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13));
+  //no tpc, no cqi and no pucch, no pdsch, no soundingRS, no AntennaInfo, no scheduling request config
+  /*
+   * NB-IoT supports the operation with either one or two antenna ports, AP0 and AP1.
+   * For the latter case, Space Frequency Block Coding (SFBC) is applied.
+   * Once selected, the same transmission scheme applies to NPBCH, NPDCCH, and NPDSCH.
+   * */
+  //FIXME: MP: CarrierConfigDedicated check the set values ----------------------------------------------
   //DL
-
- physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_CarrierFreq_r13.carrierFreq_r13=0;//random value set
- physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.downlinkBitmapNonAnchor_r13= CALLOC(1,sizeof(struct DL_CarrierConfigDedicated_NB_r13__downlinkBitmapNonAnchor_r13));
-		 physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.downlinkBitmapNonAnchor_r13->present=
-				 	 	 	 	 	 	 	 	 DL_CarrierConfigDedicated_NB_r13__downlinkBitmapNonAnchor_r13_PR_useNoBitmap_r13;
-
- physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_GapNonAnchor_r13 = CALLOC(1,sizeof(struct DL_CarrierConfigDedicated_NB_r13__dl_GapNonAnchor_r13));
- physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_GapNonAnchor_r13->present =
-		  	  	  	  	  	  	  	  	  	  	  DL_CarrierConfigDedicated_NB_r13__dl_GapNonAnchor_r13_PR_useNoGap_r13;
-
- physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.inbandCarrierInfo_r13= NULL;
-
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_CarrierFreq_r13.carrierFreq_r13=0;//random value set
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.downlinkBitmapNonAnchor_r13= CALLOC(1,sizeof(struct DL_CarrierConfigDedicated_NB_r13__downlinkBitmapNonAnchor_r13));
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.downlinkBitmapNonAnchor_r13->present=
+    DL_CarrierConfigDedicated_NB_r13__downlinkBitmapNonAnchor_r13_PR_useNoBitmap_r13;
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_GapNonAnchor_r13 = CALLOC(1,sizeof(struct DL_CarrierConfigDedicated_NB_r13__dl_GapNonAnchor_r13));
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_GapNonAnchor_r13->present =
+    DL_CarrierConfigDedicated_NB_r13__dl_GapNonAnchor_r13_PR_useNoGap_r13;
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.inbandCarrierInfo_r13= NULL;
   //UL
- physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->ul_CarrierConfig_r13.ul_CarrierFreq_r13= NULL;
-
- // NPDCCH
- physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_NumRepetitions_r13 =0;
- physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_Offset_USS_r13 =0;
- physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_StartSF_USS_r13=0;
-
- // NPUSCH //(specs TS 36.331 v14.2.1 pag 643) /* OPTIONAL */
- physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->ack_NACK_NumRepetitions_r13= NULL;
- npusch_AllSymbols= CALLOC(1, sizeof(BOOLEAN_t));
- *npusch_AllSymbols= 1; //TRUE
- physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->npusch_AllSymbols_r13= npusch_AllSymbols; /* OPTIONAL */
- physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->groupHoppingDisabled_r13=NULL; /* OPTIONAL */
-
- // UplinkPowerControlDedicated
- physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13->p0_UE_NPUSCH_r13 = 0; // 0 dB (specs TS36.331 v14.2.1 pag 643)
-
-
- //Fill the rrcConnectionSetup-NB message
- rrcConnectionSetup_NB_IoT->rrc_TransactionIdentifier = Transaction_id; //input value
- rrcConnectionSetup_NB_IoT->criticalExtensions.present = RRCConnectionSetup_NB__criticalExtensions_PR_c1;
- rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.present =RRCConnectionSetup_NB__criticalExtensions__c1_PR_rrcConnectionSetup_r13 ;
- //MP: carry only SRB1bis at the moment and phyConfigDedicated
- rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.srb_ToAddModList_r13 = *SRB_configList_NB_IoT;
- rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.drb_ToAddModList_r13 = NULL;
- rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.drb_ToReleaseList_r13 = NULL;
- rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.rlf_TimersAndConstants_r13 = NULL;
- rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.physicalConfigDedicated_r13 = physicalConfigDedicated2_NB_IoT;
- rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13 = NULL;
-
+  physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->ul_CarrierConfig_r13.ul_CarrierFreq_r13= NULL;
+  // NPDCCH
+  physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_NumRepetitions_r13 =0;
+  physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_Offset_USS_r13 =0;
+  physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_StartSF_USS_r13=0;
+  // NPUSCH //(specs TS 36.331 v14.2.1 pag 643) /* OPTIONAL */
+  physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->ack_NACK_NumRepetitions_r13= NULL;
+  npusch_AllSymbols= CALLOC(1, sizeof(BOOLEAN_t));
+  *npusch_AllSymbols= 1; //TRUE
+  physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->npusch_AllSymbols_r13= npusch_AllSymbols; /* OPTIONAL */
+  physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->groupHoppingDisabled_r13=NULL; /* OPTIONAL */
+  // UplinkPowerControlDedicated
+  physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13->p0_UE_NPUSCH_r13 = 0; // 0 dB (specs TS36.331 v14.2.1 pag 643)
+  //Fill the rrcConnectionSetup-NB message
+  rrcConnectionSetup_NB_IoT->rrc_TransactionIdentifier = Transaction_id; //input value
+  rrcConnectionSetup_NB_IoT->criticalExtensions.present = RRCConnectionSetup_NB__criticalExtensions_PR_c1;
+  rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.present =RRCConnectionSetup_NB__criticalExtensions__c1_PR_rrcConnectionSetup_r13 ;
+  //MP: carry only SRB1bis at the moment and phyConfigDedicated
+  rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.srb_ToAddModList_r13 = *SRB_configList_NB_IoT;
+  rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.drb_ToAddModList_r13 = NULL;
+  rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.drb_ToReleaseList_r13 = NULL;
+  rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.rlf_TimersAndConstants_r13 = NULL;
+  rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.physicalConfigDedicated_r13 = physicalConfigDedicated2_NB_IoT;
+  rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13 = NULL;
 #ifdef XER_PRINT
- xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void *)&dl_ccch_msg);
 #endif
- enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message_NB,
-                                  (void*)&dl_ccch_msg_NB_IoT,
-                                  buffer,
-                                  100);
+  enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message_NB,
+                                   NULL,
+                                   (void *)&dl_ccch_msg_NB_IoT,
+                                   buffer,
+                                   100);
 
- if (enc_rval.encoded <= 0) {
-     LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
-              enc_rval.failed_type->name, enc_rval.encoded);
- }
+  if (enc_rval.encoded <= 0) {
+    LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
+  }
 
 #ifdef USER_MODE
- LOG_D(RRC,"RRCConnectionSetup-NB Encoded %zd bits (%zd bytes), ecause %d\n",
-       enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
+  LOG_D(RRC,"RRCConnectionSetup-NB Encoded %zd bits (%zd bytes), ecause %d\n",
+        enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
 #endif
-
- return((enc_rval.encoded+7)/8);
+  return((enc_rval.encoded+7)/8);
 }
 
 /*do_SecurityModeCommand - exactly the same as previous implementation*/
 uint8_t do_SecurityModeCommand_NB_IoT(
-  const protocol_ctxt_t* const ctxt_pP,
-  uint8_t* const buffer,
+  const protocol_ctxt_t *const ctxt_pP,
+  uint8_t *const buffer,
   const uint8_t Transaction_id,
   const uint8_t cipheringAlgorithm,
   const uint8_t integrityProtAlgorithm)
 {
   DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
   asn_enc_rval_t enc_rval;
-
   memset(&dl_dcch_msg_NB_IoT,0,sizeof(DL_DCCH_Message_NB_t));
-
   dl_dcch_msg_NB_IoT.message.present = DL_DCCH_MessageType_NB_PR_c1;
   dl_dcch_msg_NB_IoT.message.choice.c1.present = DL_DCCH_MessageType_NB__c1_PR_securityModeCommand_r13;
-
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.rrc_TransactionIdentifier = Transaction_id;
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1;
-
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.choice.c1.present =
-		  SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8;
-
+    SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8;
   // the two following information could be based on the mod_id
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm
     = (CipheringAlgorithm_r12_t)cipheringAlgorithm; //bug solved
-
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm
     = (e_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm;
-
-//only changed "asn_DEF_DL_DCCH_Message_NB"
+  //only changed "asn_DEF_DL_DCCH_Message_NB"
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message_NB, (void*)&dl_dcch_msg_NB_IoT);
+  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message_NB, (void *)&dl_dcch_msg_NB_IoT);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message_NB,
-                                   (void*)&dl_dcch_msg_NB_IoT,
+                                   NULL,
+                                   (void *)&dl_dcch_msg_NB_IoT,
                                    buffer,
                                    100);
+
   if (enc_rval.encoded <= 0) {
-      LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+    LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
   }
 
-
-//#if defined(ENABLE_ITTI)
-//# if !defined(DISABLE_XER_SPRINT)....
-
+  //#if defined(ENABLE_ITTI)
+  //# if !defined(DISABLE_XER_SPRINT)....
 #ifdef USER_MODE
   LOG_D(RRC,"[NB-IoT %d] securityModeCommand-NB for UE %x Encoded %zd bits (%zd bytes)\n",
         ctxt_pP->module_id,
@@ -971,46 +809,40 @@ uint8_t do_SecurityModeCommand_NB_IoT(
 
 /*do_UECapabilityEnquiry_NB_IoT - very similar to legacy lte*/
 uint8_t do_UECapabilityEnquiry_NB_IoT(
-  const protocol_ctxt_t* const ctxt_pP,
-  uint8_t*               const buffer,
+  const protocol_ctxt_t *const ctxt_pP,
+  uint8_t               *const buffer,
   const uint8_t                Transaction_id
 )
 
 {
-
   DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
   //no RAT type in NB-IoT
   asn_enc_rval_t enc_rval;
-
   memset(&dl_dcch_msg_NB_IoT,0,sizeof(DL_DCCH_Message_NB_t));
-
   dl_dcch_msg_NB_IoT.message.present           = DL_DCCH_MessageType_NB_PR_c1;
   dl_dcch_msg_NB_IoT.message.choice.c1.present = DL_DCCH_MessageType_NB__c1_PR_ueCapabilityEnquiry_r13;
-
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.ueCapabilityEnquiry_r13.rrc_TransactionIdentifier = Transaction_id;
-
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.ueCapabilityEnquiry_r13.criticalExtensions.present = UECapabilityEnquiry_NB__criticalExtensions_PR_c1;
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.ueCapabilityEnquiry_r13.criticalExtensions.choice.c1.present =
-		  UECapabilityEnquiry_NB__criticalExtensions__c1_PR_ueCapabilityEnquiry_r13;
-
+    UECapabilityEnquiry_NB__criticalExtensions__c1_PR_ueCapabilityEnquiry_r13;
   //no ue_CapabilityRequest (list of RAT_Type)
-
-//only changed "asn_DEF_DL_DCCH_Message_NB"
+  //only changed "asn_DEF_DL_DCCH_Message_NB"
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message_NB, (void*)&dl_dcch_msg_NB_IoT);
+  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message_NB, (void *)&dl_dcch_msg_NB_IoT);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message_NB,
-                                   (void*)&dl_dcch_msg_NB_IoT,
+                                   NULL,
+                                   (void *)&dl_dcch_msg_NB_IoT,
                                    buffer,
                                    100);
-  if (enc_rval.encoded <= 0) {
-     LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
-    }
 
-//#if defined(ENABLE_ITTI)
-//# if !defined(DISABLE_XER_SPRINT)....
+  if (enc_rval.encoded <= 0) {
+    LOG_F(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
+  }
 
+  //#if defined(ENABLE_ITTI)
+  //# if !defined(DISABLE_XER_SPRINT)....
 #ifdef USER_MODE
   LOG_D(RRC,"[NB-IoT %d] UECapabilityEnquiry-NB for UE %x Encoded %zd bits (%zd bytes)\n",
         ctxt_pP->module_id,
@@ -1033,39 +865,32 @@ uint8_t do_UECapabilityEnquiry_NB_IoT(
  * (including RBs, MAC main configuration and physical channel configuration)
  * including any associated dedicated NAS information.*/
 uint16_t do_RRCConnectionReconfiguration_NB_IoT(
-  const protocol_ctxt_t*        const ctxt_pP,
-    uint8_t                            *buffer,
-    uint8_t                             Transaction_id,
-    SRB_ToAddModList_NB_r13_t          *SRB1_list_NB, //SRB_ConfigList2 (default)--> only SRB1
-    DRB_ToAddModList_NB_r13_t          *DRB_list_NB_IoT, //DRB_ConfigList (default)
-    DRB_ToReleaseList_NB_r13_t         *DRB_list2_NB_IoT, //is NULL when passed
-    struct PhysicalConfigDedicated_NB_r13     *physicalConfigDedicated_NB_IoT,
-	MAC_MainConfig_NB_r13_t                   *mac_MainConfig_NB_IoT,
-  struct RRCConnectionReconfiguration_NB_r13_IEs__dedicatedInfoNASList_r13* dedicatedInfoNASList_NB_IoT)
+  const protocol_ctxt_t        *const ctxt_pP,
+  uint8_t                            *buffer,
+  uint8_t                             Transaction_id,
+  SRB_ToAddModList_NB_r13_t          *SRB1_list_NB, //SRB_ConfigList2 (default)--> only SRB1
+  DRB_ToAddModList_NB_r13_t          *DRB_list_NB_IoT, //DRB_ConfigList (default)
+  DRB_ToReleaseList_NB_r13_t         *DRB_list2_NB_IoT, //is NULL when passed
+  struct PhysicalConfigDedicated_NB_r13     *physicalConfigDedicated_NB_IoT,
+  MAC_MainConfig_NB_r13_t                   *mac_MainConfig_NB_IoT,
+  struct RRCConnectionReconfiguration_NB_r13_IEs__dedicatedInfoNASList_r13 *dedicatedInfoNASList_NB_IoT)
 
 {
-
- //check on DRB_list if contains more than 2 DRB?
-
+  //check on DRB_list if contains more than 2 DRB?
   asn_enc_rval_t enc_rval;
   DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
   RRCConnectionReconfiguration_NB_t *rrcConnectionReconfiguration_NB;
-
-
   memset(&dl_dcch_msg_NB_IoT,0,sizeof(DL_DCCH_Message_NB_t));
-
   dl_dcch_msg_NB_IoT.message.present           = DL_DCCH_MessageType_NB_PR_c1;
   dl_dcch_msg_NB_IoT.message.choice.c1.present = DL_DCCH_MessageType_NB__c1_PR_rrcConnectionReconfiguration_r13;
   rrcConnectionReconfiguration_NB          = &dl_dcch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReconfiguration_r13;
-
   // RRCConnectionReconfiguration
   rrcConnectionReconfiguration_NB->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionReconfiguration_NB->criticalExtensions.present = RRCConnectionReconfiguration_NB__criticalExtensions_PR_c1;
   rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.present =RRCConnectionReconfiguration_NB__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r13 ;
-
   //RAdioResourceconfigDedicated
   rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13 =
-		  CALLOC(1,sizeof(*rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13));
+    CALLOC(1,sizeof(*rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13));
   rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->srb_ToAddModList_r13 = SRB1_list_NB; //only SRB1
   rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->drb_ToAddModList_r13 = DRB_list_NB_IoT;
   rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->drb_ToReleaseList_r13 = DRB_list2_NB_IoT; //NULL
@@ -1075,77 +900,69 @@ uint16_t do_RRCConnectionReconfiguration_NB_IoT(
 
   if (mac_MainConfig_NB_IoT!=NULL) {
     rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13 =
-    		CALLOC(1, sizeof(*rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13));
+      CALLOC(1, sizeof(*rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13));
     rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13->present
       =RadioResourceConfigDedicated_NB_r13__mac_MainConfig_r13_PR_explicitValue_r13;
-   //why memcopy only this one?
+    //why memcopy only this one?
     memcpy(&rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13->choice.explicitValue_r13,
            mac_MainConfig_NB_IoT, sizeof(*mac_MainConfig_NB_IoT));
-
   } else {
-	  rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13=NULL;
+    rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13=NULL;
   }
 
   //no measConfig, measIDlist
   //no mobilityControlInfo
-
   rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.dedicatedInfoNASList_r13 = dedicatedInfoNASList_NB_IoT;
   //mainly used for cell-reselection/handover purposes??
   rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.fullConfig_r13 = NULL;
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message_NB,
-                                   (void*)&dl_dcch_msg_NB_IoT,
+                                   NULL,
+                                   (void *)&dl_dcch_msg_NB_IoT,
                                    buffer,
                                    RRC_BUF_SIZE);
+
   if (enc_rval.encoded <= 0) {
-     LOG_F(RRC, "ASN1 message encoding failed %s, %li\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+    LOG_F(RRC, "ASN1 message encoding failed %s, %li\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
   }
 
   //changed only asn_DEF_DL_DCCH_Message_NB
 #ifdef XER_PRINT
-  xer_fprint(stdout,&asn_DEF_DL_DCCH_Message_NB,(void*)&dl_dcch_msg_NB_IoT);
+  xer_fprint(stdout,&asn_DEF_DL_DCCH_Message_NB,(void *)&dl_dcch_msg_NB_IoT);
 #endif
-
-//#if defined(ENABLE_ITTI)
-//# if !defined(DISABLE_XER_SPRINT)...
-
-
+  //#if defined(ENABLE_ITTI)
+  //# if !defined(DISABLE_XER_SPRINT)...
   LOG_I(RRC,"RRCConnectionReconfiguration-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
-
   return((enc_rval.encoded+7)/8);
 }
 
 /*do_RRCConnectionReestablishmentReject - exactly the same as legacy LTE*/
 uint8_t do_RRCConnectionReestablishmentReject_NB_IoT(
-    uint8_t                    Mod_id,
-    uint8_t*                   const buffer)
+  uint8_t                    Mod_id,
+  uint8_t                   *const buffer)
 {
-
   asn_enc_rval_t enc_rval;
-
   DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
   RRCConnectionReestablishmentReject_t *rrcConnectionReestablishmentReject;
-
   memset((void *)&dl_ccch_msg_NB_IoT,0,sizeof(DL_CCCH_Message_NB_t));
   dl_ccch_msg_NB_IoT.message.present = DL_CCCH_MessageType_NB_PR_c1;
   dl_ccch_msg_NB_IoT.message.choice.c1.present = DL_CCCH_MessageType_NB__c1_PR_rrcConnectionReestablishmentReject_r13;
   rrcConnectionReestablishmentReject    = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReestablishmentReject_r13;
-
   // RRCConnectionReestablishmentReject //exactly the same as LTE
   rrcConnectionReestablishmentReject->criticalExtensions.present = RRCConnectionReestablishmentReject__criticalExtensions_PR_rrcConnectionReestablishmentReject_r8;
-
   //Only change in "asn_DEF_DL_CCCH_Message_NB"
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message_NB, (void*)&dl_ccch_msg_NB_IoT);
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message_NB, (void *)&dl_ccch_msg_NB_IoT);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message_NB,
-                                   (void*)&dl_ccch_msg_NB_IoT,
+                                   NULL,
+                                   (void *)&dl_ccch_msg_NB_IoT,
                                    buffer,
                                    100);
+
   if (enc_rval.encoded <= 0) {
-     LOG_F(RRC,"ASN1 message encoding failed (%s, %lu)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+    LOG_F(RRC,"ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
   }
 
   //Only change in "asn_DEF_DL_CCCH_Message_NB"
@@ -1157,42 +974,34 @@ uint8_t do_RRCConnectionReestablishmentReject_NB_IoT(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_CCCH_Message_NB, (void *) &dl_ccch_msg_NB_IoT)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB_NB_IoT, 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, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
 #ifdef USER_MODE
   LOG_D(RRC,"RRCConnectionReestablishmentReject Encoded %zd bits (%zd bytes)\n",
         enc_rval.encoded,(enc_rval.encoded+7)/8);
 #endif
-
   return((enc_rval.encoded+7)/8);
 }
 
 /*do_RRCConnectionReject_NB_IoT*/
 uint8_t do_RRCConnectionReject_NB_IoT(
-    uint8_t                    Mod_id,
-    uint8_t*                   const buffer)
+  uint8_t                    Mod_id,
+  uint8_t                   *const buffer)
 
 {
-
   asn_enc_rval_t enc_rval;
-
   DL_CCCH_Message_NB_t          dl_ccch_msg_NB_IoT;
   RRCConnectionReject_NB_t      *rrcConnectionReject_NB_IoT;
-
   memset((void *)&dl_ccch_msg_NB_IoT,0,sizeof(DL_CCCH_Message_NB_t));
   dl_ccch_msg_NB_IoT.message.present           = DL_CCCH_MessageType_NB_PR_c1;
   dl_ccch_msg_NB_IoT.message.choice.c1.present = DL_CCCH_MessageType_NB__c1_PR_rrcConnectionReject_r13;
   rrcConnectionReject_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReject_r13;
-
   // RRCConnectionReject-NB_IoT
   rrcConnectionReject_NB_IoT->criticalExtensions.present = RRCConnectionReject_NB__criticalExtensions_PR_c1;
   rrcConnectionReject_NB_IoT->criticalExtensions.choice.c1.present = RRCConnectionReject_NB__criticalExtensions__c1_PR_rrcConnectionReject_r13;
@@ -1201,21 +1010,22 @@ uint8_t do_RRCConnectionReject_NB_IoT(
   //new-use of suspend indication
   //If present, this field indicates that the UE should remain suspended and not release its stored context.
   rrcConnectionReject_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReject_r13.rrc_SuspendIndication_r13=
-		  CALLOC(1, sizeof(long));
+    CALLOC(1, sizeof(long));
   *(rrcConnectionReject_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReject_r13.rrc_SuspendIndication_r13)=
-		  RRCConnectionReject_NB_r13_IEs__rrc_SuspendIndication_r13_true;
-
+    RRCConnectionReject_NB_r13_IEs__rrc_SuspendIndication_r13_true;
   //Only Modified "asn_DEF_DL_CCCH_Message_NB"
 #ifdef XER_PRINT
-  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message_NB, (void*)&dl_ccch_msg);
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message_NB, (void *)&dl_ccch_msg);
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message_NB,
-                                   (void*)&dl_ccch_msg_NB_IoT,
+                                   NULL,
+                                   (void *)&dl_ccch_msg_NB_IoT,
                                    buffer,
                                    100);
+
   if (enc_rval.encoded <= 0) {
-     LOG_F(RRC, "ASN1 message encoding failed (%s, %ld)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+    LOG_F(RRC, "ASN1 message encoding failed (%s, %ld)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
   }
 
 #if defined(ENABLE_ITTI)
@@ -1226,22 +1036,18 @@ uint8_t do_RRCConnectionReject_NB_IoT(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_CCCH_Message_NB, (void *) &dl_ccch_msg_NB_IoT)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB_NB_IoT, 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, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
 #ifdef USER_MODE
   LOG_D(RRC,"RRCConnectionReject-NB Encoded %zd bits (%zd bytes)\n",
         enc_rval.encoded,(enc_rval.encoded+7)/8);
 #endif
-
   return((enc_rval.encoded+7)/8);
 }
 
@@ -1251,19 +1057,16 @@ uint8_t do_RRCConnectionReject_NB_IoT(
 
 /*do_DLInformationTransfer_NB*/
 uint8_t do_DLInformationTransfer_NB_IoT(
-		uint8_t Mod_id,
-		uint8_t **buffer,
-		uint8_t transaction_id,
-		uint32_t pdu_length,
-		uint8_t *pdu_buffer)
+  uint8_t Mod_id,
+  uint8_t **buffer,
+  uint8_t transaction_id,
+  uint32_t pdu_length,
+  uint8_t *pdu_buffer)
 
 {
   ssize_t encoded;
-
   DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
-
   memset(&dl_dcch_msg_NB_IoT, 0, sizeof(DL_DCCH_Message_NB_t));
-
   dl_dcch_msg_NB_IoT.message.present           = DL_DCCH_MessageType_NB_PR_c1;
   dl_dcch_msg_NB_IoT.message.choice.c1.present = DL_DCCH_MessageType_NB__c1_PR_dlInformationTransfer_r13;
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.rrc_TransactionIdentifier = transaction_id;
@@ -1271,9 +1074,7 @@ uint8_t do_DLInformationTransfer_NB_IoT(
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.criticalExtensions.choice.c1.present = DLInformationTransfer_NB__criticalExtensions__c1_PR_dlInformationTransfer_r13;
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.criticalExtensions.choice.c1.choice.dlInformationTransfer_r13.dedicatedInfoNAS_r13.size = pdu_length;
   dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.criticalExtensions.choice.c1.choice.dlInformationTransfer_r13.dedicatedInfoNAS_r13.buf = pdu_buffer;
-
-  encoded = uper_encode_to_new_buffer (&asn_DEF_DL_DCCH_Message_NB, NULL, (void*) &dl_dcch_msg_NB_IoT, (void **) buffer);
-
+  encoded = uper_encode_to_new_buffer (&asn_DEF_DL_DCCH_Message_NB, NULL, (void *) &dl_dcch_msg_NB_IoT, (void **) buffer);
   //only change in "asn_DEF_DL_DCCH_Message_NB"
 #if defined(ENABLE_ITTI)
 # if !defined(DISABLE_XER_SPRINT)
@@ -1283,17 +1084,14 @@ uint8_t do_DLInformationTransfer_NB_IoT(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_DCCH_Message_NB, (void *)&dl_dcch_msg_NB_IoT)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB_NB_IoT, 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, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   return encoded;
 }
 
@@ -1304,51 +1102,44 @@ uint8_t do_DLInformationTransfer_NB_IoT(
 
 /*do_RRCConnectionReestablishment_NB-->used to re-establish SRB1*/ //which parameter to use?
 uint8_t do_RRCConnectionReestablishment_NB_IoT(
-		uint8_t Mod_id,
-		uint8_t* const buffer,
-		const uint8_t     Transaction_id,
-		const NB_IoT_DL_FRAME_PARMS* const frame_parms, //to be changed
-		SRB_ToAddModList_NB_r13_t*      SRB_list_NB_IoT) //should contain SRB1 already configured?
+  uint8_t Mod_id,
+  uint8_t *const buffer,
+  const uint8_t     Transaction_id,
+  const NB_IoT_DL_FRAME_PARMS *const frame_parms, //to be changed
+  SRB_ToAddModList_NB_r13_t      *SRB_list_NB_IoT) //should contain SRB1 already configured?
 {
+  asn_enc_rval_t enc_rval;
+  DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
+  RRCConnectionReestablishment_NB_t *rrcConnectionReestablishment_NB_IoT;
+  memset(&dl_ccch_msg_NB_IoT, 0, sizeof(DL_CCCH_Message_NB_t));
+  dl_ccch_msg_NB_IoT.message.present = DL_CCCH_MessageType_NB_PR_c1;
+  dl_ccch_msg_NB_IoT.message.choice.c1.present = DL_CCCH_MessageType_NB__c1_PR_rrcConnectionReestablishment_r13;
+  rrcConnectionReestablishment_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReestablishment_r13;
+  //rrcConnectionReestablishment_NB
+  rrcConnectionReestablishment_NB_IoT->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.present = RRCConnectionReestablishment_NB__criticalExtensions_PR_c1;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.present = RRCConnectionReestablishment_NB__criticalExtensions__c1_PR_rrcConnectionReestablishment_r13;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.srb_ToAddModList_r13 = SRB_list_NB_IoT;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.drb_ToAddModList_r13 = NULL;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.drb_ToReleaseList_r13 = NULL;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.rlf_TimersAndConstants_r13= NULL;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13= NULL;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.physicalConfigDedicated_r13 = NULL;
+  rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.nextHopChainingCount_r13=0;
+  enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message_NB,
+                                   NULL,
+                                   (void *)&dl_ccch_msg_NB_IoT,
+                                   buffer,
+                                   RRC_BUF_SIZE);
 
-	asn_enc_rval_t enc_rval;
-	DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
-	RRCConnectionReestablishment_NB_t* rrcConnectionReestablishment_NB_IoT;
-
-	memset(&dl_ccch_msg_NB_IoT, 0, sizeof(DL_CCCH_Message_NB_t));
-
-	dl_ccch_msg_NB_IoT.message.present = DL_CCCH_MessageType_NB_PR_c1;
-	dl_ccch_msg_NB_IoT.message.choice.c1.present = DL_CCCH_MessageType_NB__c1_PR_rrcConnectionReestablishment_r13;
-	rrcConnectionReestablishment_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReestablishment_r13;
-
-	//rrcConnectionReestablishment_NB
-	rrcConnectionReestablishment_NB_IoT->rrc_TransactionIdentifier = Transaction_id;
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.present = RRCConnectionReestablishment_NB__criticalExtensions_PR_c1;
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.present = RRCConnectionReestablishment_NB__criticalExtensions__c1_PR_rrcConnectionReestablishment_r13;
-
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.srb_ToAddModList_r13 = SRB_list_NB_IoT;
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.drb_ToAddModList_r13 = NULL;
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.drb_ToReleaseList_r13 = NULL;
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.rlf_TimersAndConstants_r13= NULL;
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13= NULL;
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.physicalConfigDedicated_r13 = NULL;
-
-	rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.nextHopChainingCount_r13=0;
-
-	enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message_NB,
-	                                   (void*)&dl_ccch_msg_NB_IoT,
-	                                   buffer,
-	                                   RRC_BUF_SIZE);
-
-	if (enc_rval.encoded <= 0) {
-           LOG_F(RRC, "ASN1 message encoding failed (%s, %li)!\n",
-	               enc_rval.failed_type->name, enc_rval.encoded);
-        }
+  if (enc_rval.encoded <= 0) {
+    LOG_F(RRC, "ASN1 message encoding failed (%s, %li)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
+  }
 
 #ifdef XER_PRINT
-  xer_fprint(stdout,&asn_DEF_DL_CCCH_Message_NB,(void*)&dl_ccch_msg_NB_IoT);
+  xer_fprint(stdout,&asn_DEF_DL_CCCH_Message_NB,(void *)&dl_ccch_msg_NB_IoT);
 #endif
-
 #if defined(ENABLE_ITTI)
 # if !defined(DISABLE_XER_SPRINT)
   {
@@ -1357,17 +1148,14 @@ uint8_t do_RRCConnectionReestablishment_NB_IoT(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_CCCH_Message_NB, (void *) &dl_ccch_msg_NB_IoT)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB_NB_IoT, 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, Mod_id, msg_p);
     }
   }
 # endif
 #endif
-
   LOG_I(RRC,"RRCConnectionReestablishment-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
   return 0;
 }
@@ -1376,39 +1164,30 @@ uint8_t do_RRCConnectionReestablishment_NB_IoT(
 uint8_t do_RRCConnectionRelease_NB_IoT(
   uint8_t                             Mod_id,
   uint8_t                            *buffer,
- const uint8_t                             Transaction_id)
+  const uint8_t                             Transaction_id)
 {
-
   asn_enc_rval_t enc_rval;
-
   DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
   RRCConnectionRelease_NB_t *rrcConnectionRelease_NB_IoT;
-
-
   memset(&dl_dcch_msg_NB_IoT,0,sizeof(DL_DCCH_Message_NB_t));
-
   dl_dcch_msg_NB_IoT.message.present           = DL_DCCH_MessageType_NB_PR_c1;
   dl_dcch_msg_NB_IoT.message.choice.c1.present = DL_DCCH_MessageType_NB__c1_PR_rrcConnectionRelease_r13;
   rrcConnectionRelease_NB_IoT                  = &dl_dcch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionRelease_r13;
-
   // RRCConnectionRelease
   rrcConnectionRelease_NB_IoT->rrc_TransactionIdentifier = Transaction_id;
   rrcConnectionRelease_NB_IoT->criticalExtensions.present = RRCConnectionRelease_NB__criticalExtensions_PR_c1;
   rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.present =RRCConnectionRelease_NB__criticalExtensions__c1_PR_rrcConnectionRelease_r13 ;
-
   rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.releaseCause_r13 = ReleaseCause_NB_r13_other;
   rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.redirectedCarrierInfo_r13 = NULL;
   rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.extendedWaitTime_r13 = NULL;
-
   //Why allocate memory for non critical extension?
   rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.nonCriticalExtension=CALLOC(1,
       sizeof(*rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.nonCriticalExtension));
-
   enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message_NB,
-                                   (void*)&dl_dcch_msg_NB_IoT,
+                                   NULL,
+                                   (void *)&dl_dcch_msg_NB_IoT,
                                    buffer,
                                    RRC_BUF_SIZE);//check
-
   return((enc_rval.encoded+7)/8);
 }
 
diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c
index a1d0d2f6f72ce7bb2a4cffd3dec0e0fa946f6cb6..0ee1b32a4dea3f01f80a15bc56724e9aa35353c2 100644
--- a/openair2/RRC/LTE/rrc_UE.c
+++ b/openair2/RRC/LTE/rrc_UE.c
@@ -90,38 +90,38 @@
 
 
 extern void pdcp_config_set_security(
-  const protocol_ctxt_t* const  ctxt_pP,
-  pdcp_t         * const pdcp_pP,
+  const protocol_ctxt_t *const  ctxt_pP,
+  pdcp_t          *const pdcp_pP,
   const rb_id_t         rb_idP,
   const uint16_t        lc_idP,
   const uint8_t         security_modeP,
-  uint8_t        * const kRRCenc,
-  uint8_t        * const kRRCint,
-  uint8_t        * const  kUPenc);
+  uint8_t         *const kRRCenc,
+  uint8_t         *const kRRCint,
+  uint8_t         *const  kUPenc);
 
 // internal prototypes
 
-void rrc_ue_process_securityModeCommand( const protocol_ctxt_t* const ctxt_pP, SecurityModeCommand_t* const securityModeCommand, const uint8_t eNB_index );
+void rrc_ue_process_securityModeCommand( const protocol_ctxt_t *const ctxt_pP, SecurityModeCommand_t *const securityModeCommand, const uint8_t eNB_index );
 
-static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index );
+static int decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index );
 
-static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp );
+static int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp );
 
 /** \brief Generates/Encodes RRCConnnectionSetupComplete message at UE
  *  \param ctxt_pP Running context
  *  \param eNB_index Index of corresponding eNB/CH
  *  \param Transaction_id Transaction identifier
  */
-static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id );
+static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id );
 
 /** \brief Generates/Encodes RRCConnectionReconfigurationComplete message at UE
  *  \param ctxt_pP Running context
  *  \param eNB_index Index of corresponding eNB/CH
  *  \param Transaction_id RRC transaction identifier
  */
-static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id );
+static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id );
 
-static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, uint8_t eNB_index );
+static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index );
 
 static uint8_t check_trigger_meas_event(
   uint8_t module_idP,
@@ -164,15 +164,12 @@ static int rrc_set_state (module_id_t ue_mod_idP, Rrc_State_t state)
 
   if (UE_rrc_inst[ue_mod_idP].RrcState != state) {
     UE_rrc_inst[ue_mod_idP].RrcState = state;
-
 #if defined(ENABLE_ITTI)
     {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_STATE_IND);
       RRC_STATE_IND(msg_p).state = UE_rrc_inst[ue_mod_idP].RrcState;
       RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[ue_mod_idP].RrcSubState;
-
       itti_send_msg_to_task(TASK_UNKNOWN, UE_MODULE_ID_TO_INSTANCE(ue_mod_idP), msg_p);
     }
 #endif
@@ -188,35 +185,32 @@ static int rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_t subState )
 #if (defined(ENABLE_ITTI) && (defined(ENABLE_USE_MME) || ENABLE_RAL))
 
   switch (UE_rrc_inst[ue_mod_idP].RrcState) {
-  case RRC_STATE_INACTIVE:
-    AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST),
-                 "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState);
-    break;
-
-  case RRC_STATE_IDLE:
-    AssertFatal ((RRC_SUB_STATE_IDLE_FIRST <= subState) && (subState <= RRC_SUB_STATE_IDLE_LAST),
-                 "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState);
-    break;
-
-  case RRC_STATE_CONNECTED:
-    AssertFatal ((RRC_SUB_STATE_CONNECTED_FIRST <= subState) && (subState <= RRC_SUB_STATE_CONNECTED_LAST),
-                 "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState);
-    break;
+    case RRC_STATE_INACTIVE:
+      AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST),
+                   "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState);
+      break;
+
+    case RRC_STATE_IDLE:
+      AssertFatal ((RRC_SUB_STATE_IDLE_FIRST <= subState) && (subState <= RRC_SUB_STATE_IDLE_LAST),
+                   "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState);
+      break;
+
+    case RRC_STATE_CONNECTED:
+      AssertFatal ((RRC_SUB_STATE_CONNECTED_FIRST <= subState) && (subState <= RRC_SUB_STATE_CONNECTED_LAST),
+                   "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState);
+      break;
   }
 
 #endif
 
   if (UE_rrc_inst[ue_mod_idP].RrcSubState != subState) {
     UE_rrc_inst[ue_mod_idP].RrcSubState = subState;
-
 #if defined(ENABLE_ITTI)
     {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_STATE_IND);
       RRC_STATE_IND(msg_p).state = UE_rrc_inst[ue_mod_idP].RrcState;
       RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[ue_mod_idP].RrcSubState;
-
       itti_send_msg_to_task(TASK_UNKNOWN, UE_MODULE_ID_TO_INSTANCE(ue_mod_idP), msg_p);
     }
 #endif
@@ -229,33 +223,31 @@ static int rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_t subState )
 //-----------------------------------------------------------------------------
 void
 openair_rrc_on_ue(
-  const protocol_ctxt_t* const ctxt_pP
+  const protocol_ctxt_t *const ctxt_pP
 )
 //-----------------------------------------------------------------------------
 {
   unsigned short i;
-
-
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" UE?: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;
-    }
+  LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" UE?: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;
+  }
 }
 
 //-----------------------------------------------------------------------------
-static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
+static void init_SI_UE( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index )
 {
   UE_rrc_inst[ctxt_pP->module_id].sizeof_SIB1[eNB_index] = 0;
   UE_rrc_inst[ctxt_pP->module_id].sizeof_SI[eNB_index] = 0;
-  UE_rrc_inst[ctxt_pP->module_id].SIB1[eNB_index] = (uint8_t*)malloc16_clear( 32 );
+  UE_rrc_inst[ctxt_pP->module_id].SIB1[eNB_index] = (uint8_t *)malloc16_clear( 32 );
   UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType1_t) );
   UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType2_t) );
   UE_rrc_inst[ctxt_pP->module_id].sib3[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType3_t) );
@@ -271,10 +263,8 @@ static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
   UE_rrc_inst[ctxt_pP->module_id].sib12[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType12_r9_t) );
   UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType13_r9_t) );
 #endif
-  UE_rrc_inst[ctxt_pP->module_id].SI[eNB_index] = (uint8_t*)malloc16_clear( 64 );
-
-  UE_rrc_inst[ctxt_pP->module_id].si[eNB_index] = (SystemInformation_t*)malloc16_clear( sizeof(SystemInformation_t) );
-
+  UE_rrc_inst[ctxt_pP->module_id].SI[eNB_index] = (uint8_t *)malloc16_clear( 64 );
+  UE_rrc_inst[ctxt_pP->module_id].si[eNB_index] = (SystemInformation_t *)malloc16_clear( sizeof(SystemInformation_t) );
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 0;
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt    = 0;
 }
@@ -291,21 +281,19 @@ static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index)
 
   for (i=0; i<8; i++) { // MAX MBSFN Area
     UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[i] = 0;
-
   }
 }
 #endif
 #endif
 
 //-----------------------------------------------------------------------------
-static void openair_rrc_ue_init_security( const protocol_ctxt_t* const ctxt_pP )
+static void openair_rrc_ue_init_security( const protocol_ctxt_t *const ctxt_pP )
 {
 #if defined(ENABLE_SECURITY)
   //    uint8_t *kRRCenc;
   //    uint8_t *kRRCint;
   char ascii_buffer[65];
   uint8_t i;
-
   memset(UE_rrc_inst[ctxt_pP->module_id].kenb, ctxt_pP->module_id, 32);
 
   for (i = 0; i < 32; i++) {
@@ -328,7 +316,6 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_
         PROTOCOL_RRC_CTXT_ARGS(&ctxt));
   rrc_set_state (ue_mod_idP, RRC_STATE_INACTIVE);
   rrc_set_sub_state (ue_mod_idP, RRC_SUB_STATE_INACTIVE);
-
   LOG_D(RRC,"[UE %d] INIT State = RRC_IDLE (eNB %d)\n",ctxt.module_id,eNB_index);
   UE_rrc_inst[ctxt.module_id].Info[eNB_index].State=RRC_IDLE;
   UE_rrc_inst[ctxt.module_id].Info[eNB_index].T300_active = 0;
@@ -345,16 +332,13 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_
 #else
   UE_rrc_inst[ctxt.module_id].integrity_algorithm = SecurityAlgorithmConfig__integrityProtAlgorithm_reserved;
 #endif
-
   openair_rrc_ue_init_security(&ctxt);
   init_SI_UE(&ctxt,eNB_index);
   LOG_D(RRC,PROTOCOL_RRC_CTXT_FMT"  INIT: phy_sync_2_ch_ind\n",
         PROTOCOL_RRC_CTXT_ARGS(&ctxt));
-
 #ifndef NO_RRM
   send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ctxt.module_id,eNB_index,UE_rrc_inst[ctxt.module_id].Mac_id));
 #endif
-
 #ifdef NO_RRM //init ch SRB0, SRB1 & BDTCH
   openair_rrc_on_ue(&ctxt);
 #endif
@@ -367,18 +351,15 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_
 
   UE_rrc_inst[ue_mod_idP].num_active_cba_groups = 0;
 #endif
-
   return 0;
 }
 
 //-----------------------------------------------------------------------------
-void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
+void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index )
 {
-
   uint8_t i=0,rv[6];
 
   if(UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size ==0) {
-
     // Get RRCConnectionRequest, fill random for now
     // Generate random byte stream for contention resolution
     for (i=0; i<6; i++) {
@@ -395,9 +376,8 @@ void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t* const ctxt_pP,
     UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size =
       do_RRCConnectionRequest(
         ctxt_pP->module_id,
-        (uint8_t*)UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload,
+        (uint8_t *)UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload,
         rv);
-
     LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCConnectionRequest (bytes %d, eNB %d)\n",
           ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size, eNB_index);
 
@@ -408,7 +388,6 @@ void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t* const ctxt_pP,
     LOG_T(RRC,"\n");
     /*UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff;
     UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.payload_size =i; */
-
   }
 }
 
@@ -450,12 +429,11 @@ static const char const nas_attach_req_guti[] = {
 //-----------------------------------------------------------------------------
 void
 rrc_t310_expiration(
-  const protocol_ctxt_t* const ctxt_pP,
+  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;
@@ -467,7 +445,7 @@ rrc_t310_expiration(
 
     if (UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active == 1) {
       LOG_D (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);
+             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,
@@ -489,43 +467,38 @@ rrc_t310_expiration(
 }
 
 //-----------------------------------------------------------------------------
-static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id )
+static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id )
 {
-
   uint8_t    buffer[100];
   uint8_t    size;
-  const char * nas_msg;
+  const char *nas_msg;
   int   nas_msg_length;
-
 #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
-  nas_msg         = (char*) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data;
+  nas_msg         = (char *) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data;
   nas_msg_length  = UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length;
 #else
   nas_msg         = nas_attach_req_imsi;
   nas_msg_length  = sizeof(nas_attach_req_imsi);
 #endif
-
   size = do_RRCConnectionSetupComplete(ctxt_pP->module_id, buffer, Transaction_id, nas_msg_length, nas_msg);
-
   LOG_I(RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionSetupComplete (bytes%d, eNB %d)\n",
         ctxt_pP->module_id,ctxt_pP->frame, size, eNB_index);
   LOG_D(RLC,
         "[FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n",
         ctxt_pP->frame, ctxt_pP->module_id+NB_eNB_INST, size, eNB_index, rrc_mui, ctxt_pP->module_id+NB_eNB_INST, DCCH);
   rrc_data_req_ue (
-		ctxt_pP,
-		DCCH,
-		rrc_mui++,
-		SDU_CONFIRM_NO,
-		size,
-		buffer,
-		PDCP_TRANSMISSION_MODE_CONTROL);
+    ctxt_pP,
+    DCCH,
+    rrc_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
 //-----------------------------------------------------------------------------
-static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id )
+static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id )
 {
-
   uint8_t buffer[32], size;
   size = do_RRCConnectionReconfigurationComplete(ctxt_pP, buffer, Transaction_id);
   LOG_I(RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCConnectionReconfigurationComplete (bytes %d, eNB_index %d)\n",
@@ -540,46 +513,40 @@ static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol
         UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id),
         DCCH);
   rrc_data_req_ue (
-		ctxt_pP,
-		DCCH,
-		rrc_mui++,
-		SDU_CONFIRM_NO,
-		size,
-		buffer,
-		PDCP_TRANSMISSION_MODE_CONTROL);
+    ctxt_pP,
+    DCCH,
+    rrc_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
 
 //-----------------------------------------------------------------------------
 // Called by L2 interface (MAC)
-int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* const Srb_info, const uint8_t eNB_index )
+int rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *const Srb_info, const uint8_t eNB_index )
 {
-  DL_CCCH_Message_t* dl_ccch_msg=NULL;
+  DL_CCCH_Message_t *dl_ccch_msg=NULL;
   asn_dec_rval_t dec_rval;
   int rval=0;
-
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_IN);
   //  LOG_D(RRC,"[UE %d] Decoding DL-CCCH message (%d bytes), State %d\n",ue_mod_idP,Srb_info->Rx_buffer.payload_size,
   //  UE_rrc_inst[ue_mod_idP].Info[eNB_index].State);
-
   dec_rval = uper_decode(NULL,
                          &asn_DEF_DL_CCCH_Message,
-                         (void**)&dl_ccch_msg,
-                         (uint8_t*)Srb_info->Rx_buffer.Payload,
+                         (void **)&dl_ccch_msg,
+                         (uint8_t *)Srb_info->Rx_buffer.Payload,
                          100,0,0);
-
 #ifdef XER_PRINT
-  xer_fprint(stdout,&asn_DEF_DL_CCCH_Message,(void*)dl_ccch_msg);
+  xer_fprint(stdout,&asn_DEF_DL_CCCH_Message,(void *)dl_ccch_msg);
 #endif
-
 #if defined(ENABLE_ITTI)
 # if defined(DISABLE_ITTI_XER_PRINT)
   {
     MessageDef *msg_p;
-
     msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_CCCH_MESSAGE);
     memcpy (&msg_p->ittiMsg, (void *) dl_ccch_msg, sizeof(RrcDlCcchMessage));
-
     itti_send_msg_to_task (TASK_UNKNOWN, ctxt_pP->instance, msg_p);
   }
 # else
@@ -589,11 +556,9 @@ int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* co
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_CCCH_Message, (void *)dl_ccch_msg)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, 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);
     }
   }
@@ -607,74 +572,68 @@ int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* co
   }
 
   if (dl_ccch_msg->message.present == DL_CCCH_MessageType_PR_c1) {
-
     if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_SI_RECEIVED) {
-
       switch (dl_ccch_msg->message.choice.c1.present) {
+        case DL_CCCH_MessageType__c1_PR_NOTHING:
+          LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n",
+                ctxt_pP->module_id,
+                ctxt_pP->frame);
+          rval = 0;
+          break;
 
-      case DL_CCCH_MessageType__c1_PR_NOTHING:
-        LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n",
-              ctxt_pP->module_id,
-              ctxt_pP->frame);
-        rval = 0;
-        break;
-
-      case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment:
-        LOG_I(RRC,
-              "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n",
-              ctxt_pP->module_id,
-              ctxt_pP->frame);
-        rval = 0;
-        break;
-
-      case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject:
-        LOG_I(RRC,
-              "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n",
-              ctxt_pP->module_id,
-              ctxt_pP->frame);
-        rval = 0;
-        break;
-
-      case DL_CCCH_MessageType__c1_PR_rrcConnectionReject:
-        LOG_I(RRC,
-              "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n",
-              ctxt_pP->module_id,
-              ctxt_pP->frame);
-        rval = 0;
-        break;
-
-      case DL_CCCH_MessageType__c1_PR_rrcConnectionSetup:
-        LOG_I(RRC,
-              "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup RNTI %x\n",
-              ctxt_pP->module_id,
-              ctxt_pP->frame,
-              ctxt_pP->rnti);
-        // Get configuration
+        case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment:
+          LOG_I(RRC,
+                "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n",
+                ctxt_pP->module_id,
+                ctxt_pP->frame);
+          rval = 0;
+          break;
 
-        // Release T300 timer
-        UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T300_active = 0;
-        rrc_ue_process_radioResourceConfigDedicated(
-          ctxt_pP,
-          eNB_index,
-          &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated);
+        case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject:
+          LOG_I(RRC,
+                "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n",
+                ctxt_pP->module_id,
+                ctxt_pP->frame);
+          rval = 0;
+          break;
 
-        rrc_set_state (ctxt_pP->module_id, RRC_STATE_CONNECTED);
-        rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_CONNECTED);
-        UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].rnti = ctxt_pP->rnti;
-        rrc_ue_generate_RRCConnectionSetupComplete(
-          ctxt_pP,
-          eNB_index,
-          dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.rrc_TransactionIdentifier);
+        case DL_CCCH_MessageType__c1_PR_rrcConnectionReject:
+          LOG_I(RRC,
+                "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n",
+                ctxt_pP->module_id,
+                ctxt_pP->frame);
+          rval = 0;
+          break;
 
-        rval = 0;
-        break;
+        case DL_CCCH_MessageType__c1_PR_rrcConnectionSetup:
+          LOG_I(RRC,
+                "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup RNTI %x\n",
+                ctxt_pP->module_id,
+                ctxt_pP->frame,
+                ctxt_pP->rnti);
+          // Get configuration
+          // Release T300 timer
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T300_active = 0;
+          rrc_ue_process_radioResourceConfigDedicated(
+            ctxt_pP,
+            eNB_index,
+            &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated);
+          rrc_set_state (ctxt_pP->module_id, RRC_STATE_CONNECTED);
+          rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_CONNECTED);
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].rnti = ctxt_pP->rnti;
+          rrc_ue_generate_RRCConnectionSetupComplete(
+            ctxt_pP,
+            eNB_index,
+            dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.rrc_TransactionIdentifier);
+          rval = 0;
+          break;
 
-      default:
-        LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n",
-              ctxt_pP->module_id,
-              ctxt_pP->frame);
-        rval = -1;
-        break;
+        default:
+          LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n",
+                ctxt_pP->module_id,
+                ctxt_pP->frame);
+          rval = -1;
+          break;
       }
     }
   }
@@ -689,31 +648,22 @@ rrc_ue_establish_srb1(
   module_id_t ue_mod_idP,
   frame_t frameP,
   uint8_t eNB_index,
-  struct SRB_ToAddMod* SRB_config
+  struct SRB_ToAddMod *SRB_config
 )
 //-----------------------------------------------------------------------------
 {
   // add descriptor from RRC PDU
-
   uint8_t lchan_id = DCCH;
-
   UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Active = 1;
   UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG
   UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Srb_id = 1;
-
   // copy default configuration for now
   //  memcpy(&UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Lchan_desc[0],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE);
   //  memcpy(&UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Lchan_desc[1],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE);
-
-
   LOG_I(RRC,"[UE %d], CONFIG_SRB1 %d corresponding to eNB_index %d\n", ue_mod_idP,lchan_id,eNB_index);
-
   //rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, lchan_id,UNDEF_SECURITY_MODE);
   //  rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config);
-
   //  UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size=DEFAULT_MEAS_IND_SIZE+1;
-
-
   return(0);
 }
 
@@ -723,31 +673,22 @@ rrc_ue_establish_srb2(
   module_id_t ue_mod_idP,
   frame_t frameP,
   uint8_t eNB_index,
-  struct SRB_ToAddMod* SRB_config
+  struct SRB_ToAddMod *SRB_config
 )
 //-----------------------------------------------------------------------------
 {
   // add descriptor from RRC PDU
-
   uint8_t lchan_id = DCCH1;
-
   UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Active = 1;
   UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG
   UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Srb_info.Srb_id = 2;
-
   // copy default configuration for now
   //  memcpy(&UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Srb_info.Lchan_desc[0],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE);
   //  memcpy(&UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Srb_info.Lchan_desc[1],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE);
-
-
   LOG_I(RRC,"[UE %d], CONFIG_SRB2 %d corresponding to eNB_index %d\n",ue_mod_idP,lchan_id,eNB_index);
-
   //rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, lchan_id, UNDEF_SECURITY_MODE);
   //  rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config);
-
   //  UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size=DEFAULT_MEAS_IND_SIZE+1;
-
-
   return(0);
 }
 
@@ -757,7 +698,7 @@ rrc_ue_establish_drb(
   module_id_t ue_mod_idP,
   frame_t frameP,
   uint8_t eNB_index,
-  struct DRB_ToAddMod* DRB_config
+  struct DRB_ToAddMod *DRB_config
 )
 //-----------------------------------------------------------------------------
 {
@@ -769,7 +710,6 @@ rrc_ue_establish_drb(
   (void)ip_addr_offset3;
   (void)ip_addr_offset4;
 #endif
-
   LOG_I(RRC,"[UE %d] Frame %d: processing RRCConnectionReconfiguration: reconfiguring DRB %ld/LCID %d\n",
         ue_mod_idP, frameP, DRB_config->drb_Identity, (int)*DRB_config->logicalChannelIdentity);
   /*
@@ -795,7 +735,6 @@ rrc_ue_establish_drb(
           ue_mod_idP,
           ip_addr_offset3+ue_mod_idP,
           (long int)((eNB_index * maxDRB) + DRB_config->drb_Identity));
-
     rb_conf_ipv4(0,//add
                  ue_mod_idP,//cx align with the UE index
                  ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index
@@ -808,7 +747,6 @@ rrc_ue_establish_drb(
 
 #    endif
 #endif
-
   return(0);
 }
 
@@ -816,13 +754,12 @@ rrc_ue_establish_drb(
 //-----------------------------------------------------------------------------
 void
 rrc_ue_process_measConfig(
-  const protocol_ctxt_t* const       ctxt_pP,
+  const protocol_ctxt_t *const       ctxt_pP,
   const uint8_t                      eNB_index,
-  MeasConfig_t* const               measConfig
+  MeasConfig_t *const               measConfig
 )
 //-----------------------------------------------------------------------------
 {
-
   // This is the procedure described in 36.331 Section 5.5.2.1
   int i;
   long ind;
@@ -844,8 +781,8 @@ rrc_ue_process_measConfig(
 
       if (UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1]) {
         LOG_D(RRC,"Modifying measurement object %ld\n",ind);
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1],
-               (char*)measObj,
+        memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1],
+               (char *)measObj,
                sizeof(MeasObjectToAddMod_t));
       } else {
         LOG_I(RRC,"Adding measurement object %ld\n",ind);
@@ -862,39 +799,37 @@ rrc_ue_process_measConfig(
     }
 
     LOG_I(RRC,"call rrc_mac_config_req \n");
-
     rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
-			  (RadioResourceConfigCommonSIB_t *)NULL,
-			  (struct PhysicalConfigDedicated *)NULL,
+                          (RadioResourceConfigCommonSIB_t *)NULL,
+                          (struct PhysicalConfigDedicated *)NULL,
 #if defined(Rel10) || defined(Rel14)
-			  (SCellToAddMod_r10_t *)NULL,
-			  //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+                          (SCellToAddMod_r10_t *)NULL,
+                          //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-			  UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index],
-			  (MAC_MainConfig_t *)NULL,
-			  0,
-			  (struct LogicalChannelConfig *)NULL,
-			  (MeasGapConfig_t *)NULL,
-			  (TDD_Config_t *)NULL,
-			  (MobilityControlInfo_t *)NULL,
-			  NULL,
-			  NULL,
-			  NULL,
-			  NULL,
-			  NULL,
-			  NULL
+                          UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index],
+                          (MAC_MainConfig_t *)NULL,
+                          0,
+                          (struct LogicalChannelConfig *)NULL,
+                          (MeasGapConfig_t *)NULL,
+                          (TDD_Config_t *)NULL,
+                          (MobilityControlInfo_t *)NULL,
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL
 #if defined(Rel10) || defined(Rel14)
-			  ,0,
-			  (MBSFN_AreaInfoList_r9_t *)NULL,
-			  (PMCH_InfoList_r9_t *)NULL
-
+                          ,0,
+                          (MBSFN_AreaInfoList_r9_t *)NULL,
+                          (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-			  ,
-			  0,
-			  0
+                          ,
+                          0,
+                          0
 #endif
-			  );
+                         );
   }
 
   if (measConfig->reportConfigToRemoveList != NULL) {
@@ -912,8 +847,8 @@ rrc_ue_process_measConfig(
 
       if (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1]) {
         LOG_I(RRC,"Modifying Report Configuration %ld\n",ind-1);
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1],
-               (char*)measConfig->reportConfigToAddModList->list.array[i],
+        memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1],
+               (char *)measConfig->reportConfigToAddModList->list.array[i],
                sizeof(ReportConfigToAddMod_t));
       } else {
         LOG_D(RRC,"Adding Report Configuration %ld %p \n",ind-1,measConfig->reportConfigToAddModList->list.array[i]);
@@ -925,8 +860,8 @@ rrc_ue_process_measConfig(
   if (measConfig->quantityConfig != NULL) {
     if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]) {
       LOG_D(RRC,"Modifying Quantity Configuration \n");
-      memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index],
-             (char*)measConfig->quantityConfig,
+      memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index],
+             (char *)measConfig->quantityConfig,
              sizeof(QuantityConfig_t));
     } else {
       LOG_D(RRC,"Adding Quantity configuration\n");
@@ -947,8 +882,8 @@ rrc_ue_process_measConfig(
 
       if (UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1]) {
         LOG_D(RRC,"Modifying Measurement ID %ld\n",ind-1);
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1],
-               (char*)measConfig->measIdToAddModList->list.array[i],
+        memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1],
+               (char *)measConfig->measIdToAddModList->list.array[i],
                sizeof(MeasIdToAddMod_t));
       } else {
         LOG_D(RRC,"Adding Measurement ID %ld %p\n",ind-1,measConfig->measIdToAddModList->list.array[i]);
@@ -959,8 +894,8 @@ rrc_ue_process_measConfig(
 
   if (measConfig->measGapConfig !=NULL) {
     if (UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index]) {
-      memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
-             (char*)measConfig->measGapConfig,
+      memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
+             (char *)measConfig->measGapConfig,
              sizeof(MeasGapConfig_t));
     } else {
       UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index] = measConfig->measGapConfig;
@@ -970,8 +905,8 @@ rrc_ue_process_measConfig(
   if (measConfig->quantityConfig != NULL) {
     if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]) {
       LOG_I(RRC,"Modifying Quantity Configuration \n");
-      memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index],
-             (char*)measConfig->quantityConfig,
+      memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index],
+             (char *)measConfig->quantityConfig,
              sizeof(QuantityConfig_t));
     } else {
       LOG_I(RRC,"Adding Quantity configuration\n");
@@ -982,7 +917,6 @@ rrc_ue_process_measConfig(
         (*UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP)/4);
     UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrq = 1./pow(2,
         (*UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ)/4);
-
     LOG_I(RRC,"[UE %d] set rsrp-coeff for eNB %d: %ld rsrq-coeff: %ld rsrp_factor: %f rsrq_factor: %f \n",
           ctxt_pP->module_id, eNB_index, // UE_rrc_inst[ue_mod_idP].Info[eNB_index].UE_index,
           *UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP,
@@ -997,7 +931,7 @@ rrc_ue_process_measConfig(
 
   if (measConfig->speedStatePars != NULL) {
     if (UE_rrc_inst[ctxt_pP->module_id].speedStatePars) {
-      memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].speedStatePars,(char*)measConfig->speedStatePars,sizeof(struct MeasConfig__speedStatePars));
+      memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].speedStatePars,(char *)measConfig->speedStatePars,sizeof(struct MeasConfig__speedStatePars));
     } else {
       UE_rrc_inst[ctxt_pP->module_id].speedStatePars = measConfig->speedStatePars;
     }
@@ -1009,231 +943,223 @@ rrc_ue_process_measConfig(
 
 
 void
-rrc_ue_update_radioResourceConfigDedicated(RadioResourceConfigDedicated_t* radioResourceConfigDedicated,
-        const protocol_ctxt_t* const ctxt_pP,
-        uint8_t eNB_index)
+rrc_ue_update_radioResourceConfigDedicated(RadioResourceConfigDedicated_t *radioResourceConfigDedicated,
+    const protocol_ctxt_t *const ctxt_pP,
+    uint8_t eNB_index)
 {
-    PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL;
-
-    physicalConfigDedicated2 = CALLOC(1,sizeof(*physicalConfigDedicated2));
-    physicalConfigDedicated2->pdsch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated));
-    physicalConfigDedicated2->pusch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pusch_ConfigDedicated));
-    physicalConfigDedicated2->pucch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pucch_ConfigDedicated));
-    physicalConfigDedicated2->cqi_ReportConfig              = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
-    physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic
-                                                            = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic));
-    physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated));
-    physicalConfigDedicated2->schedulingRequestConfig       = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig));
-    physicalConfigDedicated2->antennaInfo                   = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo));
-
-    physicalConfigDedicated2->uplinkPowerControlDedicated   = CALLOC(1,sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated));
-    physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH));
-    physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH));
-
-    // Update pdsch_ConfigDedicated
-    if(radioResourceConfigDedicated->physicalConfigDedicated->pdsch_ConfigDedicated != NULL)
-    {
-        LOG_I(RRC,"Update pdsch_ConfigDedicated config \n");
-
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated = CALLOC(1,sizeof(PDSCH_ConfigDedicated_t));
-
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->pdsch_ConfigDedicated,
-                sizeof(physicalConfigDedicated2->pdsch_ConfigDedicated));
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for pdsch_ConfigDedicated\n");
-    }
-
-    // Update pusch_ConfigDedicated
-    if(radioResourceConfigDedicated->physicalConfigDedicated->pusch_ConfigDedicated != NULL)
-    {
-        LOG_I(RRC,"Update pusch_ConfigDedicated config \n");
-
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated = CALLOC(1,sizeof(PUSCH_ConfigDedicated_t));
-
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->pusch_ConfigDedicated,
-                sizeof(physicalConfigDedicated2->pusch_ConfigDedicated));
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for pusch_ConfigDedicated\n");
-    }
+  PhysicalConfigDedicated_t *physicalConfigDedicated2 = NULL;
+  physicalConfigDedicated2 = CALLOC(1,sizeof(*physicalConfigDedicated2));
+  physicalConfigDedicated2->pdsch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated));
+  physicalConfigDedicated2->pusch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pusch_ConfigDedicated));
+  physicalConfigDedicated2->pucch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pucch_ConfigDedicated));
+  physicalConfigDedicated2->cqi_ReportConfig              = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic
+    = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic));
+  physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated));
+  physicalConfigDedicated2->schedulingRequestConfig       = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig));
+  physicalConfigDedicated2->antennaInfo                   = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo));
+  physicalConfigDedicated2->uplinkPowerControlDedicated   = CALLOC(1,sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated));
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH));
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH));
+
+  // Update pdsch_ConfigDedicated
+  if(radioResourceConfigDedicated->physicalConfigDedicated->pdsch_ConfigDedicated != NULL)
+  {
+    LOG_I(RRC,"Update pdsch_ConfigDedicated config \n");
 
-    // Update pucch_ConfigDedicated
-    if(radioResourceConfigDedicated->physicalConfigDedicated->pucch_ConfigDedicated != NULL)
-    {
-        LOG_I(RRC,"Update pucch_ConfigDedicated config \n");
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated = CALLOC(1,sizeof(PUCCH_ConfigDedicated_t));
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated = CALLOC(1,sizeof(PDSCH_ConfigDedicated_t));
 
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->pucch_ConfigDedicated,
-                sizeof(physicalConfigDedicated2->pucch_ConfigDedicated));
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for pucch_ConfigDedicated\n");
-    }
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->pdsch_ConfigDedicated,
+           sizeof(physicalConfigDedicated2->pdsch_ConfigDedicated));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for pdsch_ConfigDedicated\n");
+  }
 
-    // Update cqi_ReportConfig
-    if(radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig != NULL)
-    {
-        LOG_I(RRC,"Update cqi_ReportConfig config (size=%zu,%zu)\n", sizeof(*physicalConfigDedicated2->cqi_ReportConfig), sizeof(CQI_ReportConfig_t));
+  // Update pusch_ConfigDedicated
+  if(radioResourceConfigDedicated->physicalConfigDedicated->pusch_ConfigDedicated != NULL)
+  {
+    LOG_I(RRC,"Update pusch_ConfigDedicated config \n");
 
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig = CALLOC(1,sizeof(CQI_ReportConfig_t));
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated = CALLOC(1,sizeof(PUSCH_ConfigDedicated_t));
 
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig,
-                sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->pusch_ConfigDedicated,
+           sizeof(physicalConfigDedicated2->pusch_ConfigDedicated));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for pusch_ConfigDedicated\n");
+  }
 
-        if (radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic != NULL) {
-          LOG_I(RRC,"Update cqi_ReportPeriodic config (size=%zu,%zu)\n", sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic), sizeof(CQI_ReportPeriodic_t));
+  // Update pucch_ConfigDedicated
+  if(radioResourceConfigDedicated->physicalConfigDedicated->pucch_ConfigDedicated != NULL)
+  {
+    LOG_I(RRC,"Update pucch_ConfigDedicated config \n");
 
-          if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig->cqi_ReportPeriodic == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig->cqi_ReportPeriodic = CALLOC(1,sizeof(CQI_ReportPeriodic_t));
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated = CALLOC(1,sizeof(PUCCH_ConfigDedicated_t));
 
-          memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig->cqi_ReportPeriodic,
-                  (char*)radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic,
-                  sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic));
-        }
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for cqi_ReportConfig\n");
-    }
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->pucch_ConfigDedicated,
+           sizeof(physicalConfigDedicated2->pucch_ConfigDedicated));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for pucch_ConfigDedicated\n");
+  }
 
-    // Update schedulingRequestConfig
-    if(radioResourceConfigDedicated->physicalConfigDedicated->schedulingRequestConfig != NULL)
-    {
-        LOG_I(RRC,"Update schedulingRequestConfig config \n");
+  // Update cqi_ReportConfig
+  if(radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig != NULL)
+  {
+    LOG_I(RRC,"Update cqi_ReportConfig config (size=%zu,%zu)\n", sizeof(*physicalConfigDedicated2->cqi_ReportConfig), sizeof(CQI_ReportConfig_t));
 
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig = CALLOC(1,sizeof(SchedulingRequestConfig_t));
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig = CALLOC(1,sizeof(CQI_ReportConfig_t));
 
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->schedulingRequestConfig,
-                sizeof(physicalConfigDedicated2->schedulingRequestConfig));
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for schedulingRequestConfig\n");
-    }
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig,
+           sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
 
-    // Update soundingRS_UL_ConfigDedicated
-    if(radioResourceConfigDedicated->physicalConfigDedicated->soundingRS_UL_ConfigDedicated != NULL)
-    {
-        LOG_I(RRC,"Update soundingRS_UL_ConfigDedicated config \n");
+    if (radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic != NULL) {
+      LOG_I(RRC,"Update cqi_ReportPeriodic config (size=%zu,%zu)\n", sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic), sizeof(CQI_ReportPeriodic_t));
 
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(SoundingRS_UL_ConfigDedicated_t));
+      if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig->cqi_ReportPeriodic == NULL)
+        UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig->cqi_ReportPeriodic = CALLOC(1,sizeof(CQI_ReportPeriodic_t));
 
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->soundingRS_UL_ConfigDedicated,
-                sizeof(physicalConfigDedicated2->soundingRS_UL_ConfigDedicated));
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for soundingRS_UL_ConfigDedicated\n");
+      memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig->cqi_ReportPeriodic,
+             (char *)radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic,
+             sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic));
     }
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for cqi_ReportConfig\n");
+  }
 
-    // Update antennaInfo
-    if(radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo != NULL)
-    {
-        LOG_I(RRC,"Update antennaInfo config \n");
-
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo = CALLOC(1,sizeof(struct PhysicalConfigDedicated__antennaInfo));
-
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo,
-                sizeof(physicalConfigDedicated2->antennaInfo));
+  // Update schedulingRequestConfig
+  if(radioResourceConfigDedicated->physicalConfigDedicated->schedulingRequestConfig != NULL)
+  {
+    LOG_I(RRC,"Update schedulingRequestConfig config \n");
 
-        UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.transmissionMode =
-        		radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode;
-        UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.codebookSubsetRestriction =
-        		radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.codebookSubsetRestriction;
-        UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection =
-        		radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection;
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig = CALLOC(1,sizeof(SchedulingRequestConfig_t));
 
-        LOG_I(PHY,"New Transmission Mode %ld \n",radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode);
-        LOG_I(PHY,"Configured Transmission Mode %ld \n",UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.transmissionMode);
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->schedulingRequestConfig,
+           sizeof(physicalConfigDedicated2->schedulingRequestConfig));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for schedulingRequestConfig\n");
+  }
 
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for antennaInfo\n");
-    }
+  // Update soundingRS_UL_ConfigDedicated
+  if(radioResourceConfigDedicated->physicalConfigDedicated->soundingRS_UL_ConfigDedicated != NULL)
+  {
+    LOG_I(RRC,"Update soundingRS_UL_ConfigDedicated config \n");
 
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(SoundingRS_UL_ConfigDedicated_t));
 
-    // Update uplinkPowerControlDedicated
-    if(radioResourceConfigDedicated->physicalConfigDedicated->uplinkPowerControlDedicated != NULL)
-    {
-        LOG_I(RRC,"Update uplinkPowerControlDedicated config \n");
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->soundingRS_UL_ConfigDedicated,
+           sizeof(physicalConfigDedicated2->soundingRS_UL_ConfigDedicated));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for soundingRS_UL_ConfigDedicated\n");
+  }
 
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated = CALLOC(1,sizeof(UplinkPowerControlDedicated_t));
+  // Update antennaInfo
+  if(radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo != NULL)
+  {
+    LOG_I(RRC,"Update antennaInfo config \n");
+
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo = CALLOC(1,sizeof(struct PhysicalConfigDedicated__antennaInfo));
+
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo,
+           sizeof(physicalConfigDedicated2->antennaInfo));
+    UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.transmissionMode =
+      radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode;
+    UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.codebookSubsetRestriction =
+      radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.codebookSubsetRestriction;
+    UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection =
+      radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection;
+    LOG_I(PHY,"New Transmission Mode %ld \n",radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode);
+    LOG_I(PHY,"Configured Transmission Mode %ld \n",UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo->choice.explicitValue.transmissionMode);
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for antennaInfo\n");
+  }
 
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->uplinkPowerControlDedicated,
-                sizeof(physicalConfigDedicated2->uplinkPowerControlDedicated));
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for uplinkPowerControlDedicated\n");
-    }
+  // Update uplinkPowerControlDedicated
+  if(radioResourceConfigDedicated->physicalConfigDedicated->uplinkPowerControlDedicated != NULL)
+  {
+    LOG_I(RRC,"Update uplinkPowerControlDedicated config \n");
 
-    // Update tpc_PDCCH_ConfigPUCCH
-    if(radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUCCH != NULL)
-    {
-        LOG_I(RRC,"Update tpc_PDCCH_ConfigPUCCH config \n");
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated = CALLOC(1,sizeof(UplinkPowerControlDedicated_t));
 
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(TPC_PDCCH_Config_t));
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->uplinkPowerControlDedicated,
+           sizeof(physicalConfigDedicated2->uplinkPowerControlDedicated));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for uplinkPowerControlDedicated\n");
+  }
 
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUCCH,
-                sizeof(physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH));
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for tpc_PDCCH_ConfigPUCCH\n");
-    }
+  // Update tpc_PDCCH_ConfigPUCCH
+  if(radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUCCH != NULL)
+  {
+    LOG_I(RRC,"Update tpc_PDCCH_ConfigPUCCH config \n");
 
-    // Update tpc_PDCCH_ConfigPUSCH
-    if(radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUSCH != NULL)
-    {
-        LOG_I(RRC,"Update tpc_PDCCH_ConfigPUSCH config \n");
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(TPC_PDCCH_Config_t));
 
-        if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH == NULL)
-            UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(TPC_PDCCH_Config_t));
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUCCH,
+           sizeof(physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for tpc_PDCCH_ConfigPUCCH\n");
+  }
 
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH,
-                (char*)radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUSCH,
-                sizeof(physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH));
+  // Update tpc_PDCCH_ConfigPUSCH
+  if(radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUSCH != NULL)
+  {
+    LOG_I(RRC,"Update tpc_PDCCH_ConfigPUSCH config \n");
 
-    }
-    else
-    {
-        LOG_I(RRC,"Keep old config for tpc_PDCCH_ConfigPUSCH\n");
-    }
+    if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH == NULL)
+      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(TPC_PDCCH_Config_t));
 
+    memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH,
+           (char *)radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUSCH,
+           sizeof(physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH));
+  }
+  else
+  {
+    LOG_I(RRC,"Keep old config for tpc_PDCCH_ConfigPUSCH\n");
+  }
 }
 //-----------------------------------------------------------------------------
 void
 rrc_ue_process_radioResourceConfigDedicated(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   uint8_t eNB_index,
-  RadioResourceConfigDedicated_t* radioResourceConfigDedicated
+  RadioResourceConfigDedicated_t *radioResourceConfigDedicated
 )
 //-----------------------------------------------------------------------------
 {
-
   long SRB_id,DRB_id;
   int i,cnt;
   LogicalChannelConfig_t *SRB1_logicalChannelConfig,*SRB2_logicalChannelConfig;
@@ -1248,9 +1174,9 @@ rrc_ue_process_radioResourceConfigDedicated(
 
     if (UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]) {
 #if 1
-        rrc_ue_update_radioResourceConfigDedicated(radioResourceConfigDedicated, ctxt_pP, eNB_index);
+      rrc_ue_update_radioResourceConfigDedicated(radioResourceConfigDedicated, ctxt_pP, eNB_index);
 #else
-      memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],(char*)radioResourceConfigDedicated->physicalConfigDedicated,
+      memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],(char *)radioResourceConfigDedicated->physicalConfigDedicated,
              sizeof(struct PhysicalConfigDedicated));
 #endif
     } else {
@@ -1263,7 +1189,7 @@ rrc_ue_process_radioResourceConfigDedicated(
   if (radioResourceConfigDedicated->mac_MainConfig) {
     if (radioResourceConfigDedicated->mac_MainConfig->present == RadioResourceConfigDedicated__mac_MainConfig_PR_explicitValue) {
       if (UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index]) {
-        memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],(char*)&radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue,
+        memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],(char *)&radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue,
                sizeof(MAC_MainConfig_t));
       } else {
         UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index] = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue;
@@ -1311,7 +1237,6 @@ rrc_ue_process_radioResourceConfigDedicated(
   if (radioResourceConfigDedicated->srb_ToAddModList) {
     uint8_t *kRRCenc = NULL;
     uint8_t *kRRCint = NULL;
-
 #if defined(ENABLE_SECURITY)
     derive_key_rrc_enc(UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm,
                        UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCenc);
@@ -1321,8 +1246,8 @@ rrc_ue_process_radioResourceConfigDedicated(
     // Refresh SRBs
     rrc_pdcp_config_asn1_req(ctxt_pP,
                              radioResourceConfigDedicated->srb_ToAddModList,
-                             (DRB_ToAddModList_t*)NULL,
-                             (DRB_ToReleaseList_t*)NULL,
+                             (DRB_ToAddModList_t *)NULL,
+                             (DRB_ToReleaseList_t *)NULL,
                              UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm |
                              (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4),
                              kRRCenc,
@@ -1332,17 +1257,15 @@ rrc_ue_process_radioResourceConfigDedicated(
                              ,(PMCH_InfoList_r9_t *)NULL
 #endif
                              ,NULL);
-
     // Refresh SRBs
     rrc_rlc_config_asn1_req(ctxt_pP,
                             radioResourceConfigDedicated->srb_ToAddModList,
-                            (DRB_ToAddModList_t*)NULL,
-                            (DRB_ToReleaseList_t*)NULL
+                            (DRB_ToAddModList_t *)NULL,
+                            (DRB_ToReleaseList_t *)NULL
 #if defined(Rel10) || defined(Rel14)
                             ,(PMCH_InfoList_r9_t *)NULL
 #endif
                            );
-
 #if ENABLE_RAL
     // first msg that includes srb config
     UE_rrc_inst[ctxt_pP->module_id].num_srb=radioResourceConfigDedicated->srb_ToAddModList->list.count;
@@ -1364,7 +1287,6 @@ rrc_ue_process_radioResourceConfigDedicated(
           if (UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig) {
             if (UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) {
               SRB1_logicalChannelConfig = &UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig->choice.explicitValue;
-
             } else {
               SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
             }
@@ -1374,39 +1296,38 @@ rrc_ue_process_radioResourceConfigDedicated(
 
           LOG_I(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ  (SRB1 eNB %d) --->][MAC_UE][MOD %02d][]\n",
                 ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id);
-
           rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
-				(RadioResourceConfigCommonSIB_t *)NULL,
-				UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
+                                (RadioResourceConfigCommonSIB_t *)NULL,
+                                UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
 #if defined(Rel10) || defined(Rel14)
-				(SCellToAddMod_r10_t *)NULL,
-				//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+                                (SCellToAddMod_r10_t *)NULL,
+                                //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-				(MeasObjectToAddMod_t **)NULL,
-				UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
-				1,
-				SRB1_logicalChannelConfig,
-				(MeasGapConfig_t *)NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL
+                                (MeasObjectToAddMod_t **)NULL,
+                                UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
+                                1,
+                                SRB1_logicalChannelConfig,
+                                (MeasGapConfig_t *)NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL
 #if defined(Rel10) || defined(Rel14)
-				,
-				0,
-				(MBSFN_AreaInfoList_r9_t *)NULL,
-				(PMCH_InfoList_r9_t *)NULL
+                                ,
+                                0,
+                                (MBSFN_AreaInfoList_r9_t *)NULL,
+                                (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-				,
-				0,
-				0
+                                ,
+                                0,
+                                0
 #endif
-				);
+                               );
         }
       } else {
         if (UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]) {
@@ -1434,38 +1355,37 @@ rrc_ue_process_radioResourceConfigDedicated(
                 eNB_index,
                 ctxt_pP->module_id);
           rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
-				(RadioResourceConfigCommonSIB_t *)NULL,
-				UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
+                                (RadioResourceConfigCommonSIB_t *)NULL,
+                                UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
 #if defined(Rel10) || defined(Rel14)
-				(SCellToAddMod_r10_t *)NULL,
-				//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+                                (SCellToAddMod_r10_t *)NULL,
+                                //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-				(MeasObjectToAddMod_t **)NULL,
-				UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
-				2,
-				SRB2_logicalChannelConfig,
-				UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
-				(TDD_Config_t *)NULL,
-				(MobilityControlInfo_t *)NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL,
-				NULL
+                                (MeasObjectToAddMod_t **)NULL,
+                                UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
+                                2,
+                                SRB2_logicalChannelConfig,
+                                UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
+                                (TDD_Config_t *)NULL,
+                                (MobilityControlInfo_t *)NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL
 #if defined(Rel10) || defined(Rel14)
-				,
-				0,
-				(MBSFN_AreaInfoList_r9_t *)NULL,
-				(PMCH_InfoList_r9_t *)NULL
-
+                                ,
+                                0,
+                                (MBSFN_AreaInfoList_r9_t *)NULL,
+                                (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-				,
-				0,
-				0
+                                ,
+                                0,
+                                0
 #endif
-				);
+                               );
         }
       }
     }
@@ -1473,22 +1393,19 @@ rrc_ue_process_radioResourceConfigDedicated(
 
   // Establish DRBs if present
   if (radioResourceConfigDedicated->drb_ToAddModList) {
-
     if ( (UE_rrc_inst[ctxt_pP->module_id].defaultDRB == NULL) &&
          (radioResourceConfigDedicated->drb_ToAddModList->list.count >= 1) ) {
-        // configure the first DRB ID as the default DRB ID
-        UE_rrc_inst[ctxt_pP->module_id].defaultDRB = malloc(sizeof(rb_id_t));
-        *UE_rrc_inst[ctxt_pP->module_id].defaultDRB = radioResourceConfigDedicated->drb_ToAddModList->list.array[0]->drb_Identity;
-        LOG_I(RRC,"[UE %d] default DRB = %d\n",ctxt_pP->module_id, *UE_rrc_inst[ctxt_pP->module_id].defaultDRB);
-      }
+      // configure the first DRB ID as the default DRB ID
+      UE_rrc_inst[ctxt_pP->module_id].defaultDRB = malloc(sizeof(rb_id_t));
+      *UE_rrc_inst[ctxt_pP->module_id].defaultDRB = radioResourceConfigDedicated->drb_ToAddModList->list.array[0]->drb_Identity;
+      LOG_I(RRC,"[UE %d] default DRB = %d\n",ctxt_pP->module_id, *UE_rrc_inst[ctxt_pP->module_id].defaultDRB);
+    }
 
     uint8_t *kUPenc = NULL;
-
 #if defined(ENABLE_SECURITY)
     derive_key_up_enc(UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm,
                       UE_rrc_inst[ctxt_pP->module_id].kenb, &kUPenc);
 #endif
-
     MSC_LOG_TX_MESSAGE(
       MSC_RRC_UE,
       MSC_PDCP_UE,
@@ -1499,12 +1416,11 @@ rrc_ue_process_radioResourceConfigDedicated(
       ctxt_pP->rnti,
       UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm |
       (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4));
-
     // Refresh DRBs
     rrc_pdcp_config_asn1_req(ctxt_pP,
-                             (SRB_ToAddModList_t*)NULL,
+                             (SRB_ToAddModList_t *)NULL,
                              radioResourceConfigDedicated->drb_ToAddModList,
-                             (DRB_ToReleaseList_t*)NULL,
+                             (DRB_ToReleaseList_t *)NULL,
                              UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm |
                              (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4),
                              NULL,
@@ -1514,12 +1430,11 @@ rrc_ue_process_radioResourceConfigDedicated(
                              ,(PMCH_InfoList_r9_t *)NULL
 #endif
                              , UE_rrc_inst[ctxt_pP->module_id].defaultDRB);
-
     // Refresh DRBs
     rrc_rlc_config_asn1_req(ctxt_pP,
-                            (SRB_ToAddModList_t*)NULL,
+                            (SRB_ToAddModList_t *)NULL,
                             radioResourceConfigDedicated->drb_ToAddModList,
-                            (DRB_ToReleaseList_t*)NULL
+                            (DRB_ToReleaseList_t *)NULL
 #if defined(Rel10) || defined(Rel14)
                             ,(PMCH_InfoList_r9_t *)NULL
 #endif
@@ -1542,42 +1457,41 @@ rrc_ue_process_radioResourceConfigDedicated(
               eNB_index,
               ctxt_pP->module_id);
         rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
-			      (RadioResourceConfigCommonSIB_t *)NULL,
-			      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
+                              (RadioResourceConfigCommonSIB_t *)NULL,
+                              UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
 #if defined(Rel10) || defined(Rel14)
-			      (SCellToAddMod_r10_t *)NULL,
-			      //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+                              (SCellToAddMod_r10_t *)NULL,
+                              //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-			      (MeasObjectToAddMod_t **)NULL,
-			      UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
-			      *UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity,
-			      UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelConfig,
-			      UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
-			      (TDD_Config_t*)NULL,
-			      (MobilityControlInfo_t *)NULL,
-			      NULL,
-			      NULL,
-			      NULL,
-			      NULL,
-			      NULL,
-			      NULL
+                              (MeasObjectToAddMod_t **)NULL,
+                              UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
+                              *UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity,
+                              UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelConfig,
+                              UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
+                              (TDD_Config_t *)NULL,
+                              (MobilityControlInfo_t *)NULL,
+                              NULL,
+                              NULL,
+                              NULL,
+                              NULL,
+                              NULL,
+                              NULL
 #if defined(Rel10) || defined(Rel14)
-			      ,
-			      0,
-			      (MBSFN_AreaInfoList_r9_t *)NULL,
-			      (PMCH_InfoList_r9_t *)NULL
+                              ,
+                              0,
+                              (MBSFN_AreaInfoList_r9_t *)NULL,
+                              (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-			      ,
-			      UE_rrc_inst[ue_mod_idP].num_active_cba_groups, //
-			      UE_rrc_inst[ue_mod_idP].cba_rnti[0]
+                              ,
+                              UE_rrc_inst[ue_mod_idP].num_active_cba_groups, //
+                              UE_rrc_inst[ue_mod_idP].cba_rnti[0]
 #endif
-			      );
-	
+                             );
       }
     }
   }
-  
+
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_CONNECTED;
   LOG_I(RRC,"[UE %d] State = RRC_CONNECTED (eNB %d)\n",ctxt_pP->module_id,eNB_index);
 }
@@ -1586,75 +1500,69 @@ rrc_ue_process_radioResourceConfigDedicated(
 //-----------------------------------------------------------------------------
 void
 rrc_ue_process_securityModeCommand(
-  const protocol_ctxt_t* const ctxt_pP,
-  SecurityModeCommand_t* const securityModeCommand,
+  const protocol_ctxt_t *const ctxt_pP,
+  SecurityModeCommand_t *const securityModeCommand,
   const uint8_t                eNB_index
 )
 //-----------------------------------------------------------------------------
 {
-
   asn_enc_rval_t enc_rval;
-
   UL_DCCH_Message_t ul_dcch_msg;
   // SecurityModeCommand_t SecurityModeCommand;
   uint8_t buffer[200];
   int i, securityMode;
-
   LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (eNB %d)\n",
         ctxt_pP->module_id,ctxt_pP->frame,eNB_index);
 
   switch (securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm) {
-  case CipheringAlgorithm_r12_eea0:
-    LOG_I(RRC,"[UE %d] Security algorithm is set to eea0\n",
-          ctxt_pP->module_id);
-    securityMode= CipheringAlgorithm_r12_eea0;
-    break;
-
-  case CipheringAlgorithm_r12_eea1:
-    LOG_I(RRC,"[UE %d] Security algorithm is set to eea1\n",ctxt_pP->module_id);
-    securityMode= CipheringAlgorithm_r12_eea1;
-    break;
-
-  case CipheringAlgorithm_r12_eea2:
-    LOG_I(RRC,"[UE %d] Security algorithm is set to eea2\n",
-          ctxt_pP->module_id);
-    securityMode = CipheringAlgorithm_r12_eea2;
-    break;
-
-  default:
-    LOG_I(RRC,"[UE %d] Security algorithm is set to none\n",ctxt_pP->module_id);
-    securityMode = CipheringAlgorithm_r12_spare1;
-    break;
+    case CipheringAlgorithm_r12_eea0:
+      LOG_I(RRC,"[UE %d] Security algorithm is set to eea0\n",
+            ctxt_pP->module_id);
+      securityMode= CipheringAlgorithm_r12_eea0;
+      break;
+
+    case CipheringAlgorithm_r12_eea1:
+      LOG_I(RRC,"[UE %d] Security algorithm is set to eea1\n",ctxt_pP->module_id);
+      securityMode= CipheringAlgorithm_r12_eea1;
+      break;
+
+    case CipheringAlgorithm_r12_eea2:
+      LOG_I(RRC,"[UE %d] Security algorithm is set to eea2\n",
+            ctxt_pP->module_id);
+      securityMode = CipheringAlgorithm_r12_eea2;
+      break;
+
+    default:
+      LOG_I(RRC,"[UE %d] Security algorithm is set to none\n",ctxt_pP->module_id);
+      securityMode = CipheringAlgorithm_r12_spare1;
+      break;
   }
 
   switch (securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm) {
-  case SecurityAlgorithmConfig__integrityProtAlgorithm_eia1:
-    LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia1\n",ctxt_pP->module_id);
-    securityMode |= 1 << 5;
-    break;
-
-  case SecurityAlgorithmConfig__integrityProtAlgorithm_eia2:
-    LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia2\n",ctxt_pP->module_id);
-    securityMode |= 1 << 6;
-    break;
-
-  default:
-    LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id);
-    securityMode |= 0x70 ;
-    break;
+    case SecurityAlgorithmConfig__integrityProtAlgorithm_eia1:
+      LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia1\n",ctxt_pP->module_id);
+      securityMode |= 1 << 5;
+      break;
+
+    case SecurityAlgorithmConfig__integrityProtAlgorithm_eia2:
+      LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia2\n",ctxt_pP->module_id);
+      securityMode |= 1 << 6;
+      break;
+
+    default:
+      LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id);
+      securityMode |= 0x70 ;
+      break;
   }
 
   LOG_D(RRC,"[UE %d] security mode is %x \n",ctxt_pP->module_id, securityMode);
-
   /* Store the parameters received */
   UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm =
     securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm;
   UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm =
     securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm;
-
   memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
   //memset((void *)&SecurityModeCommand,0,sizeof(SecurityModeCommand_t));
-
   ul_dcch_msg.message.present           = UL_DCCH_MessageType_PR_c1;
 
   if (securityMode >= NO_SECURITY_MODE) {
@@ -1663,7 +1571,6 @@ rrc_ue_process_securityModeCommand(
     ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeFailure;
   }
 
-
 #if defined(ENABLE_SECURITY)
   uint8_t *kRRCenc = NULL;
   uint8_t *kUPenc = NULL;
@@ -1671,47 +1578,44 @@ rrc_ue_process_securityModeCommand(
   pdcp_t *pdcp_p = NULL;
   hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
   hashtable_rc_t h_rc;
-
   key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti,
-      ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES);
-  h_rc = hashtable_get(pdcp_coll_p, key, (void**) &pdcp_p);
+                            ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES);
+  h_rc = hashtable_get(pdcp_coll_p, key, (void **) &pdcp_p);
 
   if (h_rc == HASH_TABLE_OK) {
     LOG_D(RRC, "PDCP_COLL_KEY_VALUE() returns valid key = %ld\n", key);
-
     LOG_D(RRC, "driving kRRCenc, kRRCint and kUPenc from KeNB="
-        "%02x%02x%02x%02x"
-        "%02x%02x%02x%02x"
-        "%02x%02x%02x%02x"
-        "%02x%02x%02x%02x"
-        "%02x%02x%02x%02x"
-        "%02x%02x%02x%02x"
-        "%02x%02x%02x%02x"
-        "%02x%02x%02x%02x\n",
-        UE_rrc_inst[ctxt_pP->module_id].kenb[0],  UE_rrc_inst[ctxt_pP->module_id].kenb[1],  UE_rrc_inst[ctxt_pP->module_id].kenb[2],  UE_rrc_inst[ctxt_pP->module_id].kenb[3],
-        UE_rrc_inst[ctxt_pP->module_id].kenb[4],  UE_rrc_inst[ctxt_pP->module_id].kenb[5],  UE_rrc_inst[ctxt_pP->module_id].kenb[6],  UE_rrc_inst[ctxt_pP->module_id].kenb[7],
-        UE_rrc_inst[ctxt_pP->module_id].kenb[8],  UE_rrc_inst[ctxt_pP->module_id].kenb[9],  UE_rrc_inst[ctxt_pP->module_id].kenb[10], UE_rrc_inst[ctxt_pP->module_id].kenb[11],
-        UE_rrc_inst[ctxt_pP->module_id].kenb[12], UE_rrc_inst[ctxt_pP->module_id].kenb[13], UE_rrc_inst[ctxt_pP->module_id].kenb[14], UE_rrc_inst[ctxt_pP->module_id].kenb[15],
-        UE_rrc_inst[ctxt_pP->module_id].kenb[16], UE_rrc_inst[ctxt_pP->module_id].kenb[17], UE_rrc_inst[ctxt_pP->module_id].kenb[18], UE_rrc_inst[ctxt_pP->module_id].kenb[19],
-        UE_rrc_inst[ctxt_pP->module_id].kenb[20], UE_rrc_inst[ctxt_pP->module_id].kenb[21], UE_rrc_inst[ctxt_pP->module_id].kenb[22], UE_rrc_inst[ctxt_pP->module_id].kenb[23],
-        UE_rrc_inst[ctxt_pP->module_id].kenb[24], UE_rrc_inst[ctxt_pP->module_id].kenb[25], UE_rrc_inst[ctxt_pP->module_id].kenb[26], UE_rrc_inst[ctxt_pP->module_id].kenb[27],
-        UE_rrc_inst[ctxt_pP->module_id].kenb[28], UE_rrc_inst[ctxt_pP->module_id].kenb[29], UE_rrc_inst[ctxt_pP->module_id].kenb[30], UE_rrc_inst[ctxt_pP->module_id].kenb[31]);
-
+          "%02x%02x%02x%02x"
+          "%02x%02x%02x%02x"
+          "%02x%02x%02x%02x"
+          "%02x%02x%02x%02x"
+          "%02x%02x%02x%02x"
+          "%02x%02x%02x%02x"
+          "%02x%02x%02x%02x"
+          "%02x%02x%02x%02x\n",
+          UE_rrc_inst[ctxt_pP->module_id].kenb[0],  UE_rrc_inst[ctxt_pP->module_id].kenb[1],  UE_rrc_inst[ctxt_pP->module_id].kenb[2],  UE_rrc_inst[ctxt_pP->module_id].kenb[3],
+          UE_rrc_inst[ctxt_pP->module_id].kenb[4],  UE_rrc_inst[ctxt_pP->module_id].kenb[5],  UE_rrc_inst[ctxt_pP->module_id].kenb[6],  UE_rrc_inst[ctxt_pP->module_id].kenb[7],
+          UE_rrc_inst[ctxt_pP->module_id].kenb[8],  UE_rrc_inst[ctxt_pP->module_id].kenb[9],  UE_rrc_inst[ctxt_pP->module_id].kenb[10], UE_rrc_inst[ctxt_pP->module_id].kenb[11],
+          UE_rrc_inst[ctxt_pP->module_id].kenb[12], UE_rrc_inst[ctxt_pP->module_id].kenb[13], UE_rrc_inst[ctxt_pP->module_id].kenb[14], UE_rrc_inst[ctxt_pP->module_id].kenb[15],
+          UE_rrc_inst[ctxt_pP->module_id].kenb[16], UE_rrc_inst[ctxt_pP->module_id].kenb[17], UE_rrc_inst[ctxt_pP->module_id].kenb[18], UE_rrc_inst[ctxt_pP->module_id].kenb[19],
+          UE_rrc_inst[ctxt_pP->module_id].kenb[20], UE_rrc_inst[ctxt_pP->module_id].kenb[21], UE_rrc_inst[ctxt_pP->module_id].kenb[22], UE_rrc_inst[ctxt_pP->module_id].kenb[23],
+          UE_rrc_inst[ctxt_pP->module_id].kenb[24], UE_rrc_inst[ctxt_pP->module_id].kenb[25], UE_rrc_inst[ctxt_pP->module_id].kenb[26], UE_rrc_inst[ctxt_pP->module_id].kenb[27],
+          UE_rrc_inst[ctxt_pP->module_id].kenb[28], UE_rrc_inst[ctxt_pP->module_id].kenb[29], UE_rrc_inst[ctxt_pP->module_id].kenb[30], UE_rrc_inst[ctxt_pP->module_id].kenb[31]);
     derive_key_rrc_enc(UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm,
-        UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCenc);
+                       UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCenc);
     derive_key_rrc_int(UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm,
-        UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCint);
+                       UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCint);
     derive_key_up_enc(UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm,
-        UE_rrc_inst[ctxt_pP->module_id].kenb, &kUPenc);
+                      UE_rrc_inst[ctxt_pP->module_id].kenb, &kUPenc);
 
     if (securityMode != 0xff) {
       pdcp_config_set_security(ctxt_pP, pdcp_p, 0, 0,
-          UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm
-              | (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4),
-          kRRCenc, kRRCint, kUPenc);
+                               UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm
+                               | (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4),
+                               kRRCenc, kRRCint, kUPenc);
     } else {
       LOG_W(RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x",
-          securityMode);
+            securityMode);
     }
   } else {
     LOG_W(RRC, "Could not get PDCP instance where key=0x%ld\n", key);
@@ -1722,173 +1626,145 @@ rrc_ue_process_securityModeCommand(
   if (securityModeCommand->criticalExtensions.present == SecurityModeCommand__criticalExtensions_PR_c1) {
     if (securityModeCommand->criticalExtensions.choice.c1.present != SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8)
       LOG_W(RRC,"securityModeCommand->criticalExtensions.choice.c1.present (%d) != SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8\n",
-	    securityModeCommand->criticalExtensions.choice.c1.present);
-    
-    
+            securityModeCommand->criticalExtensions.choice.c1.present);
+
     ul_dcch_msg.message.choice.c1.choice.securityModeComplete.rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier;
     ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1;
     ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.choice.securityModeComplete_r8.nonCriticalExtension =NULL;
-    
     LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d)\n",
-	  ctxt_pP->module_id,ctxt_pP->frame,eNB_index);
-    
+          ctxt_pP->module_id,ctxt_pP->frame,eNB_index);
     enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message,
-				     (void*)&ul_dcch_msg,
-				     buffer,
-				     100);
+                                     NULL,
+                                     (void *)&ul_dcch_msg,
+                                     buffer,
+                                     100);
     AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n",
-		 enc_rval.failed_type->name, enc_rval.encoded);
-    
+                 enc_rval.failed_type->name, enc_rval.encoded);
 #ifdef XER_PRINT
-    xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg);
+    xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)&ul_dcch_msg);
 #endif
-    
 #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_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
-	MessageDef *msg_p;
-	
-	msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
-	msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
-	memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size);
-	
-	itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
+        MessageDef *msg_p;
+        msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
+        msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
+        memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size);
+        itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
       }
     }
 # endif
 #endif
+    LOG_D(RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8);
 
-      LOG_D(RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8);
-
-      for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) {
-        LOG_T(RRC, "%02x.", buffer[i]);
-      }
-
-      LOG_T(RRC, "\n");
-      rrc_data_req (
-		    ctxt_pP,
-		    DCCH,
-		    rrc_mui++,
-		    SDU_CONFIRM_NO,
-		    (enc_rval.encoded + 7) / 8,
-		    buffer,
-		    PDCP_TRANSMISSION_MODE_CONTROL);
+    for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) {
+      LOG_T(RRC, "%02x.", buffer[i]);
     }
-    
+
+    LOG_T(RRC, "\n");
+    rrc_data_req (
+      ctxt_pP,
+      DCCH,
+      rrc_mui++,
+      SDU_CONFIRM_NO,
+      (enc_rval.encoded + 7) / 8,
+      buffer,
+      PDCP_TRANSMISSION_MODE_CONTROL);
+  }
   else LOG_W(RRC,"securityModeCommand->criticalExtensions.present (%d) != SecurityModeCommand__criticalExtensions_PR_c1\n",
-	     securityModeCommand->criticalExtensions.present);
+               securityModeCommand->criticalExtensions.present);
 }
 
 //-----------------------------------------------------------------------------
 void
 rrc_ue_process_ueCapabilityEnquiry(
-  const protocol_ctxt_t* const ctxt_pP,
-  UECapabilityEnquiry_t* UECapabilityEnquiry,
+  const protocol_ctxt_t *const ctxt_pP,
+  UECapabilityEnquiry_t *UECapabilityEnquiry,
   uint8_t eNB_index
 )
 //-----------------------------------------------------------------------------
 {
-
   asn_enc_rval_t enc_rval;
-
   UL_DCCH_Message_t ul_dcch_msg;
-
-
   UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container;
-
   uint8_t buffer[200];
   int i;
-
   LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing UECapabilityEnquiry (eNB %d)\n",
         ctxt_pP->module_id,
         ctxt_pP->frame,
         eNB_index);
-
-
   memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
   memset((void *)&ue_CapabilityRAT_Container,0,sizeof(UE_CapabilityRAT_Container_t));
-
   ul_dcch_msg.message.present           = UL_DCCH_MessageType_PR_c1;
   ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_ueCapabilityInformation;
   ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.rrc_TransactionIdentifier = UECapabilityEnquiry->rrc_TransactionIdentifier;
-
   ue_CapabilityRAT_Container.rat_Type = RAT_Type_eutra;
   OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ueCapabilityRAT_Container,
-                       (const char*)UE_rrc_inst[ctxt_pP->module_id].UECapability,
+                       (const char *)UE_rrc_inst[ctxt_pP->module_id].UECapability,
                        UE_rrc_inst[ctxt_pP->module_id].UECapability_size);
   //  ue_CapabilityRAT_Container.ueCapabilityRAT_Container.buf  = UE_rrc_inst[ue_mod_idP].UECapability;
   // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.size = UE_rrc_inst[ue_mod_idP].UECapability_size;
-
-
   AssertFatal(UECapabilityEnquiry->criticalExtensions.present == UECapabilityEnquiry__criticalExtensions_PR_c1,
-	      "UECapabilityEnquiry->criticalExtensions.present (%d) != UECapabilityEnquiry__criticalExtensions_PR_c1 (%d)\n",
-	      UECapabilityEnquiry->criticalExtensions.present,UECapabilityEnquiry__criticalExtensions_PR_c1);
+              "UECapabilityEnquiry->criticalExtensions.present (%d) != UECapabilityEnquiry__criticalExtensions_PR_c1 (%d)\n",
+              UECapabilityEnquiry->criticalExtensions.present,UECapabilityEnquiry__criticalExtensions_PR_c1);
 
   if (UECapabilityEnquiry->criticalExtensions.choice.c1.present != UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8)
     LOG_W(RRC,"UECapabilityEnquiry->criticalExtensions.choice.c1.present (%d) != UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8)\n",
-	  UECapabilityEnquiry->criticalExtensions.choice.c1.present);
-  
+          UECapabilityEnquiry->criticalExtensions.choice.c1.present);
+
   ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.present           = UECapabilityInformation__criticalExtensions_PR_c1;
   ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.present =
     UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8;
   ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count
     =0;
-  
+
   for (i=0; i<UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count; i++) {
-    
     if (*UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.array[i]
-	== RAT_Type_eutra) {
+        == RAT_Type_eutra) {
       ASN_SEQUENCE_ADD(
-		       &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list,
-		       &ue_CapabilityRAT_Container);
-      
-      enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, (void*) &ul_dcch_msg, buffer, 100);
+        &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list,
+        &ue_CapabilityRAT_Container);
+      enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, 100);
       AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n",
-		   enc_rval.failed_type->name, enc_rval.encoded);
-      
+                   enc_rval.failed_type->name, enc_rval.encoded);
 #ifdef XER_PRINT
-      xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg);
+      xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)&ul_dcch_msg);
 #endif
-      
 #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_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
-	  MessageDef *msg_p;
-	  
-	  msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
-	  msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
-	  memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size);
-	  
-	  itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
-	}
+        char        message_string[20000];
+        size_t      message_string_size;
+
+        if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
+          MessageDef *msg_p;
+          msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
+          msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
+          memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size);
+          itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
+        }
       }
 # endif
 #endif
-	
+      LOG_D(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
 
-          LOG_D(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+      for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) {
+        LOG_T(RRC, "%02x.", buffer[i]);
+      }
 
-          for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) {
-            LOG_T(RRC, "%02x.", buffer[i]);
-          }
-      
       LOG_T(RRC, "\n");
       rrc_data_req_ue (
-		    ctxt_pP,
-		    DCCH,
-		    rrc_mui++,
-		    SDU_CONFIRM_NO,
-		    (enc_rval.encoded + 7) / 8,
-		    buffer,
-		    PDCP_TRANSMISSION_MODE_CONTROL);
+        ctxt_pP,
+        DCCH,
+        rrc_mui++,
+        SDU_CONFIRM_NO,
+        (enc_rval.encoded + 7) / 8,
+        buffer,
+        PDCP_TRANSMISSION_MODE_CONTROL);
     }
   }
 }
@@ -1897,20 +1773,19 @@ rrc_ue_process_ueCapabilityEnquiry(
 //-----------------------------------------------------------------------------
 void
 rrc_ue_process_rrcConnectionReconfiguration(
-  const protocol_ctxt_t* const       ctxt_pP,
+  const protocol_ctxt_t *const       ctxt_pP,
   RRCConnectionReconfiguration_t *rrcConnectionReconfiguration,
   uint8_t eNB_index
 )
 //-----------------------------------------------------------------------------
 {
-
   LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCConnectionReconfiguration (eNB %d)\n",
         ctxt_pP->module_id,ctxt_pP->frame,eNB_index);
 
   if (rrcConnectionReconfiguration->criticalExtensions.present == RRCConnectionReconfiguration__criticalExtensions_PR_c1) {
     if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present ==
         RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) {
-      RRCConnectionReconfiguration_r8_IEs_t* rrcConnectionReconfiguration_r8 =
+      RRCConnectionReconfiguration_r8_IEs_t *rrcConnectionReconfiguration_r8 =
         &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8;
 
       if (rrcConnectionReconfiguration_r8->mobilityControlInfo) {
@@ -1932,6 +1807,62 @@ rrc_ue_process_rrcConnectionReconfiguration(
         LOG_I(RRC,"Radio Resource Configuration is present\n");
         rrc_ue_process_radioResourceConfigDedicated(ctxt_pP,eNB_index, rrcConnectionReconfiguration_r8->radioResourceConfigDedicated);
       }
+      
+      
+/*      void *non_criticical_ext_iterator = rrcConnectionReconfiguration_r8;
+      RCCConnectionReconfiguration_v1510_IEs_t *rrc_connection_reconfiguration_v1510_IEs = (RRCConnectionReconfiguration_v1510_IEs_t *)0;
+      // fetch EN-DC for NR_RRC here
+      // r8
+      if( ((RRCConnectionReconfiguration_r8_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v890_IEs_t *)0){
+        non_criticical_ext_iterator = ((RRCConnectionReconfiguration_r8_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+      // v89
+      if( ((RRCConnectionReconfiguration_v890_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v920_IEs_t *)0){
+        non_criticical_ext_iterator = ((RRCConnectionReconfiguration_v890_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+      // v92
+      if( ((RRCConnectionReconfiguration_v920_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v1020_IEs_t *)0){
+        non_criticical_ext_iterator = ((RRCConnectionReconfiguration_v920_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+      // v1020
+      if( ((RRCConnectionReconfiguration_v1020_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v1130_IEs_t *)0){
+        non_criticical_ext_iterator = ((RRCConnectionReconfiguration_v1020_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+      // v1130
+      if( ((RRCConnectionReconfiguration_v1130_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v1250_IEs_t *)0){
+        non_criticical_ext_iterator = ((RRCConnectionReconfiguration_v1130_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+      // v1250
+      if( ((RRCConnectionReconfiguration_v1250_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v1310_IEs_t *)0){
+        non_criticical_ext_iterator = ((RRCConnectionReconfiguration_v1250_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+      // v1310
+      if( ((RRCConnectionReconfiguration_v1310_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v1430_IEs_t *)0){
+        non_criticical_ext_iterator = ((RRCConnectionReconfiguration_v1310_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+      // v1430
+      if( ((RRCConnectionReconfiguration_v1430_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension != (RRCConnectionReconfiguration_v1510_IEs_t *)0){
+        rrc_connection_reconfiguration_v1510_IEs = ((RRCConnectionReconfiguration_v1430_IEs_t *)non_criticical_ext_iterator)->nonCriticalExtension;
+      }
+
+      if( rrc_connection_reconfiguration_v1510_IEs != (RRCConnectionReconfiguration_v1510_IEs_t *)0){ //  make sure v1510 is presented.
+        if(rrc_connection_reconfiguration_v1510_IEs->nr_Config_r15 != (struct nr_Config_r15 *)0){
+          switch(rrc_connection_reconfiguration_v1510_IEs->nr_Config_r15.present){
+            case nr_Config_r15_PR_setup:
+              //  process NR sCell config
+              if(rrc_connection_reconfiguration_v1510_IEs->nr_Config_r15.choice.setup->nr_SecondaryCellGroupConfig_r15 != (OCTET_STRING_t *)0){
+                nr_rrc_ue_decode_rrcReconfiguration(  rrc_connection_reconfiguration_v1510_IEs->nr_Config_r15.choice.setup->nr_SecondaryCellGroupConfig_r15->buffer, 
+                                                      rrc_connection_reconfiguration_v1510_IEs->nr_Config_r15.choice.setup->nr_SecondaryCellGroupConfig_r15.size); 
+              }
+             
+              break;
+            case nr_Config_r15_PR_release:
+            case nr_Config_r15_PR_NOTHING:
+            default:
+              break;
+          }
+        }
+      }*/
 
 #if defined(ENABLE_ITTI)
 
@@ -1945,12 +1876,10 @@ rrc_ue_process_rrcConnectionReconfiguration(
         for (list_count = 0; list_count < rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.count; list_count++) {
           pdu_length = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->size;
           pdu_buffer = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->buf;
-
           msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_ESTABLI_CNF);
           NAS_CONN_ESTABLI_CNF(msg_p).errCode = AS_SUCCESS;
           NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length = pdu_length;
           NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer;
-
           itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
         }
 
@@ -1962,7 +1891,6 @@ rrc_ue_process_rrcConnectionReconfiguration(
         MessageDef                                 *message_ral_p = NULL;
         rrc_ral_connection_reestablishment_ind_t    connection_reestablishment_ind;
         int                                         i;
-
         message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_REESTABLISHMENT_IND);
         memset(&connection_reestablishment_ind, 0, sizeof(rrc_ral_connection_reestablishment_ind_t));
         // TO DO ral_si_ind.plmn_id        = 0;
@@ -1987,7 +1915,6 @@ rrc_ue_process_rrcConnectionReconfiguration(
           connection_reestablishment_ind.num_srb      =
             rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count +
             UE_rrc_inst[ctxt_pP->module_id].num_srb;
-
         } else {
           connection_reestablishment_ind.num_srb      += UE_rrc_inst[ctxt_pP->module_id].num_srb;
         }
@@ -2011,9 +1938,9 @@ rrc_ue_process_rrcConnectionReconfiguration(
 //-----------------------------------------------------------------------------
 void
 rrc_ue_process_mobilityControlInfo(
-  const protocol_ctxt_t* const       ctxt_pP,
+  const protocol_ctxt_t *const       ctxt_pP,
   const uint8_t                      eNB_index,
-  struct MobilityControlInfo* const mobilityControlInfo
+  struct MobilityControlInfo *const mobilityControlInfo
 )
 //-----------------------------------------------------------------------------
 {
@@ -2029,7 +1956,6 @@ rrc_ue_process_mobilityControlInfo(
 
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T304_active = 1;
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T304_cnt = T304[mobilityControlInfo->t304];
-
   /*
   drb2release_list = CALLOC (1, sizeof (*drb2release_list));
   lcid= CALLOC (1, sizeof (DRB_Identity_t)); // long
@@ -2055,22 +1981,20 @@ rrc_ue_process_mobilityControlInfo(
          NULL, // key rrc encryption
          NULL, // key rrc integrity
          NULL // key encryption
-#if defined(Rel10) || defined(Rel14)
+  #if defined(Rel10) || defined(Rel14)
          ,NULL
-#endif
+  #endif
          ,NULL);
 
   rrc_rlc_config_asn1_req(NB_eNB_INST+ue_mod_idP, frameP,0,eNB_index,
         NULL,// SRB_ToAddModList
         NULL,// DRB_ToAddModList
         drb2release_list // DRB_ToReleaseList
-#if defined(Rel10) || defined(Rel14)
+  #if defined(Rel10) || defined(Rel14)
         ,NULL
-#endif
+  #endif
         ,NULL);
    */
-
-
   //A little cleanup at RRC...
   //Copying current queue config to free RRC index
   /*
@@ -2092,47 +2016,43 @@ rrc_ue_process_mobilityControlInfo(
   LOG_I(RRC,
         "HO: Reset PDCP and RLC for configured RBs.. \n[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ  (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n",
         ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id);
-
   // Reset MAC and configure PHY
   rrc_mac_config_req_ue(ctxt_pP->module_id,
-			0,
-			eNB_index,
-			(RadioResourceConfigCommonSIB_t *)NULL,
-			(struct PhysicalConfigDedicated *)NULL,
+                        0,
+                        eNB_index,
+                        (RadioResourceConfigCommonSIB_t *)NULL,
+                        (struct PhysicalConfigDedicated *)NULL,
 #if defined(Rel10) || defined(Rel14)
-			(SCellToAddMod_r10_t *)NULL,
-			//(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+                        (SCellToAddMod_r10_t *)NULL,
+                        //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-			(MeasObjectToAddMod_t **)NULL,
-			(MAC_MainConfig_t *)NULL,
-			0,
-			(struct LogicalChannelConfig *)NULL,
-			(MeasGapConfig_t *)NULL,
-			(TDD_Config_t *)NULL,
-			mobilityControlInfo,
-			(uint8_t *)NULL,
-			(uint16_t *)NULL,
-			NULL,
-			NULL,
-			NULL,
-			NULL
+                        (MeasObjectToAddMod_t **)NULL,
+                        (MAC_MainConfig_t *)NULL,
+                        0,
+                        (struct LogicalChannelConfig *)NULL,
+                        (MeasGapConfig_t *)NULL,
+                        (TDD_Config_t *)NULL,
+                        mobilityControlInfo,
+                        (uint8_t *)NULL,
+                        (uint16_t *)NULL,
+                        NULL,
+                        NULL,
+                        NULL,
+                        NULL
 #if defined(Rel10) || defined(Rel14)
-			,0,
-			(MBSFN_AreaInfoList_r9_t *)NULL,
-			(PMCH_InfoList_r9_t *)NULL
+                        ,0,
+                        (MBSFN_AreaInfoList_r9_t *)NULL,
+                        (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-			,0,
-			0
+                        ,0,
+                        0
 #endif
-			);
-  
+                       );
   // Re-establish PDCP for all RBs that are established
   // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH);
   // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH1);
   // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DTCH);
-
-
   // Re-establish RLC for all RBs that are established
   // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH,SIGNALLING_RADIO_BEARER,Rlc_info_am_config);
   // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config);
@@ -2154,14 +2074,13 @@ rrc_detach_from_eNB(
 //-----------------------------------------------------------------------------
 void
 rrc_ue_decode_dcch(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const rb_id_t                Srb_id,
-  const uint8_t*         const Buffer,
+  const uint8_t         *const Buffer,
   const uint8_t                eNB_indexP
 )
 //-----------------------------------------------------------------------------
 {
-
   //DL_DCCH_Message_t dldcchmsg;
   DL_DCCH_Message_t *dl_dcch_msg=NULL;//&dldcchmsg;
   //  asn_dec_rval_t dec_rval;
@@ -2178,7 +2097,6 @@ rrc_ue_decode_dcch(
   }
 
   //memset(dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
-
   // decode messages
   //  LOG_D(RRC,"[UE %d] Decoding DL-DCCH message\n",ue_mod_idP);
   /*
@@ -2188,20 +2106,17 @@ rrc_ue_decode_dcch(
    */
   uper_decode(NULL,
               &asn_DEF_DL_DCCH_Message,
-              (void**)&dl_dcch_msg,
-              (uint8_t*)Buffer,
+              (void **)&dl_dcch_msg,
+              (uint8_t *)Buffer,
               RRC_BUF_SIZE,0,0);
-
 #ifdef XER_PRINT
-  xer_fprint(stdout,&asn_DEF_DL_DCCH_Message,(void*)dl_dcch_msg);
+  xer_fprint(stdout,&asn_DEF_DL_DCCH_Message,(void *)dl_dcch_msg);
 #endif
-
 #if defined(ENABLE_ITTI)
 # if defined(DISABLE_ITTI_XER_PRINT)
   {
     msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_DCCH_MESSAGE);
     memcpy (&msg_p->ittiMsg, (void *) dl_dcch_msg, sizeof(RrcDlDcchMessage));
-
     itti_send_msg_to_task (TASK_UNKNOWN, ctxt_pP->instance, msg_p);
   }
 # else
@@ -2213,7 +2128,6 @@ rrc_ue_decode_dcch(
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, 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);
     }
   }
@@ -2221,276 +2135,266 @@ rrc_ue_decode_dcch(
 #endif
 
   if (dl_dcch_msg->message.present == DL_DCCH_MessageType_PR_c1) {
-
     if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State >= RRC_CONNECTED) {
-
       switch (dl_dcch_msg->message.choice.c1.present) {
+        case DL_DCCH_MessageType__c1_PR_NOTHING:
+          LOG_I(RRC, "[UE %d] Frame %d : Received PR_NOTHING on DL-DCCH-Message\n",
+                ctxt_pP->module_id, ctxt_pP->frame);
+          return;
 
-      case DL_DCCH_MessageType__c1_PR_NOTHING:
-        LOG_I(RRC, "[UE %d] Frame %d : Received PR_NOTHING on DL-DCCH-Message\n",
-              ctxt_pP->module_id, ctxt_pP->frame);
-        return;
-
-      case DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000:
-        break;
+        case DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000:
+          break;
 
-      case DL_DCCH_MessageType__c1_PR_dlInformationTransfer: {
+        case DL_DCCH_MessageType__c1_PR_dlInformationTransfer: {
 #if defined(ENABLE_ITTI)
-        DLInformationTransfer_t *dlInformationTransfer = &dl_dcch_msg->message.choice.c1.choice.dlInformationTransfer;
-
-        if ((dlInformationTransfer->criticalExtensions.present == DLInformationTransfer__criticalExtensions_PR_c1)
-            && (dlInformationTransfer->criticalExtensions.choice.c1.present
-                == DLInformationTransfer__criticalExtensions__c1_PR_dlInformationTransfer_r8)
-            && (dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.present
-                == DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) {
-          /* This message hold a dedicated info NAS payload, forward it to NAS */
-          struct DLInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType =
+          DLInformationTransfer_t *dlInformationTransfer = &dl_dcch_msg->message.choice.c1.choice.dlInformationTransfer;
+
+          if ((dlInformationTransfer->criticalExtensions.present == DLInformationTransfer__criticalExtensions_PR_c1)
+              && (dlInformationTransfer->criticalExtensions.choice.c1.present
+                  == DLInformationTransfer__criticalExtensions__c1_PR_dlInformationTransfer_r8)
+              && (dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.present
+                  == DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) {
+            /* This message hold a dedicated info NAS payload, forward it to NAS */
+            struct DLInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType =
                 &dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType;
-          uint32_t pdu_length;
-          uint8_t *pdu_buffer;
-          MessageDef *msg_p;
-
-          pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size;
-          pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf;
-
-          msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_DOWNLINK_DATA_IND);
-          NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ?
-          NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = pdu_length;
-          NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = pdu_buffer;
-
-          itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
-        }
+            uint32_t pdu_length;
+            uint8_t *pdu_buffer;
+            MessageDef *msg_p;
+            pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size;
+            pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf;
+            msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_DOWNLINK_DATA_IND);
+            NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ?
+            NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = pdu_length;
+            NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = pdu_buffer;
+            itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
+          }
 
 #endif
-        break;
-      }
-
-      case DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest:
-        break;
+          break;
+        }
 
-      case DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand:
-        break;
+        case DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest:
+          break;
 
-      case DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration:
+        case DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand:
+          break;
 
-        // first check if mobilityControlInfo  is present
-        if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo
-            != NULL) {
-          /* 36.331, 5.3.5.4 Reception of an RRCConnectionReconfiguration including the mobilityControlInfo by the UE (handover)*/
-          if (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId
-              != dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId) {
-            LOG_W(RRC,
-                  "[UE %d] Frame %d: Handover target (%ld) is different from RSRP measured target (%ld)..\n",
-                  ctxt_pP->module_id,
-                  ctxt_pP->frame,
-                  dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId,
-                  UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId);
-            return;
-          } else if ((target_eNB_index = get_adjacent_cell_mod_id(UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId))
-                     == 0xFF) {
-            LOG_W(RRC,
-                  "[UE %d] Frame %d: ue_mod_idP of the target eNB not found, check the network topology\n",
-                  ctxt_pP->module_id,
-                  ctxt_pP->frame);
-            return;
-          } else {
-            LOG_I(RRC,
-                  "[UE% d] Frame %d: Received rrcConnectionReconfiguration with mobilityControlInfo \n",
-                  ctxt_pP->module_id,
-                  ctxt_pP->frame);
-            UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required
+        case DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration:
+
+          // first check if mobilityControlInfo  is present
+          if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo
+              != NULL) {
+            /* 36.331, 5.3.5.4 Reception of an RRCConnectionReconfiguration including the mobilityControlInfo by the UE (handover)*/
+            if (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId
+                != dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId) {
+              LOG_W(RRC,
+                    "[UE %d] Frame %d: Handover target (%ld) is different from RSRP measured target (%ld)..\n",
+                    ctxt_pP->module_id,
+                    ctxt_pP->frame,
+                    dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId,
+                    UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId);
+              return;
+            } else if ((target_eNB_index = get_adjacent_cell_mod_id(UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId))
+                       == 0xFF) {
+              LOG_W(RRC,
+                    "[UE %d] Frame %d: ue_mod_idP of the target eNB not found, check the network topology\n",
+                    ctxt_pP->module_id,
+                    ctxt_pP->frame);
+              return;
+            } else {
+              LOG_I(RRC,
+                    "[UE% d] Frame %d: Received rrcConnectionReconfiguration with mobilityControlInfo \n",
+                    ctxt_pP->module_id,
+                    ctxt_pP->frame);
+              UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required
+            }
           }
-        }
-
-        rrc_ue_process_rrcConnectionReconfiguration(
-          ctxt_pP,
-          &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration,
-          eNB_indexP);
 
-        if (target_eNB_index != 0xFF) {
-          rrc_ue_generate_RRCConnectionReconfigurationComplete(
+          rrc_ue_process_rrcConnectionReconfiguration(
             ctxt_pP,
-            target_eNB_index,
-            dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier);
-          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_HO_EXECUTION;
-          UE_rrc_inst[ctxt_pP->module_id].Info[target_eNB_index].State = RRC_RECONFIGURED;
-          LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n",
-                ctxt_pP->module_id, target_eNB_index);
+            &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration,
+            eNB_indexP);
+
+          if (target_eNB_index != 0xFF) {
+            rrc_ue_generate_RRCConnectionReconfigurationComplete(
+              ctxt_pP,
+              target_eNB_index,
+              dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier);
+            UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_HO_EXECUTION;
+            UE_rrc_inst[ctxt_pP->module_id].Info[target_eNB_index].State = RRC_RECONFIGURED;
+            LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n",
+                  ctxt_pP->module_id, target_eNB_index);
 #if defined(ENABLE_ITTI)
 #if ENABLE_RAL
-          {
-            MessageDef                                 *message_ral_p = NULL;
-            rrc_ral_connection_reconfiguration_ho_ind_t connection_reconfiguration_ho_ind;
-            int                                         i;
-
-            message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND);
-            memset(&connection_reconfiguration_ho_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t));
-            connection_reconfiguration_ho_ind.ue_id = ctxt_pP->module_id;
-
-            if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList
-                != NULL) {
-              connection_reconfiguration_ho_ind.num_drb      =
-                dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count;
-
-              for (i=0; (
-                     i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count)
-                   && (i < maxDRB); i++) {
-                // why minus 1 in RRC code for drb_identity ?
-                connection_reconfiguration_ho_ind.drb_id[i]   =
-                  dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity;
+            {
+              MessageDef                                 *message_ral_p = NULL;
+              rrc_ral_connection_reconfiguration_ho_ind_t connection_reconfiguration_ho_ind;
+              int                                         i;
+              message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND);
+              memset(&connection_reconfiguration_ho_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t));
+              connection_reconfiguration_ho_ind.ue_id = ctxt_pP->module_id;
+
+              if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList
+                  != NULL) {
+                connection_reconfiguration_ho_ind.num_drb      =
+                  dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count;
+
+                for (i=0; (
+                       i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count)
+                     && (i < maxDRB); i++) {
+                  // why minus 1 in RRC code for drb_identity ?
+                  connection_reconfiguration_ho_ind.drb_id[i]   =
+                    dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity;
+                }
+              } else {
+                connection_reconfiguration_ho_ind.num_drb      = 0;
               }
-            } else {
-              connection_reconfiguration_ho_ind.num_drb      = 0;
-            }
 
-            if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList
-                != NULL) {
-              connection_reconfiguration_ho_ind.num_srb      =
-                dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count
-                +
-                UE_rrc_inst[ctxt_pP->module_id].num_srb;
-            } else {
-              connection_reconfiguration_ho_ind.num_srb      += UE_rrc_inst[ctxt_pP->module_id].num_srb;
-            }
+              if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList
+                  != NULL) {
+                connection_reconfiguration_ho_ind.num_srb      =
+                  dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count
+                  +
+                  UE_rrc_inst[ctxt_pP->module_id].num_srb;
+              } else {
+                connection_reconfiguration_ho_ind.num_srb      += UE_rrc_inst[ctxt_pP->module_id].num_srb;
+              }
 
-            if (connection_reconfiguration_ho_ind.num_srb > 2 ) {
-              connection_reconfiguration_ho_ind.num_srb =2;
-            }
+              if (connection_reconfiguration_ho_ind.num_srb > 2 ) {
+                connection_reconfiguration_ho_ind.num_srb =2;
+              }
 
-            memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ho_ind, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t));
-            //#warning "ue_mod_idP ? for instance ? => YES"
-            LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND to mRAL\n");
-            itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p);
-          }
+              memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ho_ind, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t));
+              //#warning "ue_mod_idP ? for instance ? => YES"
+              LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND to mRAL\n");
+              itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p);
+            }
 #endif
 #endif
-        } else {
-          rrc_ue_generate_RRCConnectionReconfigurationComplete(
-            ctxt_pP,
-            eNB_indexP,
-            dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier);
-          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_RECONFIGURED;
-          LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n",
-                ctxt_pP->module_id,
-                eNB_indexP);
+          } else {
+            rrc_ue_generate_RRCConnectionReconfigurationComplete(
+              ctxt_pP,
+              eNB_indexP,
+              dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier);
+            UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_RECONFIGURED;
+            LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n",
+                  ctxt_pP->module_id,
+                  eNB_indexP);
 #if defined(ENABLE_ITTI)
 #if ENABLE_RAL
-          {
-            MessageDef                                 *message_ral_p = NULL;
-            rrc_ral_connection_reconfiguration_ind_t    connection_reconfiguration_ind;
-            int                                         i;
-
-            message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_IND);
-            memset(&connection_reconfiguration_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ind_t));
-            connection_reconfiguration_ind.ue_id = ctxt_pP->module_id;
-
-            if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList
-                != NULL) {
-              connection_reconfiguration_ind.num_drb      =
-                dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count;
-
-              for (i=0; (
-                     i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count)
-                   && (i < maxDRB); i++) {
-                // why minus 1 in RRC code for drb_identity ?
-                connection_reconfiguration_ind.drb_id[i]   =
-                  dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity;
+            {
+              MessageDef                                 *message_ral_p = NULL;
+              rrc_ral_connection_reconfiguration_ind_t    connection_reconfiguration_ind;
+              int                                         i;
+              message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_IND);
+              memset(&connection_reconfiguration_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ind_t));
+              connection_reconfiguration_ind.ue_id = ctxt_pP->module_id;
+
+              if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList
+                  != NULL) {
+                connection_reconfiguration_ind.num_drb      =
+                  dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count;
+
+                for (i=0; (
+                       i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count)
+                     && (i < maxDRB); i++) {
+                  // why minus 1 in RRC code for drb_identity ?
+                  connection_reconfiguration_ind.drb_id[i]   =
+                    dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity;
+                }
+              } else {
+                connection_reconfiguration_ind.num_drb      = 0;
               }
-            } else {
-              connection_reconfiguration_ind.num_drb      = 0;
-            }
 
-            if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList
-                != NULL) {
-              connection_reconfiguration_ind.num_srb      =
-                dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count
-                +
-                UE_rrc_inst[ctxt_pP->module_id].num_srb;
-            } else {
-              connection_reconfiguration_ind.num_srb      +=UE_rrc_inst[ctxt_pP->module_id].num_srb;
-            }
+              if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList
+                  != NULL) {
+                connection_reconfiguration_ind.num_srb      =
+                  dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count
+                  +
+                  UE_rrc_inst[ctxt_pP->module_id].num_srb;
+              } else {
+                connection_reconfiguration_ind.num_srb      +=UE_rrc_inst[ctxt_pP->module_id].num_srb;
+              }
 
-            if (connection_reconfiguration_ind.num_srb > 2 ) {
-              connection_reconfiguration_ind.num_srb =2;
-            }
+              if (connection_reconfiguration_ind.num_srb > 2 ) {
+                connection_reconfiguration_ind.num_srb =2;
+              }
 
-            memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ind, sizeof(rrc_ral_connection_reconfiguration_ind_t));
-            //#warning "ue_mod_idP ? for instance ? => YES"
-            LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_IND to mRAL\n");
-            itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p);
-          }
+              memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ind, sizeof(rrc_ral_connection_reconfiguration_ind_t));
+              //#warning "ue_mod_idP ? for instance ? => YES"
+              LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_IND to mRAL\n");
+              itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p);
+            }
 #endif
 #endif
+          }
 
-        }
-
-        break;
+          break;
 
-      case DL_DCCH_MessageType__c1_PR_rrcConnectionRelease:
+        case DL_DCCH_MessageType__c1_PR_rrcConnectionRelease:
 #if defined(ENABLE_ITTI)
-        msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND);
-
-        if ((dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.present
-             == RRCConnectionRelease__criticalExtensions_PR_c1)
-            && (dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.present
-                == RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8)) {
-          NAS_CONN_RELEASE_IND(msg_p).cause =
-            dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause;
-        }
+          msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND);
+
+          if ((dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.present
+               == RRCConnectionRelease__criticalExtensions_PR_c1)
+              && (dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.present
+                  == RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8)) {
+            NAS_CONN_RELEASE_IND(msg_p).cause =
+              dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause;
+          }
 
-        itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
+          itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
 #if ENABLE_RAL
-        msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_CONNECTION_RELEASE_IND);
-        RRC_RAL_CONNECTION_RELEASE_IND(msg_p).ue_id = ctxt_pP->module_id;
-        itti_send_msg_to_task(TASK_RAL_UE, ctxt_pP->instance, msg_p);
+          msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_CONNECTION_RELEASE_IND);
+          RRC_RAL_CONNECTION_RELEASE_IND(msg_p).ue_id = ctxt_pP->module_id;
+          itti_send_msg_to_task(TASK_RAL_UE, ctxt_pP->instance, msg_p);
 #endif
 #endif
-        break;
-
-      case DL_DCCH_MessageType__c1_PR_securityModeCommand:
-        LOG_I(RRC, "[UE %d] Received securityModeCommand (eNB %d)\n",
-              ctxt_pP->module_id, eNB_indexP);
-        rrc_ue_process_securityModeCommand(
-          ctxt_pP,
-          &dl_dcch_msg->message.choice.c1.choice.securityModeCommand,
-          eNB_indexP);
-        break;
+          break;
 
-      case DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry:
-        LOG_I(RRC, "[UE %d] Received Capability Enquiry (eNB %d)\n",
-              ctxt_pP->module_id,
-              eNB_indexP);
-        rrc_ue_process_ueCapabilityEnquiry(
-          ctxt_pP,
-          &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry,
-          eNB_indexP);
-        break;
+        case DL_DCCH_MessageType__c1_PR_securityModeCommand:
+          LOG_I(RRC, "[UE %d] Received securityModeCommand (eNB %d)\n",
+                ctxt_pP->module_id, eNB_indexP);
+          rrc_ue_process_securityModeCommand(
+            ctxt_pP,
+            &dl_dcch_msg->message.choice.c1.choice.securityModeCommand,
+            eNB_indexP);
+          break;
 
-      case DL_DCCH_MessageType__c1_PR_counterCheck:
-        break;
+        case DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry:
+          LOG_I(RRC, "[UE %d] Received Capability Enquiry (eNB %d)\n",
+                ctxt_pP->module_id,
+                eNB_indexP);
+          rrc_ue_process_ueCapabilityEnquiry(
+            ctxt_pP,
+            &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry,
+            eNB_indexP);
+          break;
 
+        case DL_DCCH_MessageType__c1_PR_counterCheck:
+          break;
 #if defined(Rel10) || defined(Rel14)
 
-      case DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9:
-        break;
+        case DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9:
+          break;
 
-      case DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10:
-        break;
+        case DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10:
+          break;
 
-      case DL_DCCH_MessageType__c1_PR_rnReconfiguration_r10:
-        break;
+        case DL_DCCH_MessageType__c1_PR_rnReconfiguration_r10:
+          break;
 #endif
 
-      case DL_DCCH_MessageType__c1_PR_spare1:
-      case DL_DCCH_MessageType__c1_PR_spare2:
-      case DL_DCCH_MessageType__c1_PR_spare3:
+        case DL_DCCH_MessageType__c1_PR_spare1:
+        case DL_DCCH_MessageType__c1_PR_spare2:
+        case DL_DCCH_MessageType__c1_PR_spare3:
 #if !defined(Rel14)
-      case DL_DCCH_MessageType__c1_PR_spare4:
+        case DL_DCCH_MessageType__c1_PR_spare4:
 #endif
-        break;
+          break;
 
-      default:
-        break;
+        default:
+          break;
       }
     }
   }
@@ -2507,7 +2411,7 @@ const char SIBType[12][6] = {"SIB3","SIB4","SIB5","SIB6","SIB7","SIB8","SIB9","S
 const char SIBPeriod[8][6]= {"rf8","rf16","rf32","rf64","rf128","rf256","rf512","ERR"};
 int siPeriod_int[7] = {80,160,320,640,1280,2560,5120};
 
-static const char* SIBreserved( long value )
+static const char *SIBreserved( long value )
 {
   if (value < 0 || value > 1)
     return "ERR";
@@ -2517,7 +2421,7 @@ static const char* SIBreserved( long value )
 
   return "reserved";
 }
-static const char* SIBbarred( long value )
+static const char *SIBbarred( long value )
 {
   if (value < 0 || value > 1)
     return "ERR";
@@ -2527,7 +2431,7 @@ static const char* SIBbarred( long value )
 
   return "barred";
 }
-static const char* SIBallowed( long value )
+static const char *SIBallowed( long value )
 {
   if (value < 0 || value > 1)
     return "ERR";
@@ -2537,22 +2441,22 @@ static const char* SIBallowed( long value )
 
   return "allowed";
 }
-static const char* SIB2SoundingPresent( int value )
+static const char *SIB2SoundingPresent( int value )
 {
   switch (value) {
-  case SoundingRS_UL_ConfigCommon_PR_NOTHING:
-    return "NOTHING";
+    case SoundingRS_UL_ConfigCommon_PR_NOTHING:
+      return "NOTHING";
 
-  case SoundingRS_UL_ConfigCommon_PR_release:
-    return "release";
+    case SoundingRS_UL_ConfigCommon_PR_release:
+      return "release";
 
-  case SoundingRS_UL_ConfigCommon_PR_setup:
-    return "setup";
+    case SoundingRS_UL_ConfigCommon_PR_setup:
+      return "setup";
   }
 
   return "ERR";
 }
-static const char* SIB2numberOfRA_Preambles( long value )
+static const char *SIB2numberOfRA_Preambles( long value )
 {
   static char temp[4] = {0};
 
@@ -2563,7 +2467,7 @@ static const char* SIB2numberOfRA_Preambles( long value )
   temp[3] = 0; // terminate string
   return temp;
 }
-static const char* SIB2powerRampingStep( long value )
+static const char *SIB2powerRampingStep( long value )
 {
   if (value < 0 || value > 3)
     return "ERR";
@@ -2571,7 +2475,7 @@ static const char* SIB2powerRampingStep( long value )
   static const char str[4][4] = {"dB0","dB2","dB4","dB6"};
   return str[value];
 }
-static const char* SIB2preambleInitialReceivedTargetPower( long value )
+static const char *SIB2preambleInitialReceivedTargetPower( long value )
 {
   static char temp[8] = {0};
 
@@ -2582,7 +2486,7 @@ static const char* SIB2preambleInitialReceivedTargetPower( long value )
   temp[7] = 0; // terminate string
   return temp;
 }
-static const char* SIB2preambleTransMax( long value )
+static const char *SIB2preambleTransMax( long value )
 {
   static char temp[5] = {0};
 
@@ -2595,26 +2499,26 @@ static const char* SIB2preambleTransMax( long value )
   }
 
   switch (value) {
-  case 6:
-    return "n10";
+    case 6:
+      return "n10";
 
-  case 7:
-    return "n20";
+    case 7:
+      return "n20";
 
-  case 8:
-    return "n50";
+    case 8:
+      return "n50";
 
-  case 9:
-    return "n100";
+    case 9:
+      return "n100";
 
-  case 10:
-    return "n200";
+    case 10:
+      return "n200";
   }
 
   /* unreachable but gcc warns... */
   return "ERR";
 }
-static const char* SIB2ra_ResponseWindowSize( long value )
+static const char *SIB2ra_ResponseWindowSize( long value )
 {
   static char temp[4] = {0};
 
@@ -2627,7 +2531,7 @@ static const char* SIB2ra_ResponseWindowSize( long value )
   snprintf( temp, sizeof(temp), "sf%ld", value+2 );
   return temp;
 }
-static const char* SIB2mac_ContentionResolutionTimer( long value )
+static const char *SIB2mac_ContentionResolutionTimer( long value )
 {
   static char temp[5] = {0};
 
@@ -2637,7 +2541,7 @@ static const char* SIB2mac_ContentionResolutionTimer( long value )
   snprintf( temp, sizeof(temp), "sf%ld", 8 + value*8 );
   return temp;
 }
-static const char* SIB2modificationPeriodCoeff( long value )
+static const char *SIB2modificationPeriodCoeff( long value )
 {
   static char temp[32] = {0};
 
@@ -2647,7 +2551,7 @@ static const char* SIB2modificationPeriodCoeff( long value )
   snprintf( temp, sizeof(temp), "n%d", (int)pow(2,value+1) );
   return temp;
 }
-static const char* SIB2defaultPagingCycle( long value )
+static const char *SIB2defaultPagingCycle( long value )
 {
   static char temp[32] = {0};
 
@@ -2657,7 +2561,7 @@ static const char* SIB2defaultPagingCycle( long value )
   snprintf( temp, sizeof(temp), "rf%d", (int)pow(2,value+4) );
   return temp;
 }
-static const char* SIB2nB( long value )
+static const char *SIB2nB( long value )
 {
   if (value < 0 || value > 7)
     return "ERR";
@@ -2671,17 +2575,16 @@ static const char* SIB2nB( long value )
 
 //-----------------------------------------------------------------------------
 int decode_BCCH_DLSCH_Message(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const uint8_t                eNB_index,
-  uint8_t*               const Sdu,
+  uint8_t               *const Sdu,
   const uint8_t                Sdu_len,
   const uint8_t                rsrq,
   const uint8_t                rsrp )
 {
   BCCH_DL_SCH_Message_t *bcch_message = NULL;
-  SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
+  SystemInformationBlockType1_t *sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
   int i;
-
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_IN );
 
   if (((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&1) == 1) &&  // SIB1 received
@@ -2693,7 +2596,6 @@ int decode_BCCH_DLSCH_Message(
   }
 
   rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_RECEIVING_SIB );
-
   asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
                             &asn_DEF_BCCH_DL_SCH_Message,
                             (void **)&bcch_message,
@@ -2704,11 +2606,13 @@ int decode_BCCH_DLSCH_Message(
     LOG_E( RRC, "[UE %"PRIu8"] Failed to decode BCCH_DLSCH_MESSAGE (%zu bits)\n",
            ctxt_pP->module_id,
            dec_rval.consumed );
-    for (i=0;i<Sdu_len;i++)
+
+    for (i=0; i<Sdu_len; i++)
       printf("%02x ",Sdu[i]);
+
     printf("\n");
     // free the memory
-    SEQUENCE_free( &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message, 1 );
+    SEQUENCE_free( &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message, 1 );
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT );
     return -1;
   }
@@ -2717,10 +2621,8 @@ int decode_BCCH_DLSCH_Message(
 # if defined(DISABLE_ITTI_XER_PRINT)
   {
     MessageDef *msg_p;
-
     msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_BCCH_MESSAGE);
     memcpy (&msg_p->ittiMsg, (void *) bcch_message, sizeof(RrcDlBcchMessage));
-
     itti_send_msg_to_task (TASK_UNKNOWN, ctxt_pP->instance, msg_p);
   }
 # else
@@ -2730,11 +2632,9 @@ int decode_BCCH_DLSCH_Message(
 
     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) {
       MessageDef *msg_p;
-
       msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
     }
   }
@@ -2743,42 +2643,39 @@ int decode_BCCH_DLSCH_Message(
 
   if (bcch_message->message.present == BCCH_DL_SCH_MessageType_PR_c1) {
     switch (bcch_message->message.choice.c1.present) {
-    case BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1:
-      if ((ctxt_pP->frame % 2) == 0) {
-        // even frame
-        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&1) == 0) {
-          SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
-          memcpy( (void*)sib1,
-                  (void*)&bcch_message->message.choice.c1.choice.systemInformationBlockType1,
-                  sizeof(SystemInformationBlockType1_t) );
-          LOG_D( RRC, "[UE %"PRIu8"] Decoding First SIB1\n", ctxt_pP->module_id );
-          decode_SIB1( ctxt_pP, eNB_index, rsrq, rsrp );
+      case BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1:
+        if ((ctxt_pP->frame % 2) == 0) {
+          // even frame
+          if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&1) == 0) {
+            SystemInformationBlockType1_t *sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
+            memcpy( (void *)sib1,
+                    (void *)&bcch_message->message.choice.c1.choice.systemInformationBlockType1,
+                    sizeof(SystemInformationBlockType1_t) );
+            LOG_D( RRC, "[UE %"PRIu8"] Decoding First SIB1\n", ctxt_pP->module_id );
+            decode_SIB1( ctxt_pP, eNB_index, rsrq, rsrp );
+          }
         }
-      }
-
-      break;
-
-    case BCCH_DL_SCH_MessageType__c1_PR_systemInformation:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&1) == 1) {
-        // SIB1 with schedulingInfoList is available
-
-        SystemInformation_t* si = UE_rrc_inst[ctxt_pP->module_id].si[eNB_index];
-        memcpy( si,
-                &bcch_message->message.choice.c1.choice.systemInformation,
-                sizeof(SystemInformation_t) );
 
-        LOG_D( RRC, "[UE %"PRIu8"] Decoding SI for frameP %"PRIu32"\n",
-               ctxt_pP->module_id,
-               ctxt_pP->frame );
+        break;
 
-        decode_SI( ctxt_pP, eNB_index );
-      }
+      case BCCH_DL_SCH_MessageType__c1_PR_systemInformation:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&1) == 1) {
+          // SIB1 with schedulingInfoList is available
+          SystemInformation_t *si = UE_rrc_inst[ctxt_pP->module_id].si[eNB_index];
+          memcpy( si,
+                  &bcch_message->message.choice.c1.choice.systemInformation,
+                  sizeof(SystemInformation_t) );
+          LOG_D( RRC, "[UE %"PRIu8"] Decoding SI for frameP %"PRIu32"\n",
+                 ctxt_pP->module_id,
+                 ctxt_pP->frame );
+          decode_SI( ctxt_pP, eNB_index );
+        }
 
-      break;
+        break;
 
-    case BCCH_DL_SCH_MessageType__c1_PR_NOTHING:
-    default:
-      break;
+      case BCCH_DL_SCH_MessageType__c1_PR_NOTHING:
+      default:
+        break;
     }
   }
 
@@ -2792,22 +2689,19 @@ int decode_BCCH_DLSCH_Message(
   }
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT );
-
   return 0;
 }
 
 //-----------------------------------------------------------------------------
 int decode_PCCH_DLSCH_Message(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const uint8_t                eNB_index,
-  uint8_t*               const Sdu,
+  uint8_t               *const Sdu,
   const uint8_t                Sdu_len)
 {
   PCCH_Message_t *pcch_message = NULL;
   int i;
-
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN );
-
   asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
                             &asn_DEF_PCCH_Message,
                             (void **)&pcch_message,
@@ -2818,11 +2712,13 @@ int decode_PCCH_DLSCH_Message(
     LOG_E( RRC, "[UE %"PRIu8"] Failed to decode PCCH_MESSAGE (%zu bits)\n",
            ctxt_pP->module_id,
            dec_rval.consumed );
-    for (i=0;i<Sdu_len;i++)
+
+    for (i=0; i<Sdu_len; i++)
       printf("%02x ",Sdu[i]);
+
     printf("\n");
     // free the memory
-    SEQUENCE_free( &asn_DEF_PCCH_Message, (void*)pcch_message, 1 );
+    SEQUENCE_free( &asn_DEF_PCCH_Message, (void *)pcch_message, 1 );
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT );
     return -1;
   }
@@ -2831,19 +2727,14 @@ int decode_PCCH_DLSCH_Message(
 }
 
 //-----------------------------------------------------------------------------
-static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp )
+static int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp )
 {
-  SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
-
+  SystemInformationBlockType1_t *sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SIB1, VCD_FUNCTION_IN );
-
   LOG_I( RRC, "[UE %d] : Dumping SIB 1\n", ctxt_pP->module_id );
-
   PLMN_Identity_t *PLMN_identity = &sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->plmn_Identity;
-
   int mccdigits = PLMN_identity->mcc->list.count;
   int mncdigits = PLMN_identity->mnc.list.count;
-
   int mcc;
 
   if (mccdigits == 2) {
@@ -2869,7 +2760,6 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
   LOG_I( RRC, "PLMN MCC %0*d, MNC %0*d, TAC 0x%04x\n", mccdigits, mcc, mncdigits, mnc, tac );
   long cellReservedForOperatorUse = sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellReservedForOperatorUse;
   LOG_I( RRC, "cellReservedForOperatorUse                 : raw:%ld decoded:%s\n", cellReservedForOperatorUse, SIBreserved(cellReservedForOperatorUse) );
-
   // search internal table for provider name
   int plmn_ind = 0;
 
@@ -2892,7 +2782,6 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
          sib1->cellAccessRelatedInfo.cellIdentity.buf[1],
          sib1->cellAccessRelatedInfo.cellIdentity.buf[2],
          sib1->cellAccessRelatedInfo.cellIdentity.buf[3] >> sib1->cellAccessRelatedInfo.cellIdentity.bits_unused);
-
   long cellBarred = sib1->cellAccessRelatedInfo.cellBarred;
   LOG_I( RRC, "cellAccessRelatedInfo.cellBarred           : raw:%ld decoded:%s\n", cellBarred, SIBbarred(cellBarred) );
   long intraFreqReselection = sib1->cellAccessRelatedInfo.intraFreqReselection;
@@ -2946,48 +2835,43 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
 
   LOG_I( RRC, "siWindowLength                             : %s\n", siWindowLength[min(sib1->si_WindowLength,7)] );
   LOG_I( RRC, "systemInfoValueTag                         : %ld\n", sib1->systemInfoValueTag );
-
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod     = siPeriod_int[sib1->schedulingInfoList.list.array[0]->si_Periodicity];
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize = siWindowLength_int[sib1->si_WindowLength];
   LOG_I( RRC, "[FRAME unknown][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB1 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
          ctxt_pP->module_id, eNB_index, ctxt_pP->module_id );
-
   rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index,
-			(RadioResourceConfigCommonSIB_t *)NULL,
-			(struct PhysicalConfigDedicated *)NULL,
+                        (RadioResourceConfigCommonSIB_t *)NULL,
+                        (struct PhysicalConfigDedicated *)NULL,
 #if defined(Rel10) || defined(Rel14)
-			(SCellToAddMod_r10_t *)NULL,
-			//(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+                        (SCellToAddMod_r10_t *)NULL,
+                        //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-			(MeasObjectToAddMod_t **)NULL,
-			(MAC_MainConfig_t *)NULL,
-			0,
-			(struct LogicalChannelConfig *)NULL,
-			(MeasGapConfig_t *)NULL,
-			UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config,
-			(MobilityControlInfo_t *) NULL,
-			&UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize,
-			&UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod,
-			NULL,
-			NULL,
-			NULL,
-			(MBSFN_SubframeConfigList_t *)NULL
+                        (MeasObjectToAddMod_t **)NULL,
+                        (MAC_MainConfig_t *)NULL,
+                        0,
+                        (struct LogicalChannelConfig *)NULL,
+                        (MeasGapConfig_t *)NULL,
+                        UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config,
+                        (MobilityControlInfo_t *) NULL,
+                        &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize,
+                        &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod,
+                        NULL,
+                        NULL,
+                        NULL,
+                        (MBSFN_SubframeConfigList_t *)NULL
 #if defined(Rel10) || defined(Rel14)
-			,0,
-			(MBSFN_AreaInfoList_r9_t *)NULL,
-			(PMCH_InfoList_r9_t *)NULL
-
+                        ,0,
+                        (MBSFN_AreaInfoList_r9_t *)NULL,
+                        (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-			,
-			0,
-			0
+                        ,
+                        0,
+                        0
 #endif
-			);
-  
+                       );
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1;
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag;
-
 #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
   {
     int cell_valid = 0;
@@ -2996,13 +2880,11 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
       /* Cell is not barred */
       int plmn;
       int plmn_number;
-
       plmn_number = sib1->cellAccessRelatedInfo.plmn_IdentityList.list.count;
 
       /* Compare requested PLMN and PLMNs from SIB1*/
       for (plmn = 0; plmn < plmn_number; plmn++) {
         PLMN_Identity_t *plmn_Identity;
-
         plmn_Identity = &sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[plmn]->plmn_Identity;
 
         if (
@@ -3028,7 +2910,6 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
         ) {
           /* PLMN match, send a confirmation to NAS */
           MessageDef  *msg_p;
-
           msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CELL_SELECTION_CNF);
           NAS_CELL_SELECTION_CNF (msg_p).errCode = AS_SUCCESS;
           NAS_CELL_SELECTION_CNF (msg_p).cellID = BIT_STRING_to_uint32(&sib1->cellAccessRelatedInfo.cellIdentity);
@@ -3036,7 +2917,6 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
           NAS_CELL_SELECTION_CNF (msg_p).rat = 0xFF;
           NAS_CELL_SELECTION_CNF (msg_p).rsrq = rsrq;
           NAS_CELL_SELECTION_CNF (msg_p).rsrp = rsrp;
-
           itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
           cell_valid = 1;
           break;
@@ -3047,16 +2927,12 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
     if (cell_valid == 0) {
       /* Cell can not be used, ask PHY to try the next one */
       MessageDef  *msg_p;
-
       msg_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_NEXT_CELL_REQ);
-
       itti_send_msg_to_task(TASK_PHY_UE, ctxt_pP->instance, msg_p);
     }
   }
 #endif
-
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SIB1, VCD_FUNCTION_OUT );
-
   return 0;
 }
 
@@ -3113,7 +2989,6 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
   LOG_I( RRC, "radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower : raw:%ld decoded:%s\n",
          sib2->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower,
          SIB2preambleInitialReceivedTargetPower(sib2->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower) );
-
   LOG_I( RRC, "radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax              : raw:%ld decoded:%s\n",
          sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax,
          SIB2preambleTransMax(sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax) );
@@ -3123,15 +2998,12 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
   LOG_I( RRC, "radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer : raw:%ld decoded:%s\n",
          sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer,
          SIB2mac_ContentionResolutionTimer(sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer) );
-
   LOG_I( RRC, "radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx : %ld\n",
          sib2->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx );
-
   // BCCH
   LOG_I( RRC, "radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff : raw:%ld decoded:%s\n",
          sib2->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff,
          SIB2modificationPeriodCoeff(sib2->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff) );
-
   // PCCH
   LOG_I( RRC, "radioResourceConfigCommon.pcch_Config.defaultPagingCycle : raw:%ld decoded:%s\n",
          sib2->radioResourceConfigCommon.pcch_Config.defaultPagingCycle,
@@ -3139,7 +3011,6 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
   LOG_I( RRC, "radioResourceConfigCommon.pcch_Config.nB                 : raw:%ld decoded:%s\n",
          sib2->radioResourceConfigCommon.pcch_Config.nB,
          SIB2nB(sib2->radioResourceConfigCommon.pcch_Config.nB) );
-
   // PRACH
   LOG_I( RRC, "radioResourceConfigCommon.prach_Config.rootSequenceIndex                          : %ld\n",
          sib2->radioResourceConfigCommon.prach_Config.rootSequenceIndex );
@@ -3151,13 +3022,11 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
          sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig );
   LOG_I( RRC, "radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset          : %ld\n",
          sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset );
-
   // PDSCH-Config
   LOG_I( RRC, "radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower : %ld\n",
          sib2->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower );
   LOG_I( RRC, "radioResourceConfigCommon.pdsch_ConfigCommon.p_b                  : %ld\n",
          sib2->radioResourceConfigCommon.pdsch_ConfigCommon.p_b );
-
   // PUSCH-Config
   LOG_I( RRC, "radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB                : %ld\n",
          sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB );
@@ -3175,7 +3044,6 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
          sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled );
   LOG_I( RRC, "radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift            : %ld\n",
          sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift );
-
   // PUCCH-Config
   LOG_I( RRC, "radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift : %ld\n",
          sib2->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift );
@@ -3185,7 +3053,6 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
          sib2->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN );
   LOG_I( RRC, "radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN       : %ld\n",
          sib2->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN );
-
   // SoundingRS_UL_Config
   LOG_I( RRC, "radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present : raw:%d decoded:%s\n",
          sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present,
@@ -3201,9 +3068,9 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
 
     if(sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts)
     {
-    LOG_I( RRC, "radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts                        : %ld\n",
-           /* TODO: check that it's okay to access [0] */
-           sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts[0] );
+      LOG_I( RRC, "radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts                        : %ld\n",
+             /* TODO: check that it's okay to access [0] */
+             sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts[0] );
     }
   }
 
@@ -3226,15 +3093,12 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
          sib2->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b );
   LOG_I( RRC, "radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 : %ld\n",
          sib2->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 );
-
   LOG_I( RRC, "radioResourceConfigCommon.ul_CyclicPrefixLength : %ld\n",
          sib2->radioResourceConfigCommon.ul_CyclicPrefixLength );
-
 #if defined(Rel10) || defined(Rel14)
   // UplinkPowerControlCommon_v1020
   // ...
 #endif
-
   LOG_I( RRC, "ue_TimersAndConstants.t300 : %ld\n", sib2->ue_TimersAndConstants.t300 );
   LOG_I( RRC, "ue_TimersAndConstants.t301 : %ld\n", sib2->ue_TimersAndConstants.t301 );
   LOG_I( RRC, "ue_TimersAndConstants.t310 : %ld\n", sib2->ue_TimersAndConstants.t310 );
@@ -3261,7 +3125,6 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
     LOG_I( RRC, "mbsfn_SubframeConfigList : not defined\n" );
 
   LOG_I( RRC, "timeAlignmentTimerCommon : %ld\n", sib2->timeAlignmentTimerCommon );
-
 #if defined(Rel10) || defined(Rel14)
 
   if (sib2->lateNonCriticalExtension) {
@@ -3306,7 +3169,6 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
 static void dump_sib3( SystemInformationBlockType3_t *sib3 )
 {
   LOG_I( RRC, "Dumping SIB3 (see TS36.331 V8.21.0)\n" );
-
   int q_Hyst_dB = sib3->cellReselectionInfoCommon.q_Hyst; // sib3->cellReselectionInfoCommon.q_Hyst is a enumerated value
 
   if (q_Hyst_dB > 6)
@@ -3341,7 +3203,6 @@ static void dump_sib3( SystemInformationBlockType3_t *sib3 )
 
   LOG_I( RRC, "cellReselectionServingFreqInfo.threshServingLow : %ld\n", sib3->cellReselectionServingFreqInfo.threshServingLow );
   LOG_I( RRC, "cellReselectionServingFreqInfo.cellReselectionPriority : %ld\n", sib3->cellReselectionServingFreqInfo.cellReselectionPriority );
-
   LOG_I( RRC, "intraFreqCellReselectionInfo.q_RxLevMin : %ld\n", sib3->intraFreqCellReselectionInfo.q_RxLevMin );
 
   if (sib3->intraFreqCellReselectionInfo.p_Max) {
@@ -3378,7 +3239,6 @@ int Qoffsettab[31] = {-24,-22,-20,-18,-16,-14,-12,-10,-8,-6,-5,-4,-3,-2,-1,0,1,2
 int PhysCellIdRange[16] = {4,8,12,16,24,32,48,64,84,96,128,168,252,504,0,0};
 
 uint64_t arfcn_to_freq(long arfcn) {
-  
   if (arfcn < 600)  // Band 1
     return((uint64_t)2110000000 + (arfcn*100000));
   else if (arfcn <1200) // Band 2
@@ -3457,93 +3317,110 @@ static void dump_sib5( SystemInformationBlockType5_t *sib5 )
   InterFreqCarrierFreqList_t interFreqCarrierFreqList = sib5->interFreqCarrierFreqList;
   int i,j;
   InterFreqCarrierFreqInfo_t *ifcfInfo;
-
   LOG_I( RRC, "Dumping SIB5 (see TS36.331 V8.21.0)\n" );
-  
-  for (i=0;i<interFreqCarrierFreqList.list.count;i++) {
+
+  for (i=0; i<interFreqCarrierFreqList.list.count; i++) {
     LOG_I(RRC, "SIB5 InterFreqCarrierFreq element %d/%d\n",i,interFreqCarrierFreqList.list.count);
     ifcfInfo = interFreqCarrierFreqList.list.array[i];
     LOG_I(RRC, "   DL Carrier Frequency/ARFCN : %ld/%ld\n",
-	  arfcn_to_freq(ifcfInfo->dl_CarrierFreq),
-	  ifcfInfo->dl_CarrierFreq);
+          arfcn_to_freq(ifcfInfo->dl_CarrierFreq),
+          ifcfInfo->dl_CarrierFreq);
     LOG_I(RRC,"   Q_RXLevMin : %ld\n", ifcfInfo->q_RxLevMin);
+
     if (ifcfInfo->p_Max != NULL)
       LOG_I(RRC,"   P_max : %ld\n", *ifcfInfo->p_Max);
+
     LOG_I(RRC,"   T_ReselectionEUTRA : %ld\n",ifcfInfo->t_ReselectionEUTRA);
+
     if (ifcfInfo->t_ReselectionEUTRA_SF) {
       LOG_I(RRC,"   t_ReselectionEUTRA_SF.sf_Medium %ld, t_ReselectionEUTRA_SF.sf_High %ld",
-	    ifcfInfo->t_ReselectionEUTRA_SF->sf_Medium,
-	    ifcfInfo->t_ReselectionEUTRA_SF->sf_High);
+            ifcfInfo->t_ReselectionEUTRA_SF->sf_Medium,
+            ifcfInfo->t_ReselectionEUTRA_SF->sf_High);
     }
+
     LOG_I(RRC,"   threshX_High : %ld\n",ifcfInfo->threshX_High);
     LOG_I(RRC,"   threshX_Low : %ld\n",ifcfInfo->threshX_Low);
+
     switch(ifcfInfo->allowedMeasBandwidth) {
-    case AllowedMeasBandwidth_mbw6:
-      LOG_I(RRC,"   AllowedMeasBandwidth : 6\n");
-      break;
-    case AllowedMeasBandwidth_mbw15:
-      LOG_I(RRC,"   AllowedMeasBandwidth : 15\n");
-      break;
-    case AllowedMeasBandwidth_mbw25:
-      LOG_I(RRC,"   AllowedMeasBandwidth : 25\n");
-      break;
-    case AllowedMeasBandwidth_mbw50:
-      LOG_I(RRC,"   AllowedMeasBandwidth : 50\n");
-      break;
-    case AllowedMeasBandwidth_mbw75:
-      LOG_I(RRC,"   AllowedMeasBandwidth : 75\n");
-      break;
-    case AllowedMeasBandwidth_mbw100:
-      LOG_I(RRC,"   AllowedMeasBandwidth : 100\n");
-      break;
+      case AllowedMeasBandwidth_mbw6:
+        LOG_I(RRC,"   AllowedMeasBandwidth : 6\n");
+        break;
+
+      case AllowedMeasBandwidth_mbw15:
+        LOG_I(RRC,"   AllowedMeasBandwidth : 15\n");
+        break;
+
+      case AllowedMeasBandwidth_mbw25:
+        LOG_I(RRC,"   AllowedMeasBandwidth : 25\n");
+        break;
+
+      case AllowedMeasBandwidth_mbw50:
+        LOG_I(RRC,"   AllowedMeasBandwidth : 50\n");
+        break;
+
+      case AllowedMeasBandwidth_mbw75:
+        LOG_I(RRC,"   AllowedMeasBandwidth : 75\n");
+        break;
+
+      case AllowedMeasBandwidth_mbw100:
+        LOG_I(RRC,"   AllowedMeasBandwidth : 100\n");
+        break;
     }
+
     if (ifcfInfo->presenceAntennaPort1)
       LOG_I(RRC,"   PresenceAntennaPort1 : True\n");
     else
       LOG_I(RRC,"   PresenceAntennaPort1 : False\n");
+
     if (ifcfInfo->cellReselectionPriority) {
       LOG_I(RRC,"   CellReselectionPriority : %ld\n",
-	    *ifcfInfo->cellReselectionPriority);
+            *ifcfInfo->cellReselectionPriority);
     }
+
     LOG_I(RRC,"   NeighCellConfig  : ");
-    for (j=0;j<ifcfInfo->neighCellConfig.size;j++) {
+
+    for (j=0; j<ifcfInfo->neighCellConfig.size; j++) {
       printf("%2x ",ifcfInfo->neighCellConfig.buf[j]);
     }
+
     printf("\n");
+
     if (ifcfInfo->q_OffsetFreq)
       LOG_I(RRC,"   Q_OffsetFreq : %d\n",Qoffsettab[*ifcfInfo->q_OffsetFreq]);
+
     if (ifcfInfo->interFreqNeighCellList) {
-      
-      for (j=0;j<ifcfInfo->interFreqNeighCellList->list.count;j++) {
-	LOG_I(RRC,"   Cell %d\n", j);
-	LOG_I(RRC,"      PhysCellId : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->physCellId);
-	LOG_I(RRC,"      Q_OffsetRange : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->q_OffsetCell);
-	
+      for (j=0; j<ifcfInfo->interFreqNeighCellList->list.count; j++) {
+        LOG_I(RRC,"   Cell %d\n", j);
+        LOG_I(RRC,"      PhysCellId : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->physCellId);
+        LOG_I(RRC,"      Q_OffsetRange : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->q_OffsetCell);
       }
     }
+
     if (ifcfInfo->interFreqBlackCellList) {
-      
-      for (j=0;j<ifcfInfo->interFreqBlackCellList->list.count;j++) {
-	LOG_I(RRC,"   Cell %d\n", j);
-	LOG_I(RRC,"      PhysCellId start: %ld\n",ifcfInfo->interFreqBlackCellList->list.array[j]->start);
-	if (ifcfInfo->interFreqBlackCellList->list.array[i]->range) {
-	  LOG_I(RRC,"      PhysCellId Range : %ld\n",*ifcfInfo->interFreqBlackCellList->list.array[j]->range);
-	}
+      for (j=0; j<ifcfInfo->interFreqBlackCellList->list.count; j++) {
+        LOG_I(RRC,"   Cell %d\n", j);
+        LOG_I(RRC,"      PhysCellId start: %ld\n",ifcfInfo->interFreqBlackCellList->list.array[j]->start);
+
+        if (ifcfInfo->interFreqBlackCellList->list.array[i]->range) {
+          LOG_I(RRC,"      PhysCellId Range : %ld\n",*ifcfInfo->interFreqBlackCellList->list.array[j]->range);
+        }
       }
     }
+
 #if defined(Rel10) || defined(Rel14)
+
     if (ifcfInfo->ext1 && ifcfInfo->ext1->q_QualMin_r9)
       LOG_I(RRC,"   Q_QualMin_r9 : %ld\n",*ifcfInfo->ext1->q_QualMin_r9);
-    
+
     if (ifcfInfo->ext1 && ifcfInfo->ext1->threshX_Q_r9) {
       LOG_I(RRC,"   threshX_HighQ_r9 : %ld\n",ifcfInfo->ext1->threshX_Q_r9->threshX_HighQ_r9);
       LOG_I(RRC,"   threshX_LowQ_r9: %ld\n",ifcfInfo->ext1->threshX_Q_r9->threshX_LowQ_r9);
     }
+
 #endif
   }
-  
 }
-  
+
 #if defined(Rel10) || defined(Rel14)
 static void dump_sib13( SystemInformationBlockType13_r9_t *sib13 )
 {
@@ -3556,13 +3433,11 @@ static void dump_sib13( SystemInformationBlockType13_r9_t *sib13 )
 #endif
 
 //-----------------------------------------------------------------------------
-static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
+static int decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index )
 {
-
-  SystemInformation_t** si = &UE_rrc_inst[ctxt_pP->module_id].si[eNB_index];
+  SystemInformation_t **si = &UE_rrc_inst[ctxt_pP->module_id].si[eNB_index];
   int new_sib = 0;
-  SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
-
+  SystemInformationBlockType1_t *sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_IN );
 
   // Dump contents
@@ -3580,252 +3455,254 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in
     typeandinfo = (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.array[i];
 
     switch(typeandinfo->present) {
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&2) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=2;
-	new_sib=1;
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index], &typeandinfo->choice.sib2, sizeof(SystemInformationBlockType2_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB2 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-	dump_sib2( UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index] );
-	LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB2 params  eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
-	       ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id );
-
-	rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index,
-			      &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->radioResourceConfigCommon,
-			      (struct PhysicalConfigDedicated *)NULL,
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&2) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=2;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index], &typeandinfo->choice.sib2, sizeof(SystemInformationBlockType2_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB2 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+          dump_sib2( UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index] );
+          LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB2 params  eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
+                 ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id );
+          rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index,
+                                &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->radioResourceConfigCommon,
+                                (struct PhysicalConfigDedicated *)NULL,
 #if defined(Rel10) || defined(Rel14)
-			      (SCellToAddMod_r10_t *)NULL,
+                                (SCellToAddMod_r10_t *)NULL,
 #endif
-			      (MeasObjectToAddMod_t **)NULL,
-			      (MAC_MainConfig_t *)NULL,
-			      0,
-			      (struct LogicalChannelConfig *)NULL,
-			      (MeasGapConfig_t *)NULL,
-			      (TDD_Config_t *)NULL,
-			      (MobilityControlInfo_t *)NULL,
-			      NULL,
-			      NULL,
-			      UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_CarrierFreq,
-			      UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth,
-			      &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission,
-			      UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->mbsfn_SubframeConfigList
+                                (MeasObjectToAddMod_t **)NULL,
+                                (MAC_MainConfig_t *)NULL,
+                                0,
+                                (struct LogicalChannelConfig *)NULL,
+                                (MeasGapConfig_t *)NULL,
+                                (TDD_Config_t *)NULL,
+                                (MobilityControlInfo_t *)NULL,
+                                NULL,
+                                NULL,
+                                UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_CarrierFreq,
+                                UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth,
+                                &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission,
+                                UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->mbsfn_SubframeConfigList
 #if defined(Rel10) || defined(Rel14)
-			      ,0,
-			      (MBSFN_AreaInfoList_r9_t *)NULL,
-			      (PMCH_InfoList_r9_t *)NULL
-
+                                ,0,
+                                (MBSFN_AreaInfoList_r9_t *)NULL,
+                                (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-			      ,0,
-			      0
+                                ,0,
+                                0
 #endif
-			      );
-	// After SI is received, prepare RRCConnectionRequest
+                               );
+          // After SI is received, prepare RRCConnectionRequest
 #if defined(Rel10) || defined(Rel14)
 
-	if (UE_rrc_inst[ctxt_pP->module_id].MBMS_flag < 3) // see -Q option
+          if (UE_rrc_inst[ctxt_pP->module_id].MBMS_flag < 3) // see -Q option
 #endif
 #if !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME))
-	  rrc_ue_generate_RRCConnectionRequest( ctxt_pP, eNB_index );
-	
+            rrc_ue_generate_RRCConnectionRequest( ctxt_pP, eNB_index );
+
 #endif
-	
-	if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_IDLE) {
-	  LOG_I( RRC, "[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n", ctxt_pP->module_id );
-	  UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_SI_RECEIVED;
+
+          if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_IDLE) {
+            LOG_I( RRC, "[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n", ctxt_pP->module_id );
+            UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_SI_RECEIVED;
 #if ENABLE_RAL
-	  {
-	    MessageDef                            *message_ral_p = NULL;
-	    rrc_ral_system_information_ind_t       ral_si_ind;
-	    
-	    message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_SYSTEM_INFORMATION_IND);
-	    memset(&ral_si_ind, 0, sizeof(rrc_ral_system_information_ind_t));
-	    ral_si_ind.plmn_id.MCCdigit2 = '0';
-	    ral_si_ind.plmn_id.MCCdigit1 = '2';
-	    ral_si_ind.plmn_id.MNCdigit3 = '0';
-	    ral_si_ind.plmn_id.MCCdigit3 = '8';
-	    ral_si_ind.plmn_id.MNCdigit2 = '9';
-	    ral_si_ind.plmn_id.MNCdigit1 = '9';
-	    ral_si_ind.cell_id        = 1;
-	    ral_si_ind.dbm            = 0;
-	    //ral_si_ind.dbm            = fifo_dump_emos_UE.PHY_measurements->rx_rssi_dBm[eNB_index];
-	    // TO DO
-	    ral_si_ind.sinr           = 0;
-	    //ral_si_ind.sinr           = fifo_dump_emos_UE.PHY_measurements->subband_cqi_dB[eNB_index][phy_vars_ue->lte_frame_parms.nb_antennas_rx][0];
-	    // TO DO
-	    ral_si_ind.link_data_rate = 0;
-	    memcpy (&message_ral_p->ittiMsg, (void *) &ral_si_ind, sizeof(rrc_ral_system_information_ind_t));
+            {
+              MessageDef                            *message_ral_p = NULL;
+              rrc_ral_system_information_ind_t       ral_si_ind;
+              message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_SYSTEM_INFORMATION_IND);
+              memset(&ral_si_ind, 0, sizeof(rrc_ral_system_information_ind_t));
+              ral_si_ind.plmn_id.MCCdigit2 = '0';
+              ral_si_ind.plmn_id.MCCdigit1 = '2';
+              ral_si_ind.plmn_id.MNCdigit3 = '0';
+              ral_si_ind.plmn_id.MCCdigit3 = '8';
+              ral_si_ind.plmn_id.MNCdigit2 = '9';
+              ral_si_ind.plmn_id.MNCdigit1 = '9';
+              ral_si_ind.cell_id        = 1;
+              ral_si_ind.dbm            = 0;
+              //ral_si_ind.dbm            = fifo_dump_emos_UE.PHY_measurements->rx_rssi_dBm[eNB_index];
+              // TO DO
+              ral_si_ind.sinr           = 0;
+              //ral_si_ind.sinr           = fifo_dump_emos_UE.PHY_measurements->subband_cqi_dB[eNB_index][phy_vars_ue->lte_frame_parms.nb_antennas_rx][0];
+              // TO DO
+              ral_si_ind.link_data_rate = 0;
+              memcpy (&message_ral_p->ittiMsg, (void *) &ral_si_ind, sizeof(rrc_ral_system_information_ind_t));
 #warning "ue_mod_idP ? for instance ?"
-	    itti_send_msg_to_task (TASK_RAL_UE, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), message_ral_p);
-	  }
+              itti_send_msg_to_task (TASK_RAL_UE, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), message_ral_p);
+            }
 #endif
-	}
-      }
-      break; // case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2
+          }
+        }
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4;
-	new_sib=1;
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib3[eNB_index], &typeandinfo->choice.sib3, sizeof(SystemInformationBlockType3_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB3 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-	dump_sib3( UE_rrc_inst[ctxt_pP->module_id].sib3[eNB_index] );
+        break; // case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2
 
-      }
-      break;
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib3[eNB_index], &typeandinfo->choice.sib3, sizeof(SystemInformationBlockType3_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB3 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+          dump_sib3( UE_rrc_inst[ctxt_pP->module_id].sib3[eNB_index] );
+        }
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&8) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=8;
-	new_sib=1;
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib4[eNB_index], &typeandinfo->choice.sib4, sizeof(SystemInformationBlockType4_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB4 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
+        break;
 
-      break;
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&8) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=8;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib4[eNB_index], &typeandinfo->choice.sib4, sizeof(SystemInformationBlockType4_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB4 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&16) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=16;
-	new_sib=1;
-     
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index], &typeandinfo->choice.sib5, sizeof(SystemInformationBlockType5_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB5 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-	dump_sib5(UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index]);
-      }
-      break;
+        break;
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&32) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=32;
-	new_sib=1;
-     
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib6[eNB_index], &typeandinfo->choice.sib6, sizeof(SystemInformationBlockType6_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB6 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
-      break;
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&16) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=16;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index], &typeandinfo->choice.sib5, sizeof(SystemInformationBlockType5_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB5 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+          dump_sib5(UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index]);
+        }
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&64) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=64;
-	new_sib=1;
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib7[eNB_index], &typeandinfo->choice.sib7, sizeof(SystemInformationBlockType7_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB7 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
-      break;
+        break;
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&128) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=128;
-	new_sib=1;
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib8[eNB_index], &typeandinfo->choice.sib8, sizeof(SystemInformationBlockType8_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB8 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
-      break;
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&32) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=32;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib6[eNB_index], &typeandinfo->choice.sib6, sizeof(SystemInformationBlockType6_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB6 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&256) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=256;
-	new_sib=1;
-      
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib9[eNB_index], &typeandinfo->choice.sib9, sizeof(SystemInformationBlockType9_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB9 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
-      break;
+        break;
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&512) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=512;
-	new_sib=1;
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib10[eNB_index], &typeandinfo->choice.sib10, sizeof(SystemInformationBlockType10_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB10 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
-      break;
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&64) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=64;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib7[eNB_index], &typeandinfo->choice.sib7, sizeof(SystemInformationBlockType7_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB7 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&1024) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=1024;
-	new_sib=1;
+        break;
 
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib11[eNB_index], &typeandinfo->choice.sib11, sizeof(SystemInformationBlockType11_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB11 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
-      break;
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&128) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=128;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib8[eNB_index], &typeandinfo->choice.sib8, sizeof(SystemInformationBlockType8_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB8 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
+
+        break;
+
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&256) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=256;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib9[eNB_index], &typeandinfo->choice.sib9, sizeof(SystemInformationBlockType9_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB9 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
+
+        break;
+
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&512) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=512;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib10[eNB_index], &typeandinfo->choice.sib10, sizeof(SystemInformationBlockType10_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB10 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
 
+        break;
+
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&1024) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=1024;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib11[eNB_index], &typeandinfo->choice.sib11, sizeof(SystemInformationBlockType11_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB11 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
+
+        break;
 #if defined(Rel10) || defined(Rel14)
 
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&2048) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=2048;
-	new_sib=1;
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib12[eNB_index], &typeandinfo->choice.sib12_v920, sizeof(SystemInformationBlockType12_r9_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB12 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-      }
-      break;
-	
-    case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920:
-      if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4096) == 0) {
-	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4096;
-	new_sib=1;
-	
-	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index], &typeandinfo->choice.sib13_v920, sizeof(SystemInformationBlockType13_r9_t) );
-	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB13 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
-	dump_sib13( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] );
-	// adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer
-	LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB13 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
-	       ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id);
-	rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
-			      (RadioResourceConfigCommonSIB_t *)NULL,
-			      (struct PhysicalConfigDedicated *)NULL,
-			      (SCellToAddMod_r10_t *)NULL,
-			      (MeasObjectToAddMod_t **)NULL,
-			      (MAC_MainConfig_t *)NULL,
-			      0,
-			      (struct LogicalChannelConfig *)NULL,
-			      (MeasGapConfig_t *)NULL,
-			      (TDD_Config_t *)NULL,
-			      (MobilityControlInfo_t *)NULL,
-			      NULL,
-			      NULL,
-			      NULL,
-			      NULL,
-			      NULL,
-			      (MBSFN_SubframeConfigList_t *)NULL,
-			      0,
-			      &UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index]->mbsfn_AreaInfoList_r9,
-			      (PMCH_InfoList_r9_t *)NULL
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&2048) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=2048;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib12[eNB_index], &typeandinfo->choice.sib12_v920, sizeof(SystemInformationBlockType12_r9_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB12 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+        }
+
+        break;
+
+      case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920:
+        if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4096) == 0) {
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4096;
+          new_sib=1;
+          memcpy( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index], &typeandinfo->choice.sib13_v920, sizeof(SystemInformationBlockType13_r9_t) );
+          LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB13 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
+          dump_sib13( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] );
+          // adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer
+          LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB13 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
+                 ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id);
+          rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
+                                (RadioResourceConfigCommonSIB_t *)NULL,
+                                (struct PhysicalConfigDedicated *)NULL,
+                                (SCellToAddMod_r10_t *)NULL,
+                                (MeasObjectToAddMod_t **)NULL,
+                                (MAC_MainConfig_t *)NULL,
+                                0,
+                                (struct LogicalChannelConfig *)NULL,
+                                (MeasGapConfig_t *)NULL,
+                                (TDD_Config_t *)NULL,
+                                (MobilityControlInfo_t *)NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                NULL,
+                                (MBSFN_SubframeConfigList_t *)NULL,
+                                0,
+                                &UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index]->mbsfn_AreaInfoList_r9,
+                                (PMCH_InfoList_r9_t *)NULL
 #ifdef CBA
-			      ,0,
-			      0
+                                ,0,
+                                0
 #endif
-			      );
-	break;
-      }
+                               );
+          break;
+        }
+
 #endif
-    default:
-      break;
-    }
 
+      default:
+        break;
+    }
   }
+
   if (new_sib == 1) {
     UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt++;
 
     if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt == sib1->schedulingInfoList.list.count)
       rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE );
 
-    LOG_I(RRC,"SIStatus %x, SIcnt %d/%d\n", 
-	  UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus,
-	  UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt,
-	  sib1->schedulingInfoList.list.count);
+    LOG_I(RRC,"SIStatus %x, SIcnt %d/%d\n",
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus,
+          UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt,
+          sib1->schedulingInfoList.list.count);
   }
 
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI  , VCD_FUNCTION_OUT);
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_OUT);
   return 0;
 }
 
 // layer 3 filtering of RSRP (EUTRA) measurements: 36.331, Sec. 5.5.3.2
 //-----------------------------------------------------------------------------
-void ue_meas_filtering( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
+void ue_meas_filtering( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index )
 {
   float a  = UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp; // 'a' in 36.331 Sec. 5.5.3.2
   float a1 = UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrq;
@@ -3837,18 +3714,17 @@ void ue_meas_filtering( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
       if(UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP != NULL) {
         for (eNB_offset = 0; eNB_offset<1+get_n_adj_cells(ctxt_pP->module_id,0); eNB_offset++) {
           UE_rrc_inst[ctxt_pP->module_id].rsrp_db[eNB_offset] = get_RSRP(ctxt_pP->module_id,0,eNB_offset);
-	  /*
-	  (dB_fixed_times10(get_RSRP(ctxt_pP->module_id,0,eNB_offset))/10.0) -
-	  get_rx_total_gain_dB(ctxt_pP->module_id,0) -
-	  get_bw_gain_dB(ctxt_pP->module_id);
-	  */
+          /*
+          (dB_fixed_times10(get_RSRP(ctxt_pP->module_id,0,eNB_offset))/10.0) -
+          get_rx_total_gain_dB(ctxt_pP->module_id,0) -
+          get_bw_gain_dB(ctxt_pP->module_id);
+          */
           UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_offset] =
             (1.0-a)*UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_offset] +
             a*UE_rrc_inst[ctxt_pP->module_id].rsrp_db[eNB_offset];
-
           LOG_D(RRC,"RSRP_dBm: %3.2f \n",get_RSRP(ctxt_pP->module_id,0,eNB_offset));;
-	  /*          LOG_D(RRC,"gain_loss_dB: %d \n",get_rx_total_gain_dB(ctxt_pP->module_id,0));
-		      LOG_D(RRC,"gain_fixed_dB: %d \n",dB_fixed(frame_parms->N_RB_DL*12));*/
+          /*          LOG_D(RRC,"gain_loss_dB: %d \n",get_rx_total_gain_dB(ctxt_pP->module_id,0));
+                LOG_D(RRC,"gain_fixed_dB: %d \n",dB_fixed(frame_parms->N_RB_DL*12));*/
           LOG_D(PHY,"[UE %d] Frame %d, RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB)\n",
                 ctxt_pP->module_id,
                 ctxt_pP->frame,
@@ -3886,9 +3762,8 @@ void ue_meas_filtering( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
 
 //Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5
 //-----------------------------------------------------------------------------
-static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, uint8_t eNB_index )
+static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index )
 {
-
   uint8_t             buffer[32], size;
   uint8_t             i;
   uint8_t             target_eNB_offset;
@@ -3900,7 +3775,6 @@ static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, ui
   float            rsrp_filtered, rsrq_filtered;
   static frame_t   pframe=0;
   int              result;
-
   nElem = 98;
   nElem1 = 35;
   target_eNB_offset = UE_rrc_inst[ctxt_pP->module_id].Info[0].handoverTarget; // eNB_offset of target eNB: used to obtain the mod_id of target eNB
@@ -3908,14 +3782,11 @@ static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, ui
   for (i=0; i<MAX_MEAS_ID; i++) {
     if (UE_rrc_inst[ctxt_pP->module_id].measReportList[0][i] != NULL) {
       measId = UE_rrc_inst[ctxt_pP->module_id].measReportList[0][i]->measId;
-
       // Note: Values in the meas report have to be the mapped values...to implement binary search for LUT
       rsrp_filtered = UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_index];//nid_cell];
       rsrp_s = binary_search_float(RSRP_meas_mapping,nElem, rsrp_filtered);
-
       rsrq_filtered = UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[eNB_index];//nid_cell]; //RSRQ of serving cell
       rsrq_s = binary_search_float(RSRQ_meas_mapping,nElem1,rsrq_filtered);//mapped RSRQ of serving cell
-
       LOG_D(RRC,"[UE %d] Frame %d: source eNB %d :rsrp_s: %ld rsrq_s: %ld rsrp_filtered: %f rsrq_filtered: %f \n",
             ctxt_pP->module_id,
             ctxt_pP->frame,
@@ -3926,7 +3797,6 @@ static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, ui
             rsrq_filtered);
       rsrp_t = binary_search_float(RSRP_meas_mapping,nElem,UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[target_eNB_offset]); //RSRP of target cell
       rsrq_t = binary_search_float(RSRQ_meas_mapping,nElem1,UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[target_eNB_offset]); //RSRQ of target cell
-
       LOG_D(RRC,"[UE %d] Frame %d: target eNB %d :rsrp_t: %ld rsrq_t: %ld rsrp_filtered: %f rsrq_filtered: %f \n",
             ctxt_pP->module_id,
             ctxt_pP->frame,
@@ -3935,7 +3805,6 @@ static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, ui
             rsrq_t,
             UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[target_eNB_offset],
             UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[target_eNB_offset]);
-
       //  if (measFlag == 1) {
       cellId = get_adjacent_cell_id(ctxt_pP->module_id, eNB_index); //PhycellId of serving cell
       targetCellId = UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId ;//get_adjacent_cell_id(ue_mod_idP,target_eNB_offset); //PhycellId of target cell
@@ -3967,7 +3836,7 @@ static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, ui
 
 // Measurement report triggering, described in 36.331 Section 5.5.4.1: called periodically
 //-----------------------------------------------------------------------------
-void ue_measurement_report_triggering(protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
+void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index )
 {
   uint8_t               i,j;
   Hysteresis_t     hys;
@@ -4009,65 +3878,65 @@ void ue_measurement_report_triggering(protocol_ctxt_t* const ctxt_pP, const uint
                           -1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset;
 
               switch (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present) {
-              case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA1:
-                LOG_D(RRC,"[UE %d] Frame %d : A1 event: check if serving becomes better than threshold\n",
-                      ctxt_pP->module_id, ctxt_pP->frame);
-                break;
-
-              case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA2:
-                LOG_D(RRC,"[UE %d] Frame %d : A2 event, check if serving becomes worse than a threshold\n",
-                      ctxt_pP->module_id, ctxt_pP->frame);
-                break;
-
-              case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3:
-                LOG_D(RRC,"[UE %d] Frame %d : A3 event: check if a neighboring cell becomes offset better than serving to trigger a measurement event \n",
-                      ctxt_pP->module_id, ctxt_pP->frame);
-
-                if ((check_trigger_meas_event(
-                       ctxt_pP->module_id,
-                       ctxt_pP->frame,
-                       eNB_index,
-                       i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)) &&
-                    (UE_rrc_inst[ctxt_pP->module_id].Info[0].State >= RRC_CONNECTED) &&
-                    (UE_rrc_inst[ctxt_pP->module_id].Info[0].T304_active == 0 )      &&
-                    (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag == 1)) {
-                  //trigger measurement reporting procedure (36.331, section 5.5.5)
-                  if (UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] == NULL) {
-                    UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST));
-                  }
-
-                  UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->measId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->measId;
-                  UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->numberOfReportsSent = 0;
-                  rrc_ue_generate_MeasurementReport(
-                    ctxt_pP,
-                    eNB_index);
-                  UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1;
-                  LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n",
-                        ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[0].State);
-                } else {
-                  if(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] != NULL) {
-                    free(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]);
+                case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA1:
+                  LOG_D(RRC,"[UE %d] Frame %d : A1 event: check if serving becomes better than threshold\n",
+                        ctxt_pP->module_id, ctxt_pP->frame);
+                  break;
+
+                case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA2:
+                  LOG_D(RRC,"[UE %d] Frame %d : A2 event, check if serving becomes worse than a threshold\n",
+                        ctxt_pP->module_id, ctxt_pP->frame);
+                  break;
+
+                case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3:
+                  LOG_D(RRC,"[UE %d] Frame %d : A3 event: check if a neighboring cell becomes offset better than serving to trigger a measurement event \n",
+                        ctxt_pP->module_id, ctxt_pP->frame);
+
+                  if ((check_trigger_meas_event(
+                         ctxt_pP->module_id,
+                         ctxt_pP->frame,
+                         eNB_index,
+                         i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)) &&
+                      (UE_rrc_inst[ctxt_pP->module_id].Info[0].State >= RRC_CONNECTED) &&
+                      (UE_rrc_inst[ctxt_pP->module_id].Info[0].T304_active == 0 )      &&
+                      (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag == 1)) {
+                    //trigger measurement reporting procedure (36.331, section 5.5.5)
+                    if (UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] == NULL) {
+                      UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST));
+                    }
+
+                    UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->measId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->measId;
+                    UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->numberOfReportsSent = 0;
+                    rrc_ue_generate_MeasurementReport(
+                      ctxt_pP,
+                      eNB_index);
+                    UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1;
+                    LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n",
+                          ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[0].State);
+                  } else {
+                    if(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] != NULL) {
+                      free(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]);
+                    }
+
+                    UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = NULL;
                   }
 
-                  UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = NULL;
-                }
+                  break;
 
-                break;
+                case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA4:
+                  LOG_D(RRC,"[UE %d] Frame %d : received an A4 event, neighbor becomes offset better than a threshold\n",
+                        ctxt_pP->module_id, ctxt_pP->frame);
+                  break;
 
-              case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA4:
-                LOG_D(RRC,"[UE %d] Frame %d : received an A4 event, neighbor becomes offset better than a threshold\n",
-                      ctxt_pP->module_id, ctxt_pP->frame);
-                break;
-
-              case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA5:
-                LOG_D(RRC,"[UE %d] Frame %d: received an A5 event, serving becomes worse than threshold 1 and neighbor becomes better than threshold 2\n",
-                      ctxt_pP->module_id, ctxt_pP->frame);
-                break;
+                case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA5:
+                  LOG_D(RRC,"[UE %d] Frame %d: received an A5 event, serving becomes worse than threshold 1 and neighbor becomes better than threshold 2\n",
+                        ctxt_pP->module_id, ctxt_pP->frame);
+                  break;
 
-              default:
-                LOG_D(RRC,"Invalid ReportConfigEUTRA__triggerType__event__eventId: %d",
-                      UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present);
-                break;
+                default:
+                  LOG_D(RRC,"Invalid ReportConfigEUTRA__triggerType__event__eventId: %d",
+                        UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present);
+                  break;
               }
             }
           }
@@ -4097,7 +3966,6 @@ static uint8_t check_trigger_meas_event(
   uint8_t eNB_offset;
   //  uint8_t currentCellIndex = frame_parms->Nid_cell;
   uint8_t tmp_offset;
-
   LOG_I(RRC,"[UE %d] ofn(%ld) ocn(%ld) hys(%ld) ofs(%ld) ocs(%ld) a3_offset(%ld) ttt(%ld) rssi %3.1f\n",
         ue_mod_idP,
         ofn,ocn,hys,ofs,ocs,a3_offset,ttt,
@@ -4127,8 +3995,8 @@ static uint8_t check_trigger_meas_event(
         LOG_D(RRC,"[UE %d] Frame %d eNB %d: Handover triggered: targetCellId: %ld currentCellId: %d eNB_offset: %d rsrp source: %3.1f rsrp target: %3.1f\n",
               ue_mod_idP, frameP, eNB_index,
               UE_rrc_inst->HandoverInfoUe.targetCellId,ue_cnx_index,eNB_offset,
-	      get_RSRP(ue_mod_idP,0,0),
-	      get_RSRP(ue_mod_idP,0,1));
+              get_RSRP(ue_mod_idP,0,0),
+              get_RSRP(ue_mod_idP,0,1));
         UE_rrc_inst->Info[0].handoverTarget = eNB_offset;
         //LOG_D(RRC,"PHY_ID: %d \n",UE_rrc_inst->HandoverInfoUe.targetCellId);
         return 1;
@@ -4145,12 +4013,10 @@ static uint8_t check_trigger_meas_event(
 
 #if defined(Rel10) || defined(Rel14)
 //-----------------------------------------------------------------------------
-int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t* const Sdu, const uint8_t Sdu_len, const uint8_t mbsfn_sync_area )
+int decode_MCCH_Message( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t *const Sdu, const uint8_t Sdu_len, const uint8_t mbsfn_sync_area )
 {
-
   MCCH_Message_t               *mcch=NULL;
-  MBSFNAreaConfiguration_r9_t** mcch_message=&UE_rrc_inst[ctxt_pP->module_id].mcch_message[eNB_index];
-
+  MBSFNAreaConfiguration_r9_t **mcch_message=&UE_rrc_inst[ctxt_pP->module_id].mcch_message[eNB_index];
   asn_dec_rval_t                dec_rval;
 
   if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].MCCHStatus[mbsfn_sync_area] == 1) {
@@ -4171,12 +4037,12 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB
             ctxt_pP->module_id,
             dec_rval.consumed);
       //free the memory
-      SEQUENCE_free(&asn_DEF_MCCH_Message, (void*)mcch, 1);
+      SEQUENCE_free(&asn_DEF_MCCH_Message, (void *)mcch, 1);
       return -1;
     }
 
 #ifdef XER_PRINT
-    xer_fprint(stdout, &asn_DEF_MCCH_Message, (void*)mcch);
+    xer_fprint(stdout, &asn_DEF_MCCH_Message, (void *)mcch);
 #endif
 
     if (mcch->message.present == MCCH_MessageType_PR_c1) {
@@ -4198,7 +4064,6 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB
           eNB_index,
           ctxt_pP->frame,
           mbsfn_sync_area);
-
       }
     }
   }
@@ -4210,54 +4075,48 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB
 static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_index, frame_t frameP, uint8_t mbsfn_sync_area )
 {
   protocol_ctxt_t               ctxt;
-
   LOG_I(RRC,"[UE %d] Frame %d : Number of MCH(s) in the MBSFN Sync Area %d  is %d\n",
         ue_mod_idP, frameP, mbsfn_sync_area, UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9.list.count);
   //  store to MAC/PHY necessary parameters for receiving MTCHs
-
   rrc_mac_config_req_ue(ue_mod_idP,0,eNB_index,
-			(RadioResourceConfigCommonSIB_t *)NULL,
-			(struct PhysicalConfigDedicated *)NULL,
+                        (RadioResourceConfigCommonSIB_t *)NULL,
+                        (struct PhysicalConfigDedicated *)NULL,
 #if defined(Rel10) || defined(Rel14)
-			(SCellToAddMod_r10_t *)NULL,
-			//(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+                        (SCellToAddMod_r10_t *)NULL,
+                        //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-			(MeasObjectToAddMod_t **)NULL,
-			(MAC_MainConfig_t *)NULL,
-			0,
-			(struct LogicalChannelConfig *)NULL,
-			(MeasGapConfig_t *)NULL,
-			(TDD_Config_t *)NULL,
-			(MobilityControlInfo_t *)NULL,
-			NULL,
-			NULL,
-			NULL,
-			NULL,
-			NULL,
-			(MBSFN_SubframeConfigList_t *)NULL
+                        (MeasObjectToAddMod_t **)NULL,
+                        (MAC_MainConfig_t *)NULL,
+                        0,
+                        (struct LogicalChannelConfig *)NULL,
+                        (MeasGapConfig_t *)NULL,
+                        (TDD_Config_t *)NULL,
+                        (MobilityControlInfo_t *)NULL,
+                        NULL,
+                        NULL,
+                        NULL,
+                        NULL,
+                        NULL,
+                        (MBSFN_SubframeConfigList_t *)NULL
 #if defined(Rel10) || defined(Rel14)
-			,
-			0,
-			(MBSFN_AreaInfoList_r9_t *)NULL,
-			&UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9
-
+                        ,
+                        0,
+                        (MBSFN_AreaInfoList_r9_t *)NULL,
+                        &UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9
 #endif
 #ifdef CBA
-			,
-			0,
-			0
+                        ,
+                        0,
+                        0
 #endif
-			);
-  
+                       );
   UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[mbsfn_sync_area] = 1;
-
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_idP, ENB_FLAG_NO, UE_rrc_inst[ue_mod_idP].Info[eNB_index].rnti, frameP, 0,eNB_index);
-
   // Config Radio Bearer for MBMS user data (similar way to configure for eNB side in init_MBMS function)
   rrc_pdcp_config_asn1_req(&ctxt,
                            NULL, // SRB_ToAddModList
                            NULL, // DRB_ToAddModList
-                           (DRB_ToReleaseList_t*)NULL,
+                           (DRB_ToReleaseList_t *)NULL,
                            0, // security mode
                            NULL, // key rrc encryption
                            NULL, // key rrc integrity
@@ -4266,7 +4125,6 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i
                            ,&(UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9)
 #endif
                            ,NULL);
-
   rrc_rlc_config_asn1_req(&ctxt,
                           NULL,// SRB_ToAddModList
                           NULL,// DRB_ToAddModList
@@ -4276,7 +4134,6 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i
 #endif
                          );
   // */
-
 }
 
 #endif // rel10
@@ -4291,467 +4148,424 @@ void *rrc_ue_task( void *args_p )
   unsigned int  ue_mod_id;
   int           result;
   SRB_INFO     *srb_info_p;
-
   protocol_ctxt_t  ctxt;
   itti_mark_task_ready (TASK_RRC_UE);
 
   while(1) {
     // Wait for a message
     itti_receive_msg (TASK_RRC_UE, &msg_p);
-
     msg_name = ITTI_MSG_NAME (msg_p);
     instance = ITTI_MSG_INSTANCE (msg_p);
     ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance);
 
     switch (ITTI_MSG_ID(msg_p)) {
-    case TERMINATE_MESSAGE:
-      LOG_W(RRC, " *** Exiting RRC thread\n");
-      itti_exit_task ();
-      break;
+      case TERMINATE_MESSAGE:
+        LOG_W(RRC, " *** Exiting RRC thread\n");
+        itti_exit_task ();
+        break;
 
-    case MESSAGE_TEST:
-      LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, msg_name);
-      break;
+      case MESSAGE_TEST:
+        LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, msg_name);
+        break;
 
       /* MAC messages */
-    case RRC_MAC_IN_SYNC_IND:
-      LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name,
-            RRC_MAC_IN_SYNC_IND (msg_p).frame, RRC_MAC_IN_SYNC_IND (msg_p).enb_index);
-
-      UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N310_cnt = 0;
-
-      if (UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].T310_active == 1) {
-        UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N311_cnt++;
-      }
+      case RRC_MAC_IN_SYNC_IND:
+        LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name,
+              RRC_MAC_IN_SYNC_IND (msg_p).frame, RRC_MAC_IN_SYNC_IND (msg_p).enb_index);
+        UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N310_cnt = 0;
 
-      break;
-
-    case RRC_MAC_OUT_OF_SYNC_IND:
-      LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name,
-            RRC_MAC_OUT_OF_SYNC_IND (msg_p).frame, RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index);
-
-      UE_rrc_inst[ue_mod_id].Info[RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index].N310_cnt ++;
-      break;
+        if (UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].T310_active == 1) {
+          UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N311_cnt++;
+        }
 
-    case RRC_MAC_BCCH_DATA_IND:
-      LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name,
-            RRC_MAC_BCCH_DATA_IND (msg_p).frame, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index);
-
-      //      PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0);
-      PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, NOT_A_RNTI, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,RRC_MAC_BCCH_DATA_IND (msg_p).enb_index);
-      decode_BCCH_DLSCH_Message (&ctxt,
-                                 RRC_MAC_BCCH_DATA_IND (msg_p).enb_index,
-                                 RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
-                                 RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size,
-                                 RRC_MAC_BCCH_DATA_IND (msg_p).rsrq,
-                                 RRC_MAC_BCCH_DATA_IND (msg_p).rsrp);
-      break;
+        break;
 
-    case RRC_MAC_CCCH_DATA_CNF:
-      LOG_D(RRC, "[UE %d] Received %s: eNB %d\n", ue_mod_id, msg_name,
-            RRC_MAC_CCCH_DATA_CNF (msg_p).enb_index);
+      case RRC_MAC_OUT_OF_SYNC_IND:
+        LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name,
+              RRC_MAC_OUT_OF_SYNC_IND (msg_p).frame, RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index);
+        UE_rrc_inst[ue_mod_id].Info[RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index].N310_cnt ++;
+        break;
 
-      // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds)
-      UE_rrc_inst[ue_mod_id].Srb0[RRC_MAC_CCCH_DATA_CNF (msg_p).enb_index].Tx_buffer.payload_size = 0;
-      break;
+      case RRC_MAC_BCCH_DATA_IND:
+        LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name,
+              RRC_MAC_BCCH_DATA_IND (msg_p).frame, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index);
+        //      PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0);
+        PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, NOT_A_RNTI, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,RRC_MAC_BCCH_DATA_IND (msg_p).enb_index);
+        decode_BCCH_DLSCH_Message (&ctxt,
+                                   RRC_MAC_BCCH_DATA_IND (msg_p).enb_index,
+                                   RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
+                                   RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size,
+                                   RRC_MAC_BCCH_DATA_IND (msg_p).rsrq,
+                                   RRC_MAC_BCCH_DATA_IND (msg_p).rsrp);
+        break;
 
-    case RRC_MAC_CCCH_DATA_IND:
-      LOG_D(RRC, "[UE %d] RNTI %x Received %s: frameP %d, eNB %d\n",
-            ue_mod_id,
-            RRC_MAC_CCCH_DATA_IND (msg_p).rnti,
-            msg_name,
-            RRC_MAC_CCCH_DATA_IND (msg_p).frame,
-            RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
-
-      srb_info_p = &UE_rrc_inst[ue_mod_id].Srb0[RRC_MAC_CCCH_DATA_IND (msg_p).enb_index];
-
-      memcpy (srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND (msg_p).sdu,
-              RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size);
-      srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size;
-      //      PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, RRC_MAC_CCCH_DATA_IND (msg_p).rnti, RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0);
-      PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, RRC_MAC_CCCH_DATA_IND (msg_p).rnti, RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
-      rrc_ue_decode_ccch (&ctxt,
-                          srb_info_p,
-                          RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
-      break;
+      case RRC_MAC_CCCH_DATA_CNF:
+        LOG_D(RRC, "[UE %d] Received %s: eNB %d\n", ue_mod_id, msg_name,
+              RRC_MAC_CCCH_DATA_CNF (msg_p).enb_index);
+        // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds)
+        UE_rrc_inst[ue_mod_id].Srb0[RRC_MAC_CCCH_DATA_CNF (msg_p).enb_index].Tx_buffer.payload_size = 0;
+        break;
 
+      case RRC_MAC_CCCH_DATA_IND:
+        LOG_D(RRC, "[UE %d] RNTI %x Received %s: frameP %d, eNB %d\n",
+              ue_mod_id,
+              RRC_MAC_CCCH_DATA_IND (msg_p).rnti,
+              msg_name,
+              RRC_MAC_CCCH_DATA_IND (msg_p).frame,
+              RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
+        srb_info_p = &UE_rrc_inst[ue_mod_id].Srb0[RRC_MAC_CCCH_DATA_IND (msg_p).enb_index];
+        memcpy (srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND (msg_p).sdu,
+                RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size);
+        srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size;
+        //      PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, RRC_MAC_CCCH_DATA_IND (msg_p).rnti, RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0);
+        PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, RRC_MAC_CCCH_DATA_IND (msg_p).rnti, RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
+        rrc_ue_decode_ccch (&ctxt,
+                            srb_info_p,
+                            RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
+        break;
 # if defined(Rel10) || defined(Rel14)
 
-    case RRC_MAC_MCCH_DATA_IND:
-      LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d, mbsfn SA %d\n", ue_mod_id, msg_name,
-            RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
-
-      //PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, M_RNTI, RRC_MAC_MCCH_DATA_IND (msg_p).frame, 0);
-      PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, M_RNTI, RRC_MAC_MCCH_DATA_IND (msg_p).frame, 0,RRC_MAC_MCCH_DATA_IND (msg_p).enb_index);
-      decode_MCCH_Message (
-        &ctxt,
-        RRC_MAC_MCCH_DATA_IND (msg_p).enb_index,
-        RRC_MAC_MCCH_DATA_IND (msg_p).sdu,
-        RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size,
-        RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
-      break;
+      case RRC_MAC_MCCH_DATA_IND:
+        LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d, mbsfn SA %d\n", ue_mod_id, msg_name,
+              RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
+        //PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, M_RNTI, RRC_MAC_MCCH_DATA_IND (msg_p).frame, 0);
+        PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, M_RNTI, RRC_MAC_MCCH_DATA_IND (msg_p).frame, 0,RRC_MAC_MCCH_DATA_IND (msg_p).enb_index);
+        decode_MCCH_Message (
+          &ctxt,
+          RRC_MAC_MCCH_DATA_IND (msg_p).enb_index,
+          RRC_MAC_MCCH_DATA_IND (msg_p).sdu,
+          RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size,
+          RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
+        break;
 # endif
 
       /* PDCP messages */
-    case RRC_DCCH_DATA_IND:
-      PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, RRC_DCCH_DATA_IND (msg_p).module_id, ENB_FLAG_NO, RRC_DCCH_DATA_IND (msg_p).rnti, RRC_DCCH_DATA_IND (msg_p).frame, 0,RRC_DCCH_DATA_IND (msg_p).eNB_index);
-      LOG_D(RRC, "[UE %d] Received %s: frameP %d, DCCH %d, eNB %d\n",
-            RRC_DCCH_DATA_IND (msg_p).module_id,
-            msg_name,
-            RRC_DCCH_DATA_IND (msg_p).frame,
-            RRC_DCCH_DATA_IND (msg_p).dcch_index,
-            RRC_DCCH_DATA_IND (msg_p).eNB_index);
-
-      LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT"Received %s DCCH %d, eNB %d\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt),
-            msg_name,
-            RRC_DCCH_DATA_IND (msg_p).dcch_index,
-            RRC_DCCH_DATA_IND (msg_p).eNB_index);
-      rrc_ue_decode_dcch (
-        &ctxt,
-        RRC_DCCH_DATA_IND (msg_p).dcch_index,
-        RRC_DCCH_DATA_IND (msg_p).sdu_p,
-        RRC_DCCH_DATA_IND (msg_p).eNB_index);
-      // Message buffer has been processed, free it now.
-      result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND (msg_p).sdu_p);
-      AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
-      break;
-
+      case RRC_DCCH_DATA_IND:
+        PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, RRC_DCCH_DATA_IND (msg_p).module_id, ENB_FLAG_NO, RRC_DCCH_DATA_IND (msg_p).rnti, RRC_DCCH_DATA_IND (msg_p).frame, 0,RRC_DCCH_DATA_IND (msg_p).eNB_index);
+        LOG_D(RRC, "[UE %d] Received %s: frameP %d, DCCH %d, eNB %d\n",
+              RRC_DCCH_DATA_IND (msg_p).module_id,
+              msg_name,
+              RRC_DCCH_DATA_IND (msg_p).frame,
+              RRC_DCCH_DATA_IND (msg_p).dcch_index,
+              RRC_DCCH_DATA_IND (msg_p).eNB_index);
+        LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT"Received %s DCCH %d, eNB %d\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt),
+              msg_name,
+              RRC_DCCH_DATA_IND (msg_p).dcch_index,
+              RRC_DCCH_DATA_IND (msg_p).eNB_index);
+        rrc_ue_decode_dcch (
+          &ctxt,
+          RRC_DCCH_DATA_IND (msg_p).dcch_index,
+          RRC_DCCH_DATA_IND (msg_p).sdu_p,
+          RRC_DCCH_DATA_IND (msg_p).eNB_index);
+        // Message buffer has been processed, free it now.
+        result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND (msg_p).sdu_p);
+        AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+        break;
 # if defined(ENABLE_USE_MME)
 
-    case NAS_KENB_REFRESH_REQ:
-        memcpy((void*)UE_rrc_inst[ue_mod_id].kenb, (void*)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb));
-
+      case NAS_KENB_REFRESH_REQ:
+        memcpy((void *)UE_rrc_inst[ue_mod_id].kenb, (void *)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb));
         LOG_D(RRC, "[UE %d] Received %s: refreshed RRC::KeNB = "
-            "%02x%02x%02x%02x"
-            "%02x%02x%02x%02x"
-            "%02x%02x%02x%02x"
-            "%02x%02x%02x%02x"
-            "%02x%02x%02x%02x"
-            "%02x%02x%02x%02x"
-            "%02x%02x%02x%02x"
-            "%02x%02x%02x%02x\n",
-            ue_mod_id, msg_name,
-            UE_rrc_inst[ue_mod_id].kenb[0],  UE_rrc_inst[ue_mod_id].kenb[1],  UE_rrc_inst[ue_mod_id].kenb[2],  UE_rrc_inst[ue_mod_id].kenb[3],
-            UE_rrc_inst[ue_mod_id].kenb[4],  UE_rrc_inst[ue_mod_id].kenb[5],  UE_rrc_inst[ue_mod_id].kenb[6],  UE_rrc_inst[ue_mod_id].kenb[7],
-            UE_rrc_inst[ue_mod_id].kenb[8],  UE_rrc_inst[ue_mod_id].kenb[9],  UE_rrc_inst[ue_mod_id].kenb[10], UE_rrc_inst[ue_mod_id].kenb[11],
-            UE_rrc_inst[ue_mod_id].kenb[12], UE_rrc_inst[ue_mod_id].kenb[13], UE_rrc_inst[ue_mod_id].kenb[14], UE_rrc_inst[ue_mod_id].kenb[15],
-            UE_rrc_inst[ue_mod_id].kenb[16], UE_rrc_inst[ue_mod_id].kenb[17], UE_rrc_inst[ue_mod_id].kenb[18], UE_rrc_inst[ue_mod_id].kenb[19],
-            UE_rrc_inst[ue_mod_id].kenb[20], UE_rrc_inst[ue_mod_id].kenb[21], UE_rrc_inst[ue_mod_id].kenb[22], UE_rrc_inst[ue_mod_id].kenb[23],
-            UE_rrc_inst[ue_mod_id].kenb[24], UE_rrc_inst[ue_mod_id].kenb[25], UE_rrc_inst[ue_mod_id].kenb[26], UE_rrc_inst[ue_mod_id].kenb[27],
-            UE_rrc_inst[ue_mod_id].kenb[28], UE_rrc_inst[ue_mod_id].kenb[29], UE_rrc_inst[ue_mod_id].kenb[30], UE_rrc_inst[ue_mod_id].kenb[31]);
-
-      break;
+              "%02x%02x%02x%02x"
+              "%02x%02x%02x%02x"
+              "%02x%02x%02x%02x"
+              "%02x%02x%02x%02x"
+              "%02x%02x%02x%02x"
+              "%02x%02x%02x%02x"
+              "%02x%02x%02x%02x"
+              "%02x%02x%02x%02x\n",
+              ue_mod_id, msg_name,
+              UE_rrc_inst[ue_mod_id].kenb[0],  UE_rrc_inst[ue_mod_id].kenb[1],  UE_rrc_inst[ue_mod_id].kenb[2],  UE_rrc_inst[ue_mod_id].kenb[3],
+              UE_rrc_inst[ue_mod_id].kenb[4],  UE_rrc_inst[ue_mod_id].kenb[5],  UE_rrc_inst[ue_mod_id].kenb[6],  UE_rrc_inst[ue_mod_id].kenb[7],
+              UE_rrc_inst[ue_mod_id].kenb[8],  UE_rrc_inst[ue_mod_id].kenb[9],  UE_rrc_inst[ue_mod_id].kenb[10], UE_rrc_inst[ue_mod_id].kenb[11],
+              UE_rrc_inst[ue_mod_id].kenb[12], UE_rrc_inst[ue_mod_id].kenb[13], UE_rrc_inst[ue_mod_id].kenb[14], UE_rrc_inst[ue_mod_id].kenb[15],
+              UE_rrc_inst[ue_mod_id].kenb[16], UE_rrc_inst[ue_mod_id].kenb[17], UE_rrc_inst[ue_mod_id].kenb[18], UE_rrc_inst[ue_mod_id].kenb[19],
+              UE_rrc_inst[ue_mod_id].kenb[20], UE_rrc_inst[ue_mod_id].kenb[21], UE_rrc_inst[ue_mod_id].kenb[22], UE_rrc_inst[ue_mod_id].kenb[23],
+              UE_rrc_inst[ue_mod_id].kenb[24], UE_rrc_inst[ue_mod_id].kenb[25], UE_rrc_inst[ue_mod_id].kenb[26], UE_rrc_inst[ue_mod_id].kenb[27],
+              UE_rrc_inst[ue_mod_id].kenb[28], UE_rrc_inst[ue_mod_id].kenb[29], UE_rrc_inst[ue_mod_id].kenb[30], UE_rrc_inst[ue_mod_id].kenb[31]);
+        break;
 
       /* NAS messages */
-    case NAS_CELL_SELECTION_REQ:
-
-      LOG_D(RRC, "[UE %d] Received %s: state %d, plmnID (%d%d%d.%d%d%d), rat %x\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id),
-            NAS_CELL_SELECTION_REQ (msg_p).plmnID.MCCdigit1,
-            NAS_CELL_SELECTION_REQ (msg_p).plmnID.MCCdigit2,
-            NAS_CELL_SELECTION_REQ (msg_p).plmnID.MCCdigit3,
-            NAS_CELL_SELECTION_REQ (msg_p).plmnID.MNCdigit1,
-            NAS_CELL_SELECTION_REQ (msg_p).plmnID.MNCdigit2,
-            NAS_CELL_SELECTION_REQ (msg_p).plmnID.MNCdigit3,
-            NAS_CELL_SELECTION_REQ (msg_p).rat);
-
-      if (rrc_get_state(ue_mod_id) == RRC_STATE_INACTIVE) {
-        // have a look at MAC/main.c void dl_phy_sync_success(...)
-        openair_rrc_ue_init(ue_mod_id,0);
-      }
-
-      /* Save cell selection criterion */
-      {
-        UE_rrc_inst[ue_mod_id].plmnID = NAS_CELL_SELECTION_REQ (msg_p).plmnID;
-        UE_rrc_inst[ue_mod_id].rat = NAS_CELL_SELECTION_REQ (msg_p).rat;
-        LOG_D(RRC, "[UE %d] Save cell selection criterion MCC %X%X%X MNC %X%X%X\n",
-              ue_mod_id,
-              UE_rrc_inst[ue_mod_id].plmnID.MCCdigit1,
-              UE_rrc_inst[ue_mod_id].plmnID.MCCdigit2,
-              UE_rrc_inst[ue_mod_id].plmnID.MCCdigit3,
-              UE_rrc_inst[ue_mod_id].plmnID.MNCdigit1,
-              UE_rrc_inst[ue_mod_id].plmnID.MNCdigit2,
-              UE_rrc_inst[ue_mod_id].plmnID.MNCdigit3);
-
-      }
-
-      switch (rrc_get_state(ue_mod_id)) {
-      case RRC_STATE_INACTIVE: {
-        /* Need to first activate lower layers */
-        MessageDef *message_p;
-
-        message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE);
-
-        itti_send_msg_to_task(TASK_L2L1, UE_MODULE_ID_TO_INSTANCE(ue_mod_id), message_p);
+      case NAS_CELL_SELECTION_REQ:
+        LOG_D(RRC, "[UE %d] Received %s: state %d, plmnID (%d%d%d.%d%d%d), rat %x\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id),
+              NAS_CELL_SELECTION_REQ (msg_p).plmnID.MCCdigit1,
+              NAS_CELL_SELECTION_REQ (msg_p).plmnID.MCCdigit2,
+              NAS_CELL_SELECTION_REQ (msg_p).plmnID.MCCdigit3,
+              NAS_CELL_SELECTION_REQ (msg_p).plmnID.MNCdigit1,
+              NAS_CELL_SELECTION_REQ (msg_p).plmnID.MNCdigit2,
+              NAS_CELL_SELECTION_REQ (msg_p).plmnID.MNCdigit3,
+              NAS_CELL_SELECTION_REQ (msg_p).rat);
+
+        if (rrc_get_state(ue_mod_id) == RRC_STATE_INACTIVE) {
+          // have a look at MAC/main.c void dl_phy_sync_success(...)
+          openair_rrc_ue_init(ue_mod_id,0);
+        }
 
-        rrc_set_state (ue_mod_id, RRC_STATE_IDLE);
-        /* Fall through to next case */
-      }
+        /* Save cell selection criterion */
+        {
+          UE_rrc_inst[ue_mod_id].plmnID = NAS_CELL_SELECTION_REQ (msg_p).plmnID;
+          UE_rrc_inst[ue_mod_id].rat = NAS_CELL_SELECTION_REQ (msg_p).rat;
+          LOG_D(RRC, "[UE %d] Save cell selection criterion MCC %X%X%X MNC %X%X%X\n",
+                ue_mod_id,
+                UE_rrc_inst[ue_mod_id].plmnID.MCCdigit1,
+                UE_rrc_inst[ue_mod_id].plmnID.MCCdigit2,
+                UE_rrc_inst[ue_mod_id].plmnID.MCCdigit3,
+                UE_rrc_inst[ue_mod_id].plmnID.MNCdigit1,
+                UE_rrc_inst[ue_mod_id].plmnID.MNCdigit2,
+                UE_rrc_inst[ue_mod_id].plmnID.MNCdigit3);
+        }
 
-      case RRC_STATE_IDLE: {
-        /* Ask to layer 1 to find a cell matching the criterion */
-        MessageDef *message_p;
+        switch (rrc_get_state(ue_mod_id)) {
+          case RRC_STATE_INACTIVE: {
+            /* Need to first activate lower layers */
+            MessageDef *message_p;
+            message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE);
+            itti_send_msg_to_task(TASK_L2L1, UE_MODULE_ID_TO_INSTANCE(ue_mod_id), message_p);
+            rrc_set_state (ue_mod_id, RRC_STATE_IDLE);
+            /* Fall through to next case */
+          }
 
-        message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ);
+          case RRC_STATE_IDLE: {
+            /* Ask to layer 1 to find a cell matching the criterion */
+            MessageDef *message_p;
+            message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ);
+            PHY_FIND_CELL_REQ (message_p).earfcn_start = 1;
+            PHY_FIND_CELL_REQ (message_p).earfcn_end = 1;
+            itti_send_msg_to_task(TASK_PHY_UE, UE_MODULE_ID_TO_INSTANCE(ue_mod_id), message_p);
+            rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_SEARCHING);
+            break;
+          }
 
-        PHY_FIND_CELL_REQ (message_p).earfcn_start = 1;
-        PHY_FIND_CELL_REQ (message_p).earfcn_end = 1;
+          case RRC_STATE_CONNECTED:
+            /* should not happen */
+            LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
+            break;
 
-        itti_send_msg_to_task(TASK_PHY_UE, UE_MODULE_ID_TO_INSTANCE(ue_mod_id), message_p);
-        rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_SEARCHING);
+          default:
+            LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
+            break;
+        }
 
         break;
-      }
 
-      case RRC_STATE_CONNECTED:
-        /* should not happen */
-        LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
-        break;
+      case NAS_CONN_ESTABLI_REQ:
+        LOG_D(RRC, "[UE %d] Received %s: cause %d, type %d, s_tmsi (mme code %"PRIu8", m-tmsi %"PRIu32"), plmnID (%d%d%d.%d%d%d)\n", ue_mod_id, msg_name, NAS_CONN_ESTABLI_REQ (msg_p).cause,
+              NAS_CONN_ESTABLI_REQ (msg_p).type,
+              NAS_CONN_ESTABLI_REQ (msg_p).s_tmsi.MMEcode,
+              NAS_CONN_ESTABLI_REQ (msg_p).s_tmsi.m_tmsi,
+              NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MCCdigit1,
+              NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MCCdigit2,
+              NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MCCdigit3,
+              NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MNCdigit1,
+              NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MNCdigit2,
+              NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MNCdigit3);
+        //PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, 0, 0);
+        PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, NOT_A_RNTI, 0, 0, 0);
+        UE_rrc_inst[ue_mod_id].initialNasMsg = NAS_CONN_ESTABLI_REQ (msg_p).initialNasMsg;
+
+        switch (rrc_get_state(ue_mod_id)) {
+          case RRC_STATE_IDLE: {
+            if (rrc_get_sub_state(ue_mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) {
+              rrc_ue_generate_RRCConnectionRequest(&ctxt, 0);
+              LOG_D(RRC, "not sending connection request\n");
+              rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_CONNECTING);
+            }
 
-      default:
-        LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
-        break;
-      }
+            break;
+          }
 
-      break;
+          case RRC_STATE_INACTIVE:
+          case RRC_STATE_CONNECTED:
+            /* should not happen */
+            LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
+            break;
 
-    case NAS_CONN_ESTABLI_REQ:
-      LOG_D(RRC, "[UE %d] Received %s: cause %d, type %d, s_tmsi (mme code %"PRIu8", m-tmsi %"PRIu32"), plmnID (%d%d%d.%d%d%d)\n", ue_mod_id, msg_name, NAS_CONN_ESTABLI_REQ (msg_p).cause,
-            NAS_CONN_ESTABLI_REQ (msg_p).type,
-            NAS_CONN_ESTABLI_REQ (msg_p).s_tmsi.MMEcode,
-            NAS_CONN_ESTABLI_REQ (msg_p).s_tmsi.m_tmsi,
-            NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MCCdigit1,
-            NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MCCdigit2,
-            NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MCCdigit3,
-            NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MNCdigit1,
-            NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MNCdigit2,
-            NAS_CONN_ESTABLI_REQ (msg_p).plmnID.MNCdigit3);
-
-      //PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, 0, 0);
-      PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, NOT_A_RNTI, 0, 0, 0);
-
-      UE_rrc_inst[ue_mod_id].initialNasMsg = NAS_CONN_ESTABLI_REQ (msg_p).initialNasMsg;
-
-      switch (rrc_get_state(ue_mod_id)) {
-      case RRC_STATE_IDLE: {
-        if (rrc_get_sub_state(ue_mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) {
-          rrc_ue_generate_RRCConnectionRequest(&ctxt, 0);
-          LOG_D(RRC, "not sending connection request\n");
-
-          rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_CONNECTING);
+          default:
+            LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
+            break;
         }
 
         break;
-      }
 
-      case RRC_STATE_INACTIVE:
-      case RRC_STATE_CONNECTED:
-        /* should not happen */
-        LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
-        break;
+      case NAS_UPLINK_DATA_REQ: {
+        uint32_t length;
+        uint8_t *buffer;
+        LOG_D(RRC, "[UE %d] Received %s: UEid %d\n", ue_mod_id, msg_name, NAS_UPLINK_DATA_REQ (msg_p).UEid);
+        /* Create message for PDCP (ULInformationTransfer_t) */
+        length = do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data);
+        /* Transfer data to PDCP */
+        PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0,0);
+
+        // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2)
+        if(UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL)
+        {
+          rrc_data_req_ue (&ctxt,
+                           DCCH,
+                           rrc_mui++,
+                           SDU_CONFIRM_NO,
+                           length, buffer,
+                           PDCP_TRANSMISSION_MODE_CONTROL);
+        }
+        else
+        {
+          rrc_data_req_ue (&ctxt,
+                           DCCH1,
+                           rrc_mui++,
+                           SDU_CONFIRM_NO,
+                           length, buffer,
+                           PDCP_TRANSMISSION_MODE_CONTROL);
+        }
 
-      default:
-        LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
         break;
       }
 
-      break;
-
-    case NAS_UPLINK_DATA_REQ: {
-      uint32_t length;
-      uint8_t *buffer;
-
-      LOG_D(RRC, "[UE %d] Received %s: UEid %d\n", ue_mod_id, msg_name, NAS_UPLINK_DATA_REQ (msg_p).UEid);
-
-      /* Create message for PDCP (ULInformationTransfer_t) */
-      length = do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data);
-
-      /* Transfer data to PDCP */
-      PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0,0);
-
-      // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) 
-      if(UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL)
-      {
-          rrc_data_req_ue (&ctxt,
-                  DCCH,
-                  rrc_mui++,
-                  SDU_CONFIRM_NO,
-                  length, buffer,
-                  PDCP_TRANSMISSION_MODE_CONTROL);
-      }
-      else
-      {
-          rrc_data_req_ue (&ctxt,
-                  DCCH1,
-                  rrc_mui++,
-                  SDU_CONFIRM_NO,
-                  length, buffer,
-                  PDCP_TRANSMISSION_MODE_CONTROL);
-      }
-      break;
-    }
-      
 # endif
-
 # if ENABLE_RAL
 
-    case RRC_RAL_SCAN_REQ:
-      LOG_D(RRC, "[UE %d] Received %s: state %d\n", ue_mod_id, msg_name);
-
-      switch (rrc_get_state(ue_mod_id)) {
-      case RRC_STATE_INACTIVE: {
-        /* Need to first activate lower layers */
-        MessageDef *message_p;
-
-        message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE);
-
-        itti_send_msg_to_task(TASK_L2L1, instance, message_p);
-
-        rrc_set_state (ue_mod_id, RRC_STATE_IDLE);
-        /* Fall through to next case */
-      }
-
-      case RRC_STATE_IDLE: {
-        if (rrc_get_sub_state(ue_mod_id) != RRC_SUB_STATE_IDLE_SEARCHING) {
-          /* Ask to layer 1 to find a cell matching the criterion */
-          MessageDef *message_p;
+      case RRC_RAL_SCAN_REQ:
+        LOG_D(RRC, "[UE %d] Received %s: state %d\n", ue_mod_id, msg_name);
+
+        switch (rrc_get_state(ue_mod_id)) {
+          case RRC_STATE_INACTIVE: {
+            /* Need to first activate lower layers */
+            MessageDef *message_p;
+            message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE);
+            itti_send_msg_to_task(TASK_L2L1, instance, message_p);
+            rrc_set_state (ue_mod_id, RRC_STATE_IDLE);
+            /* Fall through to next case */
+          }
 
-          message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ);
+          case RRC_STATE_IDLE: {
+            if (rrc_get_sub_state(ue_mod_id) != RRC_SUB_STATE_IDLE_SEARCHING) {
+              /* Ask to layer 1 to find a cell matching the criterion */
+              MessageDef *message_p;
+              message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ);
+              rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_SEARCHING);
+              PHY_FIND_CELL_REQ (message_p).transaction_id = RRC_RAL_SCAN_REQ (msg_p).transaction_id;
+              PHY_FIND_CELL_REQ (message_p).earfcn_start   = 1;
+              PHY_FIND_CELL_REQ (message_p).earfcn_end     = 1; //44
+              itti_send_msg_to_task(TASK_PHY_UE, instance, message_p);
+            }
 
-          rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_SEARCHING);
+            break;
+          }
 
-          PHY_FIND_CELL_REQ (message_p).transaction_id = RRC_RAL_SCAN_REQ (msg_p).transaction_id;
-          PHY_FIND_CELL_REQ (message_p).earfcn_start   = 1;
-          PHY_FIND_CELL_REQ (message_p).earfcn_end     = 1; //44
+          case RRC_STATE_CONNECTED:
+            /* should not happen */
+            LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
+            break;
 
-          itti_send_msg_to_task(TASK_PHY_UE, instance, message_p);
+          default:
+            LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
+            break;
         }
 
         break;
-      }
-
-      case RRC_STATE_CONNECTED:
-        /* should not happen */
-        LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
-        break;
-
-      default:
-        LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
-        break;
-      }
-
-      break;
 
-    case PHY_FIND_CELL_IND:
-      LOG_D(RRC, "[UE %d] Received %s: state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
-
-      switch (rrc_get_state(ue_mod_id)) {
-      case RRC_STATE_IDLE:
-        switch (rrc_get_sub_state(ue_mod_id)) {
-        case RRC_SUB_STATE_IDLE_SEARCHING: {
-          MessageDef *message_p;
-          int         i;
-
-          message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_SCAN_CONF);
-
-          RRC_RAL_SCAN_CONF (message_p).transaction_id = PHY_FIND_CELL_IND(msg_p).transaction_id;
-          RRC_RAL_SCAN_CONF (message_p).num_scan_resp  = PHY_FIND_CELL_IND(msg_p).cell_nb;
+      case PHY_FIND_CELL_IND:
+        LOG_D(RRC, "[UE %d] Received %s: state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
+
+        switch (rrc_get_state(ue_mod_id)) {
+          case RRC_STATE_IDLE:
+            switch (rrc_get_sub_state(ue_mod_id)) {
+              case RRC_SUB_STATE_IDLE_SEARCHING: {
+                MessageDef *message_p;
+                int         i;
+                message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_SCAN_CONF);
+                RRC_RAL_SCAN_CONF (message_p).transaction_id = PHY_FIND_CELL_IND(msg_p).transaction_id;
+                RRC_RAL_SCAN_CONF (message_p).num_scan_resp  = PHY_FIND_CELL_IND(msg_p).cell_nb;
+
+                for (i = 0 ; i < PHY_FIND_CELL_IND(msg_p).cell_nb; i++) {
+                  // TO DO
+                  memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].link_addr,  0, sizeof(ral_link_addr_t));
+                  // TO DO
+                  memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].network_id, 0, sizeof(ral_network_id_t));
+                  RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength.choice     = RAL_SIG_STRENGTH_CHOICE_DBM;
+                  RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength._union.dbm = PHY_FIND_CELL_IND(msg_p).cells[i].rsrp;
+                }
 
-          for (i = 0 ; i < PHY_FIND_CELL_IND(msg_p).cell_nb; i++) {
-            // TO DO
-            memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].link_addr,  0, sizeof(ral_link_addr_t));
-            // TO DO
-            memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].network_id, 0, sizeof(ral_network_id_t));
+                rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE);
+                itti_send_msg_to_task(TASK_RAL_UE, instance, message_p);
+                break;
+              }
 
-            RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength.choice     = RAL_SIG_STRENGTH_CHOICE_DBM;
-            RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength._union.dbm = PHY_FIND_CELL_IND(msg_p).cells[i].rsrp;
-          }
+              default:
+                LOG_C(RRC, "[UE %d] Invalid RRC state %d substate %d\n",
+                      ue_mod_id,
+                      rrc_get_state(ue_mod_id),
+                      rrc_get_sub_state(ue_mod_id));
+            }
 
-          rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE);
+            break;
 
-          itti_send_msg_to_task(TASK_RAL_UE, instance, message_p);
-          break;
-        }
+          case RRC_STATE_INACTIVE:
+          case RRC_STATE_CONNECTED:
+            /* should not happen */
+            LOG_E(RRC, "[UE %d] indication %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
+            break;
 
-        default:
-          LOG_C(RRC, "[UE %d] Invalid RRC state %d substate %d\n",
-                ue_mod_id,
-                rrc_get_state(ue_mod_id),
-                rrc_get_sub_state(ue_mod_id));
+          default:
+            LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
+            break;
         }
 
-        break;
+        break; // PHY_FIND_CELL_IND
 
-      case RRC_STATE_INACTIVE:
-      case RRC_STATE_CONNECTED:
-        /* should not happen */
-        LOG_E(RRC, "[UE %d] indication %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
-        break;
-
-      default:
-        LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
+      case PHY_MEAS_REPORT_IND: {
+        MessageDef *message_p;
+        message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_MEASUREMENT_REPORT_IND);
+        memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold,
+               &PHY_MEAS_REPORT_IND(msg_p).threshold,
+               sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold));
+        memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param,
+               &PHY_MEAS_REPORT_IND(msg_p).link_param,
+               sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param));
+        LOG_D(RRC, "[UE %d] PHY_MEAS_REPORT_IN: sending msg %s to %s \n", ue_mod_id, "RRC_RAL_MEASUREMENT_REPORT_IND", "TASK_RAL_UE");
+        itti_send_msg_to_task(TASK_RAL_UE, instance, message_p);
         break;
       }
 
-      break; // PHY_FIND_CELL_IND
-
-    case PHY_MEAS_REPORT_IND: {
-      MessageDef *message_p;
-      message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_MEASUREMENT_REPORT_IND);
-
-      memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold,
-             &PHY_MEAS_REPORT_IND(msg_p).threshold,
-             sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold));
+      case RRC_RAL_CONFIGURE_THRESHOLD_REQ:
+        rrc_ue_ral_handle_configure_threshold_request(ue_mod_id, msg_p);
+        break;
 
-      memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param,
-             &PHY_MEAS_REPORT_IND(msg_p).link_param,
-             sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param));
+      case RRC_RAL_CONNECTION_ESTABLISHMENT_REQ:
+        LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, msg_name);
 
-      LOG_D(RRC, "[UE %d] PHY_MEAS_REPORT_IN: sending msg %s to %s \n", ue_mod_id, "RRC_RAL_MEASUREMENT_REPORT_IND", "TASK_RAL_UE");
-      itti_send_msg_to_task(TASK_RAL_UE, instance, message_p);
-      break;
-    }
+        switch (rrc_get_state(ue_mod_id)) {
+          case RRC_STATE_IDLE: {
+            if (rrc_get_sub_state(ue_mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) {
+              PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0, 0);
+              rrc_ue_generate_RRCConnectionRequest(&ctxt, 0);
+              LOG_D(RRC, "not sending connection request\n");
+              rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_CONNECTING);
+            }
 
-    case RRC_RAL_CONFIGURE_THRESHOLD_REQ:
-      rrc_ue_ral_handle_configure_threshold_request(ue_mod_id, msg_p);
-      break;
+            break;
+          }
 
-    case RRC_RAL_CONNECTION_ESTABLISHMENT_REQ:
-      LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, msg_name);
+          case RRC_STATE_INACTIVE:
+          case RRC_STATE_CONNECTED:
+            /* should not happen */
+            LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
+            break;
 
-      switch (rrc_get_state(ue_mod_id)) {
-      case RRC_STATE_IDLE: {
-        if (rrc_get_sub_state(ue_mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) {
-          PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0, 0);
-          rrc_ue_generate_RRCConnectionRequest(&ctxt, 0);
-          LOG_D(RRC, "not sending connection request\n");
-          rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_CONNECTING);
+          default:
+            LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
+            break;
         }
 
         break;
-      }
 
-      case RRC_STATE_INACTIVE:
-      case RRC_STATE_CONNECTED:
-        /* should not happen */
-        LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id));
+      case RRC_RAL_CONNECTION_RELEASE_REQ:
+        LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, msg_name);
         break;
+#endif
 
       default:
-        LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", ue_mod_id, rrc_get_state(ue_mod_id));
+        LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, msg_name);
         break;
-      }
-
-      break;
-
-    case RRC_RAL_CONNECTION_RELEASE_REQ:
-      LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, msg_name);
-      break;
-#endif
-
-    default:
-      LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, msg_name);
-      break;
     }
 
     result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
@@ -4767,28 +4581,24 @@ void *rrc_ue_task( void *args_p )
 /*------------------------------------------------------------------------------*/
 void
 openair_rrc_top_init_ue(
-			int eMBMS_active,
-			char* uecap_xer,
-			uint8_t cba_group_active,
-			uint8_t HO_active
+  int eMBMS_active,
+  char *uecap_xer,
+  uint8_t cba_group_active,
+  uint8_t HO_active
 )
 //-----------------------------------------------------------------------------
 {
-
   module_id_t         module_id;
   OAI_UECapability_t *UECap     = NULL;
   int                 CC_id;
-
   /* for no gcc warnings */
   (void)CC_id;
-
   LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n", NB_UE_INST, NB_eNB_INST);
 
   if (NB_UE_INST > 0) {
-    UE_rrc_inst = (UE_RRC_INST*) malloc16(NB_UE_INST*sizeof(UE_RRC_INST));
+    UE_rrc_inst = (UE_RRC_INST *) malloc16(NB_UE_INST*sizeof(UE_RRC_INST));
     memset (UE_rrc_inst, 0, NB_UE_INST * sizeof(UE_RRC_INST));
     LOG_D(RRC, "ALLOCATE %d Bytes for UE_RRC_INST @ %p\n", (unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)), UE_rrc_inst);
-
     // fill UE capability
     UECap = fill_ue_capability (uecap_xer);
 
@@ -4809,7 +4619,6 @@ openair_rrc_top_init_ue(
   } else {
     UE_rrc_inst = NULL;
   }
-
 }
 
 //-----------------------------------------------------------------------------
@@ -4819,122 +4628,118 @@ rrc_top_cleanup_ue(
 )
 //-----------------------------------------------------------------------------
 {
-
   if (NB_UE_INST > 0) free (UE_rrc_inst);
-  
-
 }
 
 
 //-----------------------------------------------------------------------------
 RRC_status_t
 rrc_rx_tx_ue(
-  protocol_ctxt_t* const ctxt_pP,
+  protocol_ctxt_t *const ctxt_pP,
   const uint8_t      enb_indexP,
   const int          CC_id
 )
 //-----------------------------------------------------------------------------
 {
-
 #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);
 
-    // 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);
-      }
+  // check timers
 
-      UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt++;
-    }
+  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].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;
-
-	}*/
+    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_OK;
+      return (RRC_ConnSetup_failed);
     }
 
-    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].T300_cnt++;
+  }
 
-      UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_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;
 
-    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);
+    }*/
+    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].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);
-      }
+  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;
+    }
 
-      UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt--;
+    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);
     }
 
-    // Layer 3 filtering of RRC measurements
-    if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0] != NULL) {
-      ue_meas_filtering(ctxt_pP,enb_indexP);
+    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_measurement_report_triggering(ctxt_pP,enb_indexP);
+    UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt++;
+  }
 
-    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].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].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;
+    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_HO_STARTED);
+      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);
+  }
+
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT);
   return (RRC_OK);
 }
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index 3db76d3de187caa33af9bfc061a65cbf02788b4c..30efe3c8e8e9b698278da5dc47d51b67bdaf9d63 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -104,7 +104,7 @@ extern EMULATION_VARS              *Emul_vars;
 extern eNB_MAC_INST                *eNB_mac_inst;
 extern UE_MAC_INST                 *UE_mac_inst;
 #ifdef BIGPHYSAREA
-extern void*                        bigphys_malloc(int);
+extern void                        *bigphys_malloc(int);
 #endif
 
 extern uint16_t                     two_tier_hexagonal_cellIds[7];
@@ -113,30 +113,30 @@ mui_t                               rrc_eNB_mui = 0;
 
 void
 openair_rrc_on(
-  const protocol_ctxt_t* const ctxt_pP
+  const protocol_ctxt_t *const ctxt_pP
 )
 //-----------------------------------------------------------------------------
 {
   int            CC_id;
+  LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB:OPENAIR RRC IN....\n",
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
 
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB: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;
-    }
+  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;
+  }
 }
 
 //-----------------------------------------------------------------------------
 static void
 init_SI(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const int              CC_id
 #if defined(ENABLE_ITTI)
   ,
-  RrcConfigurationReq * configuration
+  RrcConfigurationReq *configuration
 #endif
 )
 //-----------------------------------------------------------------------------
@@ -144,14 +144,11 @@ init_SI(
 #if defined(Rel10) || defined(Rel14)
   int                                 i;
 #endif
-
 #ifdef Rel14
   SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext=(SystemInformationBlockType1_v1310_IEs_t *)NULL;
 #endif
-
   LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__);
-
-  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4);
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t *) malloc16(4);
   // copy basic parameters
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId      = configuration->Nid_cell[CC_id];
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB           = configuration->nb_antenna_ports[CC_id];
@@ -161,84 +158,74 @@ init_SI(
 #ifdef Rel14
   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",
+        (int)configuration->N_RB_DL[CC_id],
+        (int)configuration->phich_resource[CC_id],
+        (int)configuration->phich_duration[CC_id]);
   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]
+         configuration->N_RB_DL[CC_id],
+         configuration->phich_resource[CC_id],
+         configuration->phich_duration[CC_id]
 #else
-	 50,0,0
+         50,0,0
 #endif
-	 ,0);
-  
-
+         ,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);
-
+  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
+      , configuration
 #endif
-								   );
-
+                                                                  );
   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);
+  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
+        ctxt_pP->module_id,
+        CC_id
 #if defined(ENABLE_ITTI)
-								     , configuration
+        , configuration
 #endif
-								     );
-
+      );
   AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 != 255,"FATAL, RC.rrc[mod].carrier[CC_id].sizeof_SIB23 == 255");
-  
-
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.n_SB = %ld\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-	pusch_ConfigBasic.n_SB);
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+        pusch_ConfigBasic.n_SB);
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.hoppingMode = %ld\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-	pusch_ConfigBasic.hoppingMode);
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+        pusch_ConfigBasic.hoppingMode);
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.pusch_HoppingOffset = %ld\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-	pusch_ConfigBasic.pusch_HoppingOffset);
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+        pusch_ConfigBasic.pusch_HoppingOffset);
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.enable64QAM = %d\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	(int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-	pusch_ConfigBasic.enable64QAM);
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+        (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+        pusch_ConfigBasic.enable64QAM);
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupHoppingEnabled = %d\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	(int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-	ul_ReferenceSignalsPUSCH.groupHoppingEnabled);
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+        (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+        ul_ReferenceSignalsPUSCH.groupHoppingEnabled);
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupAssignmentPUSCH = %ld\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-	ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH);
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+        ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH);
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.sequenceHoppingEnabled = %d\n",
-	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	(int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-	ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled);
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+        (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 defined(Rel10) || defined(Rel14)
 
   if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag > 0) {
@@ -246,105 +233,104 @@ init_SI(
       // SIB 2
       //   LOG_D(RRC, "[eNB %d] mbsfn_SubframeConfigList.list.count = %ld\n", enb_mod_idP, RC.rrc[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count);
       LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN subframe allocation %d/%d(partial)\n",
-	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	    i,
-	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count);
+            PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+            i,
+            RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count);
       LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" mbsfn_Subframe_pattern is  = %x\n",
-	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0);
+            PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+            RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0);
       LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_period  = %ld (just index number, not the real value)\n",
-	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod);   // need to display the real value, using array of char (like in dumping SIB2)
+            PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+            RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod);   // need to display the real value, using array of char (like in dumping SIB2)
       LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_offset  = %ld\n",
-	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset);
+            PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+            RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset);
     }
-    
+
     //   SIB13
     for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) {
       LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN sync area %d/%d (partial)\n",
-	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-	    i,
-	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count);
+            PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+            i,
+            RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count);
       LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Repetition Period: %ld (just index number, not real value)\n",
-	    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_RepetitionPeriod_r9);
+            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_RepetitionPeriod_r9);
       LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Offset: %ld\n",
-	    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);
+            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);
     }
   }
-  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));
-#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));
 
+#endif
   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));
-
+        PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n",
+        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
 #ifdef Rel14
-  if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) && 
+
+  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;
   }
-#endif
 
+#endif
   LOG_D(RRC, "About to call rrc_mac_config_req_eNB\n");
-
   rrc_mac_config_req_eNB(ctxt_pP->module_id, CC_id,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq,
 #ifdef Rel14
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition,
 #endif
-			 0, // rnti
-			 (BCCH_BCH_Message_t *)
-			 &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib,
-			 (RadioResourceConfigCommonSIB_t *) &
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon,
+                         0, // rnti
+                         (BCCH_BCH_Message_t *)
+                         &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib,
+                         (RadioResourceConfigCommonSIB_t *) &
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon,
 #if defined(Rel14)
-			 (RadioResourceConfigCommonSIB_t *) &
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon,
+                         (RadioResourceConfigCommonSIB_t *) &
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon,
 #endif
-			 (struct PhysicalConfigDedicated *)NULL,
+                         (struct PhysicalConfigDedicated *)NULL,
 #if defined(Rel10) || defined(Rel14)
-			 (SCellToAddMod_r10_t *)NULL,
-			 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-			 (MeasObjectToAddMod_t **) NULL,
-			 (MAC_MainConfig_t *) NULL, 0,
-			 (struct LogicalChannelConfig *)NULL,
-			 (MeasGapConfig_t *) NULL,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->tdd_Config,
-			 NULL,
-			 &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->schedulingInfoList,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth,
-			 &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission,
-			 (MBSFN_SubframeConfigList_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList
+                         (SCellToAddMod_r10_t *)NULL,
+                         //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+                         (MeasObjectToAddMod_t **) NULL,
+                         (MAC_MainConfig_t *) NULL, 0,
+                         (struct LogicalChannelConfig *)NULL,
+                         (MeasGapConfig_t *) NULL,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->tdd_Config,
+                         NULL,
+                         &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->schedulingInfoList,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth,
+                         &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission,
+                         (MBSFN_SubframeConfigList_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList
 #if defined(Rel10) || defined(Rel14)
-			 ,
-			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag,
-			 (MBSFN_AreaInfoList_r9_t*) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9,
-			 (PMCH_InfoList_r9_t *) NULL
+                         ,
+                         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag,
+                         (MBSFN_AreaInfoList_r9_t *) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9,
+                         (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef Rel14
-			 , 
-			 sib1_v13ext
+                         ,
+                         sib1_v13ext
 #endif
-			 );
+                        );
 }
 
 #if defined(Rel10) || defined(Rel14)
@@ -356,92 +342,81 @@ init_MCCH(
 )
 //-----------------------------------------------------------------------------
 {
-
   int                                 sync_area = 0;
   // initialize RRC_eNB_INST MCCH entry
   RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE =
-    malloc(RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t*));
+    malloc(RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t *));
 
   for (sync_area = 0; sync_area < RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area; sync_area++) {
-
     RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = 0;
     RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] = (uint8_t *) malloc16(32);
-
     AssertFatal(RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] != NULL,
-		"[eNB %d]init_MCCH: FATAL, no memory for MCCH MESSAGE allocated \n", enb_mod_idP);
+                "[eNB %d]init_MCCH: FATAL, no memory for MCCH MESSAGE allocated \n", enb_mod_idP);
     RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = do_MBSFNAreaConfig(enb_mod_idP,
-											    sync_area,
-											    (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area],
-											    &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch,
-											    &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message);
-    
+        sync_area,
+        (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area],
+        &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch,
+        &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message);
     LOG_I(RRC, "mcch message pointer %p for sync area %d \n",
-	  RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area],
-	  sync_area);
+          RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area],
+          sync_area);
     LOG_D(RRC, "[eNB %d] MCCH_MESSAGE  contents for Sync Area %d (partial)\n", enb_mod_idP, sync_area);
     LOG_D(RRC, "[eNB %d] CommonSF_AllocPeriod_r9 %ld\n", enb_mod_idP,
-	  RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9);
+          RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9);
     LOG_D(RRC,
-	  "[eNB %d] CommonSF_Alloc_r9.list.count (number of MBSFN Subframe Pattern) %d\n",
-	  enb_mod_idP, RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count);
+          "[eNB %d] CommonSF_Alloc_r9.list.count (number of MBSFN Subframe Pattern) %d\n",
+          enb_mod_idP, RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count);
     LOG_D(RRC, "[eNB %d] MBSFN Subframe Pattern: %02x (in hex)\n",
-	  enb_mod_idP,
-	  RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation.
-	  choice.oneFrame.buf[0]);
-    
+          enb_mod_idP,
+          RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation.
+          choice.oneFrame.buf[0]);
     AssertFatal(RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] != 255,
-		"RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255");
+                "RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255");
     RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESS[sync_area].Active = 1;
   }
-  
 
   //Set the RC.rrc[enb_mod_idP]->MCCH_MESS.Active to 1 (allow to  transfer MCCH message RRC->MAC in function mac_rrc_data_req)
-
   // ??Configure MCCH logical channel
   // call mac_config_req with appropriate structure from ASN.1 description
-
-
   //  LOG_I(RRC, "DUY: serviceID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->tmgi_r9.serviceId_r9.buf[2]);
   //  LOG_I(RRC, "DUY: session ID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->sessionId_r9->buf[0]);
   rrc_mac_config_req_eNB(enb_mod_idP, CC_id,
-			 0,0,0,0,0,
-#ifdef Rel14 
-			 0,
+                         0,0,0,0,0,
+#ifdef Rel14
+                         0,
 #endif
-			 0,//rnti
-			 (BCCH_BCH_Message_t *)NULL,
-			 (RadioResourceConfigCommonSIB_t *) NULL,
+                         0,//rnti
+                         (BCCH_BCH_Message_t *)NULL,
+                         (RadioResourceConfigCommonSIB_t *) NULL,
 #ifdef Rel14
-			 (RadioResourceConfigCommonSIB_t *) NULL,
+                         (RadioResourceConfigCommonSIB_t *) NULL,
 #endif
-			 (struct PhysicalConfigDedicated *)NULL,
+                         (struct PhysicalConfigDedicated *)NULL,
 #if defined(Rel10) || defined(Rel14)
-			 (SCellToAddMod_r10_t *)NULL,
-			 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-			 (MeasObjectToAddMod_t **) NULL,
-			 (MAC_MainConfig_t *) NULL,
-			 0,
-			 (struct LogicalChannelConfig *)NULL,
-			 (MeasGapConfig_t *) NULL,
-			 (TDD_Config_t *) NULL,
-			 (MobilityControlInfo_t *)NULL, 
-			 (SchedulingInfoList_t *) NULL, 
-			 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+                         (SCellToAddMod_r10_t *)NULL,
+                         //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+                         (MeasObjectToAddMod_t **) NULL,
+                         (MAC_MainConfig_t *) NULL,
+                         0,
+                         (struct LogicalChannelConfig *)NULL,
+                         (MeasGapConfig_t *) NULL,
+                         (TDD_Config_t *) NULL,
+                         (MobilityControlInfo_t *)NULL,
+                         (SchedulingInfoList_t *) NULL,
+                         0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #if defined(Rel10) || defined(Rel14)
-			 ,
-			 0,
-			 (MBSFN_AreaInfoList_r9_t *) NULL,
-			 (PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9)
+                         ,
+                         0,
+                         (MBSFN_AreaInfoList_r9_t *) NULL,
+                         (PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9)
 #   endif
 #   ifdef Rel14
-			 ,
-			 (SystemInformationBlockType1_v1310_IEs_t *)NULL
+                         ,
+                         (SystemInformationBlockType1_v1310_IEs_t *)NULL
 #   endif
-			 );
-  
+                        );
   //LOG_I(RRC,"DUY: lcid after rrc_mac_config_req is %02d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9);
-
 }
 
 //-----------------------------------------------------------------------------
@@ -457,13 +432,11 @@ static void init_MBMS(
 
   if (RC.rrc[enb_mod_idP]->carrier[CC_id].MBMS_flag > 0) {
     PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,enb_mod_idP);
-
     LOG_D(RRC, "[eNB %d] Frame %d : Radio Bearer config request for MBMS\n", enb_mod_idP, frameP);   //check the lcid
     // Configuring PDCP and RLC for MBMS Radio Bearer
-
     rrc_pdcp_config_asn1_req(&ctxt,
-                             (SRB_ToAddModList_t  *)NULL,  // SRB_ToAddModList
-                             (DRB_ToAddModList_t  *)NULL,  // DRB_ToAddModList
+                             (SRB_ToAddModList_t *)NULL,   // SRB_ToAddModList
+                             (DRB_ToAddModList_t *)NULL,   // DRB_ToAddModList
                              (DRB_ToReleaseList_t *)NULL,
                              0,     // security mode
                              NULL,  // key rrc encryption
@@ -473,13 +446,11 @@ static void init_MBMS(
                              , &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9)
 #   endif
                              ,NULL);
-
     rrc_rlc_config_asn1_req(&ctxt,
                             NULL, // SRB_ToAddModList
                             NULL,   // DRB_ToAddModList
                             NULL,   // DRB_ToReleaseList
                             &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9));
-
     //rrc_mac_config_req();
   }
 }
@@ -532,14 +503,14 @@ rrc_eNB_get_next_transaction_identifier(
 
 //-----------------------------------------------------------------------------
 // return the ue context if there is already an UE with ue_identityP, NULL otherwise
-static struct rrc_eNB_ue_context_s*
+static struct rrc_eNB_ue_context_s *
 rrc_eNB_ue_context_random_exist(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const uint64_t               ue_identityP
 )
 //-----------------------------------------------------------------------------
 {
-  struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s        *ue_context_p = NULL;
   RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
     if (ue_context_p->ue_context.random_ue_identity == ue_identityP)
       return ue_context_p;
@@ -548,47 +519,48 @@ rrc_eNB_ue_context_random_exist(
 }
 //-----------------------------------------------------------------------------
 // return the ue context if there is already an UE with the same S-TMSI(MMEC+M-TMSI), NULL otherwise
-static struct rrc_eNB_ue_context_s*
+static struct rrc_eNB_ue_context_s *
 rrc_eNB_ue_context_stmsi_exist(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const mme_code_t             mme_codeP,
   const m_tmsi_t               m_tmsiP
 )
 //-----------------------------------------------------------------------------
 {
-  struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s        *ue_context_p = NULL;
   RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
     LOG_I(RRC,"checking for UE S-TMSI %x, mme %x (%p): rnti %x",
-	  m_tmsiP, mme_codeP, ue_context_p, 
-	  ue_context_p->ue_context.rnti);
+          m_tmsiP, mme_codeP, ue_context_p,
+          ue_context_p->ue_context.rnti);
+
     if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) {
       printf("=> S-TMSI %x, MME %x\n",
-	    ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
-	    ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code);
+             ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
+             ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code);
+
       if (ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi == m_tmsiP)
         if (ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code == mme_codeP)
           return ue_context_p;
     }
     else
       printf("\n");
-
   }
   return NULL;
 }
 
 //-----------------------------------------------------------------------------
 // return a new ue context structure if ue_identityP, ctxt_pP->rnti not found in collection
-static struct rrc_eNB_ue_context_s*
+static struct rrc_eNB_ue_context_s *
 rrc_eNB_get_next_free_ue_context(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const uint64_t               ue_identityP
 )
 //-----------------------------------------------------------------------------
 {
-  struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s        *ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
-					RC.rrc[ctxt_pP->module_id],
-					ctxt_pP->rnti);
+                   RC.rrc[ctxt_pP->module_id],
+                   ctxt_pP->rnti);
 
   if (ue_context_p == NULL) {
 #if 0
@@ -621,7 +593,6 @@ rrc_eNB_get_next_free_ue_context(
           PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
           ue_context_p->local_uid);
     return ue_context_p;
-
   } else {
     LOG_E(RRC,
           PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist\n",
@@ -640,14 +611,15 @@ void rrc_eNB_emulation_notify_ue_module_id(
   const uint8_t     cell_identity_byte3P)
 {
   module_id_t                         enb_module_id;
-  struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s        *ue_context_p = NULL;
   int                                 CC_id;
 
   // find enb_module_id
   for (enb_module_id = 0; enb_module_id < NUMBER_OF_eNB_MAX; enb_module_id++) {
-    if(enb_module_id>0){ /*FIX LATER*/
+    if(enb_module_id>0) { /*FIX LATER*/
       return;
     }
+
     for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
       if (&RC.rrc[enb_module_id]->carrier[CC_id].sib1 != NULL) {
         if (
@@ -669,6 +641,7 @@ void rrc_eNB_emulation_notify_ue_module_id(
         }
       }
     }
+
     oai_emulation.info.eNB_ue_module_id_to_rnti[enb_module_id][ue_module_idP] = rntiP;
   }
 
@@ -681,8 +654,8 @@ void rrc_eNB_emulation_notify_ue_module_id(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_free_mem_UE_context(
-  const protocol_ctxt_t*               const ctxt_pP,
-  struct rrc_eNB_ue_context_s*         const ue_context_pP
+  const protocol_ctxt_t               *const ctxt_pP,
+  struct rrc_eNB_ue_context_s         *const ue_context_pP
 )
 //-----------------------------------------------------------------------------
 {
@@ -701,11 +674,11 @@ rrc_eNB_free_mem_UE_context(
     ue_context_pP->ue_context.SRB_configList = NULL;
   }
 
-  for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){
-      if (ue_context_pP->ue_context.SRB_configList2[i]) {
-          free(ue_context_pP->ue_context.SRB_configList2[i]);
-          ue_context_pP->ue_context.SRB_configList2[i] = NULL;
-      }
+  for(i = 0; i < RRC_TRANSACTION_IDENTIFIER_NUMBER; i++) {
+    if (ue_context_pP->ue_context.SRB_configList2[i]) {
+      free(ue_context_pP->ue_context.SRB_configList2[i]);
+      ue_context_pP->ue_context.SRB_configList2[i] = NULL;
+    }
   }
 
   if (ue_context_pP->ue_context.DRB_configList) {
@@ -713,15 +686,16 @@ rrc_eNB_free_mem_UE_context(
     ue_context_pP->ue_context.DRB_configList = NULL;
   }
 
-  for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){
-      if (ue_context_pP->ue_context.DRB_configList2[i]) {
-          free(ue_context_pP->ue_context.DRB_configList2[i]);
-          ue_context_pP->ue_context.DRB_configList2[i] = NULL;
-      }
-      if (ue_context_pP->ue_context.DRB_Release_configList2[i]) {
-          free(ue_context_pP->ue_context.DRB_Release_configList2[i]);
-          ue_context_pP->ue_context.DRB_Release_configList2[i] = NULL;
-      }
+  for(i = 0; i < RRC_TRANSACTION_IDENTIFIER_NUMBER; i++) {
+    if (ue_context_pP->ue_context.DRB_configList2[i]) {
+      free(ue_context_pP->ue_context.DRB_configList2[i]);
+      ue_context_pP->ue_context.DRB_configList2[i] = NULL;
+    }
+
+    if (ue_context_pP->ue_context.DRB_Release_configList2[i]) {
+      free(ue_context_pP->ue_context.DRB_Release_configList2[i]);
+      ue_context_pP->ue_context.DRB_Release_configList2[i] = NULL;
+    }
   }
 
   memset(ue_context_pP->ue_context.DRB_active, 0, sizeof(ue_context_pP->ue_context.DRB_active));
@@ -760,14 +734,14 @@ rrc_eNB_free_mem_UE_context(
     ue_context_pP->ue_context.mac_MainConfig = NULL;
   }
 
-/*  if (ue_context_pP->ue_context.measGapConfig) {
-    ASN_STRUCT_FREE(asn_DEF_MeasGapConfig, ue_context_pP->ue_context.measGapConfig);
-    ue_context_pP->ue_context.measGapConfig = NULL;
-  }*/
-    if (ue_context_pP->ue_context.handover_info) {
-      ASN_STRUCT_FREE(asn_DEF_Handover, ue_context_pP->ue_context.handover_info);
-      ue_context_pP->ue_context.handover_info = NULL;
-    }
+  /*  if (ue_context_pP->ue_context.measGapConfig) {
+      ASN_STRUCT_FREE(asn_DEF_MeasGapConfig, ue_context_pP->ue_context.measGapConfig);
+      ue_context_pP->ue_context.measGapConfig = NULL;
+    }*/
+  if (ue_context_pP->ue_context.handover_info) {
+    ASN_STRUCT_FREE(asn_DEF_Handover, ue_context_pP->ue_context.handover_info);
+    ue_context_pP->ue_context.handover_info = NULL;
+  }
 
   //SRB_INFO                           SI;
   //SRB_INFO                           Srb0;
@@ -810,11 +784,9 @@ rrc_eNB_free_mem_UE_context(
 //-----------------------------------------------------------------------------
 // should be called when UE is lost by eNB
 void
-rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*        const ue_context_pP)
+rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s        *const ue_context_pP)
 //-----------------------------------------------------------------------------
 {
-
-
   protocol_ctxt_t                     ctxt;
 #if !defined(ENABLE_USE_MME)
   module_id_t                         ue_module_id;
@@ -822,14 +794,14 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*
   (void)ue_module_id;
 #endif
   rnti_t rnti = ue_context_pP->ue_context.rnti;
-  int i, j , CC_id, pdu_number;
+  int i, j, CC_id, pdu_number;
   LTE_eNB_ULSCH_t *ulsch = NULL;
   LTE_eNB_DLSCH_t *dlsch = NULL;
   nfapi_ul_config_request_body_t *ul_req_tmp = NULL;
   PHY_VARS_eNB *eNB_PHY = NULL;
   eNB_MAC_INST *eNB_MAC = RC.mac[enb_mod_idP];
-
   AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rnti);
+
   /*  ue_context_p = rrc_eNB_get_ue_context(
                    &RC.rrc[enb_mod_idP],
                    rntiP
@@ -838,32 +810,38 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*
   if (NULL != ue_context_pP) {
     PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0,enb_mod_idP);
     LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rnti);
-
 #if defined(ENABLE_USE_MME)
-   if( ue_context_pP->ue_context.ul_failure_timer >= 8 ) {
-	LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ RNTI %x\n", enb_mod_idP, rnti);
-    rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost
-    /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered)
-     * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before
-     *  triggering the S1 UE Context Release Request procedure
-     *  in order to allow the UE to perform the NAS recovery
-     *  procedure, see TS 23.401 [17].
-     */
-     return;
+
+    if( ue_context_pP->ue_context.ul_failure_timer >= 8 ) {
+      LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ RNTI %x\n", enb_mod_idP, rnti);
+      rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost
+      /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered)
+       * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before
+       *  triggering the S1 UE Context Release Request procedure
+       *  in order to allow the UE to perform the NAS recovery
+       *  procedure, see TS 23.401 [17].
+       */
+      return;
     }
+
 #endif
+
     for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
       eNB_PHY = RC.eNB[enb_mod_idP][CC_id];
-      for (i=0; i<MAX_MOBILES_PER_ENB; i++) {
+
+      for (i=0; i<NUMBER_OF_UE_MAX; i++) {
         ulsch = eNB_PHY->ulsch[i];
-        if((ulsch != NULL) && (ulsch->rnti == rnti)){
+
+        if((ulsch != NULL) && (ulsch->rnti == rnti)) {
           LOG_I(RRC, "clean_eNb_ulsch UE %x \n", rnti);
           clean_eNb_ulsch(ulsch);
         }
       }
-      for (i=0; i<MAX_MOBILES_PER_ENB; i++) {
+
+      for (i=0; i<NUMBER_OF_UE_MAX; i++) {
         dlsch = eNB_PHY->dlsch[i][0];
-        if((dlsch != NULL) && (dlsch->rnti == rnti)){
+
+        if((dlsch != NULL) && (dlsch->rnti == rnti)) {
           LOG_I(RRC, "clean_eNb_dlsch UE %x \n", rnti);
           clean_eNb_dlsch(dlsch);
         }
@@ -871,53 +849,55 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*
 
       if (rrc_agent_registered[enb_mod_idP]) {
         agent_rrc_xface[enb_mod_idP]->flexran_agent_notify_ue_state_change(enb_mod_idP,
-                              rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
+            rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
       }
 
-      for(j = 0; j < 10; j++){
+      for(j = 0; j < 10; j++) {
         ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body;
-        if(ul_req_tmp){
+
+        if(ul_req_tmp) {
           pdu_number = ul_req_tmp->number_of_pdus;
-          for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){
-            if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){
+
+          for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--) {
+            if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) {
               LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number);
-              if(pdu_index < pdu_number -1){
+
+              if(pdu_index < pdu_number -1) {
                 memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t));
               }
+
               ul_req_tmp->number_of_pdus--;
             }
           }
         }
       }
     }
+
     rrc_mac_remove_ue(enb_mod_idP,rnti);
     rrc_rlc_remove_ue(&ctxt);
     pdcp_remove_UE(&ctxt);
-
     rrc_eNB_remove_ue_context(
       &ctxt,
       RC.rrc[enb_mod_idP],
-      (struct rrc_eNB_ue_context_s*) ue_context_pP);
+      (struct rrc_eNB_ue_context_s *) ue_context_pP);
   }
 }
 
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_process_RRCConnectionSetupComplete(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*         ue_context_pP,
-  RRCConnectionSetupComplete_r8_IEs_t * rrcConnectionSetupComplete
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t         *ue_context_pP,
+  RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete
 )
 //-----------------------------------------------------------------------------
 {
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing RRCConnectionSetupComplete from UE (SRB1 Active)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-
-  ue_context_pP->ue_context.Srb1.Active=1;  
+  ue_context_pP->ue_context.Srb1.Active=1;
   T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
 #if defined(ENABLE_USE_MME)
 
   if (EPC_MODE_ENABLED == 1) {
@@ -940,47 +920,41 @@ rrc_eNB_process_RRCConnectionSetupComplete(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_SecurityModeCommand(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP
 )
 //-----------------------------------------------------------------------------
 {
   uint8_t                             buffer[100];
   uint8_t                             size;
-
   T(T_ENB_RRC_SECURITY_MODE_COMMAND, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   size = do_SecurityModeCommand(
            ctxt_pP,
            buffer,
            rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),
            ue_context_pP->ue_context.ciphering_algorithm,
            ue_context_pP->ue_context.integrity_algorithm);
-
 #ifdef RRC_MSG_PRINT
   uint16_t i=0;
   LOG_F(RRC,"[MSG] RRC Security Mode Command\n");
 
   for (i = 0; i < size; i++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
   }
 
   LOG_F(RRC,"\n");
 #endif
-
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
         size);
-
   LOG_D(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (securityModeCommand to UE MUI %d) --->[PDCP][RB %02d]\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
         size,
         rrc_eNB_mui,
         DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -991,50 +965,42 @@ rrc_eNB_generate_SecurityModeCommand(
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
-	       ctxt_pP,
-	       DCCH,
-	       rrc_eNB_mui++,
-	       SDU_CONFIRM_NO,
-	       size,
-	       buffer,
-	       PDCP_TRANSMISSION_MODE_CONTROL);
-
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_UECapabilityEnquiry(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP
 )
 //-----------------------------------------------------------------------------
 {
-
   uint8_t                             buffer[100];
   uint8_t                             size;
-
   T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   size = do_UECapabilityEnquiry(
            ctxt_pP,
            buffer,
            rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id));
-
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate UECapabilityEnquiry (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
         size);
-
   LOG_D(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (UECapabilityEnquiry MUI %d) --->[PDCP][RB %02d]\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
         size,
         rrc_eNB_mui,
         DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -1045,23 +1011,21 @@ rrc_eNB_generate_UECapabilityEnquiry(
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
-	       ctxt_pP,
-	       DCCH,
-	       rrc_eNB_mui++,
-	       SDU_CONFIRM_NO,
-	       size,
-	       buffer,
-	       PDCP_TRANSMISSION_MODE_CONTROL);
-
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_RRCConnectionReject(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
   const int                    CC_id
 )
 //-----------------------------------------------------------------------------
@@ -1069,24 +1033,20 @@ rrc_eNB_generate_RRCConnectionReject(
 #ifdef RRC_MSG_PRINT
   int                                 cnt;
 #endif
-
   T(T_ENB_RRC_CONNECTION_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
     do_RRCConnectionReject(ctxt_pP->module_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].Srb0.Tx_buffer.Payload);
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRCConnectionReject\n");
 
   for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]);
   }
 
   LOG_F(RRC,"\n");
 #endif
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -1096,7 +1056,6 @@ rrc_eNB_generate_RRCConnectionReject(
     MSC_AS_TIME_ARGS(ctxt_pP),
     ue_context_pP == NULL ? -1 : 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 RRCConnectionReject (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
@@ -1106,8 +1065,8 @@ rrc_eNB_generate_RRCConnectionReject(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_RRCConnectionReestablishment(
-  const protocol_ctxt_t*         const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
+  const protocol_ctxt_t         *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
   const int                            CC_id
 )
 //-----------------------------------------------------------------------------
@@ -1116,26 +1075,23 @@ rrc_eNB_generate_RRCConnectionReestablishment(
   SRB_ToAddModList_t                 **SRB_configList;
   SRB_ToAddMod_t                     *SRB1_config;
   int                                 cnt;
-
   T(T_ENB_RRC_CONNECTION_REESTABLISHMENT, 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_RRCConnectionReestablishment(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].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);
-
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRCConnectionReestablishment\n");
 
   for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload)[cnt]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload)[cnt]);
   }
 
   LOG_F(RRC,"\n");
@@ -1163,38 +1119,38 @@ rrc_eNB_generate_RRCConnectionReestablishment(
               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,
-#ifdef Rel14 
-			 0,
-#endif
-                           ctxt_pP->rnti,
-                           (BCCH_BCH_Message_t *) NULL, 
-                           (RadioResourceConfigCommonSIB_t *) NULL,
+                               ue_context_pP->ue_context.primaryCC_id,
+                               0,0,0,0,0,
+#ifdef Rel14
+                               0,
+#endif
+                               ctxt_pP->rnti,
+                               (BCCH_BCH_Message_t *) NULL,
+                               (RadioResourceConfigCommonSIB_t *) NULL,
 #ifdef Rel14
-                           (RadioResourceConfigCommonSIB_t *) NULL,
+                               (RadioResourceConfigCommonSIB_t *) NULL,
 #endif
-                           (struct PhysicalConfigDedicated* ) ue_context_pP->ue_context.physicalConfigDedicated,
+                               (struct PhysicalConfigDedicated * ) ue_context_pP->ue_context.physicalConfigDedicated,
 #if defined(Rel10) || defined(Rel14)
-                           (SCellToAddMod_r10_t *)NULL,
-                           //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-                           (MeasObjectToAddMod_t **) NULL,
-                           ue_context_pP->ue_context.mac_MainConfig,
-                           1,
-                           SRB1_logicalChannelConfig,
-                           ue_context_pP->ue_context.measGapConfig,
-                           (TDD_Config_t *) NULL,
-                           NULL,
-                           (SchedulingInfoList_t *) NULL,
-                           0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+                               (SCellToAddMod_r10_t *)NULL,
+                               //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+                               (MeasObjectToAddMod_t **) NULL,
+                               ue_context_pP->ue_context.mac_MainConfig,
+                               1,
+                               SRB1_logicalChannelConfig,
+                               ue_context_pP->ue_context.measGapConfig,
+                               (TDD_Config_t *) NULL,
+                               NULL,
+                               (SchedulingInfoList_t *) NULL,
+                               0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #if defined(Rel10) || defined(Rel14)
-                           , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+                               , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef Rel14
-                           ,(SystemInformationBlockType1_v1310_IEs_t *)NULL 
+                               ,(SystemInformationBlockType1_v1310_IEs_t *)NULL
 #endif
-        );
+                              );
         break;
       }
     }
@@ -1208,18 +1164,15 @@ rrc_eNB_generate_RRCConnectionReestablishment(
                      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 RRCConnectionReestablishment (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
         RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
-
   // activate release timer, if RRCComplete not received after 10 frames, remove UE
   //ue_context_pP->ue_context.ue_release_timer = 1;
   // remove UE after 10 frames after RRCConnectionReestablishmentRelease is triggered
   //ue_context_pP->ue_context.ue_release_timer_thres = 100;
-    // activate release timer, if RRCComplete not received after 100 frames, remove UE
+  // activate release timer, if RRCComplete not received after 100 frames, remove UE
   int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti);
   RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1;
   // remove UE after 100 frames after RRCConnectionReestablishmentRelease is triggered
@@ -1229,25 +1182,23 @@ rrc_eNB_generate_RRCConnectionReestablishment(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_process_RRCConnectionReestablishmentComplete(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const rnti_t reestablish_rnti,
-  rrc_eNB_ue_context_t*         ue_context_pP,
+  rrc_eNB_ue_context_t         *ue_context_pP,
   const uint8_t xid,
-  RRCConnectionReestablishmentComplete_r8_IEs_t * rrcConnectionReestablishmentComplete
+  RRCConnectionReestablishmentComplete_r8_IEs_t *rrcConnectionReestablishmentComplete
 )
 //-----------------------------------------------------------------------------
 {
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, processing RRCConnectionReestablishmentComplete from UE (SRB1 Active)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-
   T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-  DRB_ToAddModList_t*                 DRB_configList = ue_context_pP->ue_context.DRB_configList;
-  SRB_ToAddModList_t*                 SRB_configList = ue_context_pP->ue_context.SRB_configList;
-  SRB_ToAddModList_t**                SRB_configList2 = NULL;
-  DRB_ToAddModList_t**                DRB_configList2 = NULL;
+  DRB_ToAddModList_t                 *DRB_configList = ue_context_pP->ue_context.DRB_configList;
+  SRB_ToAddModList_t                 *SRB_configList = ue_context_pP->ue_context.SRB_configList;
+  SRB_ToAddModList_t                **SRB_configList2 = NULL;
+  DRB_ToAddModList_t                **DRB_configList2 = NULL;
   struct SRB_ToAddMod                *SRB2_config = NULL;
   struct DRB_ToAddMod                *DRB_config = NULL;
   int i = 0;
@@ -1275,22 +1226,23 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   (void)dedicatedInfoNas;
   C_RNTI_t                           *cba_RNTI                         = NULL;
   uint8_t next_xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id);
-
   ue_context_pP->ue_context.Status = RRC_CONNECTED;
-
   SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[xid];
+
   // get old configuration of SRB2
   if (*SRB_configList2 != NULL) {
     LOG_D(RRC, "SRB_configList2(%p) count is %d\n           SRB_configList2->list.array[0] addr is %p",
           SRB_configList2, (*SRB_configList2)->list.count,  (*SRB_configList2)->list.array[0]);
+
     for (i = 0; (i < (*SRB_configList2)->list.count) && (i < 3); i++) {
-      if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ){
+      if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ) {
         LOG_D(RRC, "get SRB2_config from (ue_context_pP->ue_context.SRB_configList2[%d])\n", xid);
         SRB2_config = (*SRB_configList2)->list.array[i];
         break;
       }
     }
   }
+
   SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[next_xid];
   DRB_configList2 = &ue_context_pP->ue_context.DRB_configList2[next_xid];
 
@@ -1298,70 +1250,71 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     free(*SRB_configList2);
     LOG_D(RRC, "free(ue_context_pP->ue_context.SRB_configList2[%d])\n", next_xid);
   }
+
   *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2));
+
   if (SRB2_config != NULL) {
     // Add SRB2 to SRB configuration list
-
     ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config);
     ASN_SEQUENCE_ADD(&(*SRB_configList2)->list, SRB2_config);
-
     LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList\n",
-            SRB2_config->srb_Identity);
+          SRB2_config->srb_Identity);
     LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList2[%d]\n",
-                SRB2_config->srb_Identity, next_xid);
+          SRB2_config->srb_Identity, next_xid);
   } else {
     // SRB configuration list only contains SRB1.
     LOG_W(RRC,"SRB2 configuration does not exist in SRB configuration list\n");
   }
 
-
-
   if (*DRB_configList2) {
     free(*DRB_configList2);
     LOG_D(RRC, "free(ue_context_pP->ue_context.DRB_configList2[%d])\n", next_xid);
   }
+
   *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2));
 
   if (DRB_configList != NULL) {
     LOG_D(RRC, "get DRB_config from (ue_context_pP->ue_context.DRB_configList)\n");
+
     for (i = 0; (i < DRB_configList->list.count) && (i < 3); i++) {
       DRB_config = DRB_configList->list.array[i];
-
       // Add DRB to DRB configuration list, for RRCConnectionReconfigurationComplete
       ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config);
     }
   }
+
   ue_context_pP->ue_context.Srb1.Active = 1;
   //ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2;
-
 # if defined(ENABLE_USE_MME)
-  rrc_ue_s1ap_ids_t* rrc_ue_s1ap_ids_p = NULL;
+  rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL;
   uint16_t ue_initial_id = ue_context_pP->ue_context.ue_initial_id;
   uint32_t eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
   eNB_RRC_INST *rrc_instance_p = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)];
+
   if (eNB_ue_s1ap_id > 0) {
-    h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&rrc_ue_s1ap_ids_p);
+    h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&rrc_ue_s1ap_ids_p);
+
     if  (h_rc == HASH_TABLE_OK) {
       rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti;
     }
   }
+
   if (ue_initial_id != 0) {
-    h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&rrc_ue_s1ap_ids_p);
+    h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void **)&rrc_ue_s1ap_ids_p);
+
     if  (h_rc == HASH_TABLE_OK) {
       rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti;
     }
   }
 
   gtpv1u_enb_create_tunnel_req_t  create_tunnel_req;
-
   /* Save e RAB information for later */
-  memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req));
+  memset(&create_tunnel_req, 0, sizeof(create_tunnel_req));
 
   for (j = 0, i = 0; i < NB_RB_MAX; i++) {
     if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED) {
       create_tunnel_req.eps_bearer_id[j]       = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;
       create_tunnel_req.sgw_S1u_teid[j]        = ue_context_pP->ue_context.e_rab[i].param.gtp_teid;
-
       memcpy(&create_tunnel_req.sgw_addr[j],
              &ue_context_pP->ue_context.e_rab[i].param.sgw_addr,
              sizeof(transport_layer_addr_t));
@@ -1371,11 +1324,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
 
   create_tunnel_req.rnti       = ctxt_pP->rnti; // warning put zero above
   create_tunnel_req.num_tunnels    = j;
-
   gtpv1u_update_s1u_tunnel(
-            ctxt_pP->instance,
-            &create_tunnel_req,
-            reestablish_rnti);
+    ctxt_pP->instance,
+    &create_tunnel_req,
+    reestablish_rnti);
 #endif
   /* Update RNTI in ue_context */
   ue_context_pP->ue_id_rnti                    = ctxt_pP->rnti; // here ue_id_rnti is just a key, may be something else
@@ -1383,62 +1335,51 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
 # if defined(ENABLE_USE_MME)
   uint8_t send_security_mode_command = FALSE;
   rrc_pdcp_config_security(
-      ctxt_pP,
-      ue_context_pP,
-      send_security_mode_command);
+    ctxt_pP,
+    ue_context_pP,
+    send_security_mode_command);
   LOG_D(RRC, "set security successfully \n");
 #endif
   // Measurement ID list
   MeasId_list = CALLOC(1, sizeof(*MeasId_list));
   memset((void *)MeasId_list, 0, sizeof(*MeasId_list));
-
   MeasId0 = CALLOC(1, sizeof(*MeasId0));
   MeasId0->measId = 1;
   MeasId0->measObjectId = 1;
   MeasId0->reportConfigId = 1;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0);
-
   MeasId1 = CALLOC(1, sizeof(*MeasId1));
   MeasId1->measId = 2;
   MeasId1->measObjectId = 1;
   MeasId1->reportConfigId = 2;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1);
-
   MeasId2 = CALLOC(1, sizeof(*MeasId2));
   MeasId2->measId = 3;
   MeasId2->measObjectId = 1;
   MeasId2->reportConfigId = 3;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2);
-
   MeasId3 = CALLOC(1, sizeof(*MeasId3));
   MeasId3->measId = 4;
   MeasId3->measObjectId = 1;
   MeasId3->reportConfigId = 4;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3);
-
   MeasId4 = CALLOC(1, sizeof(*MeasId4));
   MeasId4->measId = 5;
   MeasId4->measObjectId = 1;
   MeasId4->reportConfigId = 5;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4);
-
   MeasId5 = CALLOC(1, sizeof(*MeasId5));
   MeasId5->measId = 6;
   MeasId5->measObjectId = 1;
   MeasId5->reportConfigId = 6;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5);
-
   //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list;
-
   // Add one EUTRA Measurement Object
   MeasObj_list = CALLOC(1, sizeof(*MeasObj_list));
   memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list));
-
   // Configure MeasObject
-
   MeasObj = CALLOC(1, sizeof(*MeasObj));
   memset((void *)MeasObj, 0, sizeof(*MeasObj));
-
   MeasObj->measObjectId = 1;
   MeasObj->measObject.present = MeasObjectToAddMod__measObject_PR_measObjectEUTRA;
   MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz
@@ -1450,10 +1391,8 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1;
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6;
   MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL;   // Default is 15 or 0dB
-
   MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList =
     (CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList));
-
   CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList;
 
   // Add adjacent cell lists (6 per eNB)
@@ -1462,28 +1401,19 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     CellToAdd->cellIndex = i + 1;
     CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i);
     CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0;
-
     ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd);
   }
 
   ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj);
   //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list;
-
   // Report Configurations for periodical, A1-A5 events
   ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list));
-
   ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per));
-
   ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1));
-
   ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2));
-
   ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3));
-
   ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4));
-
   ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5));
-
   ReportConfig_per->reportConfigId = 1;
   ReportConfig_per->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -1495,9 +1425,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per);
-
   ReportConfig_A1->reportConfigId = 2;
   ReportConfig_A1->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -1508,13 +1436,11 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   a1_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1.
   a1_Threshold.choice.threshold_RSRP = 10;
-
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1);
 
   if (RC.rrc[ctxt_pP->module_id]->HO_flag == 1 /*HO_MEASURMENT */ ) {
@@ -1530,39 +1456,32 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     eventA2.a2_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA2.a2_Threshold.choice.threshold_RSRP = 10;
-
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2);
-
     ReportConfig_A3->reportConfigId = 4;
     ReportConfig_A3->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present =
       ReportConfigEUTRA__triggerType_PR_event;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present =
       ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3;
-
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset = 1;   //10;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA3.reportOnLeave = 1;
-
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis = 0.5; // FIXME ...hysteresis is of type long!
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger =
       TimeToTrigger_ms40;
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3);
-
     ReportConfig_A4->reportConfigId = 5;
     ReportConfig_A4->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -1573,16 +1492,13 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     eventA4.a4_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA4.a4_Threshold.choice.threshold_RSRP = 10;
-
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4);
-
     ReportConfig_A5->reportConfigId = 6;
     ReportConfig_A5->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -1597,20 +1513,16 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     eventA5.a5_Threshold1.choice.threshold_RSRP = 10;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA5.a5_Threshold2.choice.threshold_RSRP = 10;
-
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5);
     //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list;
-
     rsrp = CALLOC(1, sizeof(RSRP_Range_t));
     *rsrp = 20;
-
     Sparams = CALLOC(1, sizeof(*Sparams));
     Sparams->present = MeasConfig__speedStatePars_PR_setup;
     Sparams->choice.setup.timeToTrigger_SF.sf_High = SpeedStateScaleFactors__sf_Medium_oDot75;
@@ -1619,7 +1531,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5;
     Sparams->choice.setup.mobilityStateParameters.t_Evaluation = MobilityStateParameters__t_Evaluation_s60;
     Sparams->choice.setup.mobilityStateParameters.t_HystNormal = MobilityStateParameters__t_HystNormal_s120;
-
     quantityConfig = CALLOC(1, sizeof(*quantityConfig));
     memset((void *)quantityConfig, 0, sizeof(*quantityConfig));
     quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct QuantityConfigEUTRA));
@@ -1633,7 +1544,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
       CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ)));
     *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4;
     *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4;
-
     LOG_I(RRC,
           "[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n",
           ctxt_pP->module_id, ctxt_pP->frame);
@@ -1647,15 +1557,14 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL;
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig =
       CALLOC(1, sizeof(*ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig));
-    memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig,
+    memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig,
            (void *)ue_context_pP->ue_context.mac_MainConfig, sizeof(MAC_MainConfig_t));
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated =
       CALLOC(1, sizeof(PhysicalConfigDedicated_t));
-    memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated,
-           (void*)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(PhysicalConfigDedicated_t));
+    memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated,
+           (void *)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(PhysicalConfigDedicated_t));
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.sps_Config = NULL;
     //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,(void *)rrc_inst->sps_Config[ue_mod_idP],sizeof(SPS_Config_t));
-
   }
 
 #ifdef CBA
@@ -1683,7 +1592,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   }
 
 #endif
-
 #if defined(ENABLE_ITTI)
   /* Initialize NAS list */
   dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList));
@@ -1694,7 +1602,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
       dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
       memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
       OCTET_STRING_fromBuf(dedicatedInfoNas,
-         (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
+                           (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
                            ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length);
       LOG_D(RRC, "Add dedicatedInfoNas(%d) to dedicatedInfoNASList\n", i);
       ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
@@ -1706,11 +1614,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
       //      ue_context_pP->ue_context.e_rab[i].param.sgw_addr;
       //      ue_context_pP->ue_context.e_rab[i].param.gtp_teid;
     }
-
     /* TODO should test if e RAB are Ok before! */
     ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE;
     LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n",
-    i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE");
+          i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE");
   }
 
   /* If list is empty free the list and reset the address */
@@ -1720,47 +1627,45 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   }
 
 #endif
-
   // send RRCConnectionReconfiguration
   memset(buffer, 0, RRC_BUF_SIZE);
-
   size = do_RRCConnectionReconfiguration(ctxt_pP,
                                          buffer,
                                          next_xid,   //Transaction_id,
-                                         (SRB_ToAddModList_t*)*SRB_configList2, // SRB_configList
-                                         (DRB_ToAddModList_t*)DRB_configList,
-                                         (DRB_ToReleaseList_t*)NULL,  // DRB2_list,
-                                         (struct SPS_Config*)NULL,    // maybe ue_context_pP->ue_context.sps_Config,
-                                         (struct PhysicalConfigDedicated*)ue_context_pP->ue_context.physicalConfigDedicated,
+                                         (SRB_ToAddModList_t *)*SRB_configList2, // SRB_configList
+                                         (DRB_ToAddModList_t *)DRB_configList,
+                                         (DRB_ToReleaseList_t *)NULL, // DRB2_list,
+                                         (struct SPS_Config *)NULL,   // maybe ue_context_pP->ue_context.sps_Config,
+                                         (struct PhysicalConfigDedicated *)ue_context_pP->ue_context.physicalConfigDedicated,
 #ifdef EXMIMO_IOT
                                          NULL, NULL, NULL,NULL,
 #else
-                                         (MeasObjectToAddModList_t*)MeasObj_list,  // MeasObj_list,
-                                         (ReportConfigToAddModList_t*)ReportConfig_list,  // ReportConfig_list,
-                                         (QuantityConfig_t*)quantityConfig,  //quantityConfig,
-                                         (MeasIdToAddModList_t*)NULL,
-#endif
-                                         (MAC_MainConfig_t*)ue_context_pP->ue_context.mac_MainConfig,
-                                         (MeasGapConfig_t*)NULL,
-                                         (MobilityControlInfo_t*)NULL,
-                                         (struct MeasConfig__speedStatePars*)Sparams, // Sparams,
-                                         (RSRP_Range_t*)rsrp, // rsrp,
-                                         (C_RNTI_t*)cba_RNTI,  // cba_RNTI
-                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList //dedicatedInfoNASList
+                                         (MeasObjectToAddModList_t *)MeasObj_list, // MeasObj_list,
+                                         (ReportConfigToAddModList_t *)ReportConfig_list, // ReportConfig_list,
+                                         (QuantityConfig_t *)quantityConfig, //quantityConfig,
+                                         (MeasIdToAddModList_t *)NULL,
+#endif
+                                         (MAC_MainConfig_t *)ue_context_pP->ue_context.mac_MainConfig,
+                                         (MeasGapConfig_t *)NULL,
+                                         (MobilityControlInfo_t *)NULL,
+                                         (struct MeasConfig__speedStatePars *)Sparams, // Sparams,
+                                         (RSRP_Range_t *)rsrp, // rsrp,
+                                         (C_RNTI_t *)cba_RNTI, // cba_RNTI
+                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList //dedicatedInfoNASList
 #if defined(Rel10) || defined(Rel14)
-                                         , (SCellToAddMod_r10_t*)NULL
+                                         , (SCellToAddMod_r10_t *)NULL
 #endif
                                         );
-
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n");
+
   for (i = 0; i < size; i++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
   }
+
   LOG_F(RRC,"\n");
   ////////////////////////////////////////
 #endif
-
 #if defined(ENABLE_ITTI)
 
   /* Free all NAS PDUs */
@@ -1773,15 +1678,12 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   }
 
 #endif
-
   LOG_I(RRC,
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
-
   LOG_D(RRC,
         "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n",
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -1792,51 +1694,56 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
-         ctxt_pP,
-         DCCH,
-         rrc_eNB_mui++,
-         SDU_CONFIRM_NO,
-         size,
-         buffer,
-         PDCP_TRANSMISSION_MODE_CONTROL);
-
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
   // delete UE data of prior RNTI.  UE use current RNTI.
   protocol_ctxt_t ctxt_prior = *ctxt_pP;
   ctxt_prior.rnti = reestablish_rnti;
-
   LTE_eNB_ULSCH_t *ulsch = NULL;
   nfapi_ul_config_request_body_t *ul_req_tmp = NULL;
   PHY_VARS_eNB *eNB_PHY = NULL;
   eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id];
+
   for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
     eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id];
-    for (int i=0; i<MAX_MOBILES_PER_ENB; i++) {
+
+    for (int i=0; i<NUMBER_OF_UE_MAX; i++) {
       ulsch = eNB_PHY->ulsch[i];
-      if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){
+
+      if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)) {
         LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti);
         clean_eNb_ulsch(ulsch);
         break;
       }
     }
 
-    for(int j = 0; j < 10; j++){
+    for(int j = 0; j < 10; j++) {
       ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body;
-      if(ul_req_tmp){
+
+      if(ul_req_tmp) {
         int pdu_number = ul_req_tmp->number_of_pdus;
-        for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){
-          if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == ctxt_prior.rnti){
+
+        for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--) {
+          if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == ctxt_prior.rnti) {
             LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", ctxt_prior.rnti, pdu_index, pdu_number);
-            if(pdu_index < pdu_number -1){
-               memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t));
+
+            if(pdu_index < pdu_number -1) {
+              memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t));
             }
+
             ul_req_tmp->number_of_pdus--;
           }
         }
       }
     }
   }
+
   rrc_mac_remove_ue(ctxt_prior.module_id, ctxt_prior.rnti);
   rrc_rlc_remove_ue(&ctxt_prior);
   pdcp_remove_UE(&ctxt_prior);
@@ -1845,8 +1752,8 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_RRCConnectionReestablishmentReject(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
   const int                    CC_id
 )
 //-----------------------------------------------------------------------------
@@ -1857,24 +1764,20 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject(
   int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti);
   RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1;
   RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 20;
-
   T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
     do_RRCConnectionReestablishmentReject(ctxt_pP->module_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].Srb0.Tx_buffer.Payload);
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRCConnectionReestablishmentReject\n");
 
   for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload)[cnt]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload)[cnt]);
   }
 
   LOG_F(RRC,"\n");
 #endif
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -1884,7 +1787,6 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject(
     MSC_AS_TIME_ARGS(ctxt_pP),
     ue_context_pP == NULL ? -1 : 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 RRCConnectionReestablishmentReject (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
@@ -1894,26 +1796,22 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_RRCConnectionRelease(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP
 )
 //-----------------------------------------------------------------------------
 {
-
   uint8_t                             buffer[RRC_BUF_SIZE];
   uint16_t                            size;
-
   T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   memset(buffer, 0, RRC_BUF_SIZE);
-
   size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id));
   // set release timer
   //ue_context_pP->ue_context.ue_release_timer=1;
   // remove UE after 10 frames after RRCConnectionRelease is triggered
   //ue_context_pP->ue_context.ue_release_timer_thres=100;
-    // set release timer
+  // set release timer
   ue_context_pP->ue_context.ue_release_timer_rrc = 1;
   // remove UE after 10 frames after RRCConnectionRelease is triggered
   ue_context_pP->ue_context.ue_release_timer_thres_rrc = 100;
@@ -1924,14 +1822,12 @@ rrc_eNB_generate_RRCConnectionRelease(
         PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
         size);
-
   LOG_D(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
         size,
         rrc_eNB_mui,
         DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -1942,34 +1838,31 @@ rrc_eNB_generate_RRCConnectionRelease(
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
-	       ctxt_pP,
-	       DCCH,
-	       rrc_eNB_mui++,
-	       SDU_CONFIRM_NO,
-	       size,
-	       buffer,
-	       PDCP_TRANSMISSION_MODE_CONTROL);
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
-uint8_t qci_to_priority[9]={2,4,3,5,1,6,7,8,9};
+uint8_t qci_to_priority[9]= {2,4,3,5,1,6,7,8,9};
 
 // TBD: this directive can be remived if we create a similar e_rab_param_t structure in RRC context
-#if defined(ENABLE_ITTI) 
+#if defined(ENABLE_ITTI)
 //-----------------------------------------------------------------------------
 void
-rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP,
-						     rrc_eNB_ue_context_t*          const ue_context_pP,
-						     const uint8_t                ho_state
-						     )
+rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP,
+    rrc_eNB_ue_context_t          *const ue_context_pP,
+    const uint8_t                ho_state
+                                                      )
 //-----------------------------------------------------------------------------
 {
-  
   uint8_t                             buffer[RRC_BUF_SIZE];
   uint16_t                            size;
   int i;
-  
   struct DRB_ToAddMod                *DRB_config                       = NULL;
   struct RLC_Config                  *DRB_rlc_config                   = NULL;
   struct PDCP_Config                 *DRB_pdcp_config                  = NULL;
@@ -1978,61 +1871,53 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co
   struct LogicalChannelConfig        *DRB_lchan_config                 = NULL;
   struct LogicalChannelConfig__ul_SpecificParameters
     *DRB_ul_SpecificParameters        = NULL;
-  //  DRB_ToAddModList_t**                DRB_configList=&ue_context_pP->ue_context.DRB_configList; 
-  DRB_ToAddModList_t*                DRB_configList=ue_context_pP->ue_context.DRB_configList; 
-  DRB_ToAddModList_t**                DRB_configList2=NULL;
+  //  DRB_ToAddModList_t**                DRB_configList=&ue_context_pP->ue_context.DRB_configList;
+  DRB_ToAddModList_t                *DRB_configList=ue_context_pP->ue_context.DRB_configList;
+  DRB_ToAddModList_t                **DRB_configList2=NULL;
   //DRB_ToAddModList_t**                RRC_DRB_configList=&ue_context_pP->ue_context.DRB_configList;
-
   struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL;
   DedicatedInfoNAS_t                 *dedicatedInfoNas                 = NULL;
   /* for no gcc warnings */
   (void)dedicatedInfoNas;
-
   long  *logicalchannelgroup_drb;
-//  int drb_identity_index=0;
-
+  //  int drb_identity_index=0;
   uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id);   //Transaction_id,
   DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid];
+
   if (*DRB_configList2) {
     free(*DRB_configList2);
   }
+
   //*DRB_configList = CALLOC(1, sizeof(*DRB_configList));
-  *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); 
+  *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2));
   /* Initialize NAS list */
   dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList));
-
   int e_rab_done=0;
-  
-  for ( i = 0  ;
-	i < ue_context_pP->ue_context.setup_e_rabs ;
-	i++){
 
-    if (e_rab_done >= ue_context_pP->ue_context.nb_of_e_rabs){
-        break;
+  for ( i = 0  ;
+        i < ue_context_pP->ue_context.setup_e_rabs ;
+        i++) {
+    if (e_rab_done >= ue_context_pP->ue_context.nb_of_e_rabs) {
+      break;
     }
-    
+
     // bypass the new and already configured erabs
     if (ue_context_pP->ue_context.e_rab[i].status >= E_RAB_STATUS_DONE) {
-//      drb_identity_index++;
+      //      drb_identity_index++;
       continue;
     }
-        
-    DRB_config = CALLOC(1, sizeof(*DRB_config));
 
+    DRB_config = CALLOC(1, sizeof(*DRB_config));
     DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long));
     // allowed value 5..15, value : x+4
-    *(DRB_config->eps_BearerIdentity) = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation  
-
- //   DRB_config->drb_Identity =  1 + drb_identity_index + e_rab_done;// + i ;// (DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id;
-    // 1 + drb_identiy_index;  
+    *(DRB_config->eps_BearerIdentity) = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation
+    //   DRB_config->drb_Identity =  1 + drb_identity_index + e_rab_done;// + i ;// (DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id;
+    // 1 + drb_identiy_index;
     DRB_config->drb_Identity = i+1;
-
     DRB_config->logicalChannelIdentity = CALLOC(1, sizeof(long));
     *(DRB_config->logicalChannelIdentity) = DRB_config->drb_Identity + 2; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2
-    
     DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config));
     DRB_config->rlc_Config = DRB_rlc_config;
-
     DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
     DRB_config->pdcp_Config = DRB_pdcp_config;
     DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long));
@@ -2040,123 +1925,115 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co
     DRB_pdcp_config->rlc_AM = NULL;
     DRB_pdcp_config->rlc_UM = NULL;
 
-
-    switch (ue_context_pP->ue_context.e_rab[i].param.qos.qci){
+    switch (ue_context_pP->ue_context.e_rab[i].param.qos.qci) {
       /*
        * type: realtime data with medium packer error rate
        * action: swtich to RLC UM
        */
-    case 1: // 100ms, 10^-2, p2, GBR
-    case 2: // 150ms, 10^-3, p4, GBR
-    case 3: // 50ms, 10^-3, p3, GBR
-    case 4:  // 300ms, 10^-6, p5 
-    case 7: // 100ms, 10^-3, p7, GBR
-    case 9: // 300ms, 10^-6, p9
-    case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR
-    case 66: // 100ms, 10^-2, p2, non-mission critical  voice , GBR
-      // RLC 
-      DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional;
-      DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
-      DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
-      DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
-      // PDCP
-      PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM));
-      DRB_pdcp_config->rlc_UM = PDCP_rlc_UM;
-      PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
-      break;
-      
+      case 1: // 100ms, 10^-2, p2, GBR
+      case 2: // 150ms, 10^-3, p4, GBR
+      case 3: // 50ms, 10^-3, p3, GBR
+      case 4:  // 300ms, 10^-6, p5
+      case 7: // 100ms, 10^-3, p7, GBR
+      case 9: // 300ms, 10^-6, p9
+      case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR
+      case 66: // 100ms, 10^-2, p2, non-mission critical  voice , GBR
+        // RLC
+        DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional;
+        DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
+        DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
+        DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
+        // PDCP
+        PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM));
+        DRB_pdcp_config->rlc_UM = PDCP_rlc_UM;
+        PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
+        break;
+
       /*
        * type: non-realtime data with low packer error rate
        * action: swtich to RLC AM
        */
-    case 5:  // 100ms, 10^-6, p1 , IMS signaling 
-    case 6:  // 300ms, 10^-6, p6 
-    case 8: // 300ms, 10^-6, p8 
-    case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority 
-    case 70: // 200ms, 10^-6, p5.5, mision critical data 
-      // RLC
-       DRB_rlc_config->present = RLC_Config_PR_am;
-       DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50;
-       DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = PollPDU_p16;
-       DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity;
-       DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8;
-       DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
-       DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms25;
-
-       // PDCP
-       PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM));
-       DRB_pdcp_config->rlc_AM = PDCP_rlc_AM;
-       PDCP_rlc_AM->statusReportRequired = FALSE;
-       
-       break;
-    default :
-      LOG_E(RRC,"not supported qci %d\n", ue_context_pP->ue_context.e_rab[i].param.qos.qci);
-      ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_FAILED; 
-      ue_context_pP->ue_context.e_rab[i].xid = xid;
-      e_rab_done++;
-      continue;
+      case 5:  // 100ms, 10^-6, p1 , IMS signaling
+      case 6:  // 300ms, 10^-6, p6
+      case 8: // 300ms, 10^-6, p8
+      case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority
+      case 70: // 200ms, 10^-6, p5.5, mision critical data
+        // RLC
+        DRB_rlc_config->present = RLC_Config_PR_am;
+        DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50;
+        DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = PollPDU_p16;
+        DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity;
+        DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8;
+        DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
+        DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms25;
+        // PDCP
+        PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM));
+        DRB_pdcp_config->rlc_AM = PDCP_rlc_AM;
+        PDCP_rlc_AM->statusReportRequired = FALSE;
+        break;
+
+      default :
+        LOG_E(RRC,"not supported qci %d\n", ue_context_pP->ue_context.e_rab[i].param.qos.qci);
+        ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_FAILED;
+        ue_context_pP->ue_context.e_rab[i].xid = xid;
+        e_rab_done++;
+        continue;
     }
 
     DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
-    
     DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config));
     DRB_config->logicalChannelConfig = DRB_lchan_config;
     DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters));
     DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters;
 
     if (ue_context_pP->ue_context.e_rab[i].param.qos.qci < 9 )
-      DRB_ul_SpecificParameters->priority = qci_to_priority[ue_context_pP->ue_context.e_rab[i].param.qos.qci-1] + 3; 
+      DRB_ul_SpecificParameters->priority = qci_to_priority[ue_context_pP->ue_context.e_rab[i].param.qos.qci-1] + 3;
     // ue_context_pP->ue_context.e_rab[i].param.qos.allocation_retention_priority.priority_level;
-    else 
+    else
       DRB_ul_SpecificParameters->priority= 4;
 
     DRB_ul_SpecificParameters->prioritisedBitRate = LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8;
-      //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
+    //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
     DRB_ul_SpecificParameters->bucketSizeDuration =
       LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-    
     logicalchannelgroup_drb = CALLOC(1, sizeof(long));
     *logicalchannelgroup_drb = 1;//(i+1) % 3;
     DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb;
-
     ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config);
     ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config);
     //ue_context_pP->ue_context.DRB_configList2[drb_identity_index] = &(*DRB_configList);
-    
     LOG_I(RRC,"EPS ID %ld, DRB ID %ld (index %d), QCI %d, priority %ld, LCID %ld LCGID %ld \n",
-	  *DRB_config->eps_BearerIdentity,
-	  DRB_config->drb_Identity, i,
-	  ue_context_pP->ue_context.e_rab[i].param.qos.qci,
-	  DRB_ul_SpecificParameters->priority,
-	  *(DRB_config->logicalChannelIdentity),
-	  *DRB_ul_SpecificParameters->logicalChannelGroup	  
-	  );
-
+          *DRB_config->eps_BearerIdentity,
+          DRB_config->drb_Identity, i,
+          ue_context_pP->ue_context.e_rab[i].param.qos.qci,
+          DRB_ul_SpecificParameters->priority,
+          *(DRB_config->logicalChannelIdentity),
+          *DRB_ul_SpecificParameters->logicalChannelGroup
+         );
     e_rab_done++;
-    ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; 
+    ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE;
     ue_context_pP->ue_context.e_rab[i].xid = xid;
-    
     {
       if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) {
-	dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
-	memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
-	OCTET_STRING_fromBuf(dedicatedInfoNas, 
-			     (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
-			     ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length);
-	ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
-	LOG_I(RRC,"add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length, i);
-      } 
+        dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
+        memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
+        OCTET_STRING_fromBuf(dedicatedInfoNas,
+                             (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
+                             ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length);
+        ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
+        LOG_I(RRC,"add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length, i);
+      }
       else {
-	LOG_W(RRC,"Not received activate dedicated EPS bearer context request\n");
+        LOG_W(RRC,"Not received activate dedicated EPS bearer context request\n");
       }
+
       /* TODO parameters yet to process ... */
       {
-	//      ue_context_pP->ue_context.e_rab[i].param.qos;
-	//      ue_context_pP->ue_context.e_rab[i].param.sgw_addr;
-	//      ue_context_pP->ue_context.e_rab[i].param.gtp_teid;
+        //      ue_context_pP->ue_context.e_rab[i].param.qos;
+        //      ue_context_pP->ue_context.e_rab[i].param.sgw_addr;
+        //      ue_context_pP->ue_context.e_rab[i].param.gtp_teid;
       }
     }
-    
   }
 
   /* If list is empty free the list and reset the address */
@@ -2165,38 +2042,36 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co
       free(dedicatedInfoNASList);
       dedicatedInfoNASList = NULL;
       LOG_W(RRC,"dedlicated NAS list is empty, free the list and reset the address\n");
-    }				
+    }
   } else {
     LOG_W(RRC,"dedlicated NAS list is empty\n");
   }
 
   memset(buffer, 0, RRC_BUF_SIZE);
-
-   size = do_RRCConnectionReconfiguration(ctxt_pP,
-					  buffer,
-					  xid,
-					  (SRB_ToAddModList_t*)NULL, 
-					  (DRB_ToAddModList_t*)*DRB_configList2,
-					  (DRB_ToReleaseList_t*)NULL,  // DRB2_list,
-                                         (struct SPS_Config*)NULL,    // *sps_Config,
-					  NULL, NULL, NULL, NULL,NULL,
-					  NULL, NULL,  NULL, NULL, NULL, NULL, 
-					  (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList
+  size = do_RRCConnectionReconfiguration(ctxt_pP,
+                                         buffer,
+                                         xid,
+                                         (SRB_ToAddModList_t *)NULL,
+                                         (DRB_ToAddModList_t *)*DRB_configList2,
+                                         (DRB_ToReleaseList_t *)NULL, // DRB2_list,
+                                         (struct SPS_Config *)NULL,   // *sps_Config,
+                                         NULL, NULL, NULL, NULL,NULL,
+                                         NULL, NULL,  NULL, NULL, NULL, NULL,
+                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList
 #if defined(Rel10) || defined(Rel14)
-                                         , (SCellToAddMod_r10_t*)NULL
+                                         , (SCellToAddMod_r10_t *)NULL
 #endif
                                         );
- 
-
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n");
+
   for (i = 0; i < size; i++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
   }
+
   LOG_F(RRC,"\n");
   ////////////////////////////////////////
 #endif
-
 #if defined(ENABLE_ITTI)
 
   /* Free all NAS PDUs */
@@ -2207,16 +2082,14 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co
       ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL;
     }
   }
-#endif
 
- LOG_I(RRC,
+#endif
+  LOG_I(RRC,
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
-
   LOG_D(RRC,
         "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n",
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -2227,7 +2100,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
     ctxt_pP,
     DCCH,
@@ -2236,20 +2108,17 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co
     size,
     buffer,
     PDCP_TRANSMISSION_MODE_CONTROL);
-
-
 }
 int
-rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP,
-                             rrc_eNB_ue_context_t*          const ue_context_pP,
-                             const uint8_t                ho_state
-                             )
+rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP,
+    rrc_eNB_ue_context_t          *const ue_context_pP,
+    const uint8_t                ho_state
+                                                    )
 //-----------------------------------------------------------------------------
 {
   uint8_t                             buffer[RRC_BUF_SIZE];
   uint16_t                            size;
   int i, j;
-
   struct DRB_ToAddMod                *DRB_config                       = NULL;
   struct RLC_Config                  *DRB_rlc_config                   = NULL;
   struct PDCP_Config                 *DRB_pdcp_config                  = NULL;
@@ -2257,15 +2126,13 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   struct PDCP_Config__rlc_UM         *PDCP_rlc_UM                      = NULL;
   struct LogicalChannelConfig        *DRB_lchan_config                 = NULL;
   struct LogicalChannelConfig__ul_SpecificParameters
-  *DRB_ul_SpecificParameters        = NULL;
-  DRB_ToAddModList_t*                 DRB_configList = ue_context_pP->ue_context.DRB_configList;
-  DRB_ToAddModList_t*                DRB_configList2 = NULL;
-
+    *DRB_ul_SpecificParameters        = NULL;
+  DRB_ToAddModList_t                 *DRB_configList = ue_context_pP->ue_context.DRB_configList;
+  DRB_ToAddModList_t                *DRB_configList2 = NULL;
   struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL;
   DedicatedInfoNAS_t                 *dedicatedInfoNas                 = NULL;
   /* for no gcc warnings */
   (void)dedicatedInfoNas;
-
   uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id);   // Transaction_id,
   DRB_configList2 = CALLOC(1, sizeof(*DRB_configList2));
   /* Initialize NAS list */
@@ -2286,6 +2153,7 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     }
 
     DRB_config = NULL;
+
     // search exist DRB_config
     for (j = 0; j < DRB_configList->list.count; j++) {
       if((uint8_t)*(DRB_configList->list.array[j]->eps_BearerIdentity) == ue_context_pP->ue_context.modify_e_rab[i].param.e_rab_id) {
@@ -2293,6 +2161,7 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
         break;
       }
     }
+
     if (NULL == DRB_config) {
       ue_context_pP->ue_context.modify_e_rab[i].xid = xid;
       ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED;
@@ -2304,85 +2173,89 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     }
 
     DRB_rlc_config = DRB_config->rlc_Config;
-
     DRB_pdcp_config = DRB_config->pdcp_Config;
     *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity;
+
     switch (ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci) {
-    /*
-     * type: realtime data with medium packer error rate
-     * action: swtich to RLC UM
-     */
-    case 1: // 100ms, 10^-2, p2, GBR
-    case 2: // 150ms, 10^-3, p4, GBR
-    case 3: // 50ms, 10^-3, p3, GBR
-    case 4:  // 300ms, 10^-6, p5
-    case 7: // 100ms, 10^-3, p7, GBR
-    case 9: // 300ms, 10^-6, p9
-    case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR
-    case 66: // 100ms, 10^-2, p2, non-mission critical  voice , GBR
-      // RLC
-      DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional;
-      DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
-      DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
-      DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
-      // PDCP
-      if (DRB_pdcp_config->rlc_AM) {
-        free(DRB_pdcp_config->rlc_AM);
-        DRB_pdcp_config->rlc_AM = NULL;
-      }
-      if (DRB_pdcp_config->rlc_UM) {
-        free(DRB_pdcp_config->rlc_UM);
-        DRB_pdcp_config->rlc_UM = NULL;
-      }
-      PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM));
-      DRB_pdcp_config->rlc_UM = PDCP_rlc_UM;
-      PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
-      break;
+      /*
+       * type: realtime data with medium packer error rate
+       * action: swtich to RLC UM
+       */
+      case 1: // 100ms, 10^-2, p2, GBR
+      case 2: // 150ms, 10^-3, p4, GBR
+      case 3: // 50ms, 10^-3, p3, GBR
+      case 4:  // 300ms, 10^-6, p5
+      case 7: // 100ms, 10^-3, p7, GBR
+      case 9: // 300ms, 10^-6, p9
+      case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR
+      case 66: // 100ms, 10^-2, p2, non-mission critical  voice , GBR
+        // RLC
+        DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional;
+        DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
+        DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
+        DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
+
+        // PDCP
+        if (DRB_pdcp_config->rlc_AM) {
+          free(DRB_pdcp_config->rlc_AM);
+          DRB_pdcp_config->rlc_AM = NULL;
+        }
 
-    /*
-     * type: non-realtime data with low packer error rate
-     * action: swtich to RLC AM
-     */
-    case 5:  // 100ms, 10^-6, p1 , IMS signaling
-    case 6:  // 300ms, 10^-6, p6
-    case 8: // 300ms, 10^-6, p8
-    case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority
-    case 70: // 200ms, 10^-6, p5.5, mision critical data
-       // RLC
-       DRB_rlc_config->present = RLC_Config_PR_am;
-       DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50;
-       DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = PollPDU_p16;
-       DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity;
-       DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8;
-       DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
-       DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms25;
-
-       // PDCP
-       if (DRB_pdcp_config->rlc_AM) {
-         free(DRB_pdcp_config->rlc_AM);
-         DRB_pdcp_config->rlc_AM = NULL;
-       }
-       if (DRB_pdcp_config->rlc_UM) {
-         free(DRB_pdcp_config->rlc_UM);
-         DRB_pdcp_config->rlc_UM = NULL;
-       }
-       PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM));
-       DRB_pdcp_config->rlc_AM = PDCP_rlc_AM;
-       PDCP_rlc_AM->statusReportRequired = FALSE;
-
-       break;
-    default :
-      LOG_E(RRC, "not supported qci %d\n", ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci);
-      ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED;
-      ue_context_pP->ue_context.modify_e_rab[i].xid = xid;
-      ue_context_pP->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK;
-      ue_context_pP->ue_context.modify_e_rab[i].cause_value = 37;//S1ap_CauseRadioNetwork_not_supported_QCI_value;
-      ue_context_pP->ue_context.nb_of_failed_e_rabs++;
-      continue;
+        if (DRB_pdcp_config->rlc_UM) {
+          free(DRB_pdcp_config->rlc_UM);
+          DRB_pdcp_config->rlc_UM = NULL;
+        }
+
+        PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM));
+        DRB_pdcp_config->rlc_UM = PDCP_rlc_UM;
+        PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
+        break;
+
+      /*
+       * type: non-realtime data with low packer error rate
+       * action: swtich to RLC AM
+       */
+      case 5:  // 100ms, 10^-6, p1 , IMS signaling
+      case 6:  // 300ms, 10^-6, p6
+      case 8: // 300ms, 10^-6, p8
+      case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority
+      case 70: // 200ms, 10^-6, p5.5, mision critical data
+        // RLC
+        DRB_rlc_config->present = RLC_Config_PR_am;
+        DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50;
+        DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = PollPDU_p16;
+        DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity;
+        DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8;
+        DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
+        DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms25;
+
+        // PDCP
+        if (DRB_pdcp_config->rlc_AM) {
+          free(DRB_pdcp_config->rlc_AM);
+          DRB_pdcp_config->rlc_AM = NULL;
+        }
+
+        if (DRB_pdcp_config->rlc_UM) {
+          free(DRB_pdcp_config->rlc_UM);
+          DRB_pdcp_config->rlc_UM = NULL;
+        }
+
+        PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM));
+        DRB_pdcp_config->rlc_AM = PDCP_rlc_AM;
+        PDCP_rlc_AM->statusReportRequired = FALSE;
+        break;
+
+      default :
+        LOG_E(RRC, "not supported qci %d\n", ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci);
+        ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED;
+        ue_context_pP->ue_context.modify_e_rab[i].xid = xid;
+        ue_context_pP->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK;
+        ue_context_pP->ue_context.modify_e_rab[i].cause_value = 37;//S1ap_CauseRadioNetwork_not_supported_QCI_value;
+        ue_context_pP->ue_context.nb_of_failed_e_rabs++;
+        continue;
     }
 
     DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
-
     DRB_lchan_config = DRB_config->logicalChannelConfig;
     DRB_ul_SpecificParameters = DRB_lchan_config->ul_SpecificParameters;
 
@@ -2392,32 +2265,27 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
       DRB_ul_SpecificParameters->priority= 4;
 
     DRB_ul_SpecificParameters->prioritisedBitRate = LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8;
-
     DRB_ul_SpecificParameters->bucketSizeDuration =
       LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
     ASN_SEQUENCE_ADD(&(DRB_configList2)->list, DRB_config);
-
     LOG_I(RRC, "EPS ID %ld, DRB ID %ld (index %d), QCI %d, priority %ld, LCID %ld LCGID %ld \n",
-      *DRB_config->eps_BearerIdentity,
-      DRB_config->drb_Identity, i,
-      ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci,
-      DRB_ul_SpecificParameters->priority,
-      *(DRB_config->logicalChannelIdentity),
-      *DRB_ul_SpecificParameters->logicalChannelGroup
-      );
-
+          *DRB_config->eps_BearerIdentity,
+          DRB_config->drb_Identity, i,
+          ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci,
+          DRB_ul_SpecificParameters->priority,
+          *(DRB_config->logicalChannelIdentity),
+          *DRB_ul_SpecificParameters->logicalChannelGroup
+         );
     //e_rab_done++;
     ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_DONE;
     ue_context_pP->ue_context.modify_e_rab[i].xid = xid;
-
     {
       if (ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer != NULL) {
         dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
         memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
         OCTET_STRING_fromBuf(dedicatedInfoNas,
-                 (char*)ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer,
-                 ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length);
+                             (char *)ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer,
+                             ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length);
         ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
         LOG_I(RRC, "add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length, i);
       }
@@ -2439,32 +2307,30 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   }
 
   memset(buffer, 0, RRC_BUF_SIZE);
-
   size = do_RRCConnectionReconfiguration(ctxt_pP,
-                                          buffer,
-                                          xid,
-                                          (SRB_ToAddModList_t*)NULL,
-                                          (DRB_ToAddModList_t*)DRB_configList2,
-                                          (DRB_ToReleaseList_t*)NULL,  // DRB2_list,
-                                          (struct SPS_Config*)NULL,    // *sps_Config,
-                                          NULL, NULL, NULL, NULL,NULL,
-                                          NULL, NULL,  NULL, NULL, NULL, NULL,
-                                          (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList
+                                         buffer,
+                                         xid,
+                                         (SRB_ToAddModList_t *)NULL,
+                                         (DRB_ToAddModList_t *)DRB_configList2,
+                                         (DRB_ToReleaseList_t *)NULL, // DRB2_list,
+                                         (struct SPS_Config *)NULL,   // *sps_Config,
+                                         NULL, NULL, NULL, NULL,NULL,
+                                         NULL, NULL,  NULL, NULL, NULL, NULL,
+                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList
 #if defined(Rel10) || defined(Rel14)
-                                          , (SCellToAddMod_r10_t*)NULL
+                                         , (SCellToAddMod_r10_t *)NULL
 #endif
-                                          );
-
-
+                                        );
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n");
+
   for (i = 0; i < size; i++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
   }
+
   LOG_F(RRC,"\n");
   ////////////////////////////////////////
 #endif
-
 #if defined(ENABLE_ITTI)
 
   /* Free all NAS PDUs */
@@ -2475,16 +2341,14 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
       ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer = NULL;
     }
   }
-#endif
 
- LOG_I(RRC,
+#endif
+  LOG_I(RRC,
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
-
   LOG_D(RRC,
         "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n",
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -2495,7 +2359,6 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
     ctxt_pP,
     DCCH,
@@ -2509,101 +2372,101 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons
 
 //-----------------------------------------------------------------------------
 void
-rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(  const protocol_ctxt_t*   const ctxt_pP,
-        rrc_eNB_ue_context_t*    const ue_context_pP,
-        uint8_t                  xid,
-        uint32_t                 nas_length,
-        uint8_t*                 nas_buffer)
+rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(  const protocol_ctxt_t   *const ctxt_pP,
+    rrc_eNB_ue_context_t    *const ue_context_pP,
+    uint8_t                  xid,
+    uint32_t                 nas_length,
+    uint8_t                 *nas_buffer)
 //-----------------------------------------------------------------------------
 {
-    uint8_t                             buffer[RRC_BUF_SIZE];
-    int                                 i;
-    uint16_t                            size  = 0;
-    DRB_ToReleaseList_t**                DRB_Release_configList2=NULL;
-    DRB_Identity_t* DRB_release;
-    struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL;
-
-    DRB_Release_configList2=&ue_context_pP->ue_context.DRB_Release_configList2[xid];
-    if (*DRB_Release_configList2) {
-      free(*DRB_Release_configList2);
-    }
-    *DRB_Release_configList2 = CALLOC(1, sizeof(**DRB_Release_configList2));
-
-    for(i = 0; i < NB_RB_MAX; i++){
-        if((ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_TORELEASE) && ue_context_pP->ue_context.e_rab[i].xid == xid){
-            DRB_release = CALLOC(1, sizeof(DRB_Identity_t));
-            *DRB_release = i+1;
-            ASN_SEQUENCE_ADD(&(*DRB_Release_configList2)->list, DRB_release);
-            //free(DRB_release);
-        }
-    }
+  uint8_t                             buffer[RRC_BUF_SIZE];
+  int                                 i;
+  uint16_t                            size  = 0;
+  DRB_ToReleaseList_t                **DRB_Release_configList2=NULL;
+  DRB_Identity_t *DRB_release;
+  struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL;
+  DRB_Release_configList2=&ue_context_pP->ue_context.DRB_Release_configList2[xid];
 
-    /* If list is empty free the list and reset the address */
-    if (nas_length > 0) {
-        DedicatedInfoNAS_t                 *dedicatedInfoNas                 = NULL;
-        dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList));
-        dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
-        memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
-                       OCTET_STRING_fromBuf(dedicatedInfoNas,
-                              (char*)nas_buffer,
-                              nas_length);
-        ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
-        LOG_I(RRC,"add NAS info with size %d\n",nas_length);
-    } else {
-      LOG_W(RRC,"dedlicated NAS list is empty\n");
+  if (*DRB_Release_configList2) {
+    free(*DRB_Release_configList2);
+  }
+
+  *DRB_Release_configList2 = CALLOC(1, sizeof(**DRB_Release_configList2));
+
+  for(i = 0; i < NB_RB_MAX; i++) {
+    if((ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_TORELEASE) && ue_context_pP->ue_context.e_rab[i].xid == xid) {
+      DRB_release = CALLOC(1, sizeof(DRB_Identity_t));
+      *DRB_release = i+1;
+      ASN_SEQUENCE_ADD(&(*DRB_Release_configList2)->list, DRB_release);
+      //free(DRB_release);
     }
+  }
+
+  /* If list is empty free the list and reset the address */
+  if (nas_length > 0) {
+    DedicatedInfoNAS_t                 *dedicatedInfoNas                 = NULL;
+    dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList));
+    dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
+    memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
+    OCTET_STRING_fromBuf(dedicatedInfoNas,
+                         (char *)nas_buffer,
+                         nas_length);
+    ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
+    LOG_I(RRC,"add NAS info with size %d\n",nas_length);
+  } else {
+    LOG_W(RRC,"dedlicated NAS list is empty\n");
+  }
 
-    memset(buffer, 0, RRC_BUF_SIZE);
-    size = do_RRCConnectionReconfiguration(ctxt_pP,
-                                    buffer,
-                                    xid,
-                                    NULL,
-                                    NULL,
-                                    (DRB_ToReleaseList_t*)*DRB_Release_configList2,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList
+  memset(buffer, 0, RRC_BUF_SIZE);
+  size = do_RRCConnectionReconfiguration(ctxt_pP,
+                                         buffer,
+                                         xid,
+                                         NULL,
+                                         NULL,
+                                         (DRB_ToReleaseList_t *)*DRB_Release_configList2,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList
 #if defined(Rel10) || defined(Rel14)
-                                    , (SCellToAddMod_r10_t*)NULL
+                                         , (SCellToAddMod_r10_t *)NULL
 #endif
-                                   );
-    ue_context_pP->ue_context.e_rab_release_command_flag = 1;
-
+                                        );
+  ue_context_pP->ue_context.e_rab_release_command_flag = 1;
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n");
+
   for (i = 0; i < size; i++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
   }
+
   LOG_F(RRC,"\n");
   ////////////////////////////////////////
 #endif
-
 #if defined(ENABLE_ITTI)
+
   /* Free all NAS PDUs */
   if (nas_length > 0) {
-      /* Free the NAS PDU buffer and invalidate it */
-      free(nas_buffer);
+    /* Free the NAS PDU buffer and invalidate it */
+    free(nas_buffer);
   }
-#endif
 
+#endif
   LOG_I(RRC,
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
-
   LOG_D(RRC,
         "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n",
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -2614,7 +2477,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(  const protocol_
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
     ctxt_pP,
     DCCH,
@@ -2623,33 +2485,29 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(  const protocol_
     size,
     buffer,
     PDCP_TRANSMISSION_MODE_CONTROL);
-
 }
-#endif 
+#endif
 //-----------------------------------------------------------------------------
 void
-rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP,
-						     rrc_eNB_ue_context_t*          const ue_context_pP,
-						     const uint8_t                ho_state
-						     )
+rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP,
+    rrc_eNB_ue_context_t          *const ue_context_pP,
+    const uint8_t                ho_state
+                                                    )
 //-----------------------------------------------------------------------------
 {
   uint8_t                             buffer[RRC_BUF_SIZE];
   uint16_t                            size;
   int                                 i;
-
   // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE
-  eNB_RRC_INST*                       rrc_inst = RC.rrc[ctxt_pP->module_id];
-  struct PhysicalConfigDedicated**    physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
-
+  eNB_RRC_INST                       *rrc_inst = RC.rrc[ctxt_pP->module_id];
+  struct PhysicalConfigDedicated    **physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
   struct SRB_ToAddMod                *SRB2_config                      = NULL;
   struct SRB_ToAddMod__rlc_Config    *SRB2_rlc_config                  = NULL;
   struct SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config         = NULL;
   struct LogicalChannelConfig__ul_SpecificParameters
-      *SRB2_ul_SpecificParameters       = NULL;
-  SRB_ToAddModList_t*                 SRB_configList = ue_context_pP->ue_context.SRB_configList;
+    *SRB2_ul_SpecificParameters       = NULL;
+  SRB_ToAddModList_t                 *SRB_configList = ue_context_pP->ue_context.SRB_configList;
   SRB_ToAddModList_t                 **SRB_configList2                  = NULL;
-
   struct DRB_ToAddMod                *DRB_config                       = NULL;
   struct RLC_Config                  *DRB_rlc_config                   = NULL;
   struct PDCP_Config                 *DRB_pdcp_config                  = NULL;
@@ -2657,10 +2515,10 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   struct PDCP_Config__rlc_UM         *PDCP_rlc_UM                      = NULL;
   struct LogicalChannelConfig        *DRB_lchan_config                 = NULL;
   struct LogicalChannelConfig__ul_SpecificParameters
-      *DRB_ul_SpecificParameters        = NULL;
-  DRB_ToAddModList_t**                DRB_configList = &ue_context_pP->ue_context.DRB_configList;
-  DRB_ToAddModList_t**                DRB_configList2 = NULL;
-   MAC_MainConfig_t                   *mac_MainConfig                   = NULL;
+    *DRB_ul_SpecificParameters        = NULL;
+  DRB_ToAddModList_t                **DRB_configList = &ue_context_pP->ue_context.DRB_configList;
+  DRB_ToAddModList_t                **DRB_configList2 = NULL;
+  MAC_MainConfig_t                   *mac_MainConfig                   = NULL;
   MeasObjectToAddModList_t           *MeasObj_list                     = NULL;
   MeasObjectToAddMod_t               *MeasObj                          = NULL;
   ReportConfigToAddModList_t         *ReportConfig_list                = NULL;
@@ -2673,10 +2531,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   //     uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1);
   //uint8_t                            sCellIndexToAdd = 0;
 #endif
-
   long                               *logicalchannelgroup, *logicalchannelgroup_drb;
   long                               *maxHARQ_Tx, *periodicBSR_Timer;
-
   RSRP_Range_t                       *rsrp                             = NULL;
   struct MeasConfig__speedStatePars  *Sparams                          = NULL;
   QuantityConfig_t                   *quantityConfig                   = NULL;
@@ -2686,11 +2542,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   DedicatedInfoNAS_t                 *dedicatedInfoNas                 = NULL;
   /* for no gcc warnings */
   (void)dedicatedInfoNas;
-
   C_RNTI_t                           *cba_RNTI                         = NULL;
-
   uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id);   //Transaction_id,
-
 #ifdef CBA
   //struct PUSCH_CBAConfigDedicated_vlola  *pusch_CBAConfigDedicated_vlola;
   uint8_t                            *cba_RNTI_buf;
@@ -2716,24 +2569,22 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   }
 
 #endif
-
   T(T_ENB_RRC_CONNECTION_RECONFIGURATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   // Configure SRB2
   /// SRB2
   SRB_configList2=&ue_context_pP->ue_context.SRB_configList2[xid];
+
   if (*SRB_configList2) {
     free(*SRB_configList2);
   }
+
   *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2));
   memset(*SRB_configList2, 0, sizeof(**SRB_configList2));
   SRB2_config = CALLOC(1, sizeof(*SRB2_config));
-
   SRB2_config->srb_Identity = 2;
   SRB2_rlc_config = CALLOC(1, sizeof(*SRB2_rlc_config));
   SRB2_config->rlc_Config = SRB2_rlc_config;
-
   SRB2_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
   SRB2_rlc_config->choice.explicitValue.present = RLC_Config_PR_am;
   SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms15;
@@ -2742,26 +2593,19 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t32;
   SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
   SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms10;
-
   SRB2_lchan_config = CALLOC(1, sizeof(*SRB2_lchan_config));
   SRB2_config->logicalChannelConfig = SRB2_lchan_config;
-
   SRB2_lchan_config->present = SRB_ToAddMod__logicalChannelConfig_PR_explicitValue;
-
   SRB2_ul_SpecificParameters = CALLOC(1, sizeof(*SRB2_ul_SpecificParameters));
-
   SRB2_ul_SpecificParameters->priority = 3; // let some priority for SRB1 and dedicated DRBs
   SRB2_ul_SpecificParameters->prioritisedBitRate =
     LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
   SRB2_ul_SpecificParameters->bucketSizeDuration =
     LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
   // LCG for CCCH and DCCH is 0 as defined in 36331
   logicalchannelgroup = CALLOC(1, sizeof(long));
   *logicalchannelgroup = 0;
-
   SRB2_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup;
-
   SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB2_ul_SpecificParameters;
   // this list has the configuration for SRB1 and SRB2
   ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config);
@@ -2774,21 +2618,20 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   if (*DRB_configList) {
     free(*DRB_configList);
   }
+
   *DRB_configList = CALLOC(1, sizeof(**DRB_configList));
   memset(*DRB_configList, 0, sizeof(**DRB_configList));
-
   // list for the configured DRB for a this xid
   DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid];
+
   if (*DRB_configList2) {
     free(*DRB_configList2);
   }
+
   *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2));
   memset(*DRB_configList2, 0, sizeof(**DRB_configList2));
-
-
   /// DRB
   DRB_config = CALLOC(1, sizeof(*DRB_config));
-
   DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long));
   *(DRB_config->eps_BearerIdentity) = 5L; // LW set to first value, allowed value 5..15, value : x+4
   // DRB_config->drb_Identity = (DRB_Identity_t) 1; //allowed values 1..32
@@ -2798,7 +2641,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   *(DRB_config->logicalChannelIdentity) = (long)3; // value : x+2
   DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config));
   DRB_config->rlc_Config = DRB_rlc_config;
-
 #ifdef RRC_DEFAULT_RAB_IS_AM
   DRB_rlc_config->present = RLC_Config_PR_am;
   DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50;
@@ -2817,18 +2659,15 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
 #endif
 #endif
-
   DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
   DRB_config->pdcp_Config = DRB_pdcp_config;
   DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long));
   *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity;
   DRB_pdcp_config->rlc_AM = NULL;
   DRB_pdcp_config->rlc_UM = NULL;
-
   /* avoid gcc warnings */
   (void)PDCP_rlc_AM;
   (void)PDCP_rlc_UM;
-
 #ifdef RRC_DEFAULT_RAB_IS_AM // EXMIMO_IOT
   PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM));
   DRB_pdcp_config->rlc_AM = PDCP_rlc_AM;
@@ -2839,33 +2678,25 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
 #endif
   DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
-
   DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config));
   DRB_config->logicalChannelConfig = DRB_lchan_config;
   DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters));
   DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters;
-
   DRB_ul_SpecificParameters->priority = 12;    // lower priority than srb1, srb2 and other dedicated bearer
   DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ;
-    //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
+  //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
   DRB_ul_SpecificParameters->bucketSizeDuration =
     LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
   // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM)
   logicalchannelgroup_drb = CALLOC(1, sizeof(long));
   *logicalchannelgroup_drb = 1;
   DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb;
-
   ASN_SEQUENCE_ADD(&(*DRB_configList)->list, DRB_config);
   ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config);
-
   //ue_context_pP->ue_context.DRB_configList2[0] = &(*DRB_configList);
-
   mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig));
   ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig;
-
   mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config));
-
   maxHARQ_Tx = CALLOC(1, sizeof(long));
   *maxHARQ_Tx = MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
   mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx;
@@ -2874,20 +2705,13 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer;
   mac_MainConfig->ul_SCH_Config->retxBSR_Timer = RetxBSR_Timer_r12_sf320;
   mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE
-
   mac_MainConfig->timeAlignmentTimerDedicated = TimeAlignmentTimer_infinity;
-
   mac_MainConfig->drx_Config = NULL;
-
   mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config));
-
   mac_MainConfig->phr_Config->present = MAC_MainConfig__phr_Config_PR_setup;
   mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes
-
   mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes
-
   mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;  // Value dB1 =1 dB, dB3 = 3 dB
-
 #if defined(Rel10) || defined(Rel14)
   sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long));
   *sr_ProhibitTimer_r9 = 0;   // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR
@@ -2903,62 +2727,63 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     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]==AntennaInfoDedicated__transmissionMode_tm3) {
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-	  CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-	  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;
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm4) {
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-	  CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-	  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;
-
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm5) {
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-	  CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-	  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;
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm6) {
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-	  CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-	  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.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm4) ||
-	  (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm5) ||
-	  (rrc_inst->configuration.ue_TransmissionMode[0]==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");
+          (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm5) ||
+          (rrc_inst->configuration.ue_TransmissionMode[0]==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 defined(Rel10) || defined(Rel14)
-	*((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportModeAperiodic_rm31;
+        *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportModeAperiodic_rm31;
 #else
-	*((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI
+        *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI
 #endif
       }
     }
@@ -2973,54 +2798,43 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   // Measurement ID list
   MeasId_list = CALLOC(1, sizeof(*MeasId_list));
   memset((void *)MeasId_list, 0, sizeof(*MeasId_list));
-
   MeasId0 = CALLOC(1, sizeof(*MeasId0));
   MeasId0->measId = 1;
   MeasId0->measObjectId = 1;
   MeasId0->reportConfigId = 1;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0);
-
   MeasId1 = CALLOC(1, sizeof(*MeasId1));
   MeasId1->measId = 2;
   MeasId1->measObjectId = 1;
   MeasId1->reportConfigId = 2;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1);
-
   MeasId2 = CALLOC(1, sizeof(*MeasId2));
   MeasId2->measId = 3;
   MeasId2->measObjectId = 1;
   MeasId2->reportConfigId = 3;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2);
-
   MeasId3 = CALLOC(1, sizeof(*MeasId3));
   MeasId3->measId = 4;
   MeasId3->measObjectId = 1;
   MeasId3->reportConfigId = 4;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3);
-
   MeasId4 = CALLOC(1, sizeof(*MeasId4));
   MeasId4->measId = 5;
   MeasId4->measObjectId = 1;
   MeasId4->reportConfigId = 5;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4);
-
   MeasId5 = CALLOC(1, sizeof(*MeasId5));
   MeasId5->measId = 6;
   MeasId5->measObjectId = 1;
   MeasId5->reportConfigId = 6;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5);
-
   //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list;
-
   // Add one EUTRA Measurement Object
   MeasObj_list = CALLOC(1, sizeof(*MeasObj_list));
   memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list));
-
   // Configure MeasObject
-
   MeasObj = CALLOC(1, sizeof(*MeasObj));
   memset((void *)MeasObj, 0, sizeof(*MeasObj));
-
   MeasObj->measObjectId = 1;
   MeasObj->measObject.present = MeasObjectToAddMod__measObject_PR_measObjectEUTRA;
   MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz
@@ -3032,10 +2846,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1;
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6;
   MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL;   // Default is 15 or 0dB
-
   MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList =
     (CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList));
-
   CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList;
 
   // Add adjacent cell lists (6 per eNB)
@@ -3044,28 +2856,19 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     CellToAdd->cellIndex = i + 1;
     CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i);
     CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0;
-
     ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd);
   }
 
   ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj);
   //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list;
-
   // Report Configurations for periodical, A1-A5 events
   ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list));
-
   ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per));
-
   ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1));
-
   ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2));
-
   ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3));
-
   ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4));
-
   ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5));
-
   ReportConfig_per->reportConfigId = 1;
   ReportConfig_per->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -3077,9 +2880,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per);
-
   ReportConfig_A1->reportConfigId = 2;
   ReportConfig_A1->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -3090,15 +2891,13 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   a1_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1.
   a1_Threshold.choice.threshold_RSRP = 10;
-
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1);
-  
+
   if (ho_state == 1 /*HO_MEASURMENT */ ) {
     LOG_I(RRC, "[eNB %d] frame %d: requesting A2, A3, A4, A5, and A6 event reporting\n",
           ctxt_pP->module_id, ctxt_pP->frame);
@@ -3112,39 +2911,32 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     eventA2.a2_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA2.a2_Threshold.choice.threshold_RSRP = 10;
-
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2);
-
     ReportConfig_A3->reportConfigId = 4;
     ReportConfig_A3->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present =
       ReportConfigEUTRA__triggerType_PR_event;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present =
       ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3;
-
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset = 1;   //10;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA3.reportOnLeave = 1;
-
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis = 0.5; // FIXME ...hysteresis is of type long!
     ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger =
       TimeToTrigger_ms40;
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3);
-
     ReportConfig_A4->reportConfigId = 5;
     ReportConfig_A4->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -3155,16 +2947,13 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     eventA4.a4_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA4.a4_Threshold.choice.threshold_RSRP = 10;
-
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4);
-
     ReportConfig_A5->reportConfigId = 6;
     ReportConfig_A5->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -3179,20 +2968,16 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     eventA5.a5_Threshold1.choice.threshold_RSRP = 10;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
     eventA5.a5_Threshold2.choice.threshold_RSRP = 10;
-
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity =
       ReportConfigEUTRA__triggerQuantity_rsrp;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
     ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
     ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5);
     //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list;
-
     rsrp = CALLOC(1, sizeof(RSRP_Range_t));
     *rsrp = 20;
-
     Sparams = CALLOC(1, sizeof(*Sparams));
     Sparams->present = MeasConfig__speedStatePars_PR_setup;
     Sparams->choice.setup.timeToTrigger_SF.sf_High = SpeedStateScaleFactors__sf_Medium_oDot75;
@@ -3201,7 +2986,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5;
     Sparams->choice.setup.mobilityStateParameters.t_Evaluation = MobilityStateParameters__t_Evaluation_s60;
     Sparams->choice.setup.mobilityStateParameters.t_HystNormal = MobilityStateParameters__t_HystNormal_s120;
-
     quantityConfig = CALLOC(1, sizeof(*quantityConfig));
     memset((void *)quantityConfig, 0, sizeof(*quantityConfig));
     quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct QuantityConfigEUTRA));
@@ -3215,7 +2999,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
       CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ)));
     *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4;
     *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4;
-
     LOG_I(RRC,
           "[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n",
           ctxt_pP->module_id, ctxt_pP->frame);
@@ -3229,15 +3012,14 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL;
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig =
       CALLOC(1, sizeof(*ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig));
-    memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig,
+    memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig,
            (void *)mac_MainConfig, sizeof(MAC_MainConfig_t));
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated =
       CALLOC(1, sizeof(PhysicalConfigDedicated_t));
-    memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated,
-           (void*)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(PhysicalConfigDedicated_t));
+    memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated,
+           (void *)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(PhysicalConfigDedicated_t));
     ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.sps_Config = NULL;
     //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,(void *)rrc_inst->sps_Config[ue_mod_idP],sizeof(SPS_Config_t));
-
   }
 
 #if defined(ENABLE_ITTI)
@@ -3249,8 +3031,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) {
       dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
       memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
-      OCTET_STRING_fromBuf(dedicatedInfoNas, 
-			   (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
+      OCTET_STRING_fromBuf(dedicatedInfoNas,
+                           (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
                            ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length);
       ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
     }
@@ -3261,11 +3043,10 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
       //      ue_context_pP->ue_context.e_rab[i].param.sgw_addr;
       //      ue_context_pP->ue_context.e_rab[i].param.gtp_teid;
     }
-
     /* TODO should test if e RAB are Ok before! */
     ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE;
-    LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", 
-	  i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE");
+    LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n",
+          i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE");
   }
 
   /* If list is empty free the list and reset the address */
@@ -3275,46 +3056,44 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   }
 
 #endif
-
   memset(buffer, 0, RRC_BUF_SIZE);
-
   size = do_RRCConnectionReconfiguration(ctxt_pP,
                                          buffer,
                                          xid,   //Transaction_id,
-                                         (SRB_ToAddModList_t*)*SRB_configList2, // SRB_configList
-                                         (DRB_ToAddModList_t*)*DRB_configList,
-                                         (DRB_ToReleaseList_t*)NULL,  // DRB2_list,
-                                         (struct SPS_Config*)NULL,    // *sps_Config,
-                                         (struct PhysicalConfigDedicated*)*physicalConfigDedicated,
+                                         (SRB_ToAddModList_t *)*SRB_configList2, // SRB_configList
+                                         (DRB_ToAddModList_t *)*DRB_configList,
+                                         (DRB_ToReleaseList_t *)NULL, // DRB2_list,
+                                         (struct SPS_Config *)NULL,   // *sps_Config,
+                                         (struct PhysicalConfigDedicated *)*physicalConfigDedicated,
 #ifdef EXMIMO_IOT
                                          NULL, NULL, NULL,NULL,
 #else
-                                         (MeasObjectToAddModList_t*)MeasObj_list,
-                                         (ReportConfigToAddModList_t*)ReportConfig_list,
-                                         (QuantityConfig_t*)quantityConfig,
-                                         (MeasIdToAddModList_t*)MeasId_list,
-#endif
-                                         (MAC_MainConfig_t*)mac_MainConfig,
-                                         (MeasGapConfig_t*)NULL,
-                                         (MobilityControlInfo_t*)NULL,
-                                         (struct MeasConfig__speedStatePars*)Sparams,
-                                         (RSRP_Range_t*)rsrp,
-                                         (C_RNTI_t*)cba_RNTI,
-                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList
+                                         (MeasObjectToAddModList_t *)MeasObj_list,
+                                         (ReportConfigToAddModList_t *)ReportConfig_list,
+                                         (QuantityConfig_t *)quantityConfig,
+                                         (MeasIdToAddModList_t *)MeasId_list,
+#endif
+                                         (MAC_MainConfig_t *)mac_MainConfig,
+                                         (MeasGapConfig_t *)NULL,
+                                         (MobilityControlInfo_t *)NULL,
+                                         (struct MeasConfig__speedStatePars *)Sparams,
+                                         (RSRP_Range_t *)rsrp,
+                                         (C_RNTI_t *)cba_RNTI,
+                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList
 #if defined(Rel10) || defined(Rel14)
-                                         , (SCellToAddMod_r10_t*)NULL
+                                         , (SCellToAddMod_r10_t *)NULL
 #endif
                                         );
-
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n");
+
   for (i = 0; i < size; i++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
   }
+
   LOG_F(RRC,"\n");
   ////////////////////////////////////////
 #endif
-
 #if defined(ENABLE_ITTI)
 
   /* Free all NAS PDUs */
@@ -3327,15 +3106,12 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   }
 
 #endif
-
   LOG_I(RRC,
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
-
   LOG_D(RRC,
         "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n",
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -3346,42 +3122,38 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
-	       ctxt_pP,
-	       DCCH,
-	       rrc_eNB_mui++,
-	       SDU_CONFIRM_NO,
-	       size,
-	       buffer,
-	       PDCP_TRANSMISSION_MODE_CONTROL);
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
 //-----------------------------------------------------------------------------
 void
-flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP,
-                 rrc_eNB_ue_context_t*          const ue_context_pP,
-                 const uint8_t                ho_state,
-                 agent_reconf_rrc * trig_param
-                 )
+flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP,
+    rrc_eNB_ue_context_t          *const ue_context_pP,
+    const uint8_t                ho_state,
+    agent_reconf_rrc *trig_param
+                                                            )
 //-----------------------------------------------------------------------------
 {
   uint8_t                             buffer[RRC_BUF_SIZE];
   uint16_t                            size;
   int                                 i;
- 
   // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE
-  eNB_RRC_INST*                       rrc_inst = RC.rrc[ctxt_pP->module_id];
-  struct PhysicalConfigDedicated**    physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
-
+  eNB_RRC_INST                       *rrc_inst = RC.rrc[ctxt_pP->module_id];
+  struct PhysicalConfigDedicated    **physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
   struct SRB_ToAddMod                *SRB2_config                      = NULL;
   struct SRB_ToAddMod__rlc_Config    *SRB2_rlc_config                  = NULL;
   struct SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config         = NULL;
   struct LogicalChannelConfig__ul_SpecificParameters
-      *SRB2_ul_SpecificParameters       = NULL;
-  SRB_ToAddModList_t*                 SRB_configList = ue_context_pP->ue_context.SRB_configList;
+    *SRB2_ul_SpecificParameters       = NULL;
+  SRB_ToAddModList_t                 *SRB_configList = ue_context_pP->ue_context.SRB_configList;
   SRB_ToAddModList_t                 **SRB_configList2                  = NULL;
-
   struct DRB_ToAddMod                *DRB_config                       = NULL;
   struct RLC_Config                  *DRB_rlc_config                   = NULL;
   struct PDCP_Config                 *DRB_pdcp_config                  = NULL;
@@ -3389,15 +3161,15 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   struct PDCP_Config__rlc_UM         *PDCP_rlc_UM                      = NULL;
   struct LogicalChannelConfig        *DRB_lchan_config                 = NULL;
   struct LogicalChannelConfig__ul_SpecificParameters
-      *DRB_ul_SpecificParameters        = NULL;
-  DRB_ToAddModList_t**                DRB_configList = &ue_context_pP->ue_context.DRB_configList;
-  DRB_ToAddModList_t**                DRB_configList2 = NULL;
-   MAC_MainConfig_t                   *mac_MainConfig                   = NULL;
+    *DRB_ul_SpecificParameters        = NULL;
+  DRB_ToAddModList_t                **DRB_configList = &ue_context_pP->ue_context.DRB_configList;
+  DRB_ToAddModList_t                **DRB_configList2 = NULL;
+  MAC_MainConfig_t                   *mac_MainConfig                   = NULL;
   MeasObjectToAddModList_t           *MeasObj_list                     = NULL;
   MeasObjectToAddMod_t               *MeasObj                          = NULL;
   ReportConfigToAddModList_t         *ReportConfig_list                = NULL;
   ReportConfigToAddMod_t             *ReportConfig_per;//, *ReportConfig_A1,
-                                     // *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5;
+  // *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5;
   MeasIdToAddModList_t               *MeasId_list                      = NULL;
   MeasIdToAddMod_t                   *MeasId0; //, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5;
 #if Rel10
@@ -3405,10 +3177,8 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   //     uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1);
   //uint8_t                            sCellIndexToAdd = 0;
 #endif
-
   long                               *logicalchannelgroup, *logicalchannelgroup_drb;
   long                               *maxHARQ_Tx, *periodicBSR_Timer;
-
   RSRP_Range_t                       *rsrp                             = NULL;
   struct MeasConfig__speedStatePars  *Sparams                          = NULL;
   QuantityConfig_t                   *quantityConfig                   = NULL;
@@ -3418,11 +3188,8 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   DedicatedInfoNAS_t                 *dedicatedInfoNas                 = NULL;
   /* for no gcc warnings */
   (void)dedicatedInfoNas;
-
   C_RNTI_t                           *cba_RNTI                         = NULL;
-
   uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id);   //Transaction_id,
-
 #ifdef CBA
   //struct PUSCH_CBAConfigDedicated_vlola  *pusch_CBAConfigDedicated_vlola;
   uint8_t                            *cba_RNTI_buf;
@@ -3448,24 +3215,22 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   }
 
 #endif
-
   T(T_ENB_RRC_CONNECTION_RECONFIGURATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   // Configure SRB2
   /// SRB2
   SRB_configList2=&ue_context_pP->ue_context.SRB_configList2[xid];
+
   if (*SRB_configList2) {
     free(*SRB_configList2);
   }
+
   *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2));
   memset(*SRB_configList2, 0, sizeof(**SRB_configList2));
   SRB2_config = CALLOC(1, sizeof(*SRB2_config));
-
   SRB2_config->srb_Identity = 2;
   SRB2_rlc_config = CALLOC(1, sizeof(*SRB2_rlc_config));
   SRB2_config->rlc_Config = SRB2_rlc_config;
-
   SRB2_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
   SRB2_rlc_config->choice.explicitValue.present = RLC_Config_PR_am;
   SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms15;
@@ -3474,26 +3239,19 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t32;
   SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
   SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms10;
-
   SRB2_lchan_config = CALLOC(1, sizeof(*SRB2_lchan_config));
   SRB2_config->logicalChannelConfig = SRB2_lchan_config;
-
   SRB2_lchan_config->present = SRB_ToAddMod__logicalChannelConfig_PR_explicitValue;
-
   SRB2_ul_SpecificParameters = CALLOC(1, sizeof(*SRB2_ul_SpecificParameters));
-
   SRB2_ul_SpecificParameters->priority = 3; // let some priority for SRB1 and dedicated DRBs
   SRB2_ul_SpecificParameters->prioritisedBitRate =
     LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
   SRB2_ul_SpecificParameters->bucketSizeDuration =
     LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
   // LCG for CCCH and DCCH is 0 as defined in 36331
   logicalchannelgroup = CALLOC(1, sizeof(long));
   *logicalchannelgroup = 0;
-
   SRB2_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup;
-
   SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB2_ul_SpecificParameters;
   // this list has the configuration for SRB1 and SRB2
   ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config);
@@ -3506,21 +3264,20 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   if (*DRB_configList) {
     free(*DRB_configList);
   }
+
   *DRB_configList = CALLOC(1, sizeof(**DRB_configList));
   memset(*DRB_configList, 0, sizeof(**DRB_configList));
-
   // list for the configured DRB for a this xid
   DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid];
+
   if (*DRB_configList2) {
     free(*DRB_configList2);
   }
+
   *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2));
   memset(*DRB_configList2, 0, sizeof(**DRB_configList2));
-
-
   /// DRB
   DRB_config = CALLOC(1, sizeof(*DRB_config));
-
   DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long));
   *(DRB_config->eps_BearerIdentity) = 5L; // LW set to first value, allowed value 5..15, value : x+4
   // DRB_config->drb_Identity = (DRB_Identity_t) 1; //allowed values 1..32
@@ -3530,7 +3287,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   *(DRB_config->logicalChannelIdentity) = (long)3; // value : x+2
   DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config));
   DRB_config->rlc_Config = DRB_rlc_config;
-
 #ifdef RRC_DEFAULT_RAB_IS_AM
   DRB_rlc_config->present = RLC_Config_PR_am;
   DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50;
@@ -3549,18 +3305,15 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
 #endif
 #endif
-
   DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
   DRB_config->pdcp_Config = DRB_pdcp_config;
   DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long));
   *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity;
   DRB_pdcp_config->rlc_AM = NULL;
   DRB_pdcp_config->rlc_UM = NULL;
-
   /* avoid gcc warnings */
   (void)PDCP_rlc_AM;
   (void)PDCP_rlc_UM;
-
 #ifdef RRC_DEFAULT_RAB_IS_AM // EXMIMO_IOT
   PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM));
   DRB_pdcp_config->rlc_AM = PDCP_rlc_AM;
@@ -3571,33 +3324,25 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
 #endif
   DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
-
   DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config));
   DRB_config->logicalChannelConfig = DRB_lchan_config;
   DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters));
   DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters;
-
   DRB_ul_SpecificParameters->priority = 12;    // lower priority than srb1, srb2 and other dedicated bearer
   DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ;
-    //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
+  //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
   DRB_ul_SpecificParameters->bucketSizeDuration =
     LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
   // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM)
   logicalchannelgroup_drb = CALLOC(1, sizeof(long));
   *logicalchannelgroup_drb = 1;
   DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb;
-
   ASN_SEQUENCE_ADD(&(*DRB_configList)->list, DRB_config);
   ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config);
-
   //ue_context_pP->ue_context.DRB_configList2[0] = &(*DRB_configList);
-
   mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig));
   // ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig;
-
   mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config));
-
   maxHARQ_Tx = CALLOC(1, sizeof(long));
   *maxHARQ_Tx = MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
   mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx;
@@ -3606,20 +3351,13 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer;
   mac_MainConfig->ul_SCH_Config->retxBSR_Timer = RetxBSR_Timer_r12_sf320;
   mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE
-
   mac_MainConfig->timeAlignmentTimerDedicated = TimeAlignmentTimer_infinity;
-
   mac_MainConfig->drx_Config = NULL;
-
   mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config));
-
   mac_MainConfig->phr_Config->present = MAC_MainConfig__phr_Config_PR_setup;
   mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes
-
   mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes
-
   mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;  // Value dB1 =1 dB, dB3 = 3 dB
-
 #ifdef Rel10
   sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long));
   *sr_ProhibitTimer_r9 = 0;   // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR
@@ -3635,62 +3373,63 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
     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]==AntennaInfoDedicated__transmissionMode_tm3) {
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-    CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-    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;
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm4) {
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-    CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-    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;
-
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm5) {
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-    CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-    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;
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm6) {
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
-    CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
-  (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-    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.codebookSubsetRestriction=
+          CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR));
+        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+          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]==AntennaInfoDedicated__transmissionMode_tm4) ||
-    (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm5) ||
-    (rrc_inst->configuration.ue_TransmissionMode[0]==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");
+          (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm5) ||
+          (rrc_inst->configuration.ue_TransmissionMode[0]==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 defined(Rel10) || defined(Rel14)
-  *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportModeAperiodic_rm31;
+        *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportModeAperiodic_rm31;
 #else
-  *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI
+        *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI
 #endif
       }
     }
@@ -3705,25 +3444,19 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   // Measurement ID list
   MeasId_list = CALLOC(1, sizeof(*MeasId_list));
   memset((void *)MeasId_list, 0, sizeof(*MeasId_list));
-
   MeasId0 = CALLOC(1, sizeof(*MeasId0));
   MeasId0->measId = 1;
   MeasId0->measObjectId = 1;
   MeasId0->reportConfigId = 1;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0);
-
   /*
    * Add one EUTRA Measurement Object
   */
-
   MeasObj_list = CALLOC(1, sizeof(*MeasObj_list));
   memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list));
-
-  // Configure MeasObject 
-
+  // Configure MeasObject
   MeasObj = CALLOC(1, sizeof(*MeasObj));
   memset((void *)MeasObj, 0, sizeof(*MeasObj));
-
   MeasObj->measObjectId = 1;
   MeasObj->measObject.present = MeasObjectToAddMod__measObject_PR_measObjectEUTRA;
   MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz
@@ -3735,10 +3468,8 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1;
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6;
   MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL;   // Default is 15 or 0dB
-
   MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList =
     (CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList));
-
   CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList;
 
   // Add adjacent cell lists (6 per eNB)
@@ -3747,7 +3478,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
     CellToAdd->cellIndex = i + 1;
     CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i);
     CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0;
-
     ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd);
   }
 
@@ -3758,78 +3488,51 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
 
   /* RRC Strategy Measurement */
 
-
-  if (strcmp("one_shot", trig_param->trigger_policy) == 0){
-
-      trig_param->report_interval = 0;
-      trig_param->report_amount = 0;
-
+  if (strcmp("one_shot", trig_param->trigger_policy) == 0) {
+    trig_param->report_interval = 0;
+    trig_param->report_amount = 0;
   }
-
-  else if (strcmp("event_driven", trig_param->trigger_policy) == 0){
-
-      trig_param->report_interval = 6;
-      trig_param->report_amount = 2;
-
+  else if (strcmp("event_driven", trig_param->trigger_policy) == 0) {
+    trig_param->report_interval = 6;
+    trig_param->report_amount = 2;
   }
-
-  else if (strcmp("periodical", trig_param->trigger_policy) == 0){
-
-      trig_param->report_interval = 1;
-      trig_param->report_amount = 7;
-
+  else if (strcmp("periodical", trig_param->trigger_policy) == 0) {
+    trig_param->report_interval = 1;
+    trig_param->report_amount = 7;
   }
-
   else {
-
-     LOG_E(FLEXRAN_AGENT, "There is something wrong on RRC agent!");
+    LOG_E(FLEXRAN_AGENT, "There is something wrong on RRC agent!");
   }
 
-
-
   ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list));
-
   ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per));
-
-    // Periodical Measurement Report
-
+  // Periodical Measurement Report
   ReportConfig_per->reportConfigId = 1;
   ReportConfig_per->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
-
-    ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present =
-      ReportConfigEUTRA__triggerType_PR_periodical;
-
-    ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.periodical.purpose =
-      ReportConfigEUTRA__triggerType__periodical__purpose_reportStrongestCells;
-
-    // ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = TimeToTrigger_ms40;  
-    ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
-   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
-   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
-   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = trig_param->report_interval ;//ReportInterval_ms2048; // RRC counter frame- ms1024 is 1ms   
-
-   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = trig_param->report_amount; //ReportConfigEUTRA__reportAmount_r2; // put r1 to see once, r2 for 2 times and ...
-
-
+  ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present =
+    ReportConfigEUTRA__triggerType_PR_periodical;
+  ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.periodical.purpose =
+    ReportConfigEUTRA__triggerType__periodical__purpose_reportStrongestCells;
+  // ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = TimeToTrigger_ms40;
+  ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
+  ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
+  ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
+  ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = trig_param->report_interval ;//ReportInterval_ms2048; // RRC counter frame- ms1024 is 1ms
+  ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = trig_param->report_amount; //ReportConfigEUTRA__reportAmount_r2; // put r1 to see once, r2 for 2 times and ...
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per);
-
-
-
-    quantityConfig = CALLOC(1, sizeof(*quantityConfig));
-    memset((void *)quantityConfig, 0, sizeof(*quantityConfig));
-    quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct QuantityConfigEUTRA));
-    memset((void *)quantityConfig->quantityConfigEUTRA, 0, sizeof(*quantityConfig->quantityConfigEUTRA));
-    quantityConfig->quantityConfigCDMA2000 = NULL;
-    quantityConfig->quantityConfigGERAN = NULL;
-    quantityConfig->quantityConfigUTRA = NULL;
-    quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP =
-      CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP)));
-    quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ =
-      CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ)));
-    *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4;
-    *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4;
-
-  
+  quantityConfig = CALLOC(1, sizeof(*quantityConfig));
+  memset((void *)quantityConfig, 0, sizeof(*quantityConfig));
+  quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct QuantityConfigEUTRA));
+  memset((void *)quantityConfig->quantityConfigEUTRA, 0, sizeof(*quantityConfig->quantityConfigEUTRA));
+  quantityConfig->quantityConfigCDMA2000 = NULL;
+  quantityConfig->quantityConfigGERAN = NULL;
+  quantityConfig->quantityConfigUTRA = NULL;
+  quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP =
+    CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP)));
+  quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ =
+    CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ)));
+  *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4;
+  *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4;
 #if defined(ENABLE_ITTI)
   /* Initialize NAS list */
   dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList));
@@ -3839,23 +3542,22 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
     if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) {
       dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t));
       memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t));
-      OCTET_STRING_fromBuf(dedicatedInfoNas, 
-         (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
+      OCTET_STRING_fromBuf(dedicatedInfoNas,
+                           (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer,
                            ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length);
       ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas);
     }
 
     /* TODO parameters yet to process ... */
     // {
-      //      ue_context_pP->ue_context.e_rab[i].param.qos;
-      //      ue_context_pP->ue_context.e_rab[i].param.sgw_addr;
-      //      ue_context_pP->ue_context.e_rab[i].param.gtp_teid;
+    //      ue_context_pP->ue_context.e_rab[i].param.qos;
+    //      ue_context_pP->ue_context.e_rab[i].param.sgw_addr;
+    //      ue_context_pP->ue_context.e_rab[i].param.gtp_teid;
     // }
-
     /* TODO should test if e RAB are Ok before! */
     ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE;
-    LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", 
-    i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE");
+    LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n",
+          i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE");
   }
 
   /* If list is empty free the list and reset the address */
@@ -3865,46 +3567,44 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   }
 
 #endif
-
   memset(buffer, 0, RRC_BUF_SIZE);
-  
   size = do_RRCConnectionReconfiguration(ctxt_pP,
                                          buffer,
                                          xid,   //Transaction_id,
-                                         (SRB_ToAddModList_t*)NULL, // SRB_configList
-                                         (DRB_ToAddModList_t*)NULL,
-                                         (DRB_ToReleaseList_t*)NULL,  // DRB2_list,
-                                         (struct SPS_Config*)NULL,    // *sps_Config,
-                                         (struct PhysicalConfigDedicated*)*physicalConfigDedicated,
-// #ifdef EXMIMO_IOT
-//                                          NULL, NULL, NULL,NULL,
-// #else
-                                         (MeasObjectToAddModList_t*)MeasObj_list,
-                                         (ReportConfigToAddModList_t*)ReportConfig_list,
-                                         (QuantityConfig_t*)quantityConfig,
-                                         (MeasIdToAddModList_t*)MeasId_list,
-// #endif
-                                         (MAC_MainConfig_t*)mac_MainConfig,
-                                         (MeasGapConfig_t*)NULL,
-                                         (MobilityControlInfo_t*)NULL,
-                                         (struct MeasConfig__speedStatePars*)Sparams,
-                                         (RSRP_Range_t*)rsrp,
-                                         (C_RNTI_t*)cba_RNTI,
-                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList
+                                         (SRB_ToAddModList_t *)NULL, // SRB_configList
+                                         (DRB_ToAddModList_t *)NULL,
+                                         (DRB_ToReleaseList_t *)NULL, // DRB2_list,
+                                         (struct SPS_Config *)NULL,   // *sps_Config,
+                                         (struct PhysicalConfigDedicated *)*physicalConfigDedicated,
+                                         // #ifdef EXMIMO_IOT
+                                         //                                          NULL, NULL, NULL,NULL,
+                                         // #else
+                                         (MeasObjectToAddModList_t *)MeasObj_list,
+                                         (ReportConfigToAddModList_t *)ReportConfig_list,
+                                         (QuantityConfig_t *)quantityConfig,
+                                         (MeasIdToAddModList_t *)MeasId_list,
+                                         // #endif
+                                         (MAC_MainConfig_t *)mac_MainConfig,
+                                         (MeasGapConfig_t *)NULL,
+                                         (MobilityControlInfo_t *)NULL,
+                                         (struct MeasConfig__speedStatePars *)Sparams,
+                                         (RSRP_Range_t *)rsrp,
+                                         (C_RNTI_t *)cba_RNTI,
+                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList
 #if defined(Rel10) || defined(Rel14)
-                                         , (SCellToAddMod_r10_t*)NULL
+                                         , (SCellToAddMod_r10_t *)NULL
 #endif
                                         );
-
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n");
+
   for (i = 0; i < size; i++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
   }
+
   LOG_F(RRC,"\n");
   ////////////////////////////////////////
 #endif
-
 #if defined(ENABLE_ITTI)
 
   /* Free all NAS PDUs */
@@ -3917,15 +3617,12 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   }
 
 #endif
-
   LOG_I(RRC,
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
-
   LOG_D(RRC,
         "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n",
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -3936,31 +3633,28 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
-         ctxt_pP,
-         DCCH,
-         rrc_eNB_mui++,
-         SDU_CONFIRM_NO,
-         size,
-         buffer,
-         PDCP_TRANSMISSION_MODE_CONTROL);
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
 
 //-----------------------------------------------------------------------------
 int
 rrc_eNB_generate_RRCConnectionReconfiguration_SCell(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t* const ue_context_pP,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t *const ue_context_pP,
   uint32_t dl_CarrierFreq_r10
 )
 //-----------------------------------------------------------------------------
 {
-
   uint8_t size;
   uint8_t buffer[100];
-
 #if defined(Rel10) || defined(Rel14)
   uint8_t sCellIndexToAdd = 0; //one SCell so far
 
@@ -3978,30 +3672,28 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell(
   size = do_RRCConnectionReconfiguration(ctxt_pP,
                                          buffer,
                                          rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),//Transaction_id,
-                                         (SRB_ToAddModList_t*)NULL,
-                                         (DRB_ToAddModList_t*)NULL,
-                                         (DRB_ToReleaseList_t*)NULL,
-                                         (struct SPS_Config*)NULL,
-                                         (struct PhysicalConfigDedicated*)NULL,
-                                         (MeasObjectToAddModList_t*)NULL,
-                                         (ReportConfigToAddModList_t*)NULL,
-                                         (QuantityConfig_t*)NULL,
-                                         (MeasIdToAddModList_t*)NULL,
-                                         (MAC_MainConfig_t*)NULL,
-                                         (MeasGapConfig_t*)NULL,
-                                         (MobilityControlInfo_t*)NULL,
-                                         (struct MeasConfig__speedStatePars*)NULL,
-                                         (RSRP_Range_t*)NULL,
-                                         (C_RNTI_t*)NULL,
-                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL
-
+                                         (SRB_ToAddModList_t *)NULL,
+                                         (DRB_ToAddModList_t *)NULL,
+                                         (DRB_ToReleaseList_t *)NULL,
+                                         (struct SPS_Config *)NULL,
+                                         (struct PhysicalConfigDedicated *)NULL,
+                                         (MeasObjectToAddModList_t *)NULL,
+                                         (ReportConfigToAddModList_t *)NULL,
+                                         (QuantityConfig_t *)NULL,
+                                         (MeasIdToAddModList_t *)NULL,
+                                         (MAC_MainConfig_t *)NULL,
+                                         (MeasGapConfig_t *)NULL,
+                                         (MobilityControlInfo_t *)NULL,
+                                         (struct MeasConfig__speedStatePars *)NULL,
+                                         (RSRP_Range_t *)NULL,
+                                         (C_RNTI_t *)NULL,
+                                         (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)NULL
 #if defined(Rel10) || defined(Rel14)
                                          , ue_context_pP->ue_context.sCell_config
 #endif
                                         );
   LOG_I(RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n",
         ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
-
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
@@ -4012,15 +3704,14 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell(
     ue_context_pP->ue_context.rnti,
     rrc_eNB_mui,
     size);
-
   rrc_data_req(
-	       ctxt_pP,
-	       DCCH,
-	       rrc_eNB_mui++,
-	       SDU_CONFIRM_NO,
-	       size,
-	       buffer,
-	       PDCP_TRANSMISSION_MODE_CONTROL);
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
   return(0);
 }
 
@@ -4028,64 +3719,62 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_process_MeasurementReport(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*         ue_context_pP,
-  const MeasResults_t*   const measResults2
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t         *ue_context_pP,
+  const MeasResults_t   *const measResults2
 )
 //-----------------------------------------------------------------------------
 {
   int i=0;
   int neighboring_cells=-1;
-  
   T(T_ENB_RRC_MEASUREMENT_REPORT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 
   if (measResults2 == NULL )
     return;
-  
-  if (measResults2->measId > 0 ){
-     if (ue_context_pP->ue_context.measResults == NULL) {
-       ue_context_pP->ue_context.measResults = CALLOC(1, sizeof(MeasResults_t));
-     }
-     ue_context_pP->ue_context.measResults->measId=measResults2->measId; 
-     ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult=measResults2->measResultPCell.rsrpResult;
-     ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult=measResults2->measResultPCell.rsrqResult;
-     LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRP of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult-140);
-     LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRQ of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult/2 - 20);
-   }
-   if (measResults2->measResultNeighCells == NULL)
-     return;
-
-   if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) {
-     neighboring_cells = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count;
-     
-     if (ue_context_pP->ue_context.measResults->measResultNeighCells == NULL) {
-       
-       ue_context_pP->ue_context.measResults->measResultNeighCells = CALLOC(1, sizeof(*measResults2->measResultNeighCells)*neighboring_cells);
-     }
-     ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count = neighboring_cells;
-     for (i=0; i < neighboring_cells; i++){
-       memcpy (ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i],
-	       measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i],
-	       sizeof(MeasResultListEUTRA_t));
-       
-       LOG_D(RRC, "Physical Cell Id %d\n",
-	     (int)ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->physCellId);
-       LOG_D(RRC, "RSRP of Target %d\n",
-	     (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult));
-       LOG_D(RRC, "RSRQ of Target %d\n",
-	     (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult));
-     }
-   }
 
-// #if defined(Rel10) || defined(Rel14)
+  if (measResults2->measId > 0 ) {
+    if (ue_context_pP->ue_context.measResults == NULL) {
+      ue_context_pP->ue_context.measResults = CALLOC(1, sizeof(MeasResults_t));
+    }
+
+    ue_context_pP->ue_context.measResults->measId=measResults2->measId;
+    ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult=measResults2->measResultPCell.rsrpResult;
+    ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult=measResults2->measResultPCell.rsrqResult;
+    LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRP of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult-140);
+    LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRQ of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult/2 - 20);
+  }
+
+  if (measResults2->measResultNeighCells == NULL)
+    return;
+
+  if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) {
+    neighboring_cells = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count;
 
-  
-// #else
+    if (ue_context_pP->ue_context.measResults->measResultNeighCells == NULL) {
+      ue_context_pP->ue_context.measResults->measResultNeighCells = CALLOC(1, sizeof(*measResults2->measResultNeighCells)*neighboring_cells);
+    }
+
+    ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count = neighboring_cells;
+
+    for (i=0; i < neighboring_cells; i++) {
+      memcpy (ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i],
+              measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i],
+              sizeof(MeasResultListEUTRA_t));
+      LOG_D(RRC, "Physical Cell Id %d\n",
+            (int)ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->physCellId);
+      LOG_D(RRC, "RSRP of Target %d\n",
+            (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult));
+      LOG_D(RRC, "RSRQ of Target %d\n",
+            (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult));
+    }
+  }
+
+  // #if defined(Rel10) || defined(Rel14)
+  // #else
   // LOG_I(RRC, "RSRP of Source %d\n", measResults2->measResultServCell.rsrpResult);
   // LOG_I(RRC, "RSRQ of Source %d\n", measResults2->measResultServCell.rsrqResult);
-// #endif
-
+  // #endif
   // if (ue_context_pP->ue_context.handover_info->ho_prepare != 0xF0) {
   //   rrc_eNB_generate_HandoverPreparationInformation(ctxt_pP,
   //       ue_context_pP,
@@ -4095,33 +3784,29 @@ rrc_eNB_process_MeasurementReport(
   //   LOG_D(RRC, "[eNB %d] Frame %d: Ignoring MeasReport from UE %x as Handover is in progress... \n", ctxt_pP->module_id, ctxt_pP->frame,
   //         ctxt_pP->rnti);
   // }
-
   //Look for IP address of the target eNB
   //Send Handover Request -> target eNB
   //Wait for Handover Acknowledgement <- target eNB
   //Send Handover Command
-
   //x2delay();
   //    handover_request_x2(ue_mod_idP,enb_mod_idP,measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId);
-
   //    uint8_t buffer[100];
   //    int size=rrc_eNB_generate_Handover_Command_TeNB(0,0,buffer);
   //
   //      send_check_message((char*)buffer,size);
   //send_handover_command();
-
 }
 
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_HandoverPreparationInformation(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t* const ue_context_pP,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t *const ue_context_pP,
   PhysCellId_t                 targetPhyId
 )
 //-----------------------------------------------------------------------------
 {
-  struct rrc_eNB_ue_context_s*        ue_context_target_p = NULL;
+  struct rrc_eNB_ue_context_s        *ue_context_target_p = NULL;
   //uint8_t                             UE_id_target        = -1;
   uint8_t                             mod_id_target = get_adjacent_cell_mod_id(targetPhyId);
   HANDOVER_INFO                      *handoverInfo = CALLOC(1, sizeof(*handoverInfo));
@@ -4131,30 +3816,24 @@ rrc_eNB_generate_HandoverPreparationInformation(
      struct PhysicalConfigDedicated  **physicalConfigDedicated = &RC.rrc[enb_mod_idP]->physicalConfigDedicated[ue_mod_idP];
      RadioResourceConfigDedicated_t *radioResourceConfigDedicated = CALLOC(1,sizeof(RadioResourceConfigDedicated_t));
    */
-
   T(T_ENB_RRC_HANDOVER_PREPARATION_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   handoverInfo->as_config.antennaInfoCommon.antennaPortsCount = 0;    //Not used 0- but check value
   handoverInfo->as_config.sourceDl_CarrierFreq = 36090;   //Verify!
-
   memcpy((void *)&handoverInfo->as_config.sourceMasterInformationBlock,
-         (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.mib, sizeof(MasterInformationBlock_t));
+         (void *)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.mib, sizeof(MasterInformationBlock_t));
   memcpy((void *)&handoverInfo->as_config.sourceMeasConfig,
-         (void*)ue_context_pP->ue_context.measConfig, sizeof(MeasConfig_t));
-
+         (void *)ue_context_pP->ue_context.measConfig, sizeof(MeasConfig_t));
   // FIXME handoverInfo not used...
   free( handoverInfo );
   handoverInfo = 0;
-
   //to be configured
-  memset((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSecurityAlgorithmConfig,
+  memset((void *)&ue_context_pP->ue_context.handover_info->as_config.sourceSecurityAlgorithmConfig,
          0, sizeof(SecurityAlgorithmConfig_t));
-
-  memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType1,
-         (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB1, sizeof(SystemInformationBlockType1_t));
-  memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType2,
-         (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB23, sizeof(SystemInformationBlockType2_t));
+  memcpy((void *)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType1,
+         (void *)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB1, sizeof(SystemInformationBlockType1_t));
+  memcpy((void *)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType2,
+         (void *)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB23, sizeof(SystemInformationBlockType2_t));
   ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo =
     CALLOC(1, sizeof(ReestablishmentInfo_t));
   ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId =
@@ -4193,11 +3872,11 @@ rrc_eNB_generate_HandoverPreparationInformation(
             mod_id_target);
       ue_context_target_p->ue_context.handover_info =
         CALLOC(1, sizeof(*(ue_context_target_p->ue_context.handover_info)));
-      memcpy((void*)&ue_context_target_p->ue_context.handover_info->as_context,
-             (void*)&ue_context_pP->ue_context.handover_info->as_context,
+      memcpy((void *)&ue_context_target_p->ue_context.handover_info->as_context,
+             (void *)&ue_context_pP->ue_context.handover_info->as_context,
              sizeof(AS_Context_t));
-      memcpy((void*)&ue_context_target_p->ue_context.handover_info->as_config,
-             (void*)&ue_context_pP->ue_context.handover_info->as_config,
+      memcpy((void *)&ue_context_target_p->ue_context.handover_info->as_config,
+             (void *)&ue_context_pP->ue_context.handover_info->as_config,
              sizeof(AS_Config_t));
       ue_context_target_p->ue_context.handover_info->ho_prepare = 0x00;// 0xFF;
       ue_context_target_p->ue_context.handover_info->ho_complete = 0;
@@ -4207,11 +3886,9 @@ rrc_eNB_generate_HandoverPreparationInformation(
       ue_context_target_p->ue_context.handover_info->modid_t = mod_id_target;
       ue_context_target_p->ue_context.handover_info->modid_s = ctxt_pP->module_id;
       ue_context_target_p->ue_context.handover_info->ueid_t  = ue_context_target_p->ue_context.rnti;
-
     } else {
       LOG_E(RRC, "\nError in obtaining free UE id in target eNB %ld for handover \n", targetPhyId);
     }
-
   } else {
     LOG_E(RRC, "\nError in obtaining Module ID of target eNB for handover \n");
   }
@@ -4220,15 +3897,13 @@ rrc_eNB_generate_HandoverPreparationInformation(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_process_handoverPreparationInformation(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*           const ue_context_pP
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t           *const ue_context_pP
 )
 //-----------------------------------------------------------------------------
 {
   T(T_ENB_RRC_HANDOVER_PREPARATION_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-
   LOG_I(RRC,
         "[eNB %d] Frame %d : Logical Channel UL-DCCH, processing RRCHandoverPreparationInformation, sending RRCConnectionReconfiguration to UE %d \n",
         ctxt_pP->module_id, ctxt_pP->frame, ue_context_pP->ue_context.rnti);
@@ -4243,12 +3918,12 @@ rrc_eNB_process_handoverPreparationInformation(
 //-----------------------------------------------------------------------------
 void
 check_handovers(
-  protocol_ctxt_t* const ctxt_pP
+  protocol_ctxt_t *const ctxt_pP
 )
 //-----------------------------------------------------------------------------
 {
   int                                 result;
-  struct rrc_eNB_ue_context_s*        ue_context_p;
+  struct rrc_eNB_ue_context_s        *ue_context_p;
   RB_FOREACH(ue_context_p, rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head) {
     ctxt_pP->rnti  = ue_context_p->ue_id_rnti;
 
@@ -4296,34 +3971,30 @@ check_handovers(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_RRCConnectionReconfiguration_handover(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*           const ue_context_pP,
-  uint8_t*                const nas_pdu,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t           *const ue_context_pP,
+  uint8_t                *const nas_pdu,
   const uint32_t                nas_length
 )
 //-----------------------------------------------------------------------------
 {
   T(T_ENB_RRC_CONNECTION_RECONFIGURATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-
   uint8_t                             buffer[RRC_BUF_SIZE];
   uint16_t                            size;
   int                                 i;
   uint8_t                             rv[2];
   uint16_t                            Idx;
   // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE
-  eNB_RRC_INST*                       rrc_inst = RC.rrc[ctxt_pP->module_id];
-  struct PhysicalConfigDedicated**    physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
-
+  eNB_RRC_INST                       *rrc_inst = RC.rrc[ctxt_pP->module_id];
+  struct PhysicalConfigDedicated    **physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
   struct SRB_ToAddMod                *SRB2_config;
   struct SRB_ToAddMod__rlc_Config    *SRB2_rlc_config;
   struct SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config;
   struct LogicalChannelConfig__ul_SpecificParameters *SRB2_ul_SpecificParameters;
   LogicalChannelConfig_t             *SRB1_logicalChannelConfig = NULL;
-  SRB_ToAddModList_t*                 SRB_configList = ue_context_pP->ue_context.SRB_configList;    // not used in this context: may be removed
+  SRB_ToAddModList_t                 *SRB_configList = ue_context_pP->ue_context.SRB_configList;    // not used in this context: may be removed
   SRB_ToAddModList_t                 *SRB_configList2;
-
   struct DRB_ToAddMod                *DRB_config;
   struct RLC_Config                  *DRB_rlc_config;
   struct PDCP_Config                 *DRB_pdcp_config;
@@ -4331,7 +4002,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   struct LogicalChannelConfig        *DRB_lchan_config;
   struct LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters;
   DRB_ToAddModList_t                 *DRB_configList2;
-
   MAC_MainConfig_t                   *mac_MainConfig;
   MeasObjectToAddModList_t           *MeasObj_list;
   MeasObjectToAddMod_t               *MeasObj;
@@ -4348,10 +4018,8 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
 #if defined(Rel10) || defined(Rel14)
   long                               *sr_ProhibitTimer_r9;
 #endif
-
   long                               *logicalchannelgroup, *logicalchannelgroup_drb;
   long                               *maxHARQ_Tx, *periodicBSR_Timer;
-
   // RSRP_Range_t *rsrp;
   struct MeasConfig__speedStatePars  *Sparams;
   CellsToAddMod_t                    *CellToAdd;
@@ -4365,7 +4033,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   PhysicalConfigDedicated_t          *physicalConfigDedicated2;
   struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList;
   protocol_ctxt_t                     ctxt;
-
   LOG_D(RRC, "[eNB %d] Frame %d: handover preparation: get the newSourceUEIdentity (C-RNTI): ",
         ctxt_pP->module_id, ctxt_pP->frame);
 
@@ -4382,7 +4049,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   SRB1_config->srb_Identity = 1;
   SRB1_rlc_config = CALLOC(1, sizeof(*SRB1_rlc_config));
   SRB1_config->rlc_Config = SRB1_rlc_config;
-
   SRB1_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
   SRB1_rlc_config->choice.explicitValue.present = RLC_Config_PR_am;
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms15;
@@ -4391,35 +4057,25 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t16;
   SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
   SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms10;
-
   SRB1_lchan_config = CALLOC(1, sizeof(*SRB1_lchan_config));
   SRB1_config->logicalChannelConfig = SRB1_lchan_config;
-
   SRB1_lchan_config->present = 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 =
     LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
-
   //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50);
   SRB1_ul_SpecificParameters->bucketSizeDuration =
     LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
   logicalchannelgroup = CALLOC(1, sizeof(long));
   *logicalchannelgroup = 0;
   SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup;
-
   ASN_SEQUENCE_ADD(&SRB_configList2->list, SRB1_config);
-
   //2nd: now reconfigure phy config dedicated
   physicalConfigDedicated2 = CALLOC(1, sizeof(*physicalConfigDedicated2));
   *physicalConfigDedicated = physicalConfigDedicated2;
-
   physicalConfigDedicated2->pdsch_ConfigDedicated =
     CALLOC(1, sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated));
   physicalConfigDedicated2->pucch_ConfigDedicated =
@@ -4441,18 +4097,15 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   //assign_enum(&physicalConfigDedicated2->pdsch_ConfigDedicated->p_a,
   //          PDSCH_ConfigDedicated__p_a_dB0);
   physicalConfigDedicated2->pdsch_ConfigDedicated->p_a = PDSCH_ConfigDedicated__p_a_dB0;
-
   // PUCCH
   physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.present =
     PUCCH_ConfigDedicated__ackNackRepetition_PR_release;
   physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.choice.release = 0;
   physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode = NULL;    //PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing;
-
   // Pusch_config_dedicated
   physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_ACK_Index = 0;  // 2.00
   physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_RI_Index = 0;   // 1.25
   physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_CQI_Index = 8;  // 2.25
-
   // UplinkPowerControlDedicated
   physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUSCH = 0; // 0 dB
   //assign_enum(&physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled,
@@ -4466,7 +4119,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
     CALLOC(1, sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient));
   //  assign_enum(physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient,FilterCoefficient_fc4); // fc4 dB
   *physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient = FilterCoefficient_fc4;  // fc4 dB
-
   // TPC-PDCCH-Config
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->present = TPC_PDCCH_Config_PR_setup;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.present = TPC_Index_PR_indexOfFormat3;
@@ -4476,7 +4128,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0] = 0x12;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_context_pP->local_uid;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused = 0;
-
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present = TPC_PDCCH_Config_PR_setup;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.present = TPC_Index_PR_indexOfFormat3;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1;
@@ -4485,7 +4136,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0] = 0x22;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_context_pP->local_uid;
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused = 0;
-
   // CQI ReportConfig
   /*
      physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic));
@@ -4502,7 +4152,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
      physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL;
      physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0;
    */
-
   //soundingRS-UL-ConfigDedicated
   /*
      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup;
@@ -4517,7 +4166,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
      assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift,
      SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0);
    */
-
   //AntennaInfoDedicated
   physicalConfigDedicated2->antennaInfo = CALLOC(1, sizeof(*physicalConfigDedicated2->antennaInfo));
   physicalConfigDedicated2->antennaInfo->present = PhysicalConfigDedicated__antennaInfo_PR_explicitValue;
@@ -4545,7 +4193,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.present =
     AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release;
   physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0;
-
   // SchedulingRequestConfig
   physicalConfigDedicated2->schedulingRequestConfig->present = SchedulingRequestConfig_PR_setup;
   physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = ue_context_pP->local_uid;
@@ -4555,24 +4202,24 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
         10);   // Isr = 5 (every 10 subframes, offset=2+UE_id mod3)
   } else {
     switch (rrc_inst->carrier[0].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 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 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;
+      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;
+      default:
+        physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7; // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..)
+        break;
     }
   }
 
@@ -4581,59 +4228,55 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   //  assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4;
   physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax =
     SchedulingRequestConfig__setup__dsr_TransMax_n4;
-
   LOG_D(RRC,
         "handover_config [FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ  (SRB1 UE %x) --->][MAC_eNB][MOD %02d][]\n",
         ctxt_pP->frame, ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ctxt_pP->module_id);
   rrc_mac_config_req_eNB(
-			 ctxt_pP->module_id,
-			 ue_context_pP->ue_context.primaryCC_id,
-			 0,0,0,0,0,
-#ifdef Rel14 
-0,
-#endif 
-			 ue_context_pP->ue_context.rnti,
-			 (BCCH_BCH_Message_t *) NULL,
-			 (RadioResourceConfigCommonSIB_t*) NULL,
+    ctxt_pP->module_id,
+    ue_context_pP->ue_context.primaryCC_id,
+    0,0,0,0,0,
+#ifdef Rel14
+    0,
+#endif
+    ue_context_pP->ue_context.rnti,
+    (BCCH_BCH_Message_t *) NULL,
+    (RadioResourceConfigCommonSIB_t *) NULL,
 #ifdef Rel14
-			 (RadioResourceConfigCommonSIB_t*) NULL,
+    (RadioResourceConfigCommonSIB_t *) NULL,
 #endif
-			 ue_context_pP->ue_context.physicalConfigDedicated,
+    ue_context_pP->ue_context.physicalConfigDedicated,
 #if defined(Rel10) || defined(Rel14)
-			 (SCellToAddMod_r10_t *)NULL,
-			 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-			 (MeasObjectToAddMod_t **) NULL,
-			 ue_context_pP->ue_context.mac_MainConfig,
-			 1,
-			 SRB1_logicalChannelConfig,
-			 ue_context_pP->ue_context.measGapConfig,
-			 (TDD_Config_t*) NULL,
-			 (MobilityControlInfo_t*) NULL,
-			 (SchedulingInfoList_t*) NULL,
-			 0,
-			 NULL,
-			 NULL,
-			 (MBSFN_SubframeConfigList_t *) NULL
+    (SCellToAddMod_r10_t *)NULL,
+    //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+    (MeasObjectToAddMod_t **) NULL,
+    ue_context_pP->ue_context.mac_MainConfig,
+    1,
+    SRB1_logicalChannelConfig,
+    ue_context_pP->ue_context.measGapConfig,
+    (TDD_Config_t *) NULL,
+    (MobilityControlInfo_t *) NULL,
+    (SchedulingInfoList_t *) NULL,
+    0,
+    NULL,
+    NULL,
+    (MBSFN_SubframeConfigList_t *) NULL
 #if defined(Rel10) || defined(Rel14)
-			 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+    , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #   ifdef Rel14
-			 ,
-			 (SystemInformationBlockType1_v1310_IEs_t *)NULL
+    ,
+    (SystemInformationBlockType1_v1310_IEs_t *)NULL
 #   endif
-			 );
-  
+  );
   // Configure target eNB SRB2
   /// SRB2
   SRB2_config = CALLOC(1, sizeof(*SRB2_config));
   SRB_configList2 = CALLOC(1, sizeof(*SRB_configList2));
   memset(SRB_configList2, 0, sizeof(*SRB_configList2));
-
   SRB2_config->srb_Identity = 2;
   SRB2_rlc_config = CALLOC(1, sizeof(*SRB2_rlc_config));
   SRB2_config->rlc_Config = SRB2_rlc_config;
-
   SRB2_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
   SRB2_rlc_config->choice.explicitValue.present = RLC_Config_PR_am;
   SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms15;
@@ -4642,34 +4285,26 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t32;
   SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35;
   SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms10;
-
   SRB2_lchan_config = CALLOC(1, sizeof(*SRB2_lchan_config));
   SRB2_config->logicalChannelConfig = SRB2_lchan_config;
-
   SRB2_lchan_config->present = SRB_ToAddMod__logicalChannelConfig_PR_explicitValue;
-
   SRB2_ul_SpecificParameters = CALLOC(1, sizeof(*SRB2_ul_SpecificParameters));
-
   SRB2_ul_SpecificParameters->priority = 1;
   SRB2_ul_SpecificParameters->prioritisedBitRate =
     LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
   SRB2_ul_SpecificParameters->bucketSizeDuration =
     LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
   // LCG for CCCH and DCCH is 0 as defined in 36331
   logicalchannelgroup = CALLOC(1, sizeof(long));
   *logicalchannelgroup = 0;
-
   SRB2_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup;
   SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB2_ul_SpecificParameters;
   ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config);
   ASN_SEQUENCE_ADD(&SRB_configList2->list, SRB2_config);
-
   // Configure target eNB DRB
   DRB_configList2 = CALLOC(1, sizeof(*DRB_configList2));
   /// DRB
   DRB_config = CALLOC(1, sizeof(*DRB_config));
-
   //DRB_config->drb_Identity = (DRB_Identity_t) 1; //allowed values 1..32
   // NN: this is the 1st DRB for this ue, so set it to 1
   DRB_config->drb_Identity = (DRB_Identity_t) 1;  // (ue_mod_idP+1); //allowed values 1..32
@@ -4681,7 +4316,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
   DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
   DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
-
   DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
   DRB_config->pdcp_Config = DRB_pdcp_config;
   DRB_pdcp_config->discardTimer = NULL;
@@ -4690,53 +4324,37 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   DRB_pdcp_config->rlc_UM = PDCP_rlc_UM;
   PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
   DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
-
   DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config));
   DRB_config->logicalChannelConfig = DRB_lchan_config;
   DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters));
   DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters;
-
   DRB_ul_SpecificParameters->priority = 2;    // lower priority than srb1, srb2
   DRB_ul_SpecificParameters->prioritisedBitRate =
     LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
   DRB_ul_SpecificParameters->bucketSizeDuration =
     LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
-
   // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM)
   logicalchannelgroup_drb = CALLOC(1, sizeof(long));
   *logicalchannelgroup_drb = 1;
   DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb;
-
   ASN_SEQUENCE_ADD(&DRB_configList2->list, DRB_config);
-
   mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig));
   ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig;
-
   mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config));
-
   maxHARQ_Tx = CALLOC(1, sizeof(long));
   *maxHARQ_Tx = MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
   mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx;
-
   periodicBSR_Timer = CALLOC(1, sizeof(long));
   *periodicBSR_Timer = PeriodicBSR_Timer_r12_sf64;
   mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer;
-
   mac_MainConfig->ul_SCH_Config->retxBSR_Timer = RetxBSR_Timer_r12_sf320;
-
   mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE
-
   mac_MainConfig->drx_Config = NULL;
-
   mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config));
-
   mac_MainConfig->phr_Config->present = MAC_MainConfig__phr_Config_PR_setup;
   mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes
-
   mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes
-
   mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;  // Value dB1 =1 dB, dB3 = 3 dB
-
 #if defined(Rel10) || defined(Rel14)
   sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long));
   *sr_ProhibitTimer_r9 = 0;   // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR
@@ -4747,54 +4365,43 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   // Measurement ID list
   MeasId_list = CALLOC(1, sizeof(*MeasId_list));
   memset((void *)MeasId_list, 0, sizeof(*MeasId_list));
-
   MeasId0 = CALLOC(1, sizeof(*MeasId0));
   MeasId0->measId = 1;
   MeasId0->measObjectId = 1;
   MeasId0->reportConfigId = 1;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0);
-
   MeasId1 = CALLOC(1, sizeof(*MeasId1));
   MeasId1->measId = 2;
   MeasId1->measObjectId = 1;
   MeasId1->reportConfigId = 2;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1);
-
   MeasId2 = CALLOC(1, sizeof(*MeasId2));
   MeasId2->measId = 3;
   MeasId2->measObjectId = 1;
   MeasId2->reportConfigId = 3;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2);
-
   MeasId3 = CALLOC(1, sizeof(*MeasId3));
   MeasId3->measId = 4;
   MeasId3->measObjectId = 1;
   MeasId3->reportConfigId = 4;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3);
-
   MeasId4 = CALLOC(1, sizeof(*MeasId4));
   MeasId4->measId = 5;
   MeasId4->measObjectId = 1;
   MeasId4->reportConfigId = 5;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4);
-
   MeasId5 = CALLOC(1, sizeof(*MeasId5));
   MeasId5->measId = 6;
   MeasId5->measObjectId = 1;
   MeasId5->reportConfigId = 6;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5);
-
   //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list;
-
   // Add one EUTRA Measurement Object
   MeasObj_list = CALLOC(1, sizeof(*MeasObj_list));
   memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list));
-
   // Configure MeasObject
-
   MeasObj = CALLOC(1, sizeof(*MeasObj));
   memset((void *)MeasObj, 0, sizeof(*MeasObj));
-
   MeasObj->measObjectId = 1;
   MeasObj->measObject.present = MeasObjectToAddMod__measObject_PR_measObjectEUTRA;
   MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 36090;
@@ -4805,7 +4412,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1;
   MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6;
   MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL;   // Default is 15 or 0dB
-
   MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList =
     (CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList));
   CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList;
@@ -4816,28 +4422,19 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
     CellToAdd->cellIndex = i + 1;
     CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i);
     CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0;
-
     ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd);
   }
 
   ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj);
   //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list;
-
   // Report Configurations for periodical, A1-A5 events
   ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list));
-
   ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per));
-
   ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1));
-
   ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2));
-
   ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3));
-
   ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4));
-
   ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5));
-
   ReportConfig_per->reportConfigId = 1;
   ReportConfig_per->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -4849,9 +4446,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per);
-
   ReportConfig_A1->reportConfigId = 2;
   ReportConfig_A1->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -4862,15 +4457,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   a1_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1.
   a1_Threshold.choice.threshold_RSRP = 10;
-
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1);
-
   ReportConfig_A2->reportConfigId = 3;
   ReportConfig_A2->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -4881,15 +4473,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   a2_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
   ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA2.
   a2_Threshold.choice.threshold_RSRP = 10;
-
   ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
   ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
   ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2);
-
   ReportConfig_A3->reportConfigId = 4;
   ReportConfig_A3->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -4900,15 +4489,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
     10;
   ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
   eventA3.reportOnLeave = 1;
-
   ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
   ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
   ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3);
-
   ReportConfig_A4->reportConfigId = 5;
   ReportConfig_A4->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -4919,15 +4505,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   a4_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP;
   ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA4.
   a4_Threshold.choice.threshold_RSRP = 10;
-
   ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
   ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
   ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4);
-
   ReportConfig_A5->reportConfigId = 6;
   ReportConfig_A5->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -4942,15 +4525,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   eventA5.a5_Threshold1.choice.threshold_RSRP = 10;
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.
   eventA5.a5_Threshold2.choice.threshold_RSRP = 10;
-
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp;
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both;
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2;
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120;
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity;
-
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5);
-
   Sparams = CALLOC(1, sizeof(*Sparams));
   Sparams->present = MeasConfig__speedStatePars_PR_setup;
   Sparams->choice.setup.timeToTrigger_SF.sf_High = SpeedStateScaleFactors__sf_Medium_oDot75;
@@ -4959,7 +4539,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5;
   Sparams->choice.setup.mobilityStateParameters.t_Evaluation = MobilityStateParameters__t_Evaluation_s60;
   Sparams->choice.setup.mobilityStateParameters.t_HystNormal = MobilityStateParameters__t_HystNormal_s120;
-
   quantityConfig = CALLOC(1, sizeof(*quantityConfig));
   memset((void *)quantityConfig, 0, sizeof(*quantityConfig));
   quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(*quantityConfig->quantityConfigEUTRA));
@@ -4973,9 +4552,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
     CALLOC(1, sizeof(*quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ));
   *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4;
   *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4;
-
   /* mobilityinfo  */
-
   mobilityInfo = CALLOC(1, sizeof(*mobilityInfo));
   memset((void *)mobilityInfo, 0, sizeof(*mobilityInfo));
   mobilityInfo->targetPhysCellId =
@@ -4986,22 +4563,17 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
         mobilityInfo->targetPhysCellId,
         ctxt_pP->module_id,
         ue_context_pP->ue_context.rnti);
-
   mobilityInfo->additionalSpectrumEmission = CALLOC(1, sizeof(*mobilityInfo->additionalSpectrumEmission));
   *mobilityInfo->additionalSpectrumEmission = 1;  //Check this value!
-
   mobilityInfo->t304 = MobilityControlInfo__t304_ms50;    // need to configure an appropriate value here
-
   // New UE Identity (C-RNTI) to identify an UE uniquely in a cell
   mobilityInfo->newUE_Identity.size = 2;
   mobilityInfo->newUE_Identity.bits_unused = 0;
   mobilityInfo->newUE_Identity.buf = rv;
   mobilityInfo->newUE_Identity.buf[0] = rv[0];
   mobilityInfo->newUE_Identity.buf[1] = rv[1];
-
   //memset((void *)&mobilityInfo->radioResourceConfigCommon,(void *)&rrc_inst->sib2->radioResourceConfigCommon,sizeof(RadioResourceConfigCommon_t));
   //memset((void *)&mobilityInfo->radioResourceConfigCommon,0,sizeof(RadioResourceConfigCommon_t));
-
   // Configuring radioResourceConfigCommon
   mobilityInfo->radioResourceConfigCommon.rach_ConfigCommon =
     CALLOC(1, sizeof(*mobilityInfo->radioResourceConfigCommon.rach_ConfigCommon));
@@ -5012,7 +4584,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   memcpy((void *)mobilityInfo->radioResourceConfigCommon.prach_Config.prach_ConfigInfo,
          (void *)&rrc_inst->carrier[0] /* CROUX TBC */.sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo,
          sizeof(PRACH_ConfigInfo_t));
-
   mobilityInfo->radioResourceConfigCommon.prach_Config.rootSequenceIndex =
     rrc_inst->carrier[0] /* CROUX TBC */.sib2->radioResourceConfigCommon.prach_Config.rootSequenceIndex;
   mobilityInfo->radioResourceConfigCommon.pdsch_ConfigCommon =
@@ -5044,31 +4615,27 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   mobilityInfo->radioResourceConfigCommon.ul_CyclicPrefixLength =
     rrc_inst->carrier[0] /* CROUX TBC */.sib2->radioResourceConfigCommon.ul_CyclicPrefixLength;
   //End of configuration of radioResourceConfigCommon
-
   mobilityInfo->carrierFreq = CALLOC(1, sizeof(*mobilityInfo->carrierFreq));  //CALLOC(1,sizeof(CarrierFreqEUTRA_t)); 36090
   mobilityInfo->carrierFreq->dl_CarrierFreq = 36090;
   mobilityInfo->carrierFreq->ul_CarrierFreq = NULL;
-
   mobilityInfo->carrierBandwidth = CALLOC(1, sizeof(
       *mobilityInfo->carrierBandwidth));    //CALLOC(1,sizeof(struct CarrierBandwidthEUTRA));  AllowedMeasBandwidth_mbw25
   mobilityInfo->carrierBandwidth->dl_Bandwidth = CarrierBandwidthEUTRA__dl_Bandwidth_n25;
   mobilityInfo->carrierBandwidth->ul_Bandwidth = NULL;
   mobilityInfo->rach_ConfigDedicated = NULL;
-
   // store the srb and drb list for ho management, mainly in case of failure
-
   memcpy(ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.srb_ToAddModList,
-         (void*)SRB_configList2,
+         (void *)SRB_configList2,
          sizeof(SRB_ToAddModList_t));
-  memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToAddModList,
-         (void*)DRB_configList2,
+  memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToAddModList,
+         (void *)DRB_configList2,
          sizeof(DRB_ToAddModList_t));
   ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL;
-  memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig,
-         (void*)mac_MainConfig,
+  memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig,
+         (void *)mac_MainConfig,
          sizeof(MAC_MainConfig_t));
-  memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated,
-         (void*)ue_context_pP->ue_context.physicalConfigDedicated,
+  memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated,
+         (void *)ue_context_pP->ue_context.physicalConfigDedicated,
          sizeof(PhysicalConfigDedicated_t));
   /*    memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,
      (void *)rrc_inst->sps_Config[ue_mod_idP],
@@ -5083,19 +4650,15 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   ue_context_pP->ue_context.Srb1.Srb_info.Srb_id = Idx;
   memcpy(&ue_context_pP->ue_context.Srb1.Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
   memcpy(&ue_context_pP->ue_context.Srb1.Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
-
-  // SRB2 
+  // SRB2
   ue_context_pP->ue_context.Srb2.Active = 1;
   ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = Idx;
   memcpy(&ue_context_pP->ue_context.Srb2.Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
   memcpy(&ue_context_pP->ue_context.Srb2.Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
-
   LOG_I(RRC, "[eNB %d] CALLING RLC CONFIG SRB1 (rbid %d) for UE %x\n",
         ctxt_pP->module_id, Idx, ue_context_pP->ue_context.rnti);
-
   //      rrc_pdcp_config_req (enb_mod_idP, frameP, 1, CONFIG_ACTION_ADD, idx, UNDEF_SECURITY_MODE);
   //      rrc_rlc_config_req(enb_mod_idP,frameP,1,CONFIG_ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config);
-
   rrc_pdcp_config_asn1_req(&ctxt,
                            ue_context_pP->ue_context.SRB_configList,
                            (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL, 0xff, NULL, NULL, NULL
@@ -5103,7 +4666,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
                            , (PMCH_InfoList_r9_t *) NULL
 #endif
                            ,NULL);
-
   rrc_rlc_config_asn1_req(&ctxt,
                           ue_context_pP->ue_context.SRB_configList,
                           (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL
@@ -5111,13 +4673,10 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
                           , (PMCH_InfoList_r9_t *) NULL
 #endif
                          );
-
   /* Initialize NAS list */
   dedicatedInfoNASList = NULL;
-
   //  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list;
   memset(buffer, 0, RRC_BUF_SIZE);
-
   size = do_RRCConnectionReconfiguration(
            ctxt_pP,
            buffer,
@@ -5142,7 +4701,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
            , NULL   // SCellToAddMod_r10_t
 #endif
          );
-
   LOG_I(RRC,
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration for handover (bytes %d, UE rnti %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
@@ -5159,55 +4717,52 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
      SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
      }
    */
-
   LOG_D(RRC,
         "[FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration_handover to UE %x MUI %d) --->][PDCP][MOD %02d][RB %02d]\n",
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
   //rrc_rlc_data_req(ctxt_pP->module_id,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer);
   //pdcp_data_req (ctxt_pP->module_id, frameP, 1, (ue_mod_idP * NB_RB_MAX) + DCCH,rrc_eNB_mui++, 0, size, (char *) buffer, 1);
-
   rrc_mac_config_req_eNB(
-			 ctxt_pP->module_id,
-			 ue_context_pP->ue_context.primaryCC_id,
-			 0,0,0,0,0,
-#ifdef Rel14 
-			 0,
-#endif
-			 ue_context_pP->ue_context.rnti,
-			 (BCCH_BCH_Message_t *) NULL,
-			 (RadioResourceConfigCommonSIB_t *) NULL,
+    ctxt_pP->module_id,
+    ue_context_pP->ue_context.primaryCC_id,
+    0,0,0,0,0,
+#ifdef Rel14
+    0,
+#endif
+    ue_context_pP->ue_context.rnti,
+    (BCCH_BCH_Message_t *) NULL,
+    (RadioResourceConfigCommonSIB_t *) NULL,
 #ifdef Rel14
-			 (RadioResourceConfigCommonSIB_t *) NULL,
+    (RadioResourceConfigCommonSIB_t *) NULL,
 #endif
-			 ue_context_pP->ue_context.physicalConfigDedicated,
+    ue_context_pP->ue_context.physicalConfigDedicated,
 #if defined(Rel10) || defined(Rel14)
-			 (SCellToAddMod_r10_t *)NULL,
-			 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-			 (MeasObjectToAddMod_t **) NULL,
-			 ue_context_pP->ue_context.mac_MainConfig,
-			 1,
-			 SRB1_logicalChannelConfig,
-			 ue_context_pP->ue_context.measGapConfig,
-			 (TDD_Config_t *) NULL,
-			 (MobilityControlInfo_t *) mobilityInfo,
-			 (SchedulingInfoList_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+    (SCellToAddMod_r10_t *)NULL,
+    //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+    (MeasObjectToAddMod_t **) NULL,
+    ue_context_pP->ue_context.mac_MainConfig,
+    1,
+    SRB1_logicalChannelConfig,
+    ue_context_pP->ue_context.measGapConfig,
+    (TDD_Config_t *) NULL,
+    (MobilityControlInfo_t *) mobilityInfo,
+    (SchedulingInfoList_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #if defined(Rel10) || defined(Rel14)
-			 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+    , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #   ifdef Rel14
-			 ,
-			 (SystemInformationBlockType1_v1310_IEs_t *)NULL
+    ,
+    (SystemInformationBlockType1_v1310_IEs_t *)NULL
 #   endif
-			 );
-  
+  );
   /*
      handoverCommand.criticalExtensions.present = HandoverCommand__criticalExtensions_PR_c1;
      handoverCommand.criticalExtensions.choice.c1.present = HandoverCommand__criticalExtensions__c1_PR_handoverCommand_r8;
      handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.buf = buffer;
      handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.size = size;
    */
-//#warning "COMPILATION PROBLEM"
+  //#warning "COMPILATION PROBLEM"
 #ifdef PROBLEM_COMPILATION_RESOLVED
 
   if (sourceModId != 0xFF) {
@@ -5254,8 +4809,8 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_process_RRCConnectionReconfigurationComplete(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*        ue_context_pP,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t        *ue_context_pP,
   const uint8_t xid
 )
 //-----------------------------------------------------------------------------
@@ -5270,20 +4825,16 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
   (void)dest_ip_offset;
   (void)ue_module_id;
 #endif
-
   uint8_t                            *kRRCenc = NULL;
   uint8_t                            *kRRCint = NULL;
   uint8_t                            *kUPenc = NULL;
   ue_context_pP->ue_context.ue_reestablishment_timer = 0;
-
-  DRB_ToAddModList_t*                 DRB_configList = ue_context_pP->ue_context.DRB_configList2[xid];
-  SRB_ToAddModList_t*                 SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid];
-  DRB_ToReleaseList_t*                DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid];
-  DRB_Identity_t*                     drb_id_p      = NULL;
-
+  DRB_ToAddModList_t                 *DRB_configList = ue_context_pP->ue_context.DRB_configList2[xid];
+  SRB_ToAddModList_t                 *SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid];
+  DRB_ToReleaseList_t                *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid];
+  DRB_Identity_t                     *drb_id_p      = NULL;
   T(T_ENB_RRC_CONNECTION_RECONFIGURATION_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
 #if defined(ENABLE_SECURITY)
 
   /* Derive the keys from kenb */
@@ -5296,9 +4847,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
                      ue_context_pP->ue_context.kenb, &kRRCenc);
   derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm,
                      ue_context_pP->ue_context.kenb, &kRRCint);
-
 #endif
-
   // Refresh SRBs/DRBs
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
@@ -5308,12 +4857,11 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
     MSC_AS_TIME_FMT" CONFIG_REQ UE %x DRB (security unchanged)",
     MSC_AS_TIME_ARGS(ctxt_pP),
     ue_context_pP->ue_context.rnti);
-
   rrc_pdcp_config_asn1_req(
     ctxt_pP,
     SRB_configList, //NULL,  //LG-RK 14/05/2014 SRB_configList,
-    DRB_configList, 
-//    (DRB_ToReleaseList_t *) NULL,
+    DRB_configList,
+    //    (DRB_ToReleaseList_t *) NULL,
     DRB_Release_configList2,
     /*RC.rrc[ctxt_pP->module_id]->ciphering_algorithm[ue_mod_idP] |
              (RC.rrc[ctxt_pP->module_id]->integrity_algorithm[ue_mod_idP] << 4),
@@ -5331,44 +4879,45 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
     ctxt_pP,
     SRB_configList, // NULL,  //LG-RK 14/05/2014 SRB_configList,
     DRB_configList,
-//    (DRB_ToReleaseList_t *) NULL
+    //    (DRB_ToReleaseList_t *) NULL
     DRB_Release_configList2
 #if defined(Rel10) || defined(Rel14)
     , (PMCH_InfoList_r9_t *) NULL
 #endif
   );
-  
+
   // set the SRB active in Ue context
   if (SRB_configList != NULL) {
     for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) {
-      if (SRB_configList->list.array[i]->srb_Identity == 1 ){
-	ue_context_pP->ue_context.Srb1.Active=1;
+      if (SRB_configList->list.array[i]->srb_Identity == 1 ) {
+        ue_context_pP->ue_context.Srb1.Active=1;
       }
       else if (SRB_configList->list.array[i]->srb_Identity == 2 )  {
-	  ue_context_pP->ue_context.Srb2.Active=1;
-	  ue_context_pP->ue_context.Srb2.Srb_info.Srb_id=2;
-	     LOG_I(RRC,"[eNB %d] Frame  %d CC %d : SRB2 is now active\n",
-		ctxt_pP->module_id,
-		ctxt_pP->frame,
-		ue_context_pP->ue_context.primaryCC_id);
+        ue_context_pP->ue_context.Srb2.Active=1;
+        ue_context_pP->ue_context.Srb2.Srb_info.Srb_id=2;
+        LOG_I(RRC,"[eNB %d] Frame  %d CC %d : SRB2 is now active\n",
+              ctxt_pP->module_id,
+              ctxt_pP->frame,
+              ue_context_pP->ue_context.primaryCC_id);
       } else {
-	LOG_W(RRC,"[eNB %d] Frame  %d CC %d : invalide SRB identity %ld\n",
-	      ctxt_pP->module_id,
-	      ctxt_pP->frame,
+        LOG_W(RRC,"[eNB %d] Frame  %d CC %d : invalide SRB identity %ld\n",
+              ctxt_pP->module_id,
+              ctxt_pP->frame,
               ue_context_pP->ue_context.primaryCC_id,
-	      SRB_configList->list.array[i]->srb_Identity);
+              SRB_configList->list.array[i]->srb_Identity);
       }
     }
+
     free(SRB_configList);
     ue_context_pP->ue_context.SRB_configList2[xid] = NULL;
   }
-  
+
   // Loop through DRBs and establish if necessary
 
   if (DRB_configList != NULL) {
     for (i = 0; i < DRB_configList->list.count; i++) {  // num max DRB (11-3-8)
       if (DRB_configList->list.array[i]) {
-	drb_id = (int)DRB_configList->list.array[i]->drb_Identity;
+        drb_id = (int)DRB_configList->list.array[i]->drb_Identity;
         LOG_I(RRC,
               "[eNB %d] Frame  %d : Logical Channel UL-DCCH, Received RRCConnectionReconfigurationComplete from UE rnti %x, reconfiguring DRB %d/LCID %d\n",
               ctxt_pP->module_id,
@@ -5394,7 +4943,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
              RADIO_ACCESS_BEARER,Rlc_info_um);
            */
           ue_context_pP->ue_context.DRB_active[drb_id] = 1;
-
           LOG_D(RRC,
                 "[eNB %d] Frame %d: Establish RLC UM Bidirectional, DRB %d Active\n",
                 ctxt_pP->module_id, ctxt_pP->frame, (int)DRB_configList->list.array[i]->drb_Identity);
@@ -5429,7 +4977,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
 
 #   endif
 #endif
-
           LOG_D(RRC,
                 PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ  (DRB) ---> MAC_eNB\n",
                 PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
@@ -5439,43 +4986,41 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
           }
 
           rrc_mac_config_req_eNB(
-				 ctxt_pP->module_id,
-				 ue_context_pP->ue_context.primaryCC_id,
-				 0,0,0,0,0,
-#ifdef Rel14 
-				 0,
-#endif
-				 ue_context_pP->ue_context.rnti,
-				 (BCCH_BCH_Message_t *) NULL,
-				 (RadioResourceConfigCommonSIB_t *) NULL,
+            ctxt_pP->module_id,
+            ue_context_pP->ue_context.primaryCC_id,
+            0,0,0,0,0,
+#ifdef Rel14
+            0,
+#endif
+            ue_context_pP->ue_context.rnti,
+            (BCCH_BCH_Message_t *) NULL,
+            (RadioResourceConfigCommonSIB_t *) NULL,
 #ifdef Rel14
-				 (RadioResourceConfigCommonSIB_t *) NULL,
+            (RadioResourceConfigCommonSIB_t *) NULL,
 #endif
-				 ue_context_pP->ue_context.physicalConfigDedicated,
+            ue_context_pP->ue_context.physicalConfigDedicated,
 #if defined(Rel10) || defined(Rel14)
-				 (SCellToAddMod_r10_t *)NULL,
-				 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-				 (MeasObjectToAddMod_t **) NULL,
-				 ue_context_pP->ue_context.mac_MainConfig,
-				 DRB2LCHAN[i],
-				 DRB_configList->list.array[i]->logicalChannelConfig,
-				 ue_context_pP->ue_context.measGapConfig,
-				 (TDD_Config_t *) NULL,
-				 NULL,
-				 (SchedulingInfoList_t *) NULL,
-				 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+            (SCellToAddMod_r10_t *)NULL,
+            //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+            (MeasObjectToAddMod_t **) NULL,
+            ue_context_pP->ue_context.mac_MainConfig,
+            DRB2LCHAN[i],
+            DRB_configList->list.array[i]->logicalChannelConfig,
+            ue_context_pP->ue_context.measGapConfig,
+            (TDD_Config_t *) NULL,
+            NULL,
+            (SchedulingInfoList_t *) NULL,
+            0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #if defined(Rel10) || defined(Rel14)
-				 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+            , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #   ifdef Rel14
-				 ,
-				 (SystemInformationBlockType1_v1310_IEs_t *)NULL
+            ,
+            (SystemInformationBlockType1_v1310_IEs_t *)NULL
 #   endif
-				 );
-	  
+          );
         } else {        // remove LCHAN from MAC/PHY
-
           if (ue_context_pP->ue_context.DRB_active[drb_id] == 1) {
             // DRB has just been removed so remove RLC + PDCP for DRB
             /*      rrc_pdcp_config_req (ctxt_pP->module_id, frameP, 1, CONFIG_ACTION_REMOVE,
@@ -5495,95 +5040,94 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
                 PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ  (DRB) ---> 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,
-#ifdef Rel14 
-				 0,
-#endif
-				 ue_context_pP->ue_context.rnti,
-				 (BCCH_BCH_Message_t *) NULL,
-				 (RadioResourceConfigCommonSIB_t *) NULL,
+                                 ue_context_pP->ue_context.primaryCC_id,
+                                 0,0,0,0,0,
+#ifdef Rel14
+                                 0,
+#endif
+                                 ue_context_pP->ue_context.rnti,
+                                 (BCCH_BCH_Message_t *) NULL,
+                                 (RadioResourceConfigCommonSIB_t *) NULL,
 #ifdef Rel14
-				 (RadioResourceConfigCommonSIB_t *) NULL,
+                                 (RadioResourceConfigCommonSIB_t *) NULL,
 #endif
-				 ue_context_pP->ue_context.physicalConfigDedicated,
+                                 ue_context_pP->ue_context.physicalConfigDedicated,
 #if defined(Rel10) || defined(Rel14)
-				 (SCellToAddMod_r10_t *)NULL,
-				 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-				 (MeasObjectToAddMod_t **) NULL,
-				 ue_context_pP->ue_context.mac_MainConfig,
-				 DRB2LCHAN[i],
-				 (LogicalChannelConfig_t *) NULL,
-				 (MeasGapConfig_t *) NULL,
-				 (TDD_Config_t *) NULL,
-				 NULL, 
-				 (SchedulingInfoList_t *) NULL,
-				 0, NULL, NULL, NULL
+                                 (SCellToAddMod_r10_t *)NULL,
+                                 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+                                 (MeasObjectToAddMod_t **) NULL,
+                                 ue_context_pP->ue_context.mac_MainConfig,
+                                 DRB2LCHAN[i],
+                                 (LogicalChannelConfig_t *) NULL,
+                                 (MeasGapConfig_t *) NULL,
+                                 (TDD_Config_t *) NULL,
+                                 NULL,
+                                 (SchedulingInfoList_t *) NULL,
+                                 0, NULL, NULL, NULL
 #if defined(Rel10) || defined(Rel14)
-				 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+                                 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #   ifdef Rel14
-				 ,
-				 (SystemInformationBlockType1_v1310_IEs_t *)NULL
+                                 ,
+                                 (SystemInformationBlockType1_v1310_IEs_t *)NULL
 #   endif
-				 );
+                                );
         }
       }
     }
-   free(DRB_configList);
+
+    free(DRB_configList);
     ue_context_pP->ue_context.DRB_configList2[xid] = NULL;
   }
 
-  if(DRB_Release_configList2 != NULL){
-      for (i = 0; i < DRB_Release_configList2->list.count; i++) {
-          if (DRB_Release_configList2->list.array[i]) {
-              drb_id_p = DRB_Release_configList2->list.array[i];
-              drb_id = *drb_id_p;
-              if (ue_context_pP->ue_context.DRB_active[drb_id] == 1) {
-                  ue_context_pP->ue_context.DRB_active[drb_id] = 0;
-              }
-          }
+  if(DRB_Release_configList2 != NULL) {
+    for (i = 0; i < DRB_Release_configList2->list.count; i++) {
+      if (DRB_Release_configList2->list.array[i]) {
+        drb_id_p = DRB_Release_configList2->list.array[i];
+        drb_id = *drb_id_p;
+
+        if (ue_context_pP->ue_context.DRB_active[drb_id] == 1) {
+          ue_context_pP->ue_context.DRB_active[drb_id] = 0;
+        }
       }
-      free(DRB_Release_configList2);
-      ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL;
+    }
+
+    free(DRB_Release_configList2);
+    ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL;
   }
 }
 
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_RRCConnectionSetup(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
   const int                    CC_id
 )
 //-----------------------------------------------------------------------------
 {
-
   LogicalChannelConfig_t             *SRB1_logicalChannelConfig;  //,*SRB2_logicalChannelConfig;
   SRB_ToAddModList_t                **SRB_configList;
   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
+                          (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);
-
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Setup\n");
 
   for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]);
+    LOG_F(RRC,"%02x ", ((uint8_t *)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]);
   }
 
   LOG_F(RRC,"\n");
@@ -5612,40 +5156,40 @@ rrc_eNB_generate_RRCConnectionSetup(
               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,
-#ifdef Rel14 
-			       0,
-#endif
-			       ue_context_pP->ue_context.rnti,
-			       (BCCH_BCH_Message_t *) NULL,
-			       (RadioResourceConfigCommonSIB_t *) NULL,
+          ctxt_pP->module_id,
+          ue_context_pP->ue_context.primaryCC_id,
+          0,0,0,0,0,
 #ifdef Rel14
-			       (RadioResourceConfigCommonSIB_t *) NULL,
+          0,
 #endif
-			       ue_context_pP->ue_context.physicalConfigDedicated,
+          ue_context_pP->ue_context.rnti,
+          (BCCH_BCH_Message_t *) NULL,
+          (RadioResourceConfigCommonSIB_t *) NULL,
+#ifdef Rel14
+          (RadioResourceConfigCommonSIB_t *) NULL,
+#endif
+          ue_context_pP->ue_context.physicalConfigDedicated,
 #if defined(Rel10) || defined(Rel14)
-			       (SCellToAddMod_r10_t *)NULL,
-			       //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-			       (MeasObjectToAddMod_t **) NULL,
-			       ue_context_pP->ue_context.mac_MainConfig,
-			       1,
-			       SRB1_logicalChannelConfig,
-			       ue_context_pP->ue_context.measGapConfig,
-			       (TDD_Config_t *) NULL,
-			       NULL,
-			       (SchedulingInfoList_t *) NULL,
-			       0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+          (SCellToAddMod_r10_t *)NULL,
+          //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+          (MeasObjectToAddMod_t **) NULL,
+          ue_context_pP->ue_context.mac_MainConfig,
+          1,
+          SRB1_logicalChannelConfig,
+          ue_context_pP->ue_context.measGapConfig,
+          (TDD_Config_t *) NULL,
+          NULL,
+          (SchedulingInfoList_t *) NULL,
+          0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #if defined(Rel10) || defined(Rel14)
-			       , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+          , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #   ifdef Rel14
-			       ,
-			       (SystemInformationBlockType1_v1310_IEs_t *)NULL
+          ,
+          (SystemInformationBlockType1_v1310_IEs_t *)NULL
 #   endif
-			       );
+        );
         break;
       }
     }
@@ -5660,21 +5204,18 @@ rrc_eNB_generate_RRCConnectionSetup(
     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 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);
-
   // activate release timer, if RRCSetupComplete not received after 10 frames, remove UE
   //ue_context_pP->ue_context.ue_release_timer=1;
   // remove UE after 10 frames after RRCConnectionRelease is triggered
   //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 RRCConnectionRelease is triggered
-   ue_context_pP->ue_context.ue_release_timer_thres=1000;
+  // 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 RRCConnectionRelease is triggered
+  ue_context_pP->ue_context.ue_release_timer_thres=1000;
 }
 
 
@@ -5683,7 +5224,7 @@ rrc_eNB_generate_RRCConnectionSetup(
 char
 openair_rrc_eNB_configuration(
   const module_id_t enb_mod_idP,
-  RrcConfigurationReq* configuration
+  RrcConfigurationReq *configuration
 )
 #else
 char
@@ -5695,18 +5236,18 @@ openair_rrc_eNB_init(
 {
   protocol_ctxt_t ctxt;
   int             CC_id;
-
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, 0, 0,enb_mod_idP);
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_FMT" Init...\n",
         PROTOCOL_RRC_CTXT_ARGS(&ctxt));
-
 #if OCP_FRAMEWORK
+
   while ( RC.rrc[enb_mod_idP] == NULL ) {
     LOG_E(RRC, "RC.rrc not yet initialized, waiting 1 second\n");
     sleep(1);
   }
-#endif 
+
+#endif
   AssertFatal(RC.rrc[enb_mod_idP] != NULL, "RC.rrc not initialized!");
   AssertFatal(MAX_MOBILES_PER_ENB < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow");
 #ifdef ENABLE_ITTI
@@ -5739,21 +5280,15 @@ openair_rrc_eNB_init(
   //        RC.rrc[enb_mod_idP]->Srb2[j].Active = 0;
   //    }
 
-
-  RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL);
-  RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids    = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL);
-
+  RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
+  RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids    = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
   memcpy(&RC.rrc[ctxt.module_id]->configuration,configuration,sizeof(RrcConfigurationReq));
-
   /// System Information INIT
-
   LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Checking release \n",
         PROTOCOL_RRC_CTXT_ARGS(&ctxt));
 #if defined(Rel10) || defined(Rel14)
-
   // can clear it at runtime
   RC.rrc[ctxt.module_id]->carrier[0].MBMS_flag = 0;
-
   // This has to come from some top-level configuration
   // only CC_id 0 is logged
 #if defined(Rel10)
@@ -5763,7 +5298,6 @@ openair_rrc_eNB_init(
 #endif
         PROTOCOL_RRC_CTXT_ARGS(&ctxt),
         RC.rrc[ctxt.module_id]->carrier[0].MBMS_flag);
-
 #else
   LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel8 RRC\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
 #endif
@@ -5787,7 +5321,6 @@ openair_rrc_eNB_init(
           RC.rrc[ctxt.module_id]->carrier[CC_id].cba_rnti[3],
           RC.rrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups);
   }
-
 #endif
 
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
@@ -5797,32 +5330,33 @@ openair_rrc_eNB_init(
             , configuration
 #endif
            );
-    for (int ue_id = 0; ue_id < MAX_MOBILES_PER_ENB; ue_id++) {
-        RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0;
-        RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t*) malloc16(256);
+
+    for (int ue_id = 0; ue_id < NUMBER_OF_UE_MAX; ue_id++) {
+      RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0;
+      RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t *) malloc16(256);
     }
   }
-
   rrc_init_global_param();
-  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
 
+  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
 #if defined(Rel10) || defined(Rel14)
+
     switch (RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag) {
-    case 1:
-    case 2:
-    case 3:
-      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 1 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
-      RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 1;
-      break;
+      case 1:
+      case 2:
+      case 3:
+        LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 1 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
+        RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 1;
+        break;
 
-    case 4:
-      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 2 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
-      RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 2;
-      break;
+      case 4:
+        LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 2 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
+        RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 2;
+        break;
 
-    default:
-      RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 0;
-      break;
+      default:
+        RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 0;
+        break;
     }
 
     // if we are here the RC.rrc[enb_mod_idP]->MBMS_flag > 0,
@@ -5832,21 +5366,19 @@ openair_rrc_eNB_init(
       /// MTCH data bearer init
       init_MBMS(ctxt.module_id, CC_id, 0);
     }
-#endif
 
+#endif
     openair_rrc_top_init_eNB(RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag,0);
   }
   openair_rrc_on(&ctxt);
-
   return 0;
-
 }
 
 /*------------------------------------------------------------------------------*/
 int
 rrc_eNB_decode_ccch(
-  protocol_ctxt_t* const ctxt_pP,
-  const SRB_INFO*        const Srb_info,
+  protocol_ctxt_t *const ctxt_pP,
+  const SRB_INFO        *const Srb_info,
   const int              CC_id
 )
 //-----------------------------------------------------------------------------
@@ -5854,21 +5386,18 @@ rrc_eNB_decode_ccch(
   module_id_t                                   Idx;
   asn_dec_rval_t                      dec_rval;
   UL_CCCH_Message_t                  *ul_ccch_msg = NULL;
-  RRCConnectionRequest_r8_IEs_t*                rrcConnectionRequest = NULL;
-  RRCConnectionReestablishmentRequest_r8_IEs_t* rrcConnectionReestablishmentRequest = NULL;
+  RRCConnectionRequest_r8_IEs_t                *rrcConnectionRequest = NULL;
+  RRCConnectionReestablishmentRequest_r8_IEs_t *rrcConnectionReestablishmentRequest = NULL;
   int                                 i, rval;
-  struct rrc_eNB_ue_context_s*                  ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s                  *ue_context_p = NULL;
   uint64_t                                      random_value = 0;
   int                                           stmsi_received = 0;
-
   T(T_ENB_RRC_UL_CCCH_DATA_IN, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
   //memset(ul_ccch_msg,0,sizeof(UL_CCCH_Message_t));
-
   LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-        ((uint8_t*) Srb_info->Rx_buffer.Payload)[0],
+        ((uint8_t *) Srb_info->Rx_buffer.Payload)[0],
         ((uint8_t *) Srb_info->Rx_buffer.Payload)[1],
         ((uint8_t *) Srb_info->Rx_buffer.Payload)[2],
         ((uint8_t *) Srb_info->Rx_buffer.Payload)[3],
@@ -5877,15 +5406,15 @@ rrc_eNB_decode_ccch(
   dec_rval = uper_decode(
                NULL,
                &asn_DEF_UL_CCCH_Message,
-               (void**)&ul_ccch_msg,
-               (uint8_t*) Srb_info->Rx_buffer.Payload,
+               (void **)&ul_ccch_msg,
+               (uint8_t *) Srb_info->Rx_buffer.Payload,
                100,
                0,
                0);
 
   /*
-#if defined(ENABLE_ITTI)
-#   if defined(DISABLE_ITTI_XER_PRINT)
+  #if defined(ENABLE_ITTI)
+  #   if defined(DISABLE_ITTI_XER_PRINT)
   {
     MessageDef                         *message_p;
 
@@ -5894,7 +5423,7 @@ rrc_eNB_decode_ccch(
 
     itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, message_p);
   }
-#   else
+  #   else
   {
     char                                message_string[10000];
     size_t                              message_string_size;
@@ -5910,8 +5439,8 @@ rrc_eNB_decode_ccch(
       itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
     }
   }
-#   endif
-#endif
+  #   endif
+  #endif
   */
 
   for (i = 0; i < 8; i++) {
@@ -5926,452 +5455,440 @@ rrc_eNB_decode_ccch(
   }
 
   if (ul_ccch_msg->message.present == UL_CCCH_MessageType_PR_c1) {
-
     switch (ul_ccch_msg->message.choice.c1.present) {
+      case UL_CCCH_MessageType__c1_PR_NOTHING:
+        LOG_I(RRC,
+              PROTOCOL_RRC_CTXT_FMT" Received PR_NOTHING on UL-CCCH-Message\n",
+              PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+        break;
 
-    case UL_CCCH_MessageType__c1_PR_NOTHING:
-      LOG_I(RRC,
-            PROTOCOL_RRC_CTXT_FMT" Received PR_NOTHING on UL-CCCH-Message\n",
-            PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
-      break;
-
-    case UL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentRequest:
-      T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
+      case UL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentRequest:
+        T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC Connection Reestablishment Request\n");
+        LOG_F(RRC,"[MSG] RRC Connection Reestablishment Request\n");
 
-      for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Srb_info->Rx_buffer.Payload)[i]);
-      }
+        for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Srb_info->Rx_buffer.Payload)[i]);
+        }
 
-      LOG_F(RRC,"\n");
+        LOG_F(RRC,"\n");
 #endif
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB--- MAC_DATA_IND (rrcConnectionReestablishmentRequest on SRB0) --> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-      rrcConnectionReestablishmentRequest =
-        &ul_ccch_msg->message.choice.c1.choice.rrcConnectionReestablishmentRequest.criticalExtensions.choice.rrcConnectionReestablishmentRequest_r8;
-      LOG_I(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest cause %s\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            ((rrcConnectionReestablishmentRequest->reestablishmentCause == ReestablishmentCause_otherFailure) ?    "Other Failure" :
-             (rrcConnectionReestablishmentRequest->reestablishmentCause == ReestablishmentCause_handoverFailure) ? "Handover Failure" :
-             "reconfigurationFailure"));
-      /*{
-      uint64_t                            c_rnti = 0;
-
-      memcpy(((uint8_t *) & c_rnti) + 3, rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.buf,
-      rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.size);
-      ue_mod_id = rrc_eNB_get_UE_index(enb_mod_idP, c_rnti);
-      }
+        LOG_D(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB--- MAC_DATA_IND (rrcConnectionReestablishmentRequest on SRB0) --> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+        rrcConnectionReestablishmentRequest =
+          &ul_ccch_msg->message.choice.c1.choice.rrcConnectionReestablishmentRequest.criticalExtensions.choice.rrcConnectionReestablishmentRequest_r8;
+        LOG_I(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest cause %s\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              ((rrcConnectionReestablishmentRequest->reestablishmentCause == ReestablishmentCause_otherFailure) ?    "Other Failure" :
+               (rrcConnectionReestablishmentRequest->reestablishmentCause == ReestablishmentCause_handoverFailure) ? "Handover Failure" :
+               "reconfigurationFailure"));
+        /*{
+        uint64_t                            c_rnti = 0;
+
+        memcpy(((uint8_t *) & c_rnti) + 3, rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.buf,
+        rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.size);
+        ue_mod_id = rrc_eNB_get_UE_index(enb_mod_idP, c_rnti);
+        }
 
-      if ((RC.rrc[enb_mod_idP]->phyCellId == rrcConnectionReestablishmentRequest.UE_identity.physCellId) &&
-      (ue_mod_id != UE_INDEX_INVALID)){
-      rrc_eNB_generate_RRCConnectionReestablishment(enb_mod_idP, frameP, ue_mod_id);
-      }else {
-      rrc_eNB_generate_RRCConnectionReestablishmentReject(enb_mod_idP, frameP, ue_mod_id);
-      }
-      */
-      /* reject all reestablishment attempts for the moment */
-//      rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP,
-//                       rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti),
-//                       CC_id);
-{
-      uint16_t                          c_rnti = 0;
+        if ((RC.rrc[enb_mod_idP]->phyCellId == rrcConnectionReestablishmentRequest.UE_identity.physCellId) &&
+        (ue_mod_id != UE_INDEX_INVALID)){
+        rrc_eNB_generate_RRCConnectionReestablishment(enb_mod_idP, frameP, ue_mod_id);
+        }else {
+        rrc_eNB_generate_RRCConnectionReestablishmentReject(enb_mod_idP, frameP, ue_mod_id);
+        }
+        */
+        /* reject all reestablishment attempts for the moment */
+        //      rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP,
+        //                       rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti),
+        //                       CC_id);
+        {
+          uint16_t                          c_rnti = 0;
 
-      if (rrcConnectionReestablishmentRequest->ue_Identity.physCellId != RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId) {
-        LOG_E(RRC,
-              PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), let's reject the UE\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-              rrcConnectionReestablishmentRequest->ue_Identity.physCellId,
-              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId);
-        rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
-        break;
-      }
-      LOG_D(RRC, "physCellId is %ld\n", rrcConnectionReestablishmentRequest->ue_Identity.physCellId);
+          if (rrcConnectionReestablishmentRequest->ue_Identity.physCellId != RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId) {
+            LOG_E(RRC,
+                  PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), let's reject the UE\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                  rrcConnectionReestablishmentRequest->ue_Identity.physCellId,
+                  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId);
+            rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
+            break;
+          }
 
-      for (i = 0; i < rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.size; i++) {
-        LOG_D(RRC, "rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[%d] = %x\n",
-            i, rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[i]);
-      }
+          LOG_D(RRC, "physCellId is %ld\n", rrcConnectionReestablishmentRequest->ue_Identity.physCellId);
 
-      if (rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size == 0 ||
-          rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size > 2) {
-        LOG_E(RRC,
-              PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest c_RNTI range error, let's reject the UE\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-        rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
-        break;
+          for (i = 0; i < rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.size; i++) {
+            LOG_D(RRC, "rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[%d] = %x\n",
+                  i, rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[i]);
+          }
 
-      }
+          if (rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size == 0 ||
+              rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size > 2) {
+            LOG_E(RRC,
+                  PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest c_RNTI range error, let's reject the UE\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+            rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
+            break;
+          }
 
-      c_rnti = BIT_STRING_to_uint16(&rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI);
-      LOG_D(RRC, "c_rnti is %x\n", c_rnti);
+          c_rnti = BIT_STRING_to_uint16(&rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI);
+          LOG_D(RRC, "c_rnti is %x\n", c_rnti);
+          ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], c_rnti);
 
-      ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], c_rnti);
-      if (ue_context_p == NULL) {
-        LOG_E(RRC,
-              PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest without UE context, let's reject the UE\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-        rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
-        break;
-      }
-      int UE_id = find_UE_id(ctxt_pP->module_id, c_rnti);
-      if(ue_context_p->ue_context.ue_reestablishment_timer > 0 || RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer > 0){
-          LOG_I(RRC,
-                PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishment(Previous) don't complete, let's reject the UE\n",
-                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-          rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
-          break;
-      }
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            ue_context_p);
-      ue_context_p->ue_context.ul_failure_timer = 0;
-      ue_context_p->ue_context.ue_release_timer = 0;
-      ue_context_p->ue_context.ue_reestablishment_timer = 0;
-      ue_context_p->ue_context.ue_release_timer_s1 = 0;
-      ue_context_p->ue_context.ue_release_timer_rrc = 0;
-
-      /* reset timers */
-      ue_context_p->ue_context.ul_failure_timer = 0;
-      ue_context_p->ue_context.ue_release_timer = 0;
-
-      // insert C-RNTI to map
-      for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
-        if (reestablish_rnti_map[i][0] == 0) {
-          reestablish_rnti_map[i][0] = ctxt_pP->rnti;
-          reestablish_rnti_map[i][1] = c_rnti;
-          break;
-        }
-      }
-      LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n",
-            i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]);
+          if (ue_context_p == NULL) {
+            LOG_E(RRC,
+                  PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest without UE context, let's reject the UE\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+            rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
+            break;
+          }
+
+          int UE_id = find_UE_id(ctxt_pP->module_id, c_rnti);
+
+          if(ue_context_p->ue_context.ue_reestablishment_timer > 0 || RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer > 0) {
+            LOG_I(RRC,
+                  PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishment(Previous) don't complete, let's reject the UE\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+            rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id);
+            break;
+          }
 
+          LOG_D(RRC,
+                PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n",
+                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                ue_context_p);
+          ue_context_p->ue_context.ul_failure_timer = 0;
+          ue_context_p->ue_context.ue_release_timer = 0;
+          ue_context_p->ue_context.ue_reestablishment_timer = 0;
+          ue_context_p->ue_context.ue_release_timer_s1 = 0;
+          ue_context_p->ue_context.ue_release_timer_rrc = 0;
+          /* reset timers */
+          ue_context_p->ue_context.ul_failure_timer = 0;
+          ue_context_p->ue_context.ue_release_timer = 0;
+
+          // insert C-RNTI to map
+          for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+            if (reestablish_rnti_map[i][0] == 0) {
+              reestablish_rnti_map[i][0] = ctxt_pP->rnti;
+              reestablish_rnti_map[i][1] = c_rnti;
+              break;
+            }
+          }
+
+          LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n",
+                i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]);
 #if defined(ENABLE_ITTI)
-      ue_context_p->ue_context.reestablishment_cause = rrcConnectionReestablishmentRequest->reestablishmentCause;
-      LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection reestablishment request from UE physCellId %ld cause %ld\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            rrcConnectionReestablishmentRequest->ue_Identity.physCellId,
-            ue_context_p->ue_context.reestablishment_cause);
+          ue_context_p->ue_context.reestablishment_cause = rrcConnectionReestablishmentRequest->reestablishmentCause;
+          LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection reestablishment request from UE physCellId %ld cause %ld\n",
+                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                rrcConnectionReestablishmentRequest->ue_Identity.physCellId,
+                ue_context_p->ue_context.reestablishment_cause);
 #else
-        LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection restablishment request for UE\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+          LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection restablishment request for UE\n",
+                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
 #endif
-
 #ifndef NO_RRM
-      send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id));
+          send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id));
 #else
-
-      ue_context_p->ue_context.primaryCC_id = CC_id;
-
-      //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH;
-      Idx = DCCH;
-      // SRB1
-      ue_context_p->ue_context.Srb1.Active = 1;
-      ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx;
-      memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-      memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-
-      // SRB2: set  it to go through SRB1 with id 1 (DCCH)
-      ue_context_p->ue_context.Srb2.Active = 1;
-      ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx;
-      memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-      memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-
-      rrc_eNB_generate_RRCConnectionReestablishment(ctxt_pP, ue_context_p, CC_id);
-      LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            Idx);
-
-      MSC_LOG_TX_MESSAGE(MSC_RRC_ENB,
-                         MSC_PDCP_ENB,
-                         NULL,
-                         0,
-                         MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB",
-                         MSC_AS_TIME_ARGS(ctxt_pP),
-                         ue_context_p->ue_context.rnti);
-
-      rrc_pdcp_config_asn1_req(ctxt_pP,
-                               ue_context_p->ue_context.SRB_configList,
-                               (DRB_ToAddModList_t *) NULL,
-                               (DRB_ToReleaseList_t*) NULL,
-                               0xff,
-                               NULL,
-                               NULL,
-                               NULL
+          ue_context_p->ue_context.primaryCC_id = CC_id;
+          //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH;
+          Idx = DCCH;
+          // SRB1
+          ue_context_p->ue_context.Srb1.Active = 1;
+          ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx;
+          memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0],
+                 &DCCH_LCHAN_DESC,
+                 LCHAN_DESC_SIZE);
+          memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1],
+                 &DCCH_LCHAN_DESC,
+                 LCHAN_DESC_SIZE);
+          // SRB2: set  it to go through SRB1 with id 1 (DCCH)
+          ue_context_p->ue_context.Srb2.Active = 1;
+          ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx;
+          memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0],
+                 &DCCH_LCHAN_DESC,
+                 LCHAN_DESC_SIZE);
+          memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1],
+                 &DCCH_LCHAN_DESC,
+                 LCHAN_DESC_SIZE);
+          rrc_eNB_generate_RRCConnectionReestablishment(ctxt_pP, ue_context_p, CC_id);
+          LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n",
+                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                Idx);
+          MSC_LOG_TX_MESSAGE(MSC_RRC_ENB,
+                             MSC_PDCP_ENB,
+                             NULL,
+                             0,
+                             MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB",
+                             MSC_AS_TIME_ARGS(ctxt_pP),
+                             ue_context_p->ue_context.rnti);
+          rrc_pdcp_config_asn1_req(ctxt_pP,
+                                   ue_context_p->ue_context.SRB_configList,
+                                   (DRB_ToAddModList_t *) NULL,
+                                   (DRB_ToReleaseList_t *) NULL,
+                                   0xff,
+                                   NULL,
+                                   NULL,
+                                   NULL
 #   if defined(Rel10) || defined(Rel14)
-                               , (PMCH_InfoList_r9_t *) NULL
+                                   , (PMCH_InfoList_r9_t *) NULL
 #   endif
-                               ,NULL);
-
-      rrc_rlc_config_asn1_req(ctxt_pP,
-                              ue_context_p->ue_context.SRB_configList,
-                              (DRB_ToAddModList_t*) NULL,
-                              (DRB_ToReleaseList_t*) NULL
+                                   ,NULL);
+          rrc_rlc_config_asn1_req(ctxt_pP,
+                                  ue_context_p->ue_context.SRB_configList,
+                                  (DRB_ToAddModList_t *) NULL,
+                                  (DRB_ToReleaseList_t *) NULL
 #   if defined(Rel10) || defined(Rel14)
-                              , (PMCH_InfoList_r9_t *) NULL
+                                  , (PMCH_InfoList_r9_t *) NULL
 #   endif
-                             );
+                                 );
 #endif //NO_RRM
-      }
-      break;
-
-    case UL_CCCH_MessageType__c1_PR_rrcConnectionRequest:
-      T(T_ENB_RRC_CONNECTION_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        }
+        break;
 
+      case UL_CCCH_MessageType__c1_PR_rrcConnectionRequest:
+        T(T_ENB_RRC_CONNECTION_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC Connection Request\n");
+        LOG_F(RRC,"[MSG] RRC Connection Request\n");
 
-      for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Srb_info->Rx_buffer.Payload)[i]);
-      }
+        for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Srb_info->Rx_buffer.Payload)[i]);
+        }
 
-      LOG_F(RRC,"\n");
+        LOG_F(RRC,"\n");
 #endif
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB --- MAC_DATA_IND  (rrcConnectionRequest on SRB0) --> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-      ue_context_p = rrc_eNB_get_ue_context(
-                       RC.rrc[ctxt_pP->module_id],
-                       ctxt_pP->rnti);
-
-      if (ue_context_p != NULL) {
-        // erase content
-        rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_p);
+        LOG_D(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB --- MAC_DATA_IND  (rrcConnectionRequest on SRB0) --> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+        ue_context_p = rrc_eNB_get_ue_context(
+                         RC.rrc[ctxt_pP->module_id],
+                         ctxt_pP->rnti);
 
-        MSC_LOG_RX_DISCARDED_MESSAGE(
-          MSC_RRC_ENB,
-          MSC_RRC_UE,
-          Srb_info->Rx_buffer.Payload,
-          dec_rval.consumed,
-          MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (UE already in context)",
-          MSC_AS_TIME_ARGS(ctxt_pP),
-          ue_context_p->ue_context.rnti,
-          dec_rval.consumed);
-      } else {
-        rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8;
-        {
-          if (InitialUE_Identity_PR_randomValue == rrcConnectionRequest->ue_Identity.present) {
-            AssertFatal(rrcConnectionRequest->ue_Identity.choice.randomValue.size == 5,
-                        "wrong InitialUE-Identity randomValue size, expected 5, provided %d",
-                        rrcConnectionRequest->ue_Identity.choice.randomValue.size);
-            memcpy(((uint8_t*) & random_value) + 3,
-                   rrcConnectionRequest->ue_Identity.choice.randomValue.buf,
-                   rrcConnectionRequest->ue_Identity.choice.randomValue.size);
-            /* if there is already a registered UE (with another RNTI) with this random_value,
-             * the current one must be removed from MAC/PHY (zombie UE)
-             */
+        if (ue_context_p != NULL) {
+          // erase content
+          rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_p);
+          MSC_LOG_RX_DISCARDED_MESSAGE(
+            MSC_RRC_ENB,
+            MSC_RRC_UE,
+            Srb_info->Rx_buffer.Payload,
+            dec_rval.consumed,
+            MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (UE already in context)",
+            MSC_AS_TIME_ARGS(ctxt_pP),
+            ue_context_p->ue_context.rnti,
+            dec_rval.consumed);
+        } else {
+          rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8;
+          {
+            if (InitialUE_Identity_PR_randomValue == rrcConnectionRequest->ue_Identity.present) {
+              AssertFatal(rrcConnectionRequest->ue_Identity.choice.randomValue.size == 5,
+                          "wrong InitialUE-Identity randomValue size, expected 5, provided %d",
+                          rrcConnectionRequest->ue_Identity.choice.randomValue.size);
+              memcpy(((uint8_t *) & random_value) + 3,
+                     rrcConnectionRequest->ue_Identity.choice.randomValue.buf,
+                     rrcConnectionRequest->ue_Identity.choice.randomValue.size);
+              /* if there is already a registered UE (with another RNTI) with this random_value,
+               * the current one must be removed from MAC/PHY (zombie UE)
+               */
 #if 0
-            if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) {
-              LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n",
-                    ctxt_pP->rnti, ue_context_p->ue_context.rnti, ctxt_pP->rnti);
-	      rrc_mac_remove_ue(ctxt_pP->module_id, ctxt_pP->rnti);
-              ue_context_p = NULL;
-              return 0;
-            } else {
-              ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value);
-            }
-#endif
-            if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) {
-              LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n",
-                    ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti);
-              ue_context_p->ue_context.ul_failure_timer = 20000;
-            }
-            ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value);
-          } else if (InitialUE_Identity_PR_s_TMSI == rrcConnectionRequest->ue_Identity.present) {
-            /* Save s-TMSI */
-            S_TMSI_t   s_TMSI = rrcConnectionRequest->ue_Identity.choice.s_TMSI;
-            mme_code_t mme_code = BIT_STRING_to_uint8(&s_TMSI.mmec);
-            m_tmsi_t   m_tmsi   = BIT_STRING_to_uint32(&s_TMSI.m_TMSI);
-            random_value = (((uint64_t)mme_code) << 32) | m_tmsi;
-            if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist(ctxt_pP, mme_code, m_tmsi))) {
-	      LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti);
-	      rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti);
-	      stmsi_received=1;
-              /* replace rnti in the context */
-              /* for that, remove the context from the RB tree */
-              RB_REMOVE(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
-              /* and insert again, after changing rnti everywhere it has to be changed */
-              ue_context_p->ue_id_rnti = ctxt_pP->rnti;
-	      ue_context_p->ue_context.rnti = ctxt_pP->rnti;
-              RB_INSERT(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
-              /* reset timers */
-              ue_context_p->ue_context.ul_failure_timer = 0;
-              ue_context_p->ue_context.ue_release_timer = 0;
-              ue_context_p->ue_context.ue_reestablishment_timer = 0;
-              ue_context_p->ue_context.ue_release_timer_s1 = 0;
-              ue_context_p->ue_context.ue_release_timer_rrc = 0;
-            } else {
-	      LOG_I(RRC," S-TMSI doesn't exist, setting Initialue_identity_s_TMSI.m_tmsi to %p => %x\n",ue_context_p,m_tmsi);
-//              ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY);
-              ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP,random_value);
-              if (ue_context_p == NULL)
-                LOG_E(RRC, "%s:%d:%s: rrc_eNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__);
-              if (ue_context_p != NULL) {
-	        ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = TRUE;
-	        ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code;
-	        ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi;
+
+              if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) {
+                LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n",
+                      ctxt_pP->rnti, ue_context_p->ue_context.rnti, ctxt_pP->rnti);
+                rrc_mac_remove_ue(ctxt_pP->module_id, ctxt_pP->rnti);
+                ue_context_p = NULL;
+                return 0;
               } else {
-                /* TODO: do we have to break here? */
-                //break;
+                ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value);
               }
-            }
-
-            MSC_LOG_RX_MESSAGE(
-              MSC_RRC_ENB,
-              MSC_RRC_UE,
-              Srb_info->Rx_buffer.Payload,
-              dec_rval.consumed,
-              MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (s-TMSI mmec %u m_TMSI %u random UE id (0x%" PRIx64 ")",
-              MSC_AS_TIME_ARGS(ctxt_pP),
-              ue_context_p->ue_context.rnti,
-              dec_rval.consumed,
-              ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
-              ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
-              ue_context_p->ue_context.random_ue_identity);
-          } else {
-            LOG_E(RRC,
-                  PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionRequest without random UE identity or S-TMSI not supported, let's reject the UE\n",
-                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-            rrc_eNB_generate_RRCConnectionReject(ctxt_pP,
-                             rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti),
-                             CC_id);
-            break;
-          }
 
-        }
-        LOG_D(RRC,
-              PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-              ue_context_p);
+#endif
 
-        if (ue_context_p != NULL) {
+              if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) {
+                LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n",
+                      ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti);
+                ue_context_p->ue_context.ul_failure_timer = 20000;
+              }
 
+              ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value);
+            } else if (InitialUE_Identity_PR_s_TMSI == rrcConnectionRequest->ue_Identity.present) {
+              /* Save s-TMSI */
+              S_TMSI_t   s_TMSI = rrcConnectionRequest->ue_Identity.choice.s_TMSI;
+              mme_code_t mme_code = BIT_STRING_to_uint8(&s_TMSI.mmec);
+              m_tmsi_t   m_tmsi   = BIT_STRING_to_uint32(&s_TMSI.m_TMSI);
+              random_value = (((uint64_t)mme_code) << 32) | m_tmsi;
+
+              if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist(ctxt_pP, mme_code, m_tmsi))) {
+                LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti);
+                rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti);
+                stmsi_received=1;
+                /* replace rnti in the context */
+                /* for that, remove the context from the RB tree */
+                RB_REMOVE(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
+                /* and insert again, after changing rnti everywhere it has to be changed */
+                ue_context_p->ue_id_rnti = ctxt_pP->rnti;
+                ue_context_p->ue_context.rnti = ctxt_pP->rnti;
+                RB_INSERT(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
+                /* reset timers */
+                ue_context_p->ue_context.ul_failure_timer = 0;
+                ue_context_p->ue_context.ue_release_timer = 0;
+                ue_context_p->ue_context.ue_reestablishment_timer = 0;
+                ue_context_p->ue_context.ue_release_timer_s1 = 0;
+                ue_context_p->ue_context.ue_release_timer_rrc = 0;
+              } else {
+                LOG_I(RRC," S-TMSI doesn't exist, setting Initialue_identity_s_TMSI.m_tmsi to %p => %x\n",ue_context_p,m_tmsi);
+                //              ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY);
+                ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP,random_value);
+
+                if (ue_context_p == NULL)
+                  LOG_E(RRC, "%s:%d:%s: rrc_eNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__);
+
+                if (ue_context_p != NULL) {
+                  ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = TRUE;
+                  ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code;
+                  ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi;
+                } else {
+                  /* TODO: do we have to break here? */
+                  //break;
+                }
+              }
 
-#if defined(ENABLE_ITTI)
-          ue_context_p->ue_context.establishment_cause = rrcConnectionRequest->establishmentCause;
-          ue_context_p->ue_context.reestablishment_cause = ReestablishmentCause_spare1;
-	  if (stmsi_received==0)
-	    LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE random UE identity (0x%" PRIx64 ") MME code %u TMSI %u cause %ld\n",
-		  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-		  ue_context_p->ue_context.random_ue_identity,
-		  ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
-		  ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
-		  ue_context_p->ue_context.establishment_cause);
-	  else
-	    LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE  MME code %u TMSI %u cause %ld\n",
-		  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-		  ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
-		  ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
-		  ue_context_p->ue_context.establishment_cause);
-#else
-          LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection for UE random UE identity (0x%" PRIx64 ")\n",
-                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              MSC_LOG_RX_MESSAGE(
+                MSC_RRC_ENB,
+                MSC_RRC_UE,
+                Srb_info->Rx_buffer.Payload,
+                dec_rval.consumed,
+                MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (s-TMSI mmec %u m_TMSI %u random UE id (0x%" PRIx64 ")",
+                MSC_AS_TIME_ARGS(ctxt_pP),
+                ue_context_p->ue_context.rnti,
+                dec_rval.consumed,
+                ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
+                ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
                 ue_context_p->ue_context.random_ue_identity);
+            } else {
+              LOG_E(RRC,
+                    PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionRequest without random UE identity or S-TMSI not supported, let's reject the UE\n",
+                    PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+              rrc_eNB_generate_RRCConnectionReject(ctxt_pP,
+                                                   rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti),
+                                                   CC_id);
+              break;
+            }
+          }
+          LOG_D(RRC,
+                PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n",
+                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                ue_context_p);
+
+          if (ue_context_p != NULL) {
+#if defined(ENABLE_ITTI)
+            ue_context_p->ue_context.establishment_cause = rrcConnectionRequest->establishmentCause;
+            ue_context_p->ue_context.reestablishment_cause = ReestablishmentCause_spare1;
+
+            if (stmsi_received==0)
+              LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE random UE identity (0x%" PRIx64 ") MME code %u TMSI %u cause %ld\n",
+                    PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                    ue_context_p->ue_context.random_ue_identity,
+                    ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
+                    ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
+                    ue_context_p->ue_context.establishment_cause);
+            else
+              LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE  MME code %u TMSI %u cause %ld\n",
+                    PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                    ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
+                    ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
+                    ue_context_p->ue_context.establishment_cause);
+
+#else
+            LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection for UE random UE identity (0x%" PRIx64 ")\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                  ue_context_p->ue_context.random_ue_identity);
 #endif
-          if (stmsi_received == 0)
-	    RC.rrc[ctxt_pP->module_id]->Nb_ue++;
 
-        } else {
-          // no context available
-	  if (rrc_agent_registered[ctxt_pP->module_id]) {
-	    agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
-										      ctxt_pP->rnti,
-										      PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
-	  }
-          LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n",
-                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-                random_value);
-	  rrc_mac_remove_ue(ctxt_pP->module_id,ctxt_pP->rnti);
-          return -1;
+            if (stmsi_received == 0)
+              RC.rrc[ctxt_pP->module_id]->Nb_ue++;
+          } else {
+            // no context available
+            if (rrc_agent_registered[ctxt_pP->module_id]) {
+              agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
+                  ctxt_pP->rnti,
+                  PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
+            }
+
+            LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                  random_value);
+            rrc_mac_remove_ue(ctxt_pP->module_id,ctxt_pP->rnti);
+            return -1;
+          }
         }
-      }
 
 #ifndef NO_RRM
-      send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id));
+        send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id));
 #else
-
-      ue_context_p->ue_context.primaryCC_id = CC_id;
-
-      //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH;
-      Idx = DCCH;
-      // SRB1
-      ue_context_p->ue_context.Srb1.Active = 1;
-      ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx;
-      memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-      memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-
-      // SRB2: set  it to go through SRB1 with id 1 (DCCH)
-      ue_context_p->ue_context.Srb2.Active = 1;
-      ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx;
-      memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-      memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1],
-             &DCCH_LCHAN_DESC,
-             LCHAN_DESC_SIZE);
-      
-      rrc_eNB_generate_RRCConnectionSetup(ctxt_pP, ue_context_p, CC_id);
-      LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            Idx);
-
-      MSC_LOG_TX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_PDCP_ENB,
-        NULL,
-        0,
-        MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti);
-
-      rrc_pdcp_config_asn1_req(ctxt_pP,
-                               ue_context_p->ue_context.SRB_configList,
-                               (DRB_ToAddModList_t *) NULL,
-                               (DRB_ToReleaseList_t*) NULL,
-                               0xff,
-                               NULL,
-                               NULL,
-                               NULL
+        ue_context_p->ue_context.primaryCC_id = CC_id;
+        //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH;
+        Idx = DCCH;
+        // SRB1
+        ue_context_p->ue_context.Srb1.Active = 1;
+        ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx;
+        memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0],
+               &DCCH_LCHAN_DESC,
+               LCHAN_DESC_SIZE);
+        memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1],
+               &DCCH_LCHAN_DESC,
+               LCHAN_DESC_SIZE);
+        // SRB2: set  it to go through SRB1 with id 1 (DCCH)
+        ue_context_p->ue_context.Srb2.Active = 1;
+        ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx;
+        memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0],
+               &DCCH_LCHAN_DESC,
+               LCHAN_DESC_SIZE);
+        memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1],
+               &DCCH_LCHAN_DESC,
+               LCHAN_DESC_SIZE);
+        rrc_eNB_generate_RRCConnectionSetup(ctxt_pP, ue_context_p, CC_id);
+        LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              Idx);
+        MSC_LOG_TX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_PDCP_ENB,
+          NULL,
+          0,
+          MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti);
+        rrc_pdcp_config_asn1_req(ctxt_pP,
+                                 ue_context_p->ue_context.SRB_configList,
+                                 (DRB_ToAddModList_t *) NULL,
+                                 (DRB_ToReleaseList_t *) NULL,
+                                 0xff,
+                                 NULL,
+                                 NULL,
+                                 NULL
 #   if defined(Rel10) || defined(Rel14)
-                               , (PMCH_InfoList_r9_t *) NULL
+                                 , (PMCH_InfoList_r9_t *) NULL
 #   endif
-                               ,NULL);
-
-      rrc_rlc_config_asn1_req(ctxt_pP,
-                              ue_context_p->ue_context.SRB_configList,
-                              (DRB_ToAddModList_t*) NULL,
-                              (DRB_ToReleaseList_t*) NULL
+                                 ,NULL);
+        rrc_rlc_config_asn1_req(ctxt_pP,
+                                ue_context_p->ue_context.SRB_configList,
+                                (DRB_ToAddModList_t *) NULL,
+                                (DRB_ToReleaseList_t *) NULL
 #   if defined(Rel10) || defined(Rel14)
-                              , (PMCH_InfoList_r9_t *) NULL
+                                , (PMCH_InfoList_r9_t *) NULL
 #   endif
-                             );
+                               );
 #endif //NO_RRM
+        break;
 
-      break;
-
-    default:
-      LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-      rval = -1;
-      break;
+      default:
+        LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+        rval = -1;
+        break;
     }
 
     rval = 0;
@@ -6387,28 +5904,25 @@ rrc_eNB_decode_ccch(
 //-----------------------------------------------------------------------------
 int
 rrc_eNB_decode_dcch(
-  const protocol_ctxt_t* const ctxt_pP,
+  const protocol_ctxt_t *const ctxt_pP,
   const rb_id_t                Srb_id,
-  const uint8_t*    const      Rx_sdu,
+  const uint8_t    *const      Rx_sdu,
   const sdu_size_t             sdu_sizeP
 )
 //-----------------------------------------------------------------------------
 {
-
   asn_dec_rval_t                      dec_rval;
   //UL_DCCH_Message_t uldcchmsg;
   UL_DCCH_Message_t                  *ul_dcch_msg = NULL; //&uldcchmsg;
   int i;
-  struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s        *ue_context_p = NULL;
 #if defined(ENABLE_ITTI)
 #   if defined(ENABLE_USE_MME)
-  MessageDef *                        msg_delete_tunnels_p = NULL;
+  MessageDef                         *msg_delete_tunnels_p = NULL;
   uint8_t                             xid;
 #endif
 #endif
-
-  int dedicated_DRB=0; 
-
+  int dedicated_DRB=0;
   T(T_ENB_RRC_UL_DCCH_DATA_IN, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 
@@ -6421,21 +5935,21 @@ rrc_eNB_decode_dcch(
           PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
           Srb_id);
   }
-  //memset(ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
 
+  //memset(ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
   LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL-DCCH Message\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
   dec_rval = uper_decode(
                NULL,
                &asn_DEF_UL_DCCH_Message,
-               (void**)&ul_dcch_msg,
+               (void **)&ul_dcch_msg,
                Rx_sdu,
                sdu_sizeP,
                0,
                0);
   /*
-#if defined(ENABLE_ITTI)
-#   if defined(DISABLE_ITTI_XER_PRINT)
+  #if defined(ENABLE_ITTI)
+  #   if defined(DISABLE_ITTI_XER_PRINT)
   {
     MessageDef                         *message_p;
 
@@ -6444,7 +5958,7 @@ rrc_eNB_decode_dcch(
 
     itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, message_p);
   }
-#   else
+  #   else
   {
     char                                message_string[10000];
     size_t                              message_string_size;
@@ -6460,8 +5974,8 @@ rrc_eNB_decode_dcch(
       itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
     }
   }
-#   endif
-#endif
+  #   endif
+  #endif
   */
   {
     for (i = 0; i < sdu_sizeP; i++) {
@@ -6483,546 +5997,529 @@ rrc_eNB_decode_dcch(
                    ctxt_pP->rnti);
 
   if (ul_dcch_msg->message.present == UL_DCCH_MessageType_PR_c1) {
-
     switch (ul_dcch_msg->message.choice.c1.present) {
-    case UL_DCCH_MessageType__c1_PR_NOTHING:   /* No components present */
-      break;
+      case UL_DCCH_MessageType__c1_PR_NOTHING:   /* No components present */
+        break;
 
-    case UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000:
-      break;
+      case UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000:
+        break;
 
-    case UL_DCCH_MessageType__c1_PR_measurementReport:
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND "
-            "%d bytes (measurementReport) ---> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH,
-            sdu_sizeP);
-      rrc_eNB_process_MeasurementReport(
-        ctxt_pP,
-        ue_context_p,
-        &ul_dcch_msg->message.choice.c1.choice.measurementReport.
-        criticalExtensions.choice.c1.choice.measurementReport_r8.measResults);
-      break;
+      case UL_DCCH_MessageType__c1_PR_measurementReport:
+        LOG_D(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND "
+              "%d bytes (measurementReport) ---> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH,
+              sdu_sizeP);
+        rrc_eNB_process_MeasurementReport(
+          ctxt_pP,
+          ue_context_p,
+          &ul_dcch_msg->message.choice.c1.choice.measurementReport.
+          criticalExtensions.choice.c1.choice.measurementReport_r8.measResults);
+        break;
 
-    case UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete:
+      case UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete:
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC Connection Reconfiguration Complete\n");
+        LOG_F(RRC,"[MSG] RRC Connection Reconfiguration Complete\n");
 
-      for (i = 0; i < sdu_sizeP; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
-      }
+        for (i = 0; i < sdu_sizeP; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Rx_sdu)[i]);
+        }
+
+        LOG_F(RRC,"\n");
+#endif
+        MSC_LOG_RX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_RRC_UE,
+          Rx_sdu,
+          sdu_sizeP,
+          MSC_AS_TIME_FMT" RRCConnectionReconfigurationComplete UE %x size %u",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti,
+          sdu_sizeP);
+        LOG_D(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
+              "(RRCConnectionReconfigurationComplete) ---> RRC_eNB]\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH,
+              sdu_sizeP);
+
+        if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.
+            present ==
+            RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8) {
+          /*NN: revise the condition */
+          if (ue_context_p->ue_context.Status == RRC_RECONFIGURED) {
+            dedicated_DRB = 1;
+            LOG_I(RRC,
+                  PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld)\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
+          } else {
+            dedicated_DRB = 0;
+            ue_context_p->ue_context.Status = RRC_RECONFIGURED;
+            LOG_I(RRC,
+                  PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (default DRB, xid %ld)\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
+          }
+
+          rrc_eNB_process_RRCConnectionReconfigurationComplete(
+            ctxt_pP,
+            ue_context_p,
+            ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
+
+          //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
+          if (rrc_agent_registered[ctxt_pP->module_id]) {
+            agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
+                ue_context_p->ue_id_rnti,
+                PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED);
+          }
+        }
 
-      LOG_F(RRC,"\n");
-#endif
-      MSC_LOG_RX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_RRC_UE,
-        Rx_sdu,
-        sdu_sizeP,
-        MSC_AS_TIME_FMT" RRCConnectionReconfigurationComplete UE %x size %u",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti,
-        sdu_sizeP);
-
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
-            "(RRCConnectionReconfigurationComplete) ---> RRC_eNB]\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH,
-            sdu_sizeP);
-
-      if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.
-          present ==
-          RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8) {
-	/*NN: revise the condition */
-        if (ue_context_p->ue_context.Status == RRC_RECONFIGURED){
-	  dedicated_DRB = 1;
-	  LOG_I(RRC,
-		PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld)\n",
-		PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
-	}else {
-	  dedicated_DRB = 0;
-	  ue_context_p->ue_context.Status = RRC_RECONFIGURED;
-	  LOG_I(RRC,
-		PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (default DRB, xid %ld)\n",
-		PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
-	}
-	rrc_eNB_process_RRCConnectionReconfigurationComplete(
-          ctxt_pP,
-          ue_context_p,
-	  ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
-
-	//WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
-	if (rrc_agent_registered[ctxt_pP->module_id]) {
-	  agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
-										ue_context_p->ue_id_rnti,
-										PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED);
-	}
-      }
 #if defined(ENABLE_ITTI)
 #   if defined(ENABLE_USE_MME)
-      if (EPC_MODE_ENABLED == 1) {
-	if (dedicated_DRB == 1){
-//	  rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP,
-//					     ue_context_p,
-//					     ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
-if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
-            rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(ctxt_pP,
-                             ue_context_p,
-                             ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
-
-            ue_context_p->ue_context.nb_of_modify_e_rabs = 0;
-            ue_context_p->ue_context.nb_of_failed_e_rabs = 0;
-            memset(ue_context_p->ue_context.modify_e_rab, 0, sizeof(ue_context_p->ue_context.modify_e_rab));
-            for(int i = 0; i < NB_RB_MAX; i++) {
-              ue_context_p->ue_context.modify_e_rab[i].xid = -1;
-            }
 
-          } else if(ue_context_p->ue_context.e_rab_release_command_flag == 1){
-            xid = ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier;
-            ue_context_p->ue_context.e_rab_release_command_flag = 0;
-            //gtp tunnel delete
-            msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ);
-            memset(&GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
-            GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
-            for(i = 0; i < NB_RB_MAX; i++){
-               if(xid == ue_context_p->ue_context.e_rab[i].xid){
-                 GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i];
-                 ue_context_p->ue_context.enb_gtp_teid[i] = 0;
-                 memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i]));
-                 ue_context_p->ue_context.enb_gtp_ebi[i]  = 0;
-               }
-            }
-            itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p);
-            //S1AP_E_RAB_RELEASE_RESPONSE
-            rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(ctxt_pP,
-                    ue_context_p,
-                    xid);
-          } else {
+        if (EPC_MODE_ENABLED == 1) {
+          if (dedicated_DRB == 1) {
+            //    rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP,
+            //               ue_context_p,
+            //               ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
+            if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
+              rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(ctxt_pP,
+                                                  ue_context_p,
+                                                  ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
+              ue_context_p->ue_context.nb_of_modify_e_rabs = 0;
+              ue_context_p->ue_context.nb_of_failed_e_rabs = 0;
+              memset(ue_context_p->ue_context.modify_e_rab, 0, sizeof(ue_context_p->ue_context.modify_e_rab));
+
+              for(int i = 0; i < NB_RB_MAX; i++) {
+                ue_context_p->ue_context.modify_e_rab[i].xid = -1;
+              }
+            } else if(ue_context_p->ue_context.e_rab_release_command_flag == 1) {
+              xid = ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier;
+              ue_context_p->ue_context.e_rab_release_command_flag = 0;
+              //gtp tunnel delete
+              msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ);
+              memset(&GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
+              GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
+
+              for(i = 0; i < NB_RB_MAX; i++) {
+                if(xid == ue_context_p->ue_context.e_rab[i].xid) {
+                  GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i];
+                  ue_context_p->ue_context.enb_gtp_teid[i] = 0;
+                  memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i]));
+                  ue_context_p->ue_context.enb_gtp_ebi[i]  = 0;
+                }
+              }
+
+              itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p);
+              //S1AP_E_RAB_RELEASE_RESPONSE
+              rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(ctxt_pP,
+                  ue_context_p,
+                  xid);
+            } else {
               rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP,
-                             ue_context_p,
-                             ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
-          }
-	}else {
-          if(ue_context_p->ue_context.reestablishment_cause == ReestablishmentCause_spare1){
-	    rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP,
-						       ue_context_p);
+                                                 ue_context_p,
+                                                 ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
+            }
           } else {
-            ue_context_p->ue_context.reestablishment_cause = ReestablishmentCause_spare1;
-            for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) {
-              if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) {
-                ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED;
-              } else {
-                ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED;
+            if(ue_context_p->ue_context.reestablishment_cause == ReestablishmentCause_spare1) {
+              rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP,
+                  ue_context_p);
+            } else {
+              ue_context_p->ue_context.reestablishment_cause = ReestablishmentCause_spare1;
+
+              for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) {
+                if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) {
+                  ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED;
+                } else {
+                  ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED;
+                }
               }
             }
           }
-	}
-      }    
+        }
+
 #else  // establish a dedicated bearer 
-      if (dedicated_DRB == 0 ) {
-	//	ue_context_p->ue_context.e_rab[0].status = E_RAB_STATUS_ESTABLISHED;
-	rrc_eNB_reconfigure_DRBs(ctxt_pP,ue_context_p);
-      }
-      
-#endif
-#endif 
-      break;
 
-    case UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete:
-      T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        if (dedicated_DRB == 0 ) {
+          //  ue_context_p->ue_context.e_rab[0].status = E_RAB_STATUS_ESTABLISHED;
+          rrc_eNB_reconfigure_DRBs(ctxt_pP,ue_context_p);
+        }
+
+#endif
+#endif
+        break;
 
+      case UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete:
+        T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC Connection Reestablishment Complete\n");
+        LOG_F(RRC,"[MSG] RRC Connection Reestablishment Complete\n");
 
-      for (i = 0; i < sdu_sizeP; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
-      }
+        for (i = 0; i < sdu_sizeP; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Rx_sdu)[i]);
+        }
 
-      LOG_F(RRC,"\n");
-#endif
-
-      MSC_LOG_RX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_RRC_UE,
-        Rx_sdu,
-        sdu_sizeP,
-        MSC_AS_TIME_FMT" rrcConnectionReestablishmentComplete UE %x size %u",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti,
-        sdu_sizeP);
-
-      LOG_I(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
-            "(rrcConnectionReestablishmentComplete) ---> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH,
-            sdu_sizeP);
-       {
-        int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti);
-        RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0;
-        rnti_t reestablish_rnti = 0;
-        // select C-RNTI from map
-        for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
-          if (reestablish_rnti_map[i][0] == ctxt_pP->rnti) {
-            reestablish_rnti = reestablish_rnti_map[i][1];
-            ue_context_p = rrc_eNB_get_ue_context(
-                              RC.rrc[ctxt_pP->module_id],
-                              reestablish_rnti);
-            // clear currentC-RNTI from map
-            reestablish_rnti_map[i][0] = 0;
-            reestablish_rnti_map[i][1] = 0;
-            break;
+        LOG_F(RRC,"\n");
+#endif
+        MSC_LOG_RX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_RRC_UE,
+          Rx_sdu,
+          sdu_sizeP,
+          MSC_AS_TIME_FMT" rrcConnectionReestablishmentComplete UE %x size %u",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti,
+          sdu_sizeP);
+        LOG_I(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
+              "(rrcConnectionReestablishmentComplete) ---> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH,
+              sdu_sizeP);
+        {
+          int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti);
+          RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0;
+          rnti_t reestablish_rnti = 0;
+
+          // select C-RNTI from map
+          for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+            if (reestablish_rnti_map[i][0] == ctxt_pP->rnti) {
+              reestablish_rnti = reestablish_rnti_map[i][1];
+              ue_context_p = rrc_eNB_get_ue_context(
+                               RC.rrc[ctxt_pP->module_id],
+                               reestablish_rnti);
+              // clear currentC-RNTI from map
+              reestablish_rnti_map[i][0] = 0;
+              reestablish_rnti_map[i][1] = 0;
+              break;
+            }
           }
-        }
-        LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n",
-              i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]);
 
-        if (!ue_context_p) {
-          LOG_E(RRC,
-                PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentComplete without UE context, falt\n",
-                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-          break;
-        }
+          LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n",
+                i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]);
 
-        if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.present ==
-            RRCConnectionReestablishmentComplete__criticalExtensions_PR_rrcConnectionReestablishmentComplete_r8) {
-          rrc_eNB_process_RRCConnectionReestablishmentComplete(ctxt_pP, reestablish_rnti, ue_context_p,
-              ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier,
-              &ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8);
+          if (!ue_context_p) {
+            LOG_E(RRC,
+                  PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentComplete without UE context, falt\n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+            break;
+          }
 
-          //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
-          if (mac_agent_registered[ctxt_pP->module_id]) {
-            agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
-                                                                                      ue_context_p->ue_id_rnti,
-                                                                                      PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
+          if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.present ==
+              RRCConnectionReestablishmentComplete__criticalExtensions_PR_rrcConnectionReestablishmentComplete_r8) {
+            rrc_eNB_process_RRCConnectionReestablishmentComplete(ctxt_pP, reestablish_rnti, ue_context_p,
+                ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier,
+                &ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8);
+
+            //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
+            if (mac_agent_registered[ctxt_pP->module_id]) {
+              agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
+                  ue_context_p->ue_id_rnti,
+                  PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
+            }
           }
+
+          //ue_context_p->ue_context.ue_release_timer = 0;
+          ue_context_p->ue_context.ue_reestablishment_timer = 1;
+          // remove UE after 100 frames after RRCConnectionReestablishmentRelease is triggered
+          ue_context_p->ue_context.ue_reestablishment_timer_thres = 1000;
         }
-        //ue_context_p->ue_context.ue_release_timer = 0;
-        ue_context_p->ue_context.ue_reestablishment_timer = 1;
-        // remove UE after 100 frames after RRCConnectionReestablishmentRelease is triggered
-        ue_context_p->ue_context.ue_reestablishment_timer_thres = 1000;
-      }
-      break;
+        break;
 
-    case UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete:
+      case UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete:
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC Connection SetupComplete\n");
+        LOG_F(RRC,"[MSG] RRC Connection SetupComplete\n");
 
-      for (i = 0; i < sdu_sizeP; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
-      }
-
-      LOG_F(RRC,"\n");
-#endif
-
-      MSC_LOG_RX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_RRC_UE,
-        Rx_sdu,
-        sdu_sizeP,
-        MSC_AS_TIME_FMT" RRCConnectionSetupComplete UE %x size %u",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti,
-        sdu_sizeP);
-
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
-            "(RRCConnectionSetupComplete) ---> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH,
-            sdu_sizeP);
-
-      if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.present ==
-          RRCConnectionSetupComplete__criticalExtensions_PR_c1) {
-        if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.
-            present ==
-            RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8) {
-          rrc_eNB_process_RRCConnectionSetupComplete(
-            ctxt_pP,
-            ue_context_p,
-            &ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8);
-          ue_context_p->ue_context.Status = RRC_CONNECTED;
-          LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n",
-                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-	  
-	  //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
-	  if (rrc_agent_registered[ctxt_pP->module_id]) {
-	    agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
-										  ue_context_p->ue_id_rnti,
-										  PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
-	  }
+        for (i = 0; i < sdu_sizeP; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Rx_sdu)[i]);
         }
-      }
 
-      ue_context_p->ue_context.ue_release_timer=0;
-      break;
+        LOG_F(RRC,"\n");
+#endif
+        MSC_LOG_RX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_RRC_UE,
+          Rx_sdu,
+          sdu_sizeP,
+          MSC_AS_TIME_FMT" RRCConnectionSetupComplete UE %x size %u",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti,
+          sdu_sizeP);
+        LOG_D(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
+              "(RRCConnectionSetupComplete) ---> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH,
+              sdu_sizeP);
+
+        if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.present ==
+            RRCConnectionSetupComplete__criticalExtensions_PR_c1) {
+          if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.
+              present ==
+              RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8) {
+            rrc_eNB_process_RRCConnectionSetupComplete(
+              ctxt_pP,
+              ue_context_p,
+              &ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8);
+            ue_context_p->ue_context.Status = RRC_CONNECTED;
+            LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n",
+                  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
 
-    case UL_DCCH_MessageType__c1_PR_securityModeComplete:
-      T(T_ENB_RRC_SECURITY_MODE_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+            //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
+            if (rrc_agent_registered[ctxt_pP->module_id]) {
+              agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
+                  ue_context_p->ue_id_rnti,
+                  PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
+            }
+          }
+        }
 
-#ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC Security Mode Complete\n");
+        ue_context_p->ue_context.ue_release_timer=0;
+        break;
 
-      for (i = 0; i < sdu_sizeP; i++) eNB->pusch_vars[UE_id]{
-        LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
-      }
+      case UL_DCCH_MessageType__c1_PR_securityModeComplete:
+        T(T_ENB_RRC_SECURITY_MODE_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+#ifdef RRC_MSG_PRINT
+        LOG_F(RRC,"[MSG] RRC Security Mode Complete\n");
 
-      LOG_F(RRC,"\n");
-#endif
-
-      MSC_LOG_RX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_RRC_UE,
-        Rx_sdu,
-        sdu_sizeP,
-        MSC_AS_TIME_FMT" securityModeComplete UE %x size %u",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti,
-        sdu_sizeP);
-
-      LOG_I(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" received securityModeComplete on UL-DCCH %d from UE\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH);
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
-            "(securityModeComplete) ---> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH,
-            sdu_sizeP);
+        for (i = 0; i < sdu_sizeP; i++) eNB->pusch_vars[UE_id] {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Rx_sdu)[i]);
+        }
+        LOG_F(RRC,"\n");
+#endif
+        MSC_LOG_RX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_RRC_UE,
+          Rx_sdu,
+          sdu_sizeP,
+          MSC_AS_TIME_FMT" securityModeComplete UE %x size %u",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti,
+          sdu_sizeP);
+        LOG_I(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" received securityModeComplete on UL-DCCH %d from UE\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH);
+        LOG_D(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
+              "(securityModeComplete) ---> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH,
+              sdu_sizeP);
 #ifdef XER_PRINT
-      xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg);
-#endif
-      // confirm with PDCP about the security mode for DCCH
-      //rrc_pdcp_config_req (enb_mod_idP, frameP, 1,CONFIG_ACTION_SET_SECURITY_MODE, (ue_mod_idP * NB_RB_MAX) + DCCH, 0x77);
-      // continue the procedure
-      rrc_eNB_generate_UECapabilityEnquiry(
-        ctxt_pP,
-        ue_context_p);
-      break;
-
-    case UL_DCCH_MessageType__c1_PR_securityModeFailure:
-      T(T_ENB_RRC_SECURITY_MODE_FAILURE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg);
+#endif
+        // confirm with PDCP about the security mode for DCCH
+        //rrc_pdcp_config_req (enb_mod_idP, frameP, 1,CONFIG_ACTION_SET_SECURITY_MODE, (ue_mod_idP * NB_RB_MAX) + DCCH, 0x77);
+        // continue the procedure
+        rrc_eNB_generate_UECapabilityEnquiry(
+          ctxt_pP,
+          ue_context_p);
+        break;
 
+      case UL_DCCH_MessageType__c1_PR_securityModeFailure:
+        T(T_ENB_RRC_SECURITY_MODE_FAILURE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC Security Mode Failure\n");
+        LOG_F(RRC,"[MSG] RRC Security Mode Failure\n");
 
-      for (i = 0; i < sdu_sizeP; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
-      }
+        for (i = 0; i < sdu_sizeP; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Rx_sdu)[i]);
+        }
 
-      LOG_F(RRC,"\n");
-#endif
-
-      MSC_LOG_RX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_RRC_UE,
-        Rx_sdu,
-        sdu_sizeP,
-        MSC_AS_TIME_FMT" securityModeFailure UE %x size %u",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti,
-        sdu_sizeP);
-
-      LOG_W(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
-            "(securityModeFailure) ---> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH,
-            sdu_sizeP);
+        LOG_F(RRC,"\n");
+#endif
+        MSC_LOG_RX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_RRC_UE,
+          Rx_sdu,
+          sdu_sizeP,
+          MSC_AS_TIME_FMT" securityModeFailure UE %x size %u",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti,
+          sdu_sizeP);
+        LOG_W(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
+              "(securityModeFailure) ---> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH,
+              sdu_sizeP);
 #ifdef XER_PRINT
-      xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg);
+        xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg);
 #endif
-      // cancel the security mode in PDCP
-
-      // followup with the remaining procedure
-//#warning "LG Removed rrc_eNB_generate_UECapabilityEnquiry after receiving securityModeFailure"
-      rrc_eNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p);
-      break;
-
-    case UL_DCCH_MessageType__c1_PR_ueCapabilityInformation:
-      T(T_ENB_RRC_UE_CAPABILITY_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        // cancel the security mode in PDCP
+        // followup with the remaining procedure
+        //#warning "LG Removed rrc_eNB_generate_UECapabilityEnquiry after receiving securityModeFailure"
+        rrc_eNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p);
+        break;
 
+      case UL_DCCH_MessageType__c1_PR_ueCapabilityInformation:
+        T(T_ENB_RRC_UE_CAPABILITY_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC UECapablility Information \n");
+        LOG_F(RRC,"[MSG] RRC UECapablility Information \n");
 
-      for (i = 0; i < sdu_sizeP; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
-      }
+        for (i = 0; i < sdu_sizeP; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Rx_sdu)[i]);
+        }
 
-      LOG_F(RRC,"\n");
-#endif
-
-      MSC_LOG_RX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_RRC_UE,
-        Rx_sdu,
-        sdu_sizeP,
-        MSC_AS_TIME_FMT" ueCapabilityInformation UE %x size %u",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti,
-        sdu_sizeP);
-
-      LOG_I(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" received ueCapabilityInformation on UL-DCCH %d from UE\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH);
-      LOG_D(RRC,
-            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
-            "(UECapabilityInformation) ---> RRC_eNB\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            DCCH,
-            sdu_sizeP);
+        LOG_F(RRC,"\n");
+#endif
+        MSC_LOG_RX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_RRC_UE,
+          Rx_sdu,
+          sdu_sizeP,
+          MSC_AS_TIME_FMT" ueCapabilityInformation UE %x size %u",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti,
+          sdu_sizeP);
+        LOG_I(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" received ueCapabilityInformation on UL-DCCH %d from UE\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH);
+        LOG_D(RRC,
+              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
+              "(UECapabilityInformation) ---> RRC_eNB\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              DCCH,
+              sdu_sizeP);
 #ifdef XER_PRINT
-      xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg);
-#endif
-      LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti);
-      if (ue_context_p->ue_context.UE_Capability) {
-        LOG_I(RRC, "freeing old UE capabilities for UE %x\n", ctxt_pP->rnti);
-        asn_DEF_UE_EUTRA_Capability.free_struct(&asn_DEF_UE_EUTRA_Capability,
-              ue_context_p->ue_context.UE_Capability, 0);
-        ue_context_p->ue_context.UE_Capability = 0;
-      }
-      dec_rval = uper_decode(NULL,
-                             &asn_DEF_UE_EUTRA_Capability,
-                             (void **)&ue_context_p->ue_context.UE_Capability,
-                             ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.
-                             choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.
-                             array[0]->ueCapabilityRAT_Container.buf,
-                             ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.
-                             choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.
-                             array[0]->ueCapabilityRAT_Container.size, 0, 0);
+        xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg);
+#endif
+        LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti);
+
+        if (ue_context_p->ue_context.UE_Capability) {
+          LOG_I(RRC, "freeing old UE capabilities for UE %x\n", ctxt_pP->rnti);
+          ASN_STRUCT_FREE(asn_DEF_UE_EUTRA_Capability,
+                          ue_context_p->ue_context.UE_Capability);
+          ue_context_p->ue_context.UE_Capability = 0;
+        }
+
+        dec_rval = uper_decode(NULL,
+                               &asn_DEF_UE_EUTRA_Capability,
+                               (void **)&ue_context_p->ue_context.UE_Capability,
+                               ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.
+                               choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.
+                               array[0]->ueCapabilityRAT_Container.buf,
+                               ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.
+                               choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.
+                               array[0]->ueCapabilityRAT_Container.size, 0, 0);
 #ifdef XER_PRINT
-      xer_fprint(stdout, &asn_DEF_UE_EUTRA_Capability, ue_context_p->ue_context.UE_Capability);
+        xer_fprint(stdout, &asn_DEF_UE_EUTRA_Capability, ue_context_p->ue_context.UE_Capability);
 #endif
 
-      if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
-        LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Failed to decode UE capabilities (%zu bytes)\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-              dec_rval.consumed);
-        asn_DEF_UE_EUTRA_Capability.free_struct(&asn_DEF_UE_EUTRA_Capability,
-              ue_context_p->ue_context.UE_Capability, 0);
-        ue_context_p->ue_context.UE_Capability = 0;
-      }
+        if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+          LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Failed to decode UE capabilities (%zu bytes)\n",
+                PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+                dec_rval.consumed);
+          ASN_STRUCT_FREE(asn_DEF_UE_EUTRA_Capability,
+                          ue_context_p->ue_context.UE_Capability);
+          ue_context_p->ue_context.UE_Capability = 0;
+        }
 
 #if defined(ENABLE_USE_MME)
 
-      if (EPC_MODE_ENABLED == 1) {
-        rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(ctxt_pP,
-                                              ue_context_p,
-                                              ul_dcch_msg);
-      }
-#else 
-      ue_context_p->ue_context.nb_of_e_rabs = 1;
-      for (i = 0; i < ue_context_p->ue_context.nb_of_e_rabs; i++){
-	ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW;
-	ue_context_p->ue_context.e_rab[i].param.e_rab_id = 1+i;
-	ue_context_p->ue_context.e_rab[i].param.qos.qci=9;
-      }
-      ue_context_p->ue_context.setup_e_rabs =ue_context_p->ue_context.nb_of_e_rabs;
-#endif
+        if (EPC_MODE_ENABLED == 1) {
+          rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(ctxt_pP,
+                                                ue_context_p,
+                                                ul_dcch_msg);
+        }
 
-      rrc_eNB_generate_defaultRRCConnectionReconfiguration(ctxt_pP,
-          ue_context_p,
-          RC.rrc[ctxt_pP->module_id]->HO_flag);
-      break;
+#else
+        ue_context_p->ue_context.nb_of_e_rabs = 1;
 
-    case UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer:
-      T(T_ENB_RRC_UL_HANDOVER_PREPARATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        for (i = 0; i < ue_context_p->ue_context.nb_of_e_rabs; i++) {
+          ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW;
+          ue_context_p->ue_context.e_rab[i].param.e_rab_id = 1+i;
+          ue_context_p->ue_context.e_rab[i].param.qos.qci=9;
+        }
 
-      break;
+        ue_context_p->ue_context.setup_e_rabs =ue_context_p->ue_context.nb_of_e_rabs;
+#endif
+        rrc_eNB_generate_defaultRRCConnectionReconfiguration(ctxt_pP,
+            ue_context_p,
+            RC.rrc[ctxt_pP->module_id]->HO_flag);
+        break;
 
-    case UL_DCCH_MessageType__c1_PR_ulInformationTransfer:
-      T(T_ENB_RRC_UL_INFORMATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+      case UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer:
+        T(T_ENB_RRC_UL_HANDOVER_PREPARATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        break;
 
-      LOG_D(RRC,"[MSG] RRC UL Information Transfer \n");
+      case UL_DCCH_MessageType__c1_PR_ulInformationTransfer:
+        T(T_ENB_RRC_UL_INFORMATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        LOG_D(RRC,"[MSG] RRC UL Information Transfer \n");
 #ifdef RRC_MSG_PRINT
-      LOG_F(RRC,"[MSG] RRC UL Information Transfer \n");
+        LOG_F(RRC,"[MSG] RRC UL Information Transfer \n");
 
-      for (i = 0; i < sdu_sizeP; i++) {
-        LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
-      }
+        for (i = 0; i < sdu_sizeP; i++) {
+          LOG_F(RRC,"%02x ", ((uint8_t *)Rx_sdu)[i]);
+        }
 
-      LOG_F(RRC,"\n");
+        LOG_F(RRC,"\n");
 #endif
-
-
-      MSC_LOG_RX_MESSAGE(
-        MSC_RRC_ENB,
-        MSC_RRC_UE,
-        Rx_sdu,
-        sdu_sizeP,
-        MSC_AS_TIME_FMT" ulInformationTransfer UE %x size %u",
-        MSC_AS_TIME_ARGS(ctxt_pP),
-        ue_context_p->ue_context.rnti,
-        sdu_sizeP);
-
+        MSC_LOG_RX_MESSAGE(
+          MSC_RRC_ENB,
+          MSC_RRC_UE,
+          Rx_sdu,
+          sdu_sizeP,
+          MSC_AS_TIME_FMT" ulInformationTransfer UE %x size %u",
+          MSC_AS_TIME_ARGS(ctxt_pP),
+          ue_context_p->ue_context.rnti,
+          sdu_sizeP);
 #if defined(ENABLE_USE_MME)
 
-      if (EPC_MODE_ENABLED == 1) {
-        rrc_eNB_send_S1AP_UPLINK_NAS(ctxt_pP,
-                                     ue_context_p,
-                                     ul_dcch_msg);
-      }
+        if (EPC_MODE_ENABLED == 1) {
+          rrc_eNB_send_S1AP_UPLINK_NAS(ctxt_pP,
+                                       ue_context_p,
+                                       ul_dcch_msg);
+        }
 
 #endif
-      break;
-
-    case UL_DCCH_MessageType__c1_PR_counterCheckResponse:
-      T(T_ENB_RRC_COUNTER_CHECK_RESPONSE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-      break;
+        break;
 
+      case UL_DCCH_MessageType__c1_PR_counterCheckResponse:
+        T(T_ENB_RRC_COUNTER_CHECK_RESPONSE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        break;
 #if defined(Rel10) || defined(Rel14)
 
-    case UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9:
-      T(T_ENB_RRC_UE_INFORMATION_RESPONSE_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-      break;
-
-    case UL_DCCH_MessageType__c1_PR_proximityIndication_r9:
-      T(T_ENB_RRC_PROXIMITY_INDICATION_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-      break;
-
-    case UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10:
-      T(T_ENB_RRC_RECONFIGURATION_COMPLETE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-      break;
+      case UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9:
+        T(T_ENB_RRC_UE_INFORMATION_RESPONSE_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        break;
 
-    case UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10:
-      T(T_ENB_RRC_MBMS_COUNTING_RESPONSE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+      case UL_DCCH_MessageType__c1_PR_proximityIndication_r9:
+        T(T_ENB_RRC_PROXIMITY_INDICATION_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        break;
 
-      break;
+      case UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10:
+        T(T_ENB_RRC_RECONFIGURATION_COMPLETE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        break;
 
-    case UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10:
-      T(T_ENB_RRC_INTER_FREQ_RSTD_MEASUREMENT_INDICATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+      case UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10:
+        T(T_ENB_RRC_MBMS_COUNTING_RESPONSE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        break;
 
-      break;
+      case UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10:
+        T(T_ENB_RRC_INTER_FREQ_RSTD_MEASUREMENT_INDICATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        break;
 #endif
 
-    default:
-      T(T_ENB_RRC_UNKNOW_MESSAGE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
-        T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
-
-      LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message %s:%u\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-            __FILE__, __LINE__);
-      return -1;
+      default:
+        T(T_ENB_RRC_UNKNOW_MESSAGE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+          T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+        LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message %s:%u\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+              __FILE__, __LINE__);
+        return -1;
     }
 
     return 0;
@@ -7032,20 +6529,18 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
           __FILE__, __LINE__);
     return -1;
   }
-
 }
 
 #if defined(ENABLE_ITTI)
-void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP,
-			       rrc_eNB_ue_context_t*  ue_context_pP){
-
+void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t *const ctxt_pP,
+                               rrc_eNB_ue_context_t  *ue_context_pP) {
   int i;
   int e_rab_done=0;
-  for (i = 0; 
+
+  for (i = 0;
        i < 3;//NB_RB_MAX - 3;  // S1AP_MAX_E_RAB
        i++) {
-    
-    if ( ue_context_pP->ue_context.e_rab[i].status < E_RAB_STATUS_DONE){ 
+    if ( ue_context_pP->ue_context.e_rab[i].status < E_RAB_STATUS_DONE) {
       ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_NEW;
       ue_context_pP->ue_context.e_rab[i].param.e_rab_id = i + 1;
       ue_context_pP->ue_context.e_rab[i].param.qos.qci = i % 9;
@@ -7054,26 +6549,25 @@ void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP,
       ue_context_pP->ue_context.e_rab[i].param.qos.allocation_retention_priority.pre_emp_vulnerability= PRE_EMPTION_VULNERABILITY_DISABLED;
       ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL;
       ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length = 0;
-      //	memset (ue_context_pP->ue_context.e_rab[i].param.sgw_addr.buffer,0,20);
+      //  memset (ue_context_pP->ue_context.e_rab[i].param.sgw_addr.buffer,0,20);
       ue_context_pP->ue_context.e_rab[i].param.sgw_addr.length = 0;
       ue_context_pP->ue_context.e_rab[i].param.gtp_teid=0;
-      
       ue_context_pP->ue_context.nb_of_e_rabs++;
       e_rab_done++;
-      LOG_I(RRC,"setting up the dedicated DRBs %d (index %d) status %d \n", 
-	    ue_context_pP->ue_context.e_rab[i].param.e_rab_id, i, ue_context_pP->ue_context.e_rab[i].status);
+      LOG_I(RRC,"setting up the dedicated DRBs %d (index %d) status %d \n",
+            ue_context_pP->ue_context.e_rab[i].param.e_rab_id, i, ue_context_pP->ue_context.e_rab[i].status);
     }
   }
+
   ue_context_pP->ue_context.setup_e_rabs+=e_rab_done;
- 
   rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(ctxt_pP, ue_context_pP, 0);
 }
 
 
 //-----------------------------------------------------------------------------
-void*
+void *
 rrc_enb_task(
-  void* args_p
+  void *args_p
 )
 //-----------------------------------------------------------------------------
 {
@@ -7083,141 +6577,136 @@ rrc_enb_task(
   int                                 result;
   SRB_INFO                           *srb_info_p;
   int                                 CC_id;
-
   protocol_ctxt_t                     ctxt;
   itti_mark_task_ready(TASK_RRC_ENB);
   LOG_I(RRC,"Entering main loop of RRC message task\n");
+
   while (1) {
     // Wait for a message
     itti_receive_msg(TASK_RRC_ENB, &msg_p);
-
     msg_name_p = ITTI_MSG_NAME(msg_p);
     instance = ITTI_MSG_INSTANCE(msg_p);
     LOG_I(RRC,"Received message %s\n",msg_name_p);
 
     switch (ITTI_MSG_ID(msg_p)) {
-    case TERMINATE_MESSAGE:
-      LOG_W(RRC, " *** Exiting RRC thread\n");
-      itti_exit_task();
-      break;
+      case TERMINATE_MESSAGE:
+        LOG_W(RRC, " *** Exiting RRC thread\n");
+        itti_exit_task();
+        break;
 
-    case MESSAGE_TEST:
-      LOG_I(RRC, "[eNB %d] Received %s\n", instance, msg_name_p);
-      break;
+      case MESSAGE_TEST:
+        LOG_I(RRC, "[eNB %d] Received %s\n", instance, msg_name_p);
+        break;
 
       /* Messages from MAC */
-    case RRC_MAC_CCCH_DATA_IND:
-      PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
-                                    instance,
-                                    ENB_FLAG_YES,
-                                    RRC_MAC_CCCH_DATA_IND(msg_p).rnti,
-                                    msg_p->ittiMsgHeader.lte_time.frame,
-                                    msg_p->ittiMsgHeader.lte_time.slot);
-      LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received %s\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt),
-            msg_name_p);
-
-      CC_id = RRC_MAC_CCCH_DATA_IND(msg_p).CC_id;
-      srb_info_p = &RC.rrc[instance]->carrier[CC_id].Srb0;
-
-      LOG_I(RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n",
-	    instance,CC_id,&ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size);
-      AssertFatal(RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size < RRC_BUFFER_SIZE_MAX,
-		  "CCCH message has size %d > %d\n",
-		  RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX);
-      memcpy(srb_info_p->Rx_buffer.Payload,
-             RRC_MAC_CCCH_DATA_IND(msg_p).sdu,
-             RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size);
-      srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size;
-
-      rrc_eNB_decode_ccch(&ctxt, srb_info_p, CC_id);
-      break;
-	    
-      /* Messages from PDCP */
-    case RRC_DCCH_DATA_IND:
-      PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
-                                    instance,
-                                    ENB_FLAG_YES,
-                                    RRC_DCCH_DATA_IND(msg_p).rnti,
-                                    msg_p->ittiMsgHeader.lte_time.frame,
-                                    msg_p->ittiMsgHeader.lte_time.slot);
-      LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received on DCCH %d %s\n",
-            PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt),
-            RRC_DCCH_DATA_IND(msg_p).dcch_index,
-            msg_name_p);
-      rrc_eNB_decode_dcch(&ctxt,
-                          RRC_DCCH_DATA_IND(msg_p).dcch_index,
-                          RRC_DCCH_DATA_IND(msg_p).sdu_p,
-                          RRC_DCCH_DATA_IND(msg_p).sdu_size);
-
-      // Message buffer has been processed, free it now.
-      result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND(msg_p).sdu_p);
-      AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
-      break;
+      case RRC_MAC_CCCH_DATA_IND:
+        PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
+                                      instance,
+                                      ENB_FLAG_YES,
+                                      RRC_MAC_CCCH_DATA_IND(msg_p).rnti,
+                                      msg_p->ittiMsgHeader.lte_time.frame,
+                                      msg_p->ittiMsgHeader.lte_time.slot);
+        LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received %s\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt),
+              msg_name_p);
+        CC_id = RRC_MAC_CCCH_DATA_IND(msg_p).CC_id;
+        srb_info_p = &RC.rrc[instance]->carrier[CC_id].Srb0;
+        LOG_I(RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n",
+              instance,CC_id,&ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size);
+        AssertFatal(RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size < RRC_BUFFER_SIZE_MAX,
+                    "CCCH message has size %d > %d\n",
+                    RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX);
+        memcpy(srb_info_p->Rx_buffer.Payload,
+               RRC_MAC_CCCH_DATA_IND(msg_p).sdu,
+               RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size);
+        srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size;
+        rrc_eNB_decode_ccch(&ctxt, srb_info_p, CC_id);
+        break;
 
+      /* Messages from PDCP */
+      case RRC_DCCH_DATA_IND:
+        PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
+                                      instance,
+                                      ENB_FLAG_YES,
+                                      RRC_DCCH_DATA_IND(msg_p).rnti,
+                                      msg_p->ittiMsgHeader.lte_time.frame,
+                                      msg_p->ittiMsgHeader.lte_time.slot);
+        LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received on DCCH %d %s\n",
+              PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt),
+              RRC_DCCH_DATA_IND(msg_p).dcch_index,
+              msg_name_p);
+        rrc_eNB_decode_dcch(&ctxt,
+                            RRC_DCCH_DATA_IND(msg_p).dcch_index,
+                            RRC_DCCH_DATA_IND(msg_p).sdu_p,
+                            RRC_DCCH_DATA_IND(msg_p).sdu_size);
+        // Message buffer has been processed, free it now.
+        result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND(msg_p).sdu_p);
+        AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+        break;
 #   if defined(ENABLE_USE_MME)
 
       /* Messages from S1AP */
-    case S1AP_DOWNLINK_NAS:
-      rrc_eNB_process_S1AP_DOWNLINK_NAS(msg_p, msg_name_p, instance, &rrc_eNB_mui);
-      break;
+      case S1AP_DOWNLINK_NAS:
+        rrc_eNB_process_S1AP_DOWNLINK_NAS(msg_p, msg_name_p, instance, &rrc_eNB_mui);
+        break;
 
-    case S1AP_INITIAL_CONTEXT_SETUP_REQ:
-      rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p, msg_name_p, instance);
-      break;
+      case S1AP_INITIAL_CONTEXT_SETUP_REQ:
+        rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p, msg_name_p, instance);
+        break;
 
-    case S1AP_UE_CTXT_MODIFICATION_REQ:
-      rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(msg_p, msg_name_p, instance);
-      break;
+      case S1AP_UE_CTXT_MODIFICATION_REQ:
+        rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(msg_p, msg_name_p, instance);
+        break;
 
-    case S1AP_PAGING_IND:
-      LOG_D(RRC, "[eNB %d] Received Paging message from S1AP: %s\n", instance, msg_name_p);
-      rrc_eNB_process_PAGING_IND(msg_p, msg_name_p, instance);
-      break;
-  
-    case S1AP_E_RAB_SETUP_REQ: 
-      rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(msg_p, msg_name_p, instance);
-      LOG_D(RRC, "[eNB %d] Received the message %s\n", instance, msg_name_p);
-      break;
+      case S1AP_PAGING_IND:
+        LOG_D(RRC, "[eNB %d] Received Paging message from S1AP: %s\n", instance, msg_name_p);
+        rrc_eNB_process_PAGING_IND(msg_p, msg_name_p, instance);
+        break;
 
-    case S1AP_E_RAB_MODIFY_REQ:
-      rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(msg_p, msg_name_p, instance);
-      break;
+      case S1AP_E_RAB_SETUP_REQ:
+        rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(msg_p, msg_name_p, instance);
+        LOG_D(RRC, "[eNB %d] Received the message %s\n", instance, msg_name_p);
+        break;
 
-    case S1AP_E_RAB_RELEASE_COMMAND:
-      rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(msg_p, msg_name_p, instance);
-      break;
-    
-    case S1AP_UE_CONTEXT_RELEASE_REQ:
-      rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name_p, instance);
-      break;
+      case S1AP_E_RAB_MODIFY_REQ:
+        rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(msg_p, msg_name_p, instance);
+        break;
 
-    case S1AP_UE_CONTEXT_RELEASE_COMMAND:
-      rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p, msg_name_p, instance);
-      break;
+      case S1AP_E_RAB_RELEASE_COMMAND:
+        rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(msg_p, msg_name_p, instance);
+        break;
 
-    case GTPV1U_ENB_DELETE_TUNNEL_RESP:
-      /* Nothing to do. Apparently everything is done in S1AP processing */
-      //LOG_I(RRC, "[eNB %d] Received message %s, not processed because procedure not synched\n",
-      //instance, msg_name_p);
-      if (rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)
-          && rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc > 0) {
-        rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc =
-        rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_thres_rrc;
-      }
-      break;
+      case S1AP_UE_CONTEXT_RELEASE_REQ:
+        rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name_p, instance);
+        break;
+
+      case S1AP_UE_CONTEXT_RELEASE_COMMAND:
+        rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p, msg_name_p, instance);
+        break;
+
+      case GTPV1U_ENB_DELETE_TUNNEL_RESP:
+
+        /* Nothing to do. Apparently everything is done in S1AP processing */
+        //LOG_I(RRC, "[eNB %d] Received message %s, not processed because procedure not synched\n",
+        //instance, msg_name_p);
+        if (rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)
+            && rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc > 0) {
+          rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc =
+            rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_thres_rrc;
+        }
 
+        break;
 #   endif
 
       /* Messages from eNB app */
-    case RRC_CONFIGURATION_REQ:
-      LOG_I(RRC, "[eNB %d] Received %s : %p\n", instance, msg_name_p,&RRC_CONFIGURATION_REQ(msg_p));
-      openair_rrc_eNB_configuration(ENB_INSTANCE_TO_MODULE_ID(instance), &RRC_CONFIGURATION_REQ(msg_p));
-      break;
+      case RRC_CONFIGURATION_REQ:
+        LOG_I(RRC, "[eNB %d] Received %s : %p\n", instance, msg_name_p,&RRC_CONFIGURATION_REQ(msg_p));
+        openair_rrc_eNB_configuration(ENB_INSTANCE_TO_MODULE_ID(instance), &RRC_CONFIGURATION_REQ(msg_p));
+        break;
 
-    default:
-      LOG_E(RRC, "[eNB %d] Received unexpected message %s\n", instance, msg_name_p);
-      break;
+      default:
+        LOG_E(RRC, "[eNB %d] Received unexpected message %s\n", instance, msg_name_p);
+        break;
     }
 
     result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
@@ -7232,13 +6721,10 @@ void
 openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active)
 //-----------------------------------------------------------------------------
 {
-
   module_id_t         module_id;
   int                 CC_id;
-
   /* for no gcc warnings */
   (void)CC_id;
-
   LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_eNB_INST=%d\n", RC.nb_inst);
 
   if (RC.nb_inst > 0) {
@@ -7267,9 +6753,7 @@ openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active)
     }
 
 #endif
-  } 
-
-
+  }
 }
 
 //-----------------------------------------------------------------------------
@@ -7279,8 +6763,8 @@ rrc_top_cleanup_eNB(
 )
 //-----------------------------------------------------------------------------
 {
+  for (int i=0; i<RC.nb_inst; i++) free (RC.rrc[i]);
 
-  for (int i=0;i<RC.nb_inst;i++) free (RC.rrc[i]);
   free(RC.rrc);
 }
 
@@ -7288,7 +6772,7 @@ rrc_top_cleanup_eNB(
 //-----------------------------------------------------------------------------
 RRC_status_t
 rrc_rx_tx(
-  protocol_ctxt_t* const ctxt_pP,
+  protocol_ctxt_t *const ctxt_pP,
   const int          CC_id
 )
 //-----------------------------------------------------------------------------
@@ -7297,129 +6781,134 @@ rrc_rx_tx(
   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);
+  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)) {
+    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/8\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/8\n",
+              ue_context_p->ue_context.rnti,
+              ue_context_p->ue_context.ul_failure_timer);
+      }
+    }
 
-    check_handovers(ctxt_pP);
-    // counetr, and get the value and aggregate
+    if (ue_context_p->ue_context.ul_failure_timer>0) {
+      ue_context_p->ue_context.ul_failure_timer++;
 
-    // check for UL failure
-    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
-      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/8\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/8\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 >= 8) {
-	  // remove UE after 20 seconds after MAC has indicated UL failure
-	  LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti);
-	  ue_to_be_removed = ue_context_p;
-	  break;
-	}
+      if (ue_context_p->ue_context.ul_failure_timer >= 8) {
+        // remove UE after 20 seconds after MAC has indicated UL failure
+        LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti);
+        ue_to_be_removed = ue_context_p;
+        break;
       }
-      if (ue_context_p->ue_context.ue_release_timer_s1>0) {
-        ue_context_p->ue_context.ue_release_timer_s1++;
-        if (ue_context_p->ue_context.ue_release_timer_s1 >=
-            ue_context_p->ue_context.ue_release_timer_thres_s1) {
-          LOG_I(RRC,"Removing UE %x instance Because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n",
-                         ue_context_p->ue_context.rnti, ue_context_p->ue_context.ue_release_timer_thres_s1);
-          ue_to_be_removed = ue_context_p;
-          break;
-        }
+    }
+
+    if (ue_context_p->ue_context.ue_release_timer_s1>0) {
+      ue_context_p->ue_context.ue_release_timer_s1++;
+
+      if (ue_context_p->ue_context.ue_release_timer_s1 >=
+          ue_context_p->ue_context.ue_release_timer_thres_s1) {
+        LOG_I(RRC,"Removing UE %x instance Because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n",
+              ue_context_p->ue_context.rnti, ue_context_p->ue_context.ue_release_timer_thres_s1);
+        ue_to_be_removed = ue_context_p;
+        break;
       }
+    }
 
-      if (ue_context_p->ue_context.ue_release_timer_rrc>0) {
-        ue_context_p->ue_context.ue_release_timer_rrc++;
-        if (ue_context_p->ue_context.ue_release_timer_rrc >=
+    if (ue_context_p->ue_context.ue_release_timer_rrc>0) {
+      ue_context_p->ue_context.ue_release_timer_rrc++;
+
+      if (ue_context_p->ue_context.ue_release_timer_rrc >=
           ue_context_p->ue_context.ue_release_timer_thres_rrc) {
-          LOG_I(RRC,"Removing UE %x instance After UE_CONTEXT_RELEASE_Complete\n", ue_context_p->ue_context.rnti);
-          ue_to_be_removed = ue_context_p;
-          break;
-        }
+        LOG_I(RRC,"Removing UE %x instance After UE_CONTEXT_RELEASE_Complete\n", ue_context_p->ue_context.rnti);
+        ue_to_be_removed = ue_context_p;
+        break;
       }
+    }
 
-      if (ue_context_p->ue_context.ue_reestablishment_timer>0) {
-        ue_context_p->ue_context.ue_reestablishment_timer++;
-        if (ue_context_p->ue_context.ue_reestablishment_timer >=
-            ue_context_p->ue_context.ue_reestablishment_timer_thres) {
-          LOG_I(RRC,"UE %d reestablishment_timer max\n",ue_context_p->ue_context.rnti);
-          ue_context_p->ue_context.ul_failure_timer = 20000;
-          ue_to_be_removed = ue_context_p;
-          ue_context_p->ue_context.ue_reestablishment_timer = 0;
-          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\n",ue_context_p->ue_context.rnti);
-	  ue_to_be_removed = ue_context_p;
-	  break;
-	}
+    if (ue_context_p->ue_context.ue_reestablishment_timer>0) {
+      ue_context_p->ue_context.ue_reestablishment_timer++;
+
+      if (ue_context_p->ue_context.ue_reestablishment_timer >=
+          ue_context_p->ue_context.ue_reestablishment_timer_thres) {
+        LOG_I(RRC,"UE %d reestablishment_timer max\n",ue_context_p->ue_context.rnti);
+        ue_context_p->ue_context.ul_failure_timer = 20000;
+        ue_to_be_removed = ue_context_p;
+        ue_context_p->ue_context.ue_reestablishment_timer = 0;
+        break;
       }
     }
-    if (ue_to_be_removed) {
-      if(ue_to_be_removed->ue_context.ul_failure_timer >= 8) {
-          ue_to_be_removed->ue_context.ue_release_timer_s1 = 1;
-          ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100;
-          ue_to_be_removed->ue_context.ue_release_timer = 0;
-          ue_to_be_removed->ue_context.ue_reestablishment_timer = 0;
-      }
-      rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed);
-      if(ue_to_be_removed->ue_context.ul_failure_timer >= 8){
-        ue_to_be_removed->ue_context.ul_failure_timer = 0;
+
+    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\n",ue_context_p->ue_context.rnti);
+        ue_to_be_removed = ue_context_p;
+        break;
       }
     }
+  }
 
-#ifdef RRC_LOCALIZATION
+  if (ue_to_be_removed) {
+    if(ue_to_be_removed->ue_context.ul_failure_timer >= 8) {
+      ue_to_be_removed->ue_context.ue_release_timer_s1 = 1;
+      ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100;
+      ue_to_be_removed->ue_context.ue_release_timer = 0;
+      ue_to_be_removed->ue_context.ue_reestablishment_timer = 0;
+    }
 
-    /* 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;
-      }
+    rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed);
+
+    if(ue_to_be_removed->ue_context.ul_failure_timer >= 8) {
+      ue_to_be_removed->ue_context.ul_failure_timer = 0;
     }
+  }
 
+#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" */
-
+  (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);
 }
diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c
index 153b5d693dfc5da9d574b7023f0915a86c7ef202..5215d6fcd5d8419fd089cca6be183caffda38f2f 100644
--- a/openair2/RRC/LTE/rrc_eNB_S1AP.c
+++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c
@@ -58,7 +58,7 @@
 #include "RRC/LTE/rrc_eNB_GTPV1U.h"
 
 #include "TLVDecoder.h"
-#include "S1ap-NAS-PDU.h"
+#include "S1AP_NAS-PDU.h"
 #include "flexran_agent_common_internal.h"
 
 extern RAN_CONTEXT_t RC;
@@ -89,18 +89,16 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c
   /* Process NAS message locally to get the IMSI */
   nas_message_t nas_msg;
   memset(&nas_msg, 0, sizeof(nas_message_t));
-
   int size = 0;
-
   nas_message_security_header_t *header = &nas_msg.header;
   /* Decode the first octet of the header (security header type or EPS
   * bearer identity, and protocol discriminator) */
-  DECODE_U8((char *) pdu_buf, *(uint8_t*) (header), size);
+  DECODE_U8((char *) pdu_buf, *(uint8_t *) (header), size);
 
   /* Decode NAS message only if decodable*/
   if (!(header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED
-      && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE
-      && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE))
+        && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE
+        && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE))
     return;
 
   if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
@@ -114,11 +112,9 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c
    * can modify it as we want. The callee retains the original address! */
   pdu_buf += size;
   pdu_len -= size;
-
   /* Decode plain NAS message */
   EMM_msg *e_msg = &nas_msg.plain.emm;
   emm_msg_header_t *emm_header = &e_msg->header;
-
   /* First decode the EMM message header */
   int e_head_size = 0;
 
@@ -161,9 +157,9 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c
 
 # if defined(ENABLE_ITTI)
 //------------------------------------------------------------------------------
-struct rrc_ue_s1ap_ids_s*
+struct rrc_ue_s1ap_ids_s *
 rrc_eNB_S1AP_get_ue_ids(
-  eNB_RRC_INST* const rrc_instance_pP,
+  eNB_RRC_INST *const rrc_instance_pP,
   const uint16_t ue_initial_id,
   const uint32_t eNB_ue_s1ap_id
 )
@@ -175,44 +171,51 @@ rrc_eNB_S1AP_get_ue_ids(
 
   // we assume that a rrc_ue_s1ap_ids_s is initially inserted in initial_id2_s1ap_ids
   if (eNB_ue_s1ap_id > 0) {
-	h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result);
+    h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&result);
   }
+
   if (ue_initial_id != UE_INITIAL_ID_INVALID) {
-    h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&result);
-	if  (h_rc == HASH_TABLE_OK) {
-	  if (eNB_ue_s1ap_id > 0) {
-	    h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result2);
-	    if  (h_rc != HASH_TABLE_OK) {
-		  result2 = malloc(sizeof(*result2));
-		  if (NULL != result2) {
-		    *result2 = *result;
-		    result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-		    result->eNB_ue_s1ap_id  = eNB_ue_s1ap_id;
+    h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void **)&result);
+
+    if  (h_rc == HASH_TABLE_OK) {
+      if (eNB_ue_s1ap_id > 0) {
+        h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&result2);
+
+        if  (h_rc != HASH_TABLE_OK) {
+          result2 = malloc(sizeof(*result2));
+
+          if (NULL != result2) {
+            *result2 = *result;
+            result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id;
+            result->eNB_ue_s1ap_id  = eNB_ue_s1ap_id;
             h_rc = hashtable_insert(rrc_instance_pP->s1ap_id2_s1ap_ids,
-		    		               (hash_key_t)eNB_ue_s1ap_id,
-		    		               result2);
+                                    (hash_key_t)eNB_ue_s1ap_id,
+                                    result2);
+
             if (h_rc != HASH_TABLE_OK) {
               LOG_E(S1AP, "[eNB %ld] Error while hashtable_insert in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32"\n",
-		    		  rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id);
+                    rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id);
             }
-		  }
-		}
-	  }
-	}
+          }
+        }
+      }
+    }
   }
+
   return result;
 }
 //------------------------------------------------------------------------------
 void
 rrc_eNB_S1AP_remove_ue_ids(
-  eNB_RRC_INST*              const rrc_instance_pP,
-  struct rrc_ue_s1ap_ids_s* const ue_ids_pP
+  eNB_RRC_INST              *const rrc_instance_pP,
+  struct rrc_ue_s1ap_ids_s *const ue_ids_pP
 )
 //------------------------------------------------------------------------------
 {
   const uint16_t ue_initial_id  = ue_ids_pP->ue_initial_id;
   const uint32_t eNB_ue_s1ap_id = ue_ids_pP->eNB_ue_s1ap_id;
   hashtable_rc_t h_rc;
+
   if (rrc_instance_pP == NULL) {
     LOG_E(RRC, "Bad RRC instance\n");
     return;
@@ -224,21 +227,23 @@ rrc_eNB_S1AP_remove_ue_ids(
   }
 
   if (eNB_ue_s1ap_id > 0) {
-	h_rc = hashtable_remove(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id);
-	if (h_rc != HASH_TABLE_OK) {
-	  LOG_W(RRC, "S1AP Did not find entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id);
-	} else {
-	  LOG_W(RRC, "S1AP removed entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id);
-	}
+    h_rc = hashtable_remove(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id);
+
+    if (h_rc != HASH_TABLE_OK) {
+      LOG_W(RRC, "S1AP Did not find entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id);
+    } else {
+      LOG_W(RRC, "S1AP removed entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id);
+    }
   }
 
   if (ue_initial_id != UE_INITIAL_ID_INVALID) {
     h_rc = hashtable_remove(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id);
-	if (h_rc != HASH_TABLE_OK) {
-	  LOG_W(RRC, "S1AP Did not find entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id);
-	} else {
-	  LOG_W(RRC, "S1AP removed entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id);
-	}
+
+    if (h_rc != HASH_TABLE_OK) {
+      LOG_W(RRC, "S1AP Did not find entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id);
+    } else {
+      LOG_W(RRC, "S1AP removed entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id);
+    }
   }
 }
 
@@ -276,14 +281,14 @@ get_next_ue_initial_id(
  *\param eNB_ue_s1ap_id The value sent by S1AP.
  *\return the UE index or UE_INDEX_INVALID if not found.
  */
-static struct rrc_eNB_ue_context_s*
+static struct rrc_eNB_ue_context_s *
 rrc_eNB_get_ue_context_from_s1ap_ids(
   const instance_t  instanceP,
   const uint16_t    ue_initial_idP,
   const uint32_t    eNB_ue_s1ap_idP
 )
 {
-  rrc_ue_s1ap_ids_t* temp = NULL;
+  rrc_ue_s1ap_ids_t *temp = NULL;
   temp =
     rrc_eNB_S1AP_get_ue_ids(
       RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)],
@@ -291,7 +296,6 @@ rrc_eNB_get_ue_context_from_s1ap_ids(
       eNB_ue_s1ap_idP);
 
   if (temp) {
-
     return rrc_eNB_get_ue_context(
              RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)],
              temp->ue_rnti);
@@ -307,8 +311,7 @@ rrc_eNB_get_ue_context_from_s1ap_ids(
  */
 static CipheringAlgorithm_r12_t rrc_eNB_select_ciphering(uint16_t algorithms)
 {
-
-//#warning "Forced   return SecurityAlgorithmConfig__cipheringAlgorithm_eea0, to be deleted in future"
+  //#warning "Forced   return SecurityAlgorithmConfig__cipheringAlgorithm_eea0, to be deleted in future"
   return CipheringAlgorithm_r12_eea0;
 
   if (algorithms & S1AP_ENCRYPTION_EEA2_MASK) {
@@ -329,7 +332,6 @@ static CipheringAlgorithm_r12_t rrc_eNB_select_ciphering(uint16_t algorithms)
  */
 static e_SecurityAlgorithmConfig__integrityProtAlgorithm rrc_eNB_select_integrity(uint16_t algorithms)
 {
-
   if (algorithms & S1AP_INTEGRITY_EIA2_MASK) {
     return SecurityAlgorithmConfig__integrityProtAlgorithm_eia2;
   }
@@ -350,18 +352,16 @@ static e_SecurityAlgorithmConfig__integrityProtAlgorithm rrc_eNB_select_integrit
  */
 static int
 rrc_eNB_process_security(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
-  security_capabilities_t* security_capabilities_pP
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
+  security_capabilities_t *security_capabilities_pP
 )
 {
   boolean_t                                         changed = FALSE;
   CipheringAlgorithm_r12_t                          cipheringAlgorithm;
   e_SecurityAlgorithmConfig__integrityProtAlgorithm integrityProtAlgorithm;
-
   /* Save security parameters */
   ue_context_pP->ue_context.security_capabilities = *security_capabilities_pP;
-
   // translation
   LOG_D(RRC,
         "[eNB %d] NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n",
@@ -392,7 +392,6 @@ rrc_eNB_process_security(
          (unsigned long)cipheringAlgorithm,
          integrityProtAlgorithm,
          changed ? "changed" : "same");
-
   return changed;
 }
 
@@ -404,16 +403,15 @@ rrc_eNB_process_security(
  */
 //------------------------------------------------------------------------------
 static void process_eNB_security_key (
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
-  uint8_t*               security_key_pP
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
+  uint8_t               *security_key_pP
 )
 //------------------------------------------------------------------------------
 {
 #if defined(ENABLE_SECURITY)
   char ascii_buffer[65];
   uint8_t i;
-
   /* Saves the security key */
   memcpy (ue_context_pP->ue_context.kenb, security_key_pP, SECURITY_KEY_LENGTH);
   memset (ue_context_pP->ue_context.nh, 0, SECURITY_KEY_LENGTH);
@@ -424,7 +422,6 @@ static void process_eNB_security_key (
   }
 
   ascii_buffer[2 * i] = '\0';
-
   LOG_I (RRC, "[eNB %d][UE %x] Saved security key %s\n", ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ascii_buffer);
 #endif
 }
@@ -433,17 +430,14 @@ static void process_eNB_security_key (
 //------------------------------------------------------------------------------
 void
 rrc_pdcp_config_security(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
   const uint8_t send_security_mode_command
 )
 //------------------------------------------------------------------------------
 {
-
 #if defined(ENABLE_SECURITY)
-
-
-  SRB_ToAddModList_t*                 SRB_configList = ue_context_pP->ue_context.SRB_configList;
+  SRB_ToAddModList_t                 *SRB_configList = ue_context_pP->ue_context.SRB_configList;
   uint8_t                            *kRRCenc = NULL;
   uint8_t                            *kRRCint = NULL;
   uint8_t                            *kUPenc = NULL;
@@ -465,11 +459,9 @@ rrc_pdcp_config_security(
   derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm,
                      ue_context_pP->ue_context.kenb,
                      &kRRCint);
-
 #if !defined(USRP_REC_PLAY)
 #define DEBUG_SECURITY 1
 #endif
-  
 #if defined (DEBUG_SECURITY)
 #undef msg
 #define msg printf
@@ -484,7 +476,6 @@ rrc_pdcp_config_security(
     }
 
     msg("\n");
-
     msg("\nKRRCenc:");
 
     for(i = 0; i < 32; i++) {
@@ -492,7 +483,6 @@ rrc_pdcp_config_security(
     }
 
     msg("\n");
-
     msg("\nKRRCint:");
 
     for(i = 0; i < 32; i++) {
@@ -500,13 +490,11 @@ rrc_pdcp_config_security(
     }
 
     msg("\n");
-
   }
 
 #endif //DEBUG_SECURITY
   key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES);
-  h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
-
+  h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
 
   if (h_rc == HASH_TABLE_OK) {
     pdcp_config_set_security(
@@ -534,8 +522,8 @@ rrc_pdcp_config_security(
 //------------------------------------------------------------------------------
 void
 rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP
 )
 //------------------------------------------------------------------------------
 {
@@ -543,7 +531,6 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(
   int e_rab;
   int e_rabs_done = 0;
   int e_rabs_failed = 0;
-
   msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_INITIAL_CONTEXT_SETUP_RESP);
   S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
 
@@ -574,11 +561,8 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(
     ue_context_pP->ue_id_rnti,
     S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id,
     e_rabs_done, e_rabs_failed);
-
-
   S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done;
   S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed;
-
   itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
 }
 # endif
@@ -586,9 +570,9 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(
 //------------------------------------------------------------------------------
 void
 rrc_eNB_send_S1AP_UPLINK_NAS(
-  const protocol_ctxt_t*    const ctxt_pP,
-  rrc_eNB_ue_context_t*             const ue_context_pP,
-  UL_DCCH_Message_t*        const ul_dcch_msg
+  const protocol_ctxt_t    *const ctxt_pP,
+  rrc_eNB_ue_context_t             *const ue_context_pP,
+  UL_DCCH_Message_t        *const ul_dcch_msg
 )
 //------------------------------------------------------------------------------
 {
@@ -603,23 +587,19 @@ rrc_eNB_send_S1AP_UPLINK_NAS(
     == ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) {
       /* This message hold a dedicated info NAS payload, forward it to NAS */
       struct ULInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType =
-          &ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType;
+        &ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType;
       uint32_t pdu_length;
       uint8_t *pdu_buffer;
       MessageDef *msg_p;
-
       pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size;
       pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf;
-
       msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UPLINK_NAS);
       S1AP_UPLINK_NAS (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
       S1AP_UPLINK_NAS (msg_p).nas_pdu.length = pdu_length;
       S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer = pdu_buffer;
-
       extract_imsi(S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer,
-                   S1AP_UPLINK_NAS (msg_p).nas_pdu.length,
-                   ue_context_pP);
-
+      S1AP_UPLINK_NAS (msg_p).nas_pdu.length,
+      ue_context_pP);
       itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
     }
   }
@@ -634,7 +614,6 @@ rrc_eNB_send_S1AP_UPLINK_NAS(
     ULInformationTransfer__criticalExtensions_PR_c1) {
       if (ulInformationTransfer->criticalExtensions.choice.c1.present ==
       ULInformationTransfer__criticalExtensions__c1_PR_ulInformationTransfer_r8) {
-
         ULInformationTransfer_r8_IEs_t
         *ulInformationTransferR8;
         ulInformationTransferR8 =
@@ -642,15 +621,13 @@ rrc_eNB_send_S1AP_UPLINK_NAS(
         c1.choice.ulInformationTransfer_r8;
 
         if (ulInformationTransferR8->dedicatedInfoType.present ==
-            ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS) {
-
+        ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS) {
           extract_imsi(ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf,
-                       ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size,
-                       ue_context_pP);
-
+          ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size,
+          ue_context_pP);
           s1ap_eNB_new_data_request (mod_id, ue_index,
-              ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf,
-              ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size);
+          ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf,
+          ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size);
         }
       }
     }
@@ -660,9 +637,9 @@ rrc_eNB_send_S1AP_UPLINK_NAS(
 
 //------------------------------------------------------------------------------
 void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
-  UL_DCCH_Message_t* ul_dcch_msg
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
+  UL_DCCH_Message_t *ul_dcch_msg
 )
 //------------------------------------------------------------------------------
 {
@@ -678,39 +655,39 @@ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(
     return;
   }
 
-  asn_enc_rval_t ret = uper_encode_to_buffer(&asn_DEF_UECapabilityInformation, ueCapabilityInformation, buf, 4096);
+  asn_enc_rval_t ret = uper_encode_to_buffer(&asn_DEF_UECapabilityInformation, NULL, ueCapabilityInformation, buf, 4096);
+
   if (ret.encoded == -1) abort();
 
   memset(&rac, 0, sizeof(UERadioAccessCapabilityInformation_t));
-
   rac.criticalExtensions.present = UERadioAccessCapabilityInformation__criticalExtensions_PR_c1;
   rac.criticalExtensions.choice.c1.present = UERadioAccessCapabilityInformation__criticalExtensions__c1_PR_ueRadioAccessCapabilityInformation_r8;
   rac.criticalExtensions.choice.c1.choice.ueRadioAccessCapabilityInformation_r8.ue_RadioAccessCapabilityInfo.buf = buf;
   rac.criticalExtensions.choice.c1.choice.ueRadioAccessCapabilityInformation_r8.ue_RadioAccessCapabilityInfo.size = (ret.encoded+7)/8;
   rac.criticalExtensions.choice.c1.choice.ueRadioAccessCapabilityInformation_r8.nonCriticalExtension = NULL;
-
   /* 8192 is arbitrary, should be big enough */
   buf2 = malloc16(8192);
+
   if (buf2 == NULL) abort();
-  ret = uper_encode_to_buffer(&asn_DEF_UERadioAccessCapabilityInformation, &rac, buf2, 8192);
+
+  ret = uper_encode_to_buffer(&asn_DEF_UERadioAccessCapabilityInformation, NULL, &rac, buf2, 8192);
+
   if (ret.encoded == -1) abort();
 
   MessageDef *msg_p;
-
   msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UE_CAPABILITIES_IND);
   S1AP_UE_CAPABILITIES_IND (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
   S1AP_UE_CAPABILITIES_IND (msg_p).ue_radio_cap.length = (ret.encoded+7)/8;
   S1AP_UE_CAPABILITIES_IND (msg_p).ue_radio_cap.buffer = buf2;
-
   itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
 }
 
 //------------------------------------------------------------------------------
 void
 rrc_eNB_send_S1AP_NAS_FIRST_REQ(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*          const ue_context_pP,
-  RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP,
+  RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete
 )
 //------------------------------------------------------------------------------
 
@@ -719,67 +696,58 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
   eNB_RRC_INST *rrc=RC.rrc[ctxt_pP->module_id];
 #if defined(ENABLE_ITTI)
   {
-    MessageDef*         message_p         = NULL;
-    rrc_ue_s1ap_ids_t*  rrc_ue_s1ap_ids_p = NULL;
+    MessageDef         *message_p         = NULL;
+    rrc_ue_s1ap_ids_t  *rrc_ue_s1ap_ids_p = NULL;
     hashtable_rc_t      h_rc;
-
     message_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_NAS_FIRST_REQ);
     memset(&message_p->ittiMsg.s1ap_nas_first_req, 0, sizeof(s1ap_nas_first_req_t));
-
     ue_context_pP->ue_context.ue_initial_id = get_next_ue_initial_id (ctxt_pP->module_id);
     S1AP_NAS_FIRST_REQ (message_p).ue_initial_id = ue_context_pP->ue_context.ue_initial_id;
-
     rrc_ue_s1ap_ids_p = malloc(sizeof(*rrc_ue_s1ap_ids_p));
     rrc_ue_s1ap_ids_p->ue_initial_id  = ue_context_pP->ue_context.ue_initial_id;
     rrc_ue_s1ap_ids_p->eNB_ue_s1ap_id = UE_INITIAL_ID_INVALID;
     rrc_ue_s1ap_ids_p->ue_rnti        = ctxt_pP->rnti;
-
     h_rc = hashtable_insert(RC.rrc[ctxt_pP->module_id]->initial_id2_s1ap_ids,
-    		               (hash_key_t)ue_context_pP->ue_context.ue_initial_id,
-    		               rrc_ue_s1ap_ids_p);
+                            (hash_key_t)ue_context_pP->ue_context.ue_initial_id,
+                            rrc_ue_s1ap_ids_p);
+
     if (h_rc != HASH_TABLE_OK) {
       LOG_E(S1AP, "[eNB %d] Error while hashtable_insert in initial_id2_s1ap_ids ue_initial_id %u\n",
-    		  ctxt_pP->module_id, ue_context_pP->ue_context.ue_initial_id);
+            ctxt_pP->module_id, ue_context_pP->ue_context.ue_initial_id);
     }
 
     /* Assume that cause is coded in the same way in RRC and S1ap, just check that the value is in S1ap range */
     AssertFatal(ue_context_pP->ue_context.establishment_cause < RRC_CAUSE_LAST,
-    "Establishment cause invalid (%jd/%d) for eNB %d!",
-    ue_context_pP->ue_context.establishment_cause, RRC_CAUSE_LAST, ctxt_pP->module_id);
-
+                "Establishment cause invalid (%jd/%d) for eNB %d!",
+                ue_context_pP->ue_context.establishment_cause, RRC_CAUSE_LAST, ctxt_pP->module_id);
     S1AP_NAS_FIRST_REQ (message_p).establishment_cause = ue_context_pP->ue_context.establishment_cause;
-
     /* Forward NAS message */S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer =
-    rrcConnectionSetupComplete->dedicatedInfoNAS.buf;
+      rrcConnectionSetupComplete->dedicatedInfoNAS.buf;
     S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length = rrcConnectionSetupComplete->dedicatedInfoNAS.size;
-
     extract_imsi(S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer,
                  S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length,
                  ue_context_pP);
-
     /* Fill UE identities with available information */
     {
       S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask = UE_IDENTITIES_NONE;
 
       if (ue_context_pP->ue_context.Initialue_identity_s_TMSI.presence) {
         /* Fill s-TMSI */
-        UE_S_TMSI* s_TMSI = &ue_context_pP->ue_context.Initialue_identity_s_TMSI;
-
+        UE_S_TMSI *s_TMSI = &ue_context_pP->ue_context.Initialue_identity_s_TMSI;
         S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask |= UE_IDENTITIES_s_tmsi;
         S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code = s_TMSI->mme_code;
         S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi = s_TMSI->m_tmsi;
         LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ with s_TMSI: MME code %u M-TMSI %u ue %x\n",
-            ctxt_pP->module_id,
-            S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code,
-            S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi,
-            ue_context_pP->ue_context.rnti);
+              ctxt_pP->module_id,
+              S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code,
+              S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi,
+              ue_context_pP->ue_context.rnti);
       }
 
       if (rrcConnectionSetupComplete->registeredMME != NULL) {
         /* Fill GUMMEI */
         struct RegisteredMME *r_mme = rrcConnectionSetupComplete->registeredMME;
         //int selected_plmn_identity = rrcConnectionSetupComplete->selectedPLMN_Identity;
-
         S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask |= UE_IDENTITIES_gummei;
 
         if (r_mme->plmn_Identity != NULL) {
@@ -787,9 +755,9 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
             /* Use first indicated PLMN MCC if it is defined */
             S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc = *r_mme->plmn_Identity->mcc->list.array[0];
             LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MCC %u ue %x\n",
-                ctxt_pP->module_id,
-                S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc,
-                ue_context_pP->ue_context.rnti);
+                  ctxt_pP->module_id,
+                  S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc,
+                  ue_context_pP->ue_context.rnti);
           }
 
           if (r_mme->plmn_Identity->mnc.list.count > 0) {
@@ -801,9 +769,8 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
                   ue_context_pP->ue_context.rnti);
           }
         } else {
-	  //          const Enb_properties_array_t   *enb_properties_p  = NULL;
-	  //          enb_properties_p = enb_config_get();
-
+          //          const Enb_properties_array_t   *enb_properties_p  = NULL;
+          //          enb_properties_p = enb_config_get();
           // actually the eNB configuration contains only one PLMN (can be up to 6)
           S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc = rrc->mcc;
           S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc = rrc->mnc;
@@ -812,7 +779,6 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
 
         S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code     = BIT_STRING_to_uint8 (&r_mme->mmec);
         S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id = BIT_STRING_to_uint16 (&r_mme->mmegi);
-
         MSC_LOG_TX_MESSAGE(
           MSC_S1AP_ENB,
           MSC_S1AP_MME,
@@ -822,7 +788,6 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
           MSC_AS_TIME_ARGS(ctxt_pP),
           ctxt_pP->module_id,
           ctxt_pP->rnti);
-
         LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI mme_code %u mme_group_id %u ue %x\n",
               ctxt_pP->module_id,
               S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code,
@@ -849,10 +814,10 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
 //------------------------------------------------------------------------------
 int
 rrc_eNB_process_S1AP_DOWNLINK_NAS(
-  MessageDef* msg_p,
-  const char* msg_name,
+  MessageDef *msg_p,
+  const char *msg_name,
   instance_t instance,
-  mui_t* rrc_eNB_mui
+  mui_t *rrc_eNB_mui
 )
 //------------------------------------------------------------------------------
 {
@@ -860,15 +825,12 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS(
   uint32_t eNB_ue_s1ap_id;
   uint32_t length;
   uint8_t *buffer;
-  uint8_t srb_id; 
-  
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  uint8_t srb_id;
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   protocol_ctxt_t              ctxt;
   ue_initial_id = S1AP_DOWNLINK_NAS (msg_p).ue_initial_id;
   eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id;
   ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id);
-
-
   LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d\n",
         instance,
         msg_name,
@@ -876,7 +838,6 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS(
         eNB_ue_s1ap_id);
 
   if (ue_context_p == NULL) {
-
     MSC_LOG_RX_MESSAGE(
       MSC_RRC_ENB,
       MSC_S1AP_ENB,
@@ -886,20 +847,14 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS(
       0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
       ue_initial_id,
       eNB_ue_s1ap_id);
-
     /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */
     MessageDef *msg_fail_p;
-
     LOG_W(RRC, "[eNB %d] In S1AP_DOWNLINK_NAS: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id);
-
     msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_NAS_NON_DELIVERY_IND);
     S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
     S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).nas_pdu.length = S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length;
     S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).nas_pdu.buffer = S1AP_DOWNLINK_NAS (msg_p).nas_pdu.buffer;
-
     // TODO add failure cause when defined!
-
-
     MSC_LOG_TX_MESSAGE(
       MSC_RRC_ENB,
       MSC_S1AP_ENB,
@@ -909,14 +864,11 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS(
       0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
       ue_initial_id,
       eNB_ue_s1ap_id);
-
     itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p);
     return (-1);
   } else {
     PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0);
-
     srb_id = ue_context_p->ue_context.Srb2.Srb_info.Srb_id;
-  
 
     /* Is it the first income from S1AP ? */
     if (ue_context_p->ue_context.eNB_ue_s1ap_id == 0) {
@@ -932,8 +884,6 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS(
       0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
       ue_initial_id,
       S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id);
-
-
     /* Create message for PDCP (DLInformationTransfer_t) */
     length = do_DLInformationTransfer (
                instance,
@@ -941,30 +891,28 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS(
                rrc_eNB_get_next_transaction_identifier (instance),
                S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length,
                S1AP_DOWNLINK_NAS (msg_p).nas_pdu.buffer);
-
 #ifdef RRC_MSG_PRINT
     int i=0;
     LOG_F(RRC,"[MSG] RRC DL Information Transfer\n");
 
     for (i = 0; i < length; i++) {
-      LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]);
+      LOG_F(RRC,"%02x ", ((uint8_t *)buffer)[i]);
     }
 
     LOG_F(RRC,"\n");
 #endif
-    /* 
-     * switch UL or DL NAS message without RRC piggybacked to SRB2 if active. 
+    /*
+     * switch UL or DL NAS message without RRC piggybacked to SRB2 if active.
      */
     /* Transfer data to PDCP */
     rrc_data_req (
-		  &ctxt,
-		  srb_id,
-		  *rrc_eNB_mui++,
-		  SDU_CONFIRM_NO,
-		  length,
-		  buffer,
-		  PDCP_TRANSMISSION_MODE_CONTROL);
-    
+      &ctxt,
+      srb_id,
+      *rrc_eNB_mui++,
+      SDU_CONFIRM_NO,
+      length,
+      buffer,
+      PDCP_TRANSMISSION_MODE_CONTROL);
     return (0);
   }
 }
@@ -977,9 +925,8 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char
   //MessageDef                     *message_gtpv1u_p = NULL;
   gtpv1u_enb_create_tunnel_req_t  create_tunnel_req;
   gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp;
-  uint8_t                         inde_list[NB_RB_MAX - 3]={0};
-
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  uint8_t                         inde_list[NB_RB_MAX - 3]= {0};
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   protocol_ctxt_t              ctxt;
   ue_initial_id  = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).ue_initial_id;
   eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id;
@@ -990,63 +937,49 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char
   if (ue_context_p == NULL) {
     /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */
     MessageDef *msg_fail_p = NULL;
-
     LOG_W(RRC, "[eNB %d] In S1AP_INITIAL_CONTEXT_SETUP_REQ: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id);
-
     msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_INITIAL_CONTEXT_SETUP_FAIL);
     S1AP_INITIAL_CONTEXT_SETUP_FAIL (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-
     // TODO add failure cause when defined!
-
     itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p);
     return (-1);
   } else {
-
     PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0);
     ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id;
-
     /* Save e RAB information for later */
     {
       int i;
-
-      memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req));
+      memset(&create_tunnel_req, 0, sizeof(create_tunnel_req));
       ue_context_p->ue_context.nb_of_e_rabs = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs;
-     
+
       for (i = 0; i < ue_context_p->ue_context.nb_of_e_rabs; i++) {
         ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW;
         ue_context_p->ue_context.e_rab[i].param = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i];
-
-
         create_tunnel_req.eps_bearer_id[i]       = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].e_rab_id;
         create_tunnel_req.sgw_S1u_teid[i]        = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].gtp_teid;
-
         memcpy(&create_tunnel_req.sgw_addr[i],
                &S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].sgw_addr,
                sizeof(transport_layer_addr_t));
         inde_list[create_tunnel_req.num_tunnels]= i;
         create_tunnel_req.num_tunnels++;
       }
-    
-      create_tunnel_req.rnti       = ue_context_p->ue_context.rnti; // warning put zero above
-//      create_tunnel_req.num_tunnels    = i;
 
+      create_tunnel_req.rnti       = ue_context_p->ue_context.rnti; // warning put zero above
+      //      create_tunnel_req.num_tunnels    = i;
       gtpv1u_create_s1u_tunnel(
         instance,
         &create_tunnel_req,
         &create_tunnel_resp);
-
       rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(
-          &ctxt,
-          &create_tunnel_resp,
-          &inde_list[0]); 
+        &ctxt,
+        &create_tunnel_resp,
+        &inde_list[0]);
       ue_context_p->ue_context.setup_e_rabs=ue_context_p->ue_context.nb_of_e_rabs;
     }
-
     /* TODO parameters yet to process ... */
     {
       //      S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr;
     }
-
     rrc_eNB_process_security (
       &ctxt,
       ue_context_p,
@@ -1055,10 +988,8 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char
       &ctxt,
       ue_context_p,
       S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_key);
-
     {
       uint8_t send_security_mode_command = TRUE;
-
 #ifndef EXMIMO_IOT
 
       if ((ue_context_p->ue_context.ciphering_algorithm == SecurityAlgorithmConfig__cipheringAlgorithm_eea0)
@@ -1073,7 +1004,6 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char
         send_security_mode_command);
 
       if (send_security_mode_command) {
-
         rrc_eNB_generate_SecurityModeCommand (
           &ctxt,
           ue_context_p);
@@ -1095,27 +1025,21 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char
 int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance)
 {
   uint32_t eNB_ue_s1ap_id;
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   protocol_ctxt_t              ctxt;
-
   eNB_ue_s1ap_id = S1AP_UE_CTXT_MODIFICATION_REQ (msg_p).eNB_ue_s1ap_id;
   ue_context_p   = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id);
 
   if (ue_context_p == NULL) {
     /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */
     MessageDef *msg_fail_p;
-
     LOG_W(RRC, "[eNB %d] In S1AP_UE_CTXT_MODIFICATION_REQ: unknown UE from eNB_ue_s1ap_id (%d)\n", instance, eNB_ue_s1ap_id);
-
     msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UE_CTXT_MODIFICATION_FAIL);
     S1AP_UE_CTXT_MODIFICATION_FAIL (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-
     // TODO add failure cause when defined!
-
     itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p);
     return (-1);
   } else {
-
     PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0);
     /* TODO parameters yet to process ... */
     {
@@ -1141,20 +1065,16 @@ int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char
         &ctxt,
         ue_context_p,
         S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_key);
-
       /* TODO reconfigure lower layers... */
     }
 
     /* Send the response */
     {
       MessageDef *msg_resp_p;
-
       msg_resp_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CTXT_MODIFICATION_RESP);
       S1AP_UE_CTXT_MODIFICATION_RESP(msg_resp_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-
       itti_send_msg_to_task(TASK_S1AP, instance, msg_resp_p);
     }
-
     return (0);
   }
 }
@@ -1163,39 +1083,30 @@ int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char
 int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char *msg_name, instance_t instance)
 {
   uint32_t eNB_ue_s1ap_id;
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
-
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_REQ(msg_p).eNB_ue_s1ap_id;
   ue_context_p   = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id);
 
   if (ue_context_p == NULL) {
     /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */
     MessageDef *msg_fail_p;
-
     LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_REQ: unknown UE from eNB_ue_s1ap_id (%d)\n",
           instance,
           eNB_ue_s1ap_id);
-
     msg_fail_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_RESP); /* TODO change message ID. */
     S1AP_UE_CONTEXT_RELEASE_RESP(msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-
     // TODO add failure cause when defined!
-
     itti_send_msg_to_task(TASK_S1AP, instance, msg_fail_p);
     return (-1);
   } else {
     /* TODO release context. */
-
     /* Send the response */
     {
       MessageDef *msg_resp_p;
-
       msg_resp_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_RESP);
       S1AP_UE_CONTEXT_RELEASE_RESP(msg_resp_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-
       itti_send_msg_to_task(TASK_S1AP, instance, msg_resp_p);
     }
-
     return (0);
   }
 }
@@ -1203,7 +1114,7 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char *
 //------------------------------------------------------------------------------
 void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ (
   const module_id_t                        enb_mod_idP,
-  const rrc_eNB_ue_context_t*        const ue_context_pP,
+  const rrc_eNB_ue_context_t        *const ue_context_pP,
   const s1ap_Cause_t                       causeP,
   const long                               cause_valueP
 )
@@ -1213,13 +1124,12 @@ void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ (
     LOG_W(RRC,
           "[eNB] In S1AP_UE_CONTEXT_RELEASE_COMMAND: invalid  UE\n");
   } else {
-	  MSC_LOG_TX_MESSAGE(
-			  MSC_RRC_ENB,
-	  		  MSC_S1AP_ENB,
-	  		  NULL,0,
-	  		  "0 S1AP_UE_CONTEXT_RELEASE_REQ eNB_ue_s1ap_id 0x%06"PRIX32" ",
-	  		  ue_context_pP->ue_context.eNB_ue_s1ap_id);
-
+    MSC_LOG_TX_MESSAGE(
+      MSC_RRC_ENB,
+      MSC_S1AP_ENB,
+      NULL,0,
+      "0 S1AP_UE_CONTEXT_RELEASE_REQ eNB_ue_s1ap_id 0x%06"PRIX32" ",
+      ue_context_pP->ue_context.eNB_ue_s1ap_id);
     MessageDef *msg_context_release_req_p = NULL;
     msg_context_release_req_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_REQ);
     S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
@@ -1237,47 +1147,40 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch
   protocol_ctxt_t              ctxt;
   struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   struct rrc_ue_s1ap_ids_s    *rrc_ue_s1ap_ids = NULL;
-
   eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p).eNB_ue_s1ap_id;
-
-
   ue_context_p   = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id);
 
   if (ue_context_p == NULL) {
     /* Can not associate this message to an UE index */
     MessageDef *msg_complete_p;
-
     LOG_W(RRC,
           "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: unknown UE from eNB_ue_s1ap_id (%d)\n",
           instance,
           eNB_ue_s1ap_id);
-
     MSC_LOG_EVENT(
-          MSC_RRC_ENB,
-  		  "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found",
-  		eNB_ue_s1ap_id);
-
+      MSC_RRC_ENB,
+      "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found",
+      eNB_ue_s1ap_id);
     MSC_LOG_TX_MESSAGE(
-          MSC_RRC_ENB,
-  		  MSC_S1AP_ENB,
-  		  NULL,0,
-  		  "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ",
-  		eNB_ue_s1ap_id);
-
+      MSC_RRC_ENB,
+      MSC_S1AP_ENB,
+      NULL,0,
+      "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ",
+      eNB_ue_s1ap_id);
     msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE);
     S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
     itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p);
-
     rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(
-    		RC.rrc[instance],
-    		UE_INITIAL_ID_INVALID,
-    		eNB_ue_s1ap_id);
+                        RC.rrc[instance],
+                        UE_INITIAL_ID_INVALID,
+                        eNB_ue_s1ap_id);
 
     if (NULL != rrc_ue_s1ap_ids) {
       rrc_eNB_S1AP_remove_ue_ids(
-    		  RC.rrc[instance],
-    		  rrc_ue_s1ap_ids);
+        RC.rrc[instance],
+        rrc_ue_s1ap_ids);
     }
+
     return (-1);
   } else {
     ue_context_p->ue_context.ue_release_timer_s1 = 0;
@@ -1293,19 +1196,16 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch
       int      e_rab;
       //int      mod_id = 0;
       MessageDef *msg_delete_tunnels_p = NULL;
-
       MSC_LOG_TX_MESSAGE(
-            MSC_RRC_ENB,
-            MSC_GTPU_ENB,
-            NULL,0,
-            "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ",
-            eNB_ue_s1ap_id);
-
+        MSC_RRC_ENB,
+        MSC_GTPU_ENB,
+        NULL,0,
+        "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ",
+        eNB_ue_s1ap_id);
       msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ);
       memset(&GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p),
              0,
              sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
-
       // do not wait response
       GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
 
@@ -1319,32 +1219,27 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch
       }
 
       itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p);
-
-
       MSC_LOG_TX_MESSAGE(
-            MSC_RRC_ENB,
-            MSC_S1AP_ENB,
-            NULL,0,
-            "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ",
-            eNB_ue_s1ap_id);
-
+        MSC_RRC_ENB,
+        MSC_S1AP_ENB,
+        NULL,0,
+        "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ",
+        eNB_ue_s1ap_id);
       MessageDef *msg_complete_p = NULL;
       msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE);
       S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
       itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p);
-
       rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(
-      		RC.rrc[instance],
-      		UE_INITIAL_ID_INVALID,
-      		eNB_ue_s1ap_id);
+                          RC.rrc[instance],
+                          UE_INITIAL_ID_INVALID,
+                          eNB_ue_s1ap_id);
 
       if (NULL != rrc_ue_s1ap_ids) {
         rrc_eNB_S1AP_remove_ue_ids(
-      		  RC.rrc[instance],
-      		  rrc_ue_s1ap_ids);
+          RC.rrc[instance],
+          rrc_ue_s1ap_ids);
       }
     }
-
     return (0);
   }
 }
@@ -1355,12 +1250,10 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name
   uint32_t                        eNB_ue_s1ap_id;
   gtpv1u_enb_create_tunnel_req_t  create_tunnel_req;
   gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp;
-  uint8_t                         inde_list[NB_RB_MAX - 3]={0};
-
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  uint8_t                         inde_list[NB_RB_MAX - 3]= {0};
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   protocol_ctxt_t              ctxt;
   uint8_t                      e_rab_done;
-
   ue_initial_id  = S1AP_E_RAB_SETUP_REQ (msg_p).ue_initial_id;
   eNB_ue_s1ap_id = S1AP_E_RAB_SETUP_REQ (msg_p).eNB_ue_s1ap_id;
   ue_context_p   = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id);
@@ -1370,174 +1263,150 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name
   if (ue_context_p == NULL) {
     /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */
     MessageDef *msg_fail_p = NULL;
-
     LOG_W(RRC, "[eNB %d] In S1AP_E_RAB_SETUP_REQ: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id);
-
     msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_SETUP_REQUEST_FAIL);
     S1AP_E_RAB_SETUP_REQ  (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-
     // TODO add failure cause when defined!
-
     itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p);
     return (-1);
   } else {
-
     PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0);
     ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_E_RAB_SETUP_REQ  (msg_p).eNB_ue_s1ap_id;
-
     /* Save e RAB information for later */
     {
       int i;
-
-      memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req));
+      memset(&create_tunnel_req, 0, sizeof(create_tunnel_req));
       uint8_t nb_e_rabs_tosetup = S1AP_E_RAB_SETUP_REQ  (msg_p).nb_e_rabs_tosetup;
       e_rab_done = 0;
 
       // keep the previous bearer
       // the index for the rec
-      for (i = 0; 
-	  // i < nb_e_rabs_tosetup; 
-           i < NB_RB_MAX - 3;  // loop all e-rabs in e_rab[] 
-	   i++) {
-	//if (ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status == E_RAB_STATUS_DONE) 
-	//  LOG_W(RRC,"E-RAB already configured, reconfiguring\n");
+      for (i = 0;
+           // i < nb_e_rabs_tosetup;
+           i < NB_RB_MAX - 3;  // loop all e-rabs in e_rab[]
+           i++) {
+        //if (ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status == E_RAB_STATUS_DONE)
+        //  LOG_W(RRC,"E-RAB already configured, reconfiguring\n");
         // check e-rab status, if e rab status is greater than E_RAB_STATUS_DONE, don't not config this one
         if(ue_context_p->ue_context.e_rab[i].status >= E_RAB_STATUS_DONE)
-            continue;
+          continue;
+
         //ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status = E_RAB_STATUS_NEW;
         //ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].param = S1AP_E_RAB_SETUP_REQ  (msg_p).e_rab_setup_params[i];
         ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW;
         ue_context_p->ue_context.e_rab[i].param = S1AP_E_RAB_SETUP_REQ  (msg_p).e_rab_setup_params[e_rab_done];
-
         create_tunnel_req.eps_bearer_id[e_rab_done]       = S1AP_E_RAB_SETUP_REQ  (msg_p).e_rab_setup_params[e_rab_done].e_rab_id;
         create_tunnel_req.sgw_S1u_teid[e_rab_done]        = S1AP_E_RAB_SETUP_REQ  (msg_p).e_rab_setup_params[e_rab_done].gtp_teid;
-
         memcpy(&create_tunnel_req.sgw_addr[e_rab_done],
                & S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done].sgw_addr,
                sizeof(transport_layer_addr_t));
-	
-	LOG_I(RRC,"E_RAB setup REQ: local index %d teid %u, eps id %d \n", 
-	      i,
-	      create_tunnel_req.sgw_S1u_teid[e_rab_done],
-	       create_tunnel_req.eps_bearer_id[i] );
+        LOG_I(RRC,"E_RAB setup REQ: local index %d teid %u, eps id %d \n",
+              i,
+              create_tunnel_req.sgw_S1u_teid[e_rab_done],
+              create_tunnel_req.eps_bearer_id[i] );
         inde_list[e_rab_done] = i;
-        e_rab_done++;        
-        if(e_rab_done >= nb_e_rabs_tosetup){
-            break;
+        e_rab_done++;
+
+        if(e_rab_done >= nb_e_rabs_tosetup) {
+          break;
         }
       }
+
       ue_context_p->ue_context.nb_of_e_rabs=nb_e_rabs_tosetup;
-     
-     
       create_tunnel_req.rnti       = ue_context_p->ue_context.rnti; // warning put zero above
       create_tunnel_req.num_tunnels    = e_rab_done;
-      
       // NN: not sure if we should create a new tunnel: need to check teid, etc.
       gtpv1u_create_s1u_tunnel(
         instance,
         &create_tunnel_req,
         &create_tunnel_resp);
-
       rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(
-          &ctxt,
-          &create_tunnel_resp,
-          &inde_list[0]);
-
+        &ctxt,
+        &create_tunnel_resp,
+        &inde_list[0]);
       ue_context_p->ue_context.setup_e_rabs+=nb_e_rabs_tosetup;
-
     }
-
     /* TODO parameters yet to process ... */
     {
       //      S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr;
     }
-
     rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(&ctxt, ue_context_p, 0);
-							 
     return (0);
   }
 }
 
 /*NN: careful about the typcast of xid (long -> uint8_t*/
-int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t* const ctxt_pP,
-				   rrc_eNB_ue_context_t*          const ue_context_pP,
-				   uint8_t xid ){  
-
+int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t *const ctxt_pP,
+                                       rrc_eNB_ue_context_t          *const ue_context_pP,
+                                       uint8_t xid ) {
   MessageDef      *msg_p         = NULL;
   int e_rab;
   int e_rabs_done = 0;
   int e_rabs_failed = 0;
-    
   msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_SETUP_RESP);
   S1AP_E_RAB_SETUP_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
- 
-  for (e_rab = 0; e_rab <  ue_context_pP->ue_context.setup_e_rabs ; e_rab++) {
 
-    /* only respond to the corresponding transaction */ 
+  for (e_rab = 0; e_rab <  ue_context_pP->ue_context.setup_e_rabs ; e_rab++) {
+    /* only respond to the corresponding transaction */
     //if (((xid+1)%4) == ue_context_pP->ue_context.e_rab[e_rab].xid) {
     if (xid == ue_context_pP->ue_context.e_rab[e_rab].xid) {
-      
       if (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) {
-     
-	S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id;
-	// TODO add other information from S1-U when it will be integrated
-	S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid = ue_context_pP->ue_context.enb_gtp_teid[e_rab];
-	S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr = ue_context_pP->ue_context.enb_gtp_addrs[e_rab];
-	//S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr.length += 4;
-	ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED;
-	
-	LOG_I (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d, xid %d): nb_of_e_rabs %d,  e_rab_id %d, teid: %u, addr: %d.%d.%d.%d \n ",
-	       e_rabs_done,  e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid,
-	       ue_context_pP->ue_context.nb_of_e_rabs,
-	       S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id,
-	       S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid,
-	       S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[0],
-	       S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[1],
-	       S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[2],
-	       S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[3]);
-	
-	e_rabs_done++;
-      } else if ((ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_NEW)  || 
-		 (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)){
-	LOG_D (RRC,"E-RAB is NEW or already ESTABLISHED\n");
-      }else { /* to be improved */
-	ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED;
-	S1AP_E_RAB_SETUP_RESP  (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id;
-	e_rabs_failed++;
-	// TODO add cause when it will be integrated
-      } 
-      
+        S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id;
+        // TODO add other information from S1-U when it will be integrated
+        S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid = ue_context_pP->ue_context.enb_gtp_teid[e_rab];
+        S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr = ue_context_pP->ue_context.enb_gtp_addrs[e_rab];
+        //S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr.length += 4;
+        ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED;
+        LOG_I (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d, xid %d): nb_of_e_rabs %d,  e_rab_id %d, teid: %u, addr: %d.%d.%d.%d \n ",
+               e_rabs_done,  e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid,
+               ue_context_pP->ue_context.nb_of_e_rabs,
+               S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id,
+               S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid,
+               S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[0],
+               S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[1],
+               S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[2],
+               S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[3]);
+        e_rabs_done++;
+      } else if ((ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_NEW)  ||
+                 (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)) {
+        LOG_D (RRC,"E-RAB is NEW or already ESTABLISHED\n");
+      } else { /* to be improved */
+        ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED;
+        S1AP_E_RAB_SETUP_RESP  (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id;
+        e_rabs_failed++;
+        // TODO add cause when it will be integrated
+      }
+
       S1AP_E_RAB_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done;
       S1AP_E_RAB_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed;
-      // NN: add conditions for e_rabs_failed 
+      // NN: add conditions for e_rabs_failed
     } else {
-      /*debug info for the xid */ 
+      /*debug info for the xid */
       LOG_D(RRC,"xid does not corresponds  (context e_rab index %d, status %d, xid %d/%d) \n ",
-      	     e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, ue_context_pP->ue_context.e_rab[e_rab].xid);
-    } 
+            e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, ue_context_pP->ue_context.e_rab[e_rab].xid);
+    }
   }
-      if ((e_rabs_done > 0) ){  
-
-	LOG_I(RRC,"S1AP_E_RAB_SETUP_RESP: sending the message: nb_of_erabs %d, total e_rabs %d, index %d\n",
-	      ue_context_pP->ue_context.nb_of_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab);
-	MSC_LOG_TX_MESSAGE(
-			   MSC_RRC_ENB,
-			   MSC_S1AP_ENB,
-			   (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p),
-			   sizeof(s1ap_e_rab_setup_resp_t),
-			   MSC_AS_TIME_FMT" E_RAB_SETUP_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail",
-			   MSC_AS_TIME_ARGS(ctxt_pP),
-			   ue_context_pP->ue_id_rnti,
-			   S1AP_E_RAB_SETUP_RESP (msg_p).eNB_ue_s1ap_id,
-			   e_rabs_done, e_rabs_failed);
-	
-	
-	itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
-      }
+
+  if ((e_rabs_done > 0) ) {
+    LOG_I(RRC,"S1AP_E_RAB_SETUP_RESP: sending the message: nb_of_erabs %d, total e_rabs %d, index %d\n",
+          ue_context_pP->ue_context.nb_of_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab);
+    MSC_LOG_TX_MESSAGE(
+      MSC_RRC_ENB,
+      MSC_S1AP_ENB,
+      (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p),
+      sizeof(s1ap_e_rab_setup_resp_t),
+      MSC_AS_TIME_FMT" E_RAB_SETUP_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail",
+      MSC_AS_TIME_ARGS(ctxt_pP),
+      ue_context_pP->ue_id_rnti,
+      S1AP_E_RAB_SETUP_RESP (msg_p).eNB_ue_s1ap_id,
+      e_rabs_done, e_rabs_failed);
+    itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
+  }
+
   for(int i = 0; i < NB_RB_MAX; i++) {
-      ue_context_pP->ue_context.e_rab[i].xid = -1;
+    ue_context_pP->ue_context.e_rab[i].xid = -1;
   }
-  
+
   return 0;
 }
 
@@ -1546,9 +1415,8 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
   int                             i;
   uint16_t                        ue_initial_id;
   uint32_t                        eNB_ue_s1ap_id;
-  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  struct rrc_eNB_ue_context_s *ue_context_p = NULL;
   protocol_ctxt_t              ctxt;
-
   ue_initial_id  = S1AP_E_RAB_MODIFY_REQ (msg_p).ue_initial_id;
   eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id;
   ue_context_p   = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id);
@@ -1560,27 +1428,23 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
     LOG_W(RRC, "[eNB %d] In S1AP_E_RAB_MODIFY_REQ: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id);
     int nb_of_e_rabs_failed = 0;
     MessageDef *msg_fail_p = NULL;
-
     msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP);
-
     S1AP_E_RAB_MODIFY_RESP (msg_fail_p).eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id;
     S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs = 0;
 
     for (nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; nb_of_e_rabs_failed++) {
       S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id =
-              S1AP_E_RAB_MODIFY_REQ (msg_p).e_rab_modify_params[nb_of_e_rabs_failed].e_rab_id;
+        S1AP_E_RAB_MODIFY_REQ (msg_p).e_rab_modify_params[nb_of_e_rabs_failed].e_rab_id;
       S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK;
       S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = 31;//S1ap_CauseRadioNetwork_multiple_E_RAB_ID_instances;
     }
-    S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed;
 
+    S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed;
     itti_send_msg_to_task(TASK_S1AP, instance, msg_fail_p);
     return (-1);
-
   } else {
     PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0);
     ue_context_p->ue_context.eNB_ue_s1ap_id = eNB_ue_s1ap_id;
-
     /* Save e RAB information for later */
     {
       int j;
@@ -1594,9 +1458,10 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
           // already treated
           continue;
         }
+
         for (j = i+1; j < S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; j++) {
           if (is_treated[j] == FALSE &&
-            S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) {
+              S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) {
             // handle multiple E-RAB ID
             ue_context_p->ue_context.modify_e_rab[j].status = E_RAB_STATUS_NEW;
             ue_context_p->ue_context.modify_e_rab[j].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id;
@@ -1607,6 +1472,7 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
             is_treated[j] = TRUE;
           }
         }
+
         if (is_treated[i] == TRUE) {
           // handle multiple E-RAB ID
           ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW;
@@ -1630,9 +1496,10 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
 
         for (j = 0; j < NB_RB_MAX-3; j++) {
           if (ue_context_p->ue_context.e_rab[j].param.e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) {
-            if(ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_TORELEASE || ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_DONE){
+            if(ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_TORELEASE || ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_DONE) {
               break;
             }
+
             ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW;
             ue_context_p->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_NOTHING;
             ue_context_p->ue_context.modify_e_rab[i].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id;
@@ -1641,7 +1508,6 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
             ue_context_p->ue_context.modify_e_rab[i].param.nas_pdu.buffer = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].nas_pdu.buffer;
             ue_context_p->ue_context.modify_e_rab[i].param.sgw_addr = ue_context_p->ue_context.e_rab[j].param.sgw_addr;
             ue_context_p->ue_context.modify_e_rab[i].param.gtp_teid = ue_context_p->ue_context.e_rab[j].param.gtp_teid;
-
             is_treated[i] = TRUE;
             break;
           }
@@ -1661,7 +1527,6 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
       ue_context_p->ue_context.nb_of_modify_e_rabs = S1AP_E_RAB_MODIFY_REQ  (msg_p).nb_e_rabs_tomodify;
       ue_context_p->ue_context.nb_of_failed_e_rabs = nb_of_failed_e_rabs;
     }
-
     /* TODO parameters yet to process ... */
     {
       //      S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr;
@@ -1676,36 +1541,31 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam
     {
       int nb_of_e_rabs_failed = 0;
       MessageDef *msg_fail_p = NULL;
-
       msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP);
-
       S1AP_E_RAB_MODIFY_RESP (msg_fail_p).eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id;
-//      S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs[S1AP_MAX_E_RAB];
+      //      S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs[S1AP_MAX_E_RAB];
       S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs = 0;
 
       for(nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < ue_context_p->ue_context.nb_of_failed_e_rabs; nb_of_e_rabs_failed++) {
         S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id =
-                ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].param.e_rab_id;
+          ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].param.e_rab_id;
         S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause = ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].cause;
       }
-      S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed;
 
+      S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed;
       itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p);
-
       ue_context_p->ue_context.nb_of_modify_e_rabs = 0;
       ue_context_p->ue_context.nb_of_failed_e_rabs = 0;
       memset(ue_context_p->ue_context.modify_e_rab, 0, sizeof(ue_context_p->ue_context.modify_e_rab));
-
       return (0);
     }
   }  // end of ue_context_p != NULL
 }
 
 /*NN: careful about the typcast of xid (long -> uint8_t*/
-int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t* const ctxt_pP,
-           rrc_eNB_ue_context_t*          const ue_context_pP,
-           uint8_t xid ) {
-
+int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t *const ctxt_pP,
+                                        rrc_eNB_ue_context_t          *const ue_context_pP,
+                                        uint8_t xid ) {
   MessageDef      *msg_p         = NULL;
   int i;
   int e_rab;
@@ -1715,7 +1575,6 @@ int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t* const ctxt_pP,
   S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
 
   for (e_rab = 0; e_rab < ue_context_pP->ue_context.nb_of_modify_e_rabs; e_rab++) {
-
     /* only respond to the corresponding transaction */
     if (xid == ue_context_pP->ue_context.modify_e_rab[e_rab].xid) {
       if (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_DONE) {
@@ -1728,199 +1587,198 @@ int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t* const ctxt_pP,
             break;
           }
         }
+
         if (i < ue_context_pP->ue_context.setup_e_rabs) {
           S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id;
-              // TODO add other information from S1-U when it will be integrated
-
+          // TODO add other information from S1-U when it will be integrated
           LOG_D (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d, xid %d): nb_of_modify_e_rabs %d,  e_rab_id %d \n ",
-              e_rabs_done,  e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid,
-              ue_context_pP->ue_context.nb_of_modify_e_rabs,
-              S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id);
-
+                 e_rabs_done,  e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid,
+                 ue_context_pP->ue_context.nb_of_modify_e_rabs,
+                 S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id);
           e_rabs_done++;
         } else {
           // unexpected
           S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id;
-
           S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK;
           S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause_value = 30;//S1ap_CauseRadioNetwork_unknown_E_RAB_ID;
-
           e_rabs_failed++;
         }
       } else if ((ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_NEW) ||
-          (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)){
+                 (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)) {
         LOG_D (RRC,"E-RAB is NEW or already ESTABLISHED\n");
       } else {  /* status == E_RAB_STATUS_FAILED; */
         S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id;
         // add failure cause when defined
         S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause = ue_context_pP->ue_context.modify_e_rab[e_rab].cause;
-
         e_rabs_failed++;
       }
     } else {
       /*debug info for the xid */
       LOG_D(RRC,"xid does not corresponds  (context e_rab index %d, status %d, xid %d/%d) \n ",
-             e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, ue_context_pP->ue_context.modify_e_rab[e_rab].xid);
+            e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, ue_context_pP->ue_context.modify_e_rab[e_rab].xid);
     }
   }
 
-
   S1AP_E_RAB_MODIFY_RESP (msg_p).nb_of_e_rabs = e_rabs_done;
   S1AP_E_RAB_MODIFY_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed;
+
   // NN: add conditions for e_rabs_failed
   if (e_rabs_done > 0 || e_rabs_failed > 0) {
     LOG_D(RRC,"S1AP_E_RAB_MODIFY_RESP: sending the message: nb_of_modify_e_rabs %d, total e_rabs %d, index %d\n",
-    ue_context_pP->ue_context.nb_of_modify_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab);
-MSC_LOG_TX_MESSAGE(
-     MSC_RRC_ENB,
-     MSC_S1AP_ENB,
-     (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p),
-     sizeof(s1ap_e_rab_setup_resp_t),
-     MSC_AS_TIME_FMT" E_RAB_MODIFY_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail",
-     MSC_AS_TIME_ARGS(ctxt_pP),
-     ue_context_pP->ue_id_rnti,
-     S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id,
-     e_rabs_done, e_rabs_failed);
-
+          ue_context_pP->ue_context.nb_of_modify_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab);
+    MSC_LOG_TX_MESSAGE(
+      MSC_RRC_ENB,
+      MSC_S1AP_ENB,
+      (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p),
+      sizeof(s1ap_e_rab_setup_resp_t),
+      MSC_AS_TIME_FMT" E_RAB_MODIFY_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail",
+      MSC_AS_TIME_ARGS(ctxt_pP),
+      ue_context_pP->ue_id_rnti,
+      S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id,
+      e_rabs_done, e_rabs_failed);
     itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
   }
 
   return 0;
 }
-int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *msg_name, instance_t instance){
-    uint16_t                        mme_ue_s1ap_id;
-    uint32_t                        eNB_ue_s1ap_id;
-    struct rrc_eNB_ue_context_s*    ue_context_p = NULL;
-    protocol_ctxt_t                 ctxt;
-    e_rab_release_t e_rab_release_params[S1AP_MAX_E_RAB];
-    uint8_t nb_e_rabs_torelease;
-    int erab;
-    int i;
-    uint8_t b_existed,is_existed;
-    uint8_t xid;
-    uint8_t e_rab_release_drb;
-    MessageDef *                    msg_delete_tunnels_p = NULL;
-    e_rab_release_drb = 0;
-    memcpy(&e_rab_release_params[0], &(S1AP_E_RAB_RELEASE_COMMAND (msg_p).e_rab_release_params[0]), sizeof(e_rab_release_t)*S1AP_MAX_E_RAB);
-
-    mme_ue_s1ap_id  = S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id;
-    eNB_ue_s1ap_id = S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id;
-    nb_e_rabs_torelease = S1AP_E_RAB_RELEASE_COMMAND (msg_p).nb_e_rabs_torelease;
-    ue_context_p   = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id);
-    if(ue_context_p != NULL){
-        PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0);
-
-        xid = rrc_eNB_get_next_transaction_identifier(ctxt.module_id);
-
-        LOG_D(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d  ENB_UE_S1AP_ID %d release_e_rabs %d \n",
-            mme_ue_s1ap_id, eNB_ue_s1ap_id,nb_e_rabs_torelease);
-        for(erab = 0; erab < nb_e_rabs_torelease; erab++){
-            b_existed = 0;
-            is_existed = 0;
-            for ( i = erab-1;  i>= 0; i--){
-                if (e_rab_release_params[erab].e_rab_id == e_rab_release_params[i].e_rab_id){
-                    is_existed = 1;
-                    break;
-                }
-            }
-            if(is_existed == 1){
-                //e_rab_id is existed
-                continue;
-            }
-            for ( i = 0;  i < NB_RB_MAX; i++){
-                if (e_rab_release_params[erab].e_rab_id == ue_context_p->ue_context.e_rab[i].param.e_rab_id){
-                    b_existed = 1;
-                    break;
-                }
-            }
-            if(b_existed == 0) {
-                //no e_rab_id
-                ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id;
-                ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK;
-                ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 30;
-                ue_context_p->ue_context.nb_release_of_e_rabs++;
-            } else {
-                if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_FAILED){
-                    ue_context_p->ue_context.e_rab[i].xid = xid;
-                    continue;
-                } else if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED){
-                    ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_TORELEASE;
-                    ue_context_p->ue_context.e_rab[i].xid = xid;
-                    e_rab_release_drb++;
-                }else{
-                    //e_rab_id status NG
-                    ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id;
-                    ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK;
-                    ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 0;
-                    ue_context_p->ue_context.nb_release_of_e_rabs++;
-                }
-            }
+int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *msg_name, instance_t instance) {
+  uint16_t                        mme_ue_s1ap_id;
+  uint32_t                        eNB_ue_s1ap_id;
+  struct rrc_eNB_ue_context_s    *ue_context_p = NULL;
+  protocol_ctxt_t                 ctxt;
+  e_rab_release_t e_rab_release_params[S1AP_MAX_E_RAB];
+  uint8_t nb_e_rabs_torelease;
+  int erab;
+  int i;
+  uint8_t b_existed,is_existed;
+  uint8_t xid;
+  uint8_t e_rab_release_drb;
+  MessageDef                     *msg_delete_tunnels_p = NULL;
+  e_rab_release_drb = 0;
+  memcpy(&e_rab_release_params[0], &(S1AP_E_RAB_RELEASE_COMMAND (msg_p).e_rab_release_params[0]), sizeof(e_rab_release_t)*S1AP_MAX_E_RAB);
+  mme_ue_s1ap_id  = S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id;
+  eNB_ue_s1ap_id = S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id;
+  nb_e_rabs_torelease = S1AP_E_RAB_RELEASE_COMMAND (msg_p).nb_e_rabs_torelease;
+  ue_context_p   = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id);
+
+  if(ue_context_p != NULL) {
+    PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0);
+    xid = rrc_eNB_get_next_transaction_identifier(ctxt.module_id);
+    LOG_D(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d  ENB_UE_S1AP_ID %d release_e_rabs %d \n",
+          mme_ue_s1ap_id, eNB_ue_s1ap_id,nb_e_rabs_torelease);
+
+    for(erab = 0; erab < nb_e_rabs_torelease; erab++) {
+      b_existed = 0;
+      is_existed = 0;
+
+      for ( i = erab-1;  i>= 0; i--) {
+        if (e_rab_release_params[erab].e_rab_id == e_rab_release_params[i].e_rab_id) {
+          is_existed = 1;
+          break;
         }
-        if(e_rab_release_drb > 0) {
-            //RRCConnectionReconfiguration To UE
-            rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(&ctxt, ue_context_p, xid, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.length, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.buffer);
-        } else {
-            //gtp tunnel delete
-            msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ);
-            memset(&GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
-            GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
-            for(i = 0; i < NB_RB_MAX; i++){
-               if(xid == ue_context_p->ue_context.e_rab[i].xid){
-                 GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i];
-                 ue_context_p->ue_context.enb_gtp_teid[i] = 0;
-                 memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i]));
-                 ue_context_p->ue_context.enb_gtp_ebi[i]  = 0;
-               }
-            }
+      }
+
+      if(is_existed == 1) {
+        //e_rab_id is existed
+        continue;
+      }
 
-            itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p);
+      for ( i = 0;  i < NB_RB_MAX; i++) {
+        if (e_rab_release_params[erab].e_rab_id == ue_context_p->ue_context.e_rab[i].param.e_rab_id) {
+          b_existed = 1;
+          break;
+        }
+      }
 
-            //S1AP_E_RAB_RELEASE_RESPONSE
-            rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(&ctxt, ue_context_p, xid);
+      if(b_existed == 0) {
+        //no e_rab_id
+        ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id;
+        ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK;
+        ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 30;
+        ue_context_p->ue_context.nb_release_of_e_rabs++;
+      } else {
+        if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_FAILED) {
+          ue_context_p->ue_context.e_rab[i].xid = xid;
+          continue;
+        } else if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED) {
+          ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_TORELEASE;
+          ue_context_p->ue_context.e_rab[i].xid = xid;
+          e_rab_release_drb++;
+        } else {
+          //e_rab_id status NG
+          ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id;
+          ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK;
+          ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 0;
+          ue_context_p->ue_context.nb_release_of_e_rabs++;
         }
+      }
+    }
+
+    if(e_rab_release_drb > 0) {
+      //RRCConnectionReconfiguration To UE
+      rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(&ctxt, ue_context_p, xid, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.length, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.buffer);
     } else {
-        LOG_E(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d  ENB_UE_S1AP_ID %d  Error ue_context_p NULL \n",
-            S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id, S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id);
-         return -1;
+      //gtp tunnel delete
+      msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ);
+      memset(&GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
+      GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
+
+      for(i = 0; i < NB_RB_MAX; i++) {
+        if(xid == ue_context_p->ue_context.e_rab[i].xid) {
+          GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i];
+          ue_context_p->ue_context.enb_gtp_teid[i] = 0;
+          memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i]));
+          ue_context_p->ue_context.enb_gtp_ebi[i]  = 0;
+        }
+      }
+
+      itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p);
+      //S1AP_E_RAB_RELEASE_RESPONSE
+      rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(&ctxt, ue_context_p, xid);
     }
+  } else {
+    LOG_E(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d  ENB_UE_S1AP_ID %d  Error ue_context_p NULL \n",
+          S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id, S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id);
+    return -1;
+  }
 
-    return 0;
+  return 0;
 }
 
 
-int rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, uint8_t xid){
-    int e_rabs_released = 0;
-    MessageDef   *msg_p;
+int rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t xid) {
+  int e_rabs_released = 0;
+  MessageDef   *msg_p;
+  msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_RELEASE_RESPONSE);
+  S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
 
-    msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_RELEASE_RESPONSE);
-    S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id;
-    
-    for (int i = 0;  i < NB_RB_MAX; i++){
-        if (xid == ue_context_pP->ue_context.e_rab[i].xid){
-            S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rab_release[e_rabs_released].e_rab_id = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;
-            e_rabs_released++;
-            //clear
-            memset(&ue_context_pP->ue_context.e_rab[i],0,sizeof(e_rab_param_t));
-        }
+  for (int i = 0;  i < NB_RB_MAX; i++) {
+    if (xid == ue_context_pP->ue_context.e_rab[i].xid) {
+      S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rab_release[e_rabs_released].e_rab_id = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;
+      e_rabs_released++;
+      //clear
+      memset(&ue_context_pP->ue_context.e_rab[i],0,sizeof(e_rab_param_t));
     }
-    S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_released = e_rabs_released;
-    S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_failed = ue_context_pP->ue_context.nb_release_of_e_rabs;
-    memcpy(&(S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rabs_failed[0]),&ue_context_pP->ue_context.e_rabs_release_failed[0],sizeof(e_rab_failed_t)*ue_context_pP->ue_context.nb_release_of_e_rabs);
-
-    ue_context_pP->ue_context.setup_e_rabs -= e_rabs_released;
-    LOG_I(RRC,"S1AP-E-RAB RELEASE RESPONSE: ENB_UE_S1AP_ID %d release_e_rabs %d setup_e_rabs %d \n",
-              S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id,
-              e_rabs_released, ue_context_pP->ue_context.setup_e_rabs);
-    
-    itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
-    //clear xid
-    for(int i = 0; i < NB_RB_MAX; i++) {
-        ue_context_pP->ue_context.e_rab[i].xid = -1;
-    }
-    //clear release e_rabs
-    ue_context_pP->ue_context.nb_release_of_e_rabs = 0;
-    memset(&ue_context_pP->ue_context.e_rabs_release_failed[0],0,sizeof(e_rab_failed_t)*S1AP_MAX_E_RAB);
-    return 0;
+  }
+
+  S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_released = e_rabs_released;
+  S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_failed = ue_context_pP->ue_context.nb_release_of_e_rabs;
+  memcpy(&(S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rabs_failed[0]),&ue_context_pP->ue_context.e_rabs_release_failed[0],sizeof(e_rab_failed_t)*ue_context_pP->ue_context.nb_release_of_e_rabs);
+  ue_context_pP->ue_context.setup_e_rabs -= e_rabs_released;
+  LOG_I(RRC,"S1AP-E-RAB RELEASE RESPONSE: ENB_UE_S1AP_ID %d release_e_rabs %d setup_e_rabs %d \n",
+        S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id,
+        e_rabs_released, ue_context_pP->ue_context.setup_e_rabs);
+  itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p);
+
+  //clear xid
+  for(int i = 0; i < NB_RB_MAX; i++) {
+    ue_context_pP->ue_context.e_rab[i].xid = -1;
+  }
+
+  //clear release e_rabs
+  ue_context_pP->ue_context.nb_release_of_e_rabs = 0;
+  memset(&ue_context_pP->ue_context.e_rabs_release_failed[0],0,sizeof(e_rab_failed_t)*S1AP_MAX_E_RAB);
+  return 0;
 }
 
 /*------------------------------------------------------------------------------*/
@@ -1933,125 +1791,143 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
   uint32_t Ns = 0;  /* Ns: max(1,nB/T) */
   uint8_t i_s;  /* i_s = floor(UE_ID/N) mod Ns */
   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]);
-      if (RC.rrc[instance]->configuration.mcc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc
-          && RC.rrc[instance]->configuration.mnc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc
-          && RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) {
-          for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-              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];
-              if (Tc < PCCH_Config__defaultPagingCycle_rf32 || Tc > PCCH_Config__defaultPagingCycle_rf256) {
-                  continue;
-              }
-              Tue = (uint8_t)S1AP_PAGING_IND(msg_p).paging_drx;
-              /* 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];
-              switch (pcch_nB) {
-                case PCCH_Config__nB_fourT:
-                    Ns = 4;
-                    break;
-                case PCCH_Config__nB_twoT:
-                    Ns = 2;
-                    break;
-                default:
-                    Ns = 1;
-                    break;
-              }
-              /* set N = min(T,nB) */
-              if (pcch_nB > PCCH_Config__nB_oneT) {
-                switch (pcch_nB) {
-                case PCCH_Config__nB_halfT:
-                  N = T/2;
-                  break;
-                case PCCH_Config__nB_quarterT:
-                  N = T/4;
-                  break;
-                case PCCH_Config__nB_oneEighthT:
-                  N = T/8;
-                  break;
-                case PCCH_Config__nB_oneSixteenthT:
-                  N = T/16;
-                  break;
-                case PCCH_Config__nB_oneThirtySecondT:
-                  N = T/32;
-                  break;
-                default:
-                  /* pcch_nB error */
-                  LOG_E(RRC, "[eNB %d] In S1AP_PAGING_IND:  pcch_nB error (pcch_nB %d) \n",
-                      instance, pcch_nB);
-                  return (-1);
-                }
-              } else {
-                N = T;
-              }
-
-              /* insert data to UE_PF_PO or update data in UE_PF_PO */
-              pthread_mutex_lock(&ue_pf_po_mutex);
-              uint8_t i = 0;
-              for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
-                if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value))
-                    || (UE_PF_PO[CC_id][i].enable_flag != TRUE)) {
-                    /* set T = min(Tc,Tue) */
-                    UE_PF_PO[CC_id][i].T = T;
-                    /* set UE_ID */
-                    UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)S1AP_PAGING_IND(msg_p).ue_index_value;
-                    /* calculate PF and PO */
-                    /* set PF_min : SFN mod T = (T div N)*(UE_ID mod N) */
-                    UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N);
-                    /* set PO */
-                    /* i_s = floor(UE_ID/N) mod Ns */
-                    i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns);
-                    if (Ns == 1) {
-                        UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? 9 : 0;
-                    } else if (Ns==2) {
-                        UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4+(5*i_s)) : (5*i_s);
-                    } else if (Ns==4) {
-                        UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1)));
-                    }
-                    if (UE_PF_PO[CC_id][i].enable_flag == TRUE) {
-                        //paging exist UE log
-                        LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Update exist UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
-                    } else {
-                        /* set enable_flag */
-                        UE_PF_PO[CC_id][i].enable_flag = TRUE;
-                        //paging new UE log
-                        LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Insert a new UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
-                    }
-                    break;
-                }
-              }
-              pthread_mutex_unlock(&ue_pf_po_mutex);
-
-              uint32_t length;
-              uint8_t buffer[RRC_BUF_SIZE];
-              uint8_t *message_buffer;
-              /* Transfer data to PDCP */
-              MessageDef *message_p;
-              message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_PCCH_DATA_REQ);
-              /* Create message for PDCP (DLInformationTransfer_t) */
-              length = do_Paging (instance,
-                                  buffer,
-                                  S1AP_PAGING_IND(msg_p).ue_paging_identity,
-                                  S1AP_PAGING_IND(msg_p).cn_domain);
-              message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length);
-              /* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */
-              memcpy (message_buffer, buffer, length);
-              RRC_PCCH_DATA_REQ (message_p).sdu_size  = length;
-              RRC_PCCH_DATA_REQ (message_p).sdu_p     = message_buffer;
-              RRC_PCCH_DATA_REQ (message_p).mode      = PDCP_TRANSMISSION_MODE_TRANSPARENT;  /* not used */
-              RRC_PCCH_DATA_REQ (message_p).rnti      = P_RNTI;
-              RRC_PCCH_DATA_REQ (message_p).ue_index  = i;
-              RRC_PCCH_DATA_REQ (message_p).CC_id  = CC_id;
-              LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length);
-              itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p);
+
+    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]);
+
+    if (RC.rrc[instance]->configuration.mcc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc
+        && RC.rrc[instance]->configuration.mnc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc
+        && RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) {
+      for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+        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];
+
+        if (Tc < PCCH_Config__defaultPagingCycle_rf32 || Tc > PCCH_Config__defaultPagingCycle_rf256) {
+          continue;
+        }
+
+        Tue = (uint8_t)S1AP_PAGING_IND(msg_p).paging_drx;
+        /* 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];
+
+        switch (pcch_nB) {
+          case PCCH_Config__nB_fourT:
+            Ns = 4;
+            break;
+
+          case PCCH_Config__nB_twoT:
+            Ns = 2;
+            break;
+
+          default:
+            Ns = 1;
+            break;
+        }
+
+        /* set N = min(T,nB) */
+        if (pcch_nB > PCCH_Config__nB_oneT) {
+          switch (pcch_nB) {
+            case PCCH_Config__nB_halfT:
+              N = T/2;
+              break;
+
+            case PCCH_Config__nB_quarterT:
+              N = T/4;
+              break;
+
+            case PCCH_Config__nB_oneEighthT:
+              N = T/8;
+              break;
+
+            case PCCH_Config__nB_oneSixteenthT:
+              N = T/16;
+              break;
+
+            case PCCH_Config__nB_oneThirtySecondT:
+              N = T/32;
+              break;
+
+            default:
+              /* pcch_nB error */
+              LOG_E(RRC, "[eNB %d] In S1AP_PAGING_IND:  pcch_nB error (pcch_nB %d) \n",
+                    instance, pcch_nB);
+              return (-1);
+          }
+        } else {
+          N = T;
+        }
+
+        /* insert data to UE_PF_PO or update data in UE_PF_PO */
+        pthread_mutex_lock(&ue_pf_po_mutex);
+        uint8_t i = 0;
+
+        for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+          if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value))
+              || (UE_PF_PO[CC_id][i].enable_flag != TRUE)) {
+            /* set T = min(Tc,Tue) */
+            UE_PF_PO[CC_id][i].T = T;
+            /* set UE_ID */
+            UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)S1AP_PAGING_IND(msg_p).ue_index_value;
+            /* calculate PF and PO */
+            /* set PF_min : SFN mod T = (T div N)*(UE_ID mod N) */
+            UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N);
+            /* set PO */
+            /* i_s = floor(UE_ID/N) mod Ns */
+            i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns);
+
+            if (Ns == 1) {
+              UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? 9 : 0;
+            } else if (Ns==2) {
+              UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4+(5*i_s)) : (5*i_s);
+            } else if (Ns==4) {
+              UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1)));
+            }
+
+            if (UE_PF_PO[CC_id][i].enable_flag == TRUE) {
+              //paging exist UE log
+              LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Update exist UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
+            } else {
+              /* set enable_flag */
+              UE_PF_PO[CC_id][i].enable_flag = TRUE;
+              //paging new UE log
+              LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Insert a new UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
+            }
+
+            break;
           }
+        }
+
+        pthread_mutex_unlock(&ue_pf_po_mutex);
+        uint32_t length;
+        uint8_t buffer[RRC_BUF_SIZE];
+        uint8_t *message_buffer;
+        /* Transfer data to PDCP */
+        MessageDef *message_p;
+        message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_PCCH_DATA_REQ);
+        /* Create message for PDCP (DLInformationTransfer_t) */
+        length = do_Paging (instance,
+                            buffer,
+                            S1AP_PAGING_IND(msg_p).ue_paging_identity,
+                            S1AP_PAGING_IND(msg_p).cn_domain);
+        message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length);
+        /* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */
+        memcpy (message_buffer, buffer, length);
+        RRC_PCCH_DATA_REQ (message_p).sdu_size  = length;
+        RRC_PCCH_DATA_REQ (message_p).sdu_p     = message_buffer;
+        RRC_PCCH_DATA_REQ (message_p).mode      = PDCP_TRANSMISSION_MODE_TRANSPARENT;  /* not used */
+        RRC_PCCH_DATA_REQ (message_p).rnti      = P_RNTI;
+        RRC_PCCH_DATA_REQ (message_p).ue_index  = i;
+        RRC_PCCH_DATA_REQ (message_p).CC_id  = CC_id;
+        LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length);
+        itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p);
       }
+    }
   }
 
   return (0);
diff --git a/openair2/RRC/NR/L2_interface_NR.c b/openair2/RRC/NR/L2_interface_NR.c
new file mode 100644
index 0000000000000000000000000000000000000000..91834d9c9d64f4742cec1cd2b9d538a8ca9b8065
--- /dev/null
+++ b/openair2/RRC/NR/L2_interface_NR.c
@@ -0,0 +1,519 @@
+/*
+ * 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 l2_interface.c
+ * \brief layer 2 interface, used to support different RRC sublayer
+ * \author Raymond Knopp and Navid Nikaein
+ * \date 2010-2014
+ * \version 1.0
+ * \company Eurecom
+ * \email: raymond.knopp@eurecom.fr
+ */
+
+#include "platform_types.h"
+//#include "openair_defs.h"
+//#include "openair_proto.h"
+#include "defs.h"
+#include "extern.h"
+//#include "mac_lchan_interface.h"
+//#include "openair_rrc_utils.h"
+//#include "openair_rrc_main.h"
+#include "UTIL/LOG/log.h"
+#include "rrc_eNB_UE_context.h"
+#include "pdcp.h"
+#include "msc.h"
+#include "common/ran_context.h"
+
+#ifdef PHY_EMUL
+#include "SIMULATION/simulation_defs.h"
+extern EMULATION_VARS *Emul_vars;
+extern eNB_MAC_INST *eNB_mac_inst;
+extern UE_MAC_INST *UE_mac_inst;
+#endif
+
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+#endif
+
+#include "flexran_agent_extern.h"
+
+//#define RRC_DATA_REQ_DEBUG
+//#define DEBUG_RRC 1
+
+
+extern RAN_CONTEXT_t RC;
+
+//------------------------------------------------------------------------------
+int8_t
+mac_rrc_data_req(
+  const module_id_t Mod_idP,
+  const int         CC_id,
+  const frame_t     frameP,
+  const rb_id_t     Srb_id,
+  const uint8_t     Nb_tb,
+  uint8_t*    const buffer_pP,
+  const uint8_t     mbsfn_sync_area
+)
+//--------------------------------------------------------------------------
+{
+  asn_enc_rval_t enc_rval;
+  SRB_INFO *Srb_info;
+  uint8_t Sdu_size                = 0;
+  uint8_t sfn                     = (uint8_t)((frameP>>2)&0xff);
+
+
+#ifdef DEBUG_RRC
+  int i;
+  LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id);
+#endif
+
+  eNB_RRC_INST *rrc;
+  rrc_eNB_carrier_data_t *carrier;
+  BCCH_BCH_Message_t *mib;
+
+
+    rrc     = RC.rrc[Mod_idP];
+    carrier = &rrc->carrier[0];
+    mib     = &carrier->mib;
+
+    if((Srb_id & RAB_OFFSET) == BCCH) {
+      if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) {
+        return 0;
+      }
+
+      // All even frames transmit SIB in SF 5
+      AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255, 
+		  "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP);
+
+      if ((frameP%2) == 0) {
+        memcpy(&buffer_pP[0],
+               RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
+               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
+
+#if 0 //defined(ENABLE_ITTI)
+        {
+          MessageDef *message_p;
+          int sib1_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1;
+          int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
+
+          if (sib1_size > sdu_size) {
+            LOG_E(RRC, "SIB1 SDU larger than BCCH SDU buffer size (%d, %d)", sib1_size, sdu_size);
+            sib1_size = sdu_size;
+          }
+
+          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ);
+          RRC_MAC_BCCH_DATA_REQ (message_p).frame    = frameP;
+          RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib1_size;
+          memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
+          memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
+                  RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
+                  sib1_size);
+          RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
+
+          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+        }
+#endif
+
+#ifdef DEBUG_RRC
+        LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP);
+
+        for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1; i++) {
+          LOG_T(RRC,"%x.",buffer_pP[i]);
+        }
+
+        LOG_T(RRC,"\n");
+#endif
+
+        return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
+      } // All RFN mod 8 transmit SIB2-3 in SF 5
+      else if ((frameP%8) == 1) {
+        memcpy(&buffer_pP[0],
+               RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
+               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
+
+#if 0 //defined(ENABLE_ITTI)
+        {
+          MessageDef *message_p;
+          int sib23_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23;
+          int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
+
+          if (sib23_size > sdu_size) {
+            LOG_E(RRC, "SIB23 SDU larger than BCCH SDU buffer size (%d, %d)", sib23_size, sdu_size);
+            sib23_size = sdu_size;
+          }
+
+          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ);
+          RRC_MAC_BCCH_DATA_REQ (message_p).frame = frameP;
+          RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib23_size;
+          memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
+          memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
+                  RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
+                  sib23_size);
+          RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
+
+          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+        }
+#endif
+
+#ifdef DEBUG_RRC
+        LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP);
+
+        for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23; i++) {
+          LOG_T(RRC,"%x.",buffer_pP[i]);
+        }
+
+        LOG_T(RRC,"\n");
+#endif
+        return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
+      } else {
+        return(0);
+      }
+    }
+    if( (Srb_id & RAB_OFFSET ) == MIBCH) {
+
+        mib->message.systemFrameNumber.buf = &sfn;
+	enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message,
+					 (void*)mib,
+					 carrier->MIB,
+					 24);
+	LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded);
+	buffer_pP[0]=carrier->MIB[0];
+	buffer_pP[1]=carrier->MIB[1];
+	buffer_pP[2]=carrier->MIB[2];
+	AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
+		     enc_rval.failed_type->name, enc_rval.encoded);
+	return(3);
+    }
+
+    if( (Srb_id & RAB_OFFSET ) == CCCH) {
+      LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id);
+
+      if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) {
+        LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP);
+        return -1;
+      }
+
+      Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0;
+
+      // check if data is there for MAC
+      if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer
+        LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload);
+
+#if 0 // defined(ENABLE_ITTI)
+        {
+          MessageDef *message_p;
+          int ccch_size = Srb_info->Tx_buffer.payload_size;
+          int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu);
+
+          if (ccch_size > sdu_size) {
+            LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", ccch_size, sdu_size);
+            ccch_size = sdu_size;
+          }
+
+          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_CCCH_DATA_REQ);
+          RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP;
+          RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size;
+          memset (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, 0, CCCH_SDU_SIZE);
+          memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, Srb_info->Tx_buffer.Payload, ccch_size);
+          RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index;
+
+          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+        }
+#endif
+
+        memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size);
+        Sdu_size = Srb_info->Tx_buffer.payload_size;
+        Srb_info->Tx_buffer.payload_size=0;
+      }
+
+      return (Sdu_size);
+    }
+
+    if( (Srb_id & RAB_OFFSET ) == PCCH) {
+      LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id);
+
+      // check if data is there for MAC
+      if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer
+        LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area],
+               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]);
+
+#if 0 //defined(ENABLE_ITTI)
+        {
+          MessageDef *message_p;
+          int pcch_size = RC.rrc[Mod_idP]->arrier[CC_id].sizeof_paging[mbsfn_sync_area];
+          int sdu_size = sizeof(RRC_MAC_PCCH_DATA_REQ (message_p).sdu);
+
+          if (pcch_size > sdu_size) {
+            LOG_E(RRC, "SDU larger than PCCH SDU buffer size (%d, %d)", pcch_size, sdu_size);
+            pcch_size = sdu_size;
+          }
+
+          message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_PCCH_DATA_REQ);
+          RRC_MAC_PCCH_DATA_REQ (message_p).frame = frameP;
+          RRC_MAC_PCCH_DATA_REQ (message_p).sdu_size = pcch_size;
+          memset (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, 0, PCCH_SDU_SIZE);
+          memcpy (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], pcch_size);
+          RRC_MAC_PCCH_DATA_REQ (message_p).enb_index = eNB_index;
+
+          itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+        }
+#endif
+
+        memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]);
+        Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area];
+        RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0;
+      }
+
+      return (Sdu_size);
+    }
+
+#if defined(Rel10) || defined(Rel14)
+
+    if((Srb_id & RAB_OFFSET) == MCCH) {
+      if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) {
+        return 0;  // this parameter is set in function init_mcch in rrc_eNB.c
+      }
+
+
+#if 0 // defined(ENABLE_ITTI)
+      {
+        MessageDef *message_p;
+        int mcch_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area];
+        int sdu_size = sizeof(RRC_MAC_MCCH_DATA_REQ (message_p).sdu);
+
+        if (mcch_size > sdu_size) {
+          LOG_E(RRC, "SDU larger than MCCH SDU buffer size (%d, %d)", mcch_size, sdu_size);
+          mcch_size = sdu_size;
+        }
+
+        message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_MCCH_DATA_REQ);
+        RRC_MAC_MCCH_DATA_REQ (message_p).frame = frameP;
+        RRC_MAC_MCCH_DATA_REQ (message_p).sdu_size = mcch_size;
+        memset (RRC_MAC_MCCH_DATA_REQ (message_p).sdu, 0, MCCH_SDU_SIZE);
+        memcpy (RRC_MAC_MCCH_DATA_REQ (message_p).sdu,
+                RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
+                mcch_size);
+        RRC_MAC_MCCH_DATA_REQ (message_p).enb_index = eNB_index;
+        RRC_MAC_MCCH_DATA_REQ (message_p).mbsfn_sync_area = mbsfn_sync_area;
+
+        itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
+      }
+#endif
+
+      memcpy(&buffer_pP[0],
+             RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
+             RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
+
+#ifdef DEBUG_RRC
+      LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP);
+
+      for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) {
+        LOG_T(RRC,"%x.",buffer_pP[i]);
+      }
+
+      LOG_T(RRC,"\n");
+#endif
+
+      return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
+      //      }
+      //else
+      //return(0);
+    }
+
+#endif //Rel10 || Rel14
+
+#ifdef Rel14
+    if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR){
+        memcpy(&buffer_pP[0],
+               RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR,
+               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
+        return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
+    }
+
+    if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR){ // First SI message with SIB2/3
+        memcpy(&buffer_pP[0],
+               RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR,
+               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR);
+        return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR);
+    }
+
+#endif
+
+
+  return(0);
+}
+
+//------------------------------------------------------------------------------
+int8_t
+mac_rrc_data_ind(
+  const module_id_t     module_idP,
+  const int             CC_id,
+  const frame_t         frameP,
+  const sub_frame_t     sub_frameP,
+  const rnti_t          rntiP,
+  const rb_id_t         srb_idP,
+  const uint8_t*        sduP,
+  const sdu_size_t      sdu_lenP,
+  const uint8_t         mbsfn_sync_areaP
+)
+//--------------------------------------------------------------------------
+{
+  SRB_INFO *Srb_info;
+  protocol_ctxt_t ctxt;
+  sdu_size_t      sdu_size = 0;
+
+  /* for no gcc warnings */
+  (void)sdu_size;
+
+  /*
+  int si_window;
+   */
+  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, rntiP, frameP, sub_frameP,0);
+
+    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);
+    
+#if 0 //defined(ENABLE_ITTI)
+    {
+      MessageDef *message_p;
+      int msg_sdu_size = sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu);
+
+      if (sdu_lenP > msg_sdu_size) {
+        LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_lenP, msg_sdu_size);
+        sdu_size = msg_sdu_size;
+      } else {
+        sdu_size = sdu_lenP;
+      }
+
+      message_p = itti_alloc_new_message (TASK_MAC_ENB, RRC_MAC_CCCH_DATA_IND);
+      RRC_MAC_CCCH_DATA_IND (message_p).frame     = frameP;
+      RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frameP;
+      RRC_MAC_CCCH_DATA_IND (message_p).rnti      = rntiP;
+      RRC_MAC_CCCH_DATA_IND (message_p).sdu_size  = sdu_size;
+      RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
+      memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
+      memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, sduP, sdu_size);
+      LOG_D(RRC,"[eNB %d] Sending message to RRC task\n",module_idP);
+      itti_send_msg_to_task (TASK_RRC_ENB, ctxt.instance, message_p);
+    }
+#else
+
+    //    msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id);
+    if (sdu_lenP > 0) {
+      memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP);
+      Srb_info->Rx_buffer.payload_size = sdu_lenP;
+      rrc_eNB_decode_ccch(&ctxt, Srb_info, CC_id);
+    }
+
+#endif
+
+  return(0);
+
+}
+
+//------------------------------------------------------------------------------
+int
+mac_eNB_get_rrc_status(
+  const module_id_t Mod_idP,
+  const rnti_t      rntiP
+)
+//------------------------------------------------------------------------------
+{
+  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  ue_context_p = rrc_eNB_get_ue_context(
+                   RC.rrc[Mod_idP],
+                   rntiP);
+
+  if (ue_context_p != NULL) {
+    return(ue_context_p->ue_context.Status);
+  } else {
+    return RRC_INACTIVE;
+  }
+}
+
+void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
+			    const int CC_idP,
+			    const frame_t frameP,
+			    const sub_frame_t subframeP,
+			    const rnti_t rntiP)
+{
+  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  ue_context_p = rrc_eNB_get_ue_context(
+                   RC.rrc[Mod_instP],
+                   rntiP);
+
+  if (ue_context_p != NULL) {
+    LOG_I(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP);
+    if(ue_context_p->ue_context.ul_failure_timer == 0)
+      ue_context_p->ue_context.ul_failure_timer=1;
+  }
+  else {
+    LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP);
+  }
+  if (rrc_agent_registered[Mod_instP]) {
+    agent_rrc_xface[Mod_instP]->flexran_agent_notify_ue_state_change(Mod_instP,
+								     rntiP,
+								     PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
+  }
+//  rrc_mac_remove_ue(Mod_instP,rntiP);
+}
+
+void mac_eNB_rrc_uplane_failure(const module_id_t Mod_instP,
+                const int CC_idP,
+                const frame_t frameP,
+                const sub_frame_t subframeP,
+                const rnti_t rntiP)
+{
+    struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+    ue_context_p = rrc_eNB_get_ue_context(
+                     RC.rrc[Mod_instP],
+                     rntiP);
+    if (ue_context_p != NULL) {
+      LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP);
+
+      if(ue_context_p->ue_context.ul_failure_timer == 0)
+          ue_context_p->ue_context.ul_failure_timer=19999;
+    }
+    else {
+      LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP);
+    }
+}
+
+void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, 
+			    const int CC_idP, 
+			    const frame_t frameP,
+			    const sub_frame_t subframeP,
+			    const rnti_t rntiP)
+{
+  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  ue_context_p = rrc_eNB_get_ue_context(
+                   RC.rrc[Mod_instP],
+                   rntiP);
+
+  if (ue_context_p != NULL) {
+    LOG_I(RRC,"Frame %d, Subframe %d: UE %x to UL in synch\n",
+          frameP, subframeP, rntiP);
+    ue_context_p->ue_context.ul_failure_timer = 0;
+  } else {
+    LOG_E(RRC,"Frame %d, Subframe %d: UE %x unknown \n",
+          frameP, subframeP, rntiP);
+  }
+}
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c
new file mode 100644
index 0000000000000000000000000000000000000000..58440134628ab9faf1159c60977f1f913e039184
--- /dev/null
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c
@@ -0,0 +1,3238 @@
+/*
+ * 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 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
+*/
+
+#ifdef USER_MODE
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdlib.h> /* for atoi(3) */
+#include <unistd.h> /* for getopt(3) */
+#include <string.h> /* for strerror(3) */
+#include <sysexits.h> /* for EX_* exit codes */
+#include <errno.h>  /* for errno */
+#else
+#include <linux/module.h>  /* Needed by all modules */
+#endif
+#ifdef USER_MODE
+//#include "RRC/LITE/defs.h"
+//#include "COMMON/mac_rrc_primitives.h"
+#include "UTIL/LOG/log.h"
+#endif
+#include <asn_application.h>
+#include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */
+#include <per_encoder.h>
+
+#include "RRC/NR/defs_NR.h"
+//#include "RRC/LITE/extern.h"
+
+#if defined(Rel15)
+#include "assertions.h"
+//#include "RRCConnectionRequest.h"
+//#include "UL-CCCH-Message.h"
+#include "UL-DCCH-Message.h"
+//#include "DL-CCCH-Message.h"
+#include "DL-DCCH-Message.h"
+//#include "EstablishmentCause.h"
+//#include "RRCConnectionSetup.h"
+#include "SRB-ToAddModList.h"
+#include "DRB-ToAddModList.h"
+//#include "MCCH-Message.h"
+//#define MRB1 1
+
+//#include "RRCConnectionSetupComplete.h"
+//#include "RRCConnectionReconfigurationComplete.h"
+//#include "RRCConnectionReconfiguration.h"
+#include "MIB.h"
+//#include "SystemInformation.h"
+
+#include "SIB1.h"
+#include "ServingCellConfigCommon.h"
+//#include "SIB-Type.h"
+
+//#include "BCCH-DL-SCH-Message.h"
+
+//#include "PHY/defs.h"
+
+#include "MeasObjectToAddModList.h"
+#include "ReportConfigToAddModList.h"
+#include "MeasIdToAddModList.h"
+#include "gnb_config.h"
+#endif
+
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+#endif
+
+#include "common/ran_context.h"
+
+//#include "PHY/defs.h"
+#ifndef USER_MODE
+#define msg printk
+#ifndef errno
+int errno;
+#endif
+#else
+# if !defined (msg)
+#   define msg printf
+# endif
+#endif
+
+//#define XER_PRINT
+
+typedef struct xer_sprint_string_s {
+  char *string;
+  size_t string_size;
+  size_t string_index;
+} xer_sprint_string_t;
+
+//repplace LTE
+//extern unsigned char NB_eNB_INST;
+extern unsigned char NB_gNB_INST;
+extern uint8_t usim_test;
+
+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}
+};// CellId 8
+
+/*
+ * This is a helper function for xer_sprint, which directs all incoming data
+ * into the provided string.
+ */
+static int xer__print2s_NR (const void *buffer, size_t size, void *app_key)
+{
+  xer_sprint_string_t *string_buffer = (xer_sprint_string_t *) app_key;
+  size_t string_remaining = string_buffer->string_size - string_buffer->string_index;
+
+  if (string_remaining > 0) {
+    if (size > string_remaining) {
+      size = string_remaining;
+    }
+
+    memcpy(&string_buffer->string[string_buffer->string_index], buffer, size);
+    string_buffer->string_index += size;
+  }
+
+  return 0;
+}
+
+int xer_sprint_NR (char *string, size_t string_size, asn_TYPE_descriptor_t *td, void *sptr)
+{
+  asn_enc_rval_t er;
+  xer_sprint_string_t string_buffer;
+
+  string_buffer.string = string;
+  string_buffer.string_size = string_size;
+  string_buffer.string_index = 0;
+
+  er = xer_encode(td, sptr, XER_F_BASIC, xer__print2s, &string_buffer);
+
+  if (er.encoded < 0) {
+    LOG_E(RRC, "xer_sprint encoding error (%zd)!", er.encoded);
+    er.encoded = string_buffer.string_size;
+  } else {
+    if (er.encoded > string_buffer.string_size) {
+      LOG_E(RRC, "xer_sprint string buffer too small, got %zd need %zd!", string_buffer.string_size, er.encoded);
+      er.encoded = string_buffer.string_size;
+    }
+  }
+
+  return er.encoded;
+}
+
+uint16_t get_adjacent_cell_id_NR(uint8_t Mod_id,uint8_t index)
+{
+  return(two_tier_hexagonal_adjacent_cellIds[Mod_id][index]);
+}
+/* This only works for the hexagonal topology...need a more general function for other topologies */
+
+uint8_t get_adjacent_cell_mod_id_NR(uint16_t phyCellId)
+{
+  uint8_t i;
+
+  for(i=0; i<7; i++) {
+    if(two_tier_hexagonal_cellIds[i] == phyCellId) {
+      return i;
+    }
+  }
+
+  LOG_E(RRC,"\nCannot get adjacent cell mod id! Fatal error!\n");
+  return 0xFF; //error!
+}
+
+//------------------------------------------------------------------------------
+
+uint8_t do_MIB_NR(rrc_gNB_carrier_data_t *carrier, 
+                  uint32_t frame, 
+                  uint32_t ssb_SubcarrierOffset, 
+                  uint32_t pdcch_ConfigSIB1, 
+                  uint32_t subCarrierSpacingCommon, 
+                  uint32_t dmrs_TypeA_Position)
+{
+
+  asn_enc_rval_t enc_rval;
+
+  BCCH_BCH_Message_t *mib=&carrier->mib
+  memset(mib,0,sizeof(BCCH_BCH_Message_t));
+  mib->message.present = BCCH_BCH_MessageType_PR_mib;
+  
+  //36.331 SFN BIT STRING (SIZE (8)  , 38.331 SFN BIT STRING (SIZE (6))
+  uint8_t sfn = (uint8_t)((frame>>4)&0x3f);
+  mib->message.choice.mib.systemFrameNumber.buf = &sfn;
+  mib->message.choice.mib.systemFrameNumber.size = 1;
+  mib->message.choice.mib.systemFrameNumber.bits_unused=0;
+
+  //38.331 spare BIT STRING (SIZE (1))
+  uint8_t *spare= calloc(1, sizeof(uint8_t));
+  if (spare == NULL) abort();
+  mib->message.choice.mib.spare.buf = (uint8_t *)spare;
+  mib->message.choice.mib.spare.size = 1;
+  mib->message.choice.mib.spare.bits_unused = 7;  // This makes a spare of 1 bits
+
+  mib->message.choice.mib.ssb_SubcarrierOffset = ssb_SubcarrierOffset;
+  mib->message.choice.mib.pdcch_ConfigSIB1 = pdcch_ConfigSIB1;
+  
+  switch (subCarrierSpacingCommon) {
+    case 15:
+      mib->message.choice.mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
+      break;
+
+    case 30:
+      mib->message.choice.mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
+      break;
+
+    case 60:
+      mib->message.choice.mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
+      break;
+
+    case 120:
+      mib->message.choice.mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
+      break;
+
+    default:
+    AssertFatal(1==0,"Unknown subCarrierSpacingCommon %d\n",subCarrierSpacingCommon);
+  }
+
+    switch (dmrs_TypeA_Position) {
+    case 2:
+      mib->message.choice.mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
+      break;
+
+    case 3:
+      mib->message.choice.mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos3;
+      break;
+
+    default:
+    AssertFatal(1==0,"Unknown dmrs_TypeA_Position %d\n",dmrs_TypeA_Position);
+
+  }
+
+  //  assign_enum
+  mib->message.choice.mib.cellBarred = MIB__cellBarred_notBarred;
+  //  assign_enum
+  mib->message.choice.mib.intraFreqReselection = MIB__intraFreqReselection_notAllowed;
+
+  
+
+  //encode MIB to data
+  enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message,
+                                   (void*)mib,
+                                   carrier->MIB,
+                                   24);
+  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
+               enc_rval.failed_type->name, enc_rval.encoded);
+
+
+  if (enc_rval.encoded==-1) {
+    return(-1);
+  }
+
+  return((enc_rval.encoded+7)/8);
+}
+
+//------------------------------------------------------------------------------
+
+uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier,
+		              int Mod_id,
+                  int CC_id
+                  #if defined(ENABLE_ITTI)
+                  , gNB_RrcConfigurationReq *configuration
+                  #endif
+                  )
+{
+
+  //  SystemInformation_t systemInformation;
+  PLMN_IdentityInfo_t PLMN_identity_info;
+  MCC_MNC_Digit_t dummy_mcc[3],dummy_mnc[3];
+  asn_enc_rval_t enc_rval;
+  SchedulingInfo_t schedulingInfo;
+  SIB_Type_t sib_type;
+
+  uint8_t *buffer                      = carrier->SIB1;
+  BCCH_DL_SCH_Message_t *bcch_message  = &carrier->siblock1;
+  SIB1_t **sib1 = &carrier->sib1;
+
+  
+  memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t));
+  bcch_message->message.present = BCCH_DL_SCH_MessageType_PR_c1;
+  bcch_message->message.choice.c1.present = 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,sizeof(PLMN_IdentityInfo_t));
+  memset(&schedulingInfo,0,sizeof(SchedulingInfo_t));
+  memset(&sib_type,0,sizeof(SIB_Type_t));
+
+
+
+  PLMN_identity_info.plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
+  memset(PLMN_identity_info.plmn_Identity.mcc,0,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
+
+  asn_set_empty(&PLMN_identity_info.plmn_Identity.mcc->list);//.size=0;
+
+#if defined(ENABLE_ITTI)
+  dummy_mcc[0] = (configuration->mcc / 100) % 10;
+  dummy_mcc[1] = (configuration->mcc / 10) % 10;
+  dummy_mcc[2] = (configuration->mcc / 1) % 10;
+#else
+  dummy_mcc[0] = 0;
+  dummy_mcc[1] = 0;
+  dummy_mcc[2] = 1;
+#endif
+  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[0]);
+  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[1]);
+  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[2]);
+
+  PLMN_identity_info.plmn_Identity.mnc.list.size=0;
+  PLMN_identity_info.plmn_Identity.mnc.list.count=0;
+#if defined(ENABLE_ITTI)
+
+  if (configuration->mnc >= 100) {
+    dummy_mnc[0] = (configuration->mnc / 100) % 10;
+    dummy_mnc[1] = (configuration->mnc / 10) % 10;
+    dummy_mnc[2] = (configuration->mnc / 1) % 10;
+  } else {
+    if (configuration->mnc_digit_length == 2) {
+      dummy_mnc[0] = (configuration->mnc / 10) % 10;
+      dummy_mnc[1] = (configuration->mnc / 1) % 10;
+      dummy_mnc[2] = 0xf;
+    } else {
+      dummy_mnc[0] = (configuration->mnc / 100) % 100;
+      dummy_mnc[1] = (configuration->mnc / 10) % 10;
+      dummy_mnc[2] = (configuration->mnc / 1) % 10;
+    }
+  }
+
+#else
+  dummy_mnc[0] = 0;
+  dummy_mnc[1] = 1;
+  dummy_mnc[2] = 0xf;
+#endif
+  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy_mnc[0]);
+  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy_mnc[1]);
+
+  if (dummy_mnc[2] != 0xf) {
+    ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy_mnc[2]);
+  }
+
+  //assign_enum(&PLMN_identity_info.cellReservedForOperatorUse,PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved);
+  PLMN_identity_info.cellReservedForOperatorUse=PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
+
+  ASN_SEQUENCE_ADD(&(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list,&PLMN_identity_info);
+
+
+  // 16 bits
+  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf = MALLOC(2);
+#if defined(ENABLE_ITTI)
+  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[0] = (configuration->tac >> 8) & 0xff;
+  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[1] = (configuration->tac >> 0) & 0xff;
+#else
+  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[0] = 0x00;
+  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[1] = 0x01;
+#endif
+  (*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;
+#else
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[0] = 0x00;
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[1] = 0x00;
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[2] = 0x00;
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[3] = 0x10;
+#endif
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.size=4;
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.bits_unused=4;
+
+  //  assign_enum(&(*sib1)->cellAccessRelatedInfo.cellBarred,SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred);
+  (*sib1)->cellAccessRelatedInfo.cellBarred=SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred;
+
+  //  assign_enum(&(*sib1)->cellAccessRelatedInfo.intraFreqReselection,SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed);
+  (*sib1)->cellAccessRelatedInfo.intraFreqReselection=SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_notAllowed;
+  (*sib1)->cellAccessRelatedInfo.csg_Indication=0;
+
+  (*sib1)->cellSelectionInfo.q_RxLevMin=-65;
+  (*sib1)->cellSelectionInfo.q_RxLevMinOffset=NULL;
+  //(*sib1)->p_Max = CALLOC(1, sizeof(P_Max_t));
+  //*((*sib1)->p_Max) = 23;
+  (*sib1)->freqBandIndicator =
+#if defined(ENABLE_ITTI)
+    configuration->eutra_band[CC_id];
+#else
+    7;
+#endif
+
+  schedulingInfo.si_Periodicity=SchedulingInfo__si_Periodicity_rf8;
+
+  // This is for SIB2/3
+  sib_type=SIB_Type_sibType3;
+  ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type);
+  ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo);
+
+  //  ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,NULL);
+
+#if defined(ENABLE_ITTI)
+
+  if (configuration->frame_type[CC_id] == TDD)
+#endif
+  {
+    (*sib1)->tdd_Config =                             CALLOC(1,sizeof(struct TDD_Config));
+
+    (*sib1)->tdd_Config->subframeAssignment =
+#if defined(ENABLE_ITTI)
+      configuration->tdd_config[CC_id];
+#else
+      3;
+#endif
+
+    (*sib1)->tdd_Config->specialSubframePatterns =
+#if defined(ENABLE_ITTI)
+      configuration->tdd_config_s[CC_id];
+#else
+    0;
+#endif
+  }
+
+  (*sib1)->si_WindowLength=SystemInformationBlockType1__si_WindowLength_ms20;
+  (*sib1)->systemInfoValueTag=0;
+  //  (*sib1).nonCriticalExtension = calloc(1,sizeof(*(*sib1).nonCriticalExtension));
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_DL_SCH_Message,
+                                   (void*)bcch_message,
+                                   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[10000];
+    size_t      message_string_size;
+
+    if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
+      itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  if (enc_rval.encoded==-1) {
+    return(-1);
+  }
+
+  return((enc_rval.encoded+7)/8);
+}
+
+void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id,
+                                   int CC_id
+                                   #if defined(ENABLE_ITTI)
+                                   ,gNB_RrcConfigurationReq *configuration
+                                   #endif
+                                  )
+{ 
+  // ServingCellConfigCommon //
+  struct FrequencyInfoDL    **frequencyinfordl           = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->frequencyInfoDL;
+  BWP_DownlinkCommon_t      **bwp_downlinkcommon         = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->initialDownlinkBWP;
+  UplinkConfigCommon_t      **uplinkconfigcommon         = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->uplinkConfigCommon;
+  UplinkConfigCommon_t      **supplementaryuplinkconfig  = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->supplementaryUplinkConfig; 
+  
+  /////RateMatchPatternLTE_CRS_t   **lte_crs_tomatcharound = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->lte_CRS_ToMatchAround;
+  
+  struct ServingCellConfigCommon__rateMatchPatternToAddModList **ratematchpatterntoaddmodlist = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->rateMatchPatternToAddModList;
+  struct RateMatchPattern *ratematchpattern; 
+  struct ServingCellConfigCommon__rateMatchPatternToReleaseList **ratematchpatterntoreleaselist = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->rateMatchPatternToReleaseList;
+  RateMatchPatternId_t *ratematchpatternid;
+
+  struct TDD_UL_DL_ConfigCommon **tdd_ul_dl_configurationcommon;
+  struct TDD_UL_DL_ConfigCommon **tdd_ul_dl_configurationcommon2;
+
+  // FrequencyInfoDL //
+  FreqBandIndicatorNR_t                     *dl_frequencyBandList;
+  struct SCS_SpecificCarrier                *dl_scs_SpecificCarrierList;
+  // BWP_DownlinkCommon //
+  ControlResourceSet_t                      *bwp_dl_controlresourceset;
+  TCI_StateId_t                             *TCI_StateId;
+  SearchSpace_t                             *bwp_dl_searchspace;
+  struct PDSCH_TimeDomainResourceAllocation *bwp_dl_timedomainresourceallocation;
+  // UplinkConfigCommon //
+  FreqBandIndicatorNR_t                     *ul_frequencyBandList;
+  struct SCS_SpecificCarrier                *ul_scs_SpecificCarrierList;
+  // PUSCH_ConfigCommon //
+  struct PUSCH_TimeDomainResourceAllocation *pusch_configcommontimedomainresourceallocation;
+  
+  //------------------------------------Start Fill ServingCellConfigCommon------------------------------------//
+  RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->physCellId = configuration->Nid_cell[CC_id];
+
+  (*ssb_positionsinburst)->present = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id];
+  if((*ssb_positionsinburst)->present == ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap){
+    (*ssb_positionsinburst)->choice.shortBitmap.buf = MALLOC(1);
+    (*ssb_positionsinburst)->choice.shortBitmap.size = 1;
+    (*ssb_positionsinburst)->choice.shortBitmap.bits_unused = 4;
+    (*ssb_positionsinburst)->choice.shortBitmap.buf[0] = 0x0f;
+  }else if((*ssb_positionsinburst)->present == ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap){
+    (*ssb_positionsinburst)->choice.mediumBitmap.buf = MALLOC(1);
+    (*ssb_positionsinburst)->choice.mediumBitmap.size = 1;
+    (*ssb_positionsinburst)->choice.mediumBitmap.bits_unused = 0;
+    (*ssb_positionsinburst)->choice.mediumBitmap.buf[0] = 0xff;
+  }else if((*ssb_positionsinburst)->present == ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap){
+    (*ssb_positionsinburst)->choice.longBitmap.buf = MALLOC(8);
+    (*ssb_positionsinburst)->choice.longBitmap.size = 8;
+    (*ssb_positionsinburst)->choice.longBitmap.bits_unused = 0;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[0] = 0xff;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[1] = 0xff;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[2] = 0xff;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[3] = 0xff;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[4] = 0xff;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[5] = 0xff;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[6] = 0xff;
+    (*ssb_positionsinburst)->choice.longBitmap.buf[7] = 0xff;    
+  }
+
+  RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->ssb_periodicityServingCell = configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id];
+  RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->dmrs_TypeA_Position        = configuration->ServingCellConfigCommon_dmrs_TypeA_Position[CC_id];
+  
+  ratematchpattern = CALLOC(1,sizeof(struct RateMatchPattern));
+  memset(&ratematchpattern,0,sizeof(struct RateMatchPattern));
+  ratematchpattern->rateMatchPatternId = configuration->rateMatchPatternId[CC_id];
+  ratematchpattern->patternType.present  = configuration->RateMatchPattern_patternType[CC_id];
+  if(ratematchpattern->patternType.present == RateMatchPattern__patternType_PR_bitmaps){
+
+    ratematchpattern->patternType.choice.bitmaps.resourceBlocks.buf = MALLOC(35);
+    ratematchpattern->patternType.choice.bitmaps.resourceBlocks.size = 35;
+    ratematchpattern->patternType.choice.bitmaps.resourceBlocks.bits_unused = 5;
+    ratematchpattern->patternType.choice.bitmaps.resourceBlocks.buf[0] = 0x07;
+    for (int i =1;i<=34;i++ ){
+      ratematchpattern->patternType.choice.bitmaps.resourceBlocks.buf[i] =0xff;
+    }
+
+    ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.present = configuration->symbolsInResourceBlock[CC_id];
+    if(ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.present == RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_oneSlot){
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.oneSlot.buf=MALLOC(2);
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.oneSlot.size=2;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.oneSlot.bits_unused=2;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.oneSlot.buf[0]=0x3f;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.oneSlot.buf[1]=0xff;      
+    }else if(ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.present == RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_twoSlots){
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.twoSlots.buf=MALLOC(4);
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.twoSlots.size=4;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.twoSlots.bits_unused=4;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.twoSlots.buf[0]=0x0f;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.twoSlots.buf[1]=0xff;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.twoSlots.buf[2]=0xff;
+      ratematchpattern->patternType.choice.bitmaps.symbolsInResourceBlock.choice.twoSlots.buf[3]=0xff;      
+    }
+
+    ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern = CALLOC(1,sizeof(struct RateMatchPattern__patternType__bitmaps__periodicityAndPattern));
+    ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present = configuration->periodicityAndPattern[CC_id];
+    if(ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present == RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n2){
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n2.buf = MALLOC(1);
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n2.size = 1;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n2.bits_unused = 6;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n2.buf[0] =0x03;
+    }else if(ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present == RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n4){
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n4.buf = MALLOC(1);
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n4.size = 1;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n4.bits_unused = 4;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n4.buf[0] = 0x0f;
+    }else if(ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present == RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n5){
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n5.buf = MALLOC(1);
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n5.size = 1;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n5.bits_unused = 3;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n5.buf[0] = 0x1f;   
+    }else if(ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present == RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n8){
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n8.buf = MALLOC(1);
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n8.size = 1;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n8.bits_unused = 0;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n8.buf[0] = 0xff;    
+    }else if(ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present == RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n10){
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n10.buf = MALLOC(2);
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n10.size = 2;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n10.bits_unused = 6;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n10.buf[0] = 0x03;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n10.buf[1] = 0xff;    
+    }else if(ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present == RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n20){
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n20.buf = MALLOC(3);
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n20.size = 3;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n20.bits_unused = 4;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n20.buf[0] = 0x0f;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n20.buf[1] = 0xff;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n20.buf[2] = 0xff;   
+    }else if(ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->present == RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n40){
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.buf = MALLOC(5)
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.size = 5;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.bits_unused = 0;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.buf[0] = 0xff;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.buf[1] = 0xff; 
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.buf[2] = 0xff;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.buf[3] = 0xff;
+      ratematchpattern->patternType.choice.bitmaps.periodicityAndPattern->choice.n40.buf[4] = 0xff;     
+    }
+
+  }else if(ratematchpattern->patternType.present == RateMatchPattern__patternType_PR_controlResourceSet){
+    ratematchpattern->patternType.choice.controlResourceSet = RateMatchPattern_controlResourceSet[CC_id];
+  }
+
+  ratematchpattern->subcarrierSpacing = CALLOC(1,sizeof(SubcarrierSpacing_t));
+  ratematchpattern->subcarrierSpacing = configuration->RateMatchPattern_subcarrierSpacing[CC_id];
+  ratematchpattern->mode = configuration->RateMatchPattern_mode[CC_id];
+
+  ASN_SEQUENCE_ADD(&(*ratematchpatterntoaddmodlist)->list,&ratematchpattern);
+  
+  ratematchpatternid = CALLOC(1,sizeof(RateMatchPatternId_t));
+  memset(&ratematchpatternid,0,sizeof(RateMatchPatternId_t));
+  ratematchpatternid = configuration->rateMatchPatternId[CC_id];
+  ASN_SEQUENCE_ADD(&(*ratematchpatterntoreleaselist)->list,&ratematchpatternid);
+
+  RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->subcarrierSpacing = configuration->NIA_SubcarrierSpacing[CC_id];
+  RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon->ss_PBCH_BlockPower = configuration->ServingCellConfigCommon_ss_PBCH_BlockPower[CC_id];
+
+  //Fill  FrequencyInfoDL //
+  (*frequencyinfordl)->absoluteFrequencySSB = configuration->absoluteFrequencySSB[CC_id];
+  (*frequencyinfordl)->ssb_SubcarrierOffset = CALLOC(1,sizeof(long));
+  (*frequencyinfordl)->ssb_SubcarrierOffset = configuration->ssb_SubcarrierOffset[CC_id];  
+
+  dl_frequencyBandList = CALLOC(1,sizeof(FreqBandIndicatorNR_t));
+  memset(&dl_frequencyBandList,0,sizeof(FreqBandIndicatorNR_t));
+  dl_frequencyBandList = configuration->DL_FreqBandIndicatorNR[CC_id];
+  ASN_SEQUENCE_ADD(&(*frequencyinfordl)->frequencyBandList.list,&dl_frequencyBandList);
+
+  (*frequencyinfordl)->absoluteFrequencyPointA = configuration->DL_absoluteFrequencyPointA[CC_id];
+  
+  dl_scs_SpecificCarrierList = CALLOC(1,sizeof(struct SCS_SpecificCarrier));
+  memset(&dl_scs_SpecificCarrierList,0,sizeof(struct SCS_SpecificCarrier));
+  dl_scs_SpecificCarrierList->offsetToCarrier    = configuration->DL_offsetToCarrier[CC_id];
+  dl_scs_SpecificCarrierList->subcarrierSpacing  = configuration->DL_SCS_SubcarrierSpacing[CC_id];
+  dl_scs_SpecificCarrierList->k0                 = configuration->DL_SCS_SpecificCarrier_k0[CC_id];
+  dl_scs_SpecificCarrierList->carrierBandwidth   = configuration->DL_carrierBandwidth[CC_id];
+  ASN_SEQUENCE_ADD(&(*frequencyinfordl)->scs_SpecificCarrierList.list,&dl_scs_SpecificCarrierList);
+
+  //Fill  BWP_DownlinkCommon  ->  genericParameters  //
+  (*bwp_downlinkcommon)->genericParameters.locationAndBandwidth = configuration->DL_locationAndBandwidth[CC_id];
+  (*bwp_downlinkcommon)->genericParameters.subcarrierSpacing    = configuration->DL_BWP_SubcarrierSpacing[CC_id];
+
+  if(configuration->DL_BWP_prefix_type[CC_id]){
+    (*bwp_downlinkcommon)->genericParameters.cyclicPrefix = CALLOC(1,sizeof(long));
+    (*bwp_downlinkcommon)->genericParameters.cyclicPrefix = BWP__cyclicPrefix_extended;
+  }
+  //Fill  BWP_DownlinkCommon  ->  pdcch_ConfigCommon  //
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon                                     = CALLOC(1,sizeof(struct PDCCH_ConfigCommon));
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->searchSpaceSIB1                    = CALLOC(1,sizeof(SearchSpaceId_t));
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->searchSpaceOtherSystemInformation  = CALLOC(1,sizeof(SearchSpaceId_t));
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->pagingSearchSpace                  = CALLOC(1,sizeof(SearchSpaceId_t));
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->ra_SearchSpace                     = CALLOC(1,sizeof(SearchSpaceId_t));
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->ra_ControlResourceSet              = CALLOC(1,sizeof(ControlResourceSetId_t));
+
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->searchSpaceSIB1                    = configuration->searchSpaceSIB1[CC_id];
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->searchSpaceOtherSystemInformation  = configuration->searchSpaceOtherSystemInformation[CC_id];
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->pagingSearchSpace                  = configuration->pagingSearchSpace[CC_id];
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->ra_SearchSpace                     = configuration->ra_SearchSpace[CC_id];
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->ra_ControlResourceSet              = configuration->rach_ra_ControlResourceSet[CC_id];
+
+  //Fill  BWP_DownlinkCommon  ->  pdcch_ConfigCommon  ->  ControlResourceSet list //
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->commonControlResourcesSets = CALLOC(1,sizeof(struct PDCCH_ConfigCommon__commonControlResourcesSets));
+  bwp_dl_controlresourceset = CALLOC(1,sizeof(ControlResourceSet_t));
+  memset(&bwp_dl_controlresourceset,0,sizeof(ControlResourceSet_t));
+  bwp_dl_controlresourceset->controlResourceSetId      = configuration->PDCCH_common_controlResourceSetId[CC_id];
+  //BIT STRING (SIZE (45))
+  bwp_dl_controlresourceset->frequencyDomainResources.buf =MALLOC(6);
+  bwp_dl_controlresourceset->frequencyDomainResources.size = 6;
+  bwp_dl_controlresourceset->frequencyDomainResources.bits_unused = 3;
+  bwp_dl_controlresourceset->frequencyDomainResources.buf[0] = 0x1f;
+  bwp_dl_controlresourceset->frequencyDomainResources.buf[1] = 0xff;   
+  bwp_dl_controlresourceset->frequencyDomainResources.buf[2] = 0xff; 
+  bwp_dl_controlresourceset->frequencyDomainResources.buf[3] = 0xff; 
+  bwp_dl_controlresourceset->frequencyDomainResources.buf[4] = 0xff; 
+  bwp_dl_controlresourceset->frequencyDomainResources.buf[5] = 0xff; 
+  bwp_dl_controlresourceset->frequencyDomainResources.buf[6] = 0xff; 
+
+  bwp_dl_controlresourceset->duration = configuration->PDCCH_common_ControlResourceSet_duration[CC_id];
+
+  bwp_dl_controlresourceset->cce_REG_MappingType.present = configuration->PDCCH_cce_REG_MappingType[CC_id];
+
+  if(bwp_dl_controlresourceset->cce_REG_MappingType == ControlResourceSet__cce_REG_MappingType_PR_interleaved ){
+    bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved.reg_BundleSize    = configuration->PDCCH_reg_BundleSize[CC_id];
+    bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved.interleaverSize   = configuration->PDCCH_interleaverSize[CC_id];
+    bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved.shiftIndex        = configuration->PDCCH_shiftIndex[CC_id];
+  }else if(bwp_dl_controlresourceset->cce_REG_MappingType == ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved){
+    bwp_dl_controlresourceset->cce_REG_MappingType.choice.nonInterleaved = NULL;
+  }
+
+  bwp_dl_controlresourceset->precoderGranularity =  configuration->PDCCH_precoderGranularity[CC_id];
+
+  bwp_dl_controlresourceset->tci_StatesPDCCH = CALLOC(1,sizeof(struct ControlResourceSet__tci_StatesPDCCH));
+  TCI_StateId = CALLOC(1,sizeof(TCI_StateId_t));
+  memset(&TCI_StateId,0,sizeof(TCI_StateId_t));
+  TCI_StateId = configuration->PDCCH_TCI_StateId[CC_id];
+  ASN_SEQUENCE_ADD(&bwp_dl_controlresourceset->tci_StatesPDCCH->list,&TCI_StateId);
+
+  if(configuration->tci_PresentInDCI[CC_id]){
+    bwp_dl_controlresourceset->tci_PresentInDCI  = CALLOC(1,sizeof(long));
+    bwp_dl_controlresourceset->tci_PresentInDCI  = ControlResourceSet__tci_PresentInDCI_enabled;
+  }
+
+  bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID = CALLOC(1,sizeof(pdcch_DMRS_ScramblingID));
+  bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID->buf  = MALLOC(2);
+  bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID->size = 2;
+  bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID->bits_unused = 0;
+  bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID->buf[0] = 0xff;
+  bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID->buf[1] = 0xff;
+
+  ASN_SEQUENCE_ADD(&(*bwp_downlinkcommon)->pdcch_ConfigCommon->commonControlResourcesSets->list,&bwp_dl_controlresourceset);
+
+  //Fill  BWP_DownlinkCommon  ->  pdcch_ConfigCommon  ->  SearchSpace list //
+  (*bwp_downlinkcommon)->pdcch_ConfigCommon->commonSearchSpaces = CALLOC(1,sizeof(struct PDCCH_ConfigCommon__commonSearchSpaces));
+
+  bwp_dl_searchspace = CALLOC(1,sizeof(SearchSpace_t));
+  memset(&bwp_dl_searchspace,0,sizeof(SearchSpace_t));
+  bwp_dl_searchspace->searchSpaceId         = configuration->SearchSpaceId[CC_id];
+  bwp_dl_searchspace->controlResourceSetId  = CALLOC(1,sizeof(ControlResourceSetId_t));
+  bwp_dl_searchspace->controlResourceSetId  = configuration->commonSearchSpaces_controlResourceSetId[CC_id];
+
+  bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset = CALLOC(1,sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
+  bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_choice[CC_id];
+  
+  if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl1 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl1[CC_id];
+  }else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl2 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl2[CC_id];    
+  }else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl4 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl4[CC_id];    
+  }else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl5 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl5[CC_id];    
+  }else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl8 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl8[CC_id];    
+  }else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl10 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl10[CC_id];    
+  }else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl16 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl16[CC_id];    
+  }else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20){
+    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl20 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_sl20[CC_id];    
+  }
+  bwp_dl_searchspace->monitoringSymbolsWithinSlot = CALLOC(1,sizeof(BIT_STRING_t));
+  bwp_dl_searchspace->monitoringSymbolsWithinSlot->buf=MALLOC(2);
+  bwp_dl_searchspace->monitoringSymbolsWithinSlot->size=2;
+  bwp_dl_searchspace->monitoringSymbolsWithinSlot->bits_unused=2;  
+  bwp_dl_searchspace->monitoringSymbolsWithinSlot->buf[0]=0x3f;
+  bwp_dl_searchspace->monitoringSymbolsWithinSlot->buf[1]=0xff;
+
+  bwp_dl_searchspace->nrofCandidates = CALLOC(1,sizeof(struct SearchSpace__nrofCandidates)); 
+  bwp_dl_searchspace->nrofCandidates->aggregationLevel1 = configuration->SearchSpace_nrofCandidates_aggregationLevel1[CC_id];
+  bwp_dl_searchspace->nrofCandidates->aggregationLevel2 = configuration->SearchSpace_nrofCandidates_aggregationLevel2[CC_id];
+  bwp_dl_searchspace->nrofCandidates->aggregationLevel4 = configuration->SearchSpace_nrofCandidates_aggregationLevel4[CC_id];
+  bwp_dl_searchspace->nrofCandidates->aggregationLevel8 = configuration->SearchSpace_nrofCandidates_aggregationLevel8[CC_id];
+  bwp_dl_searchspace->nrofCandidates->aggregationLevel16 = configuration->SearchSpace_nrofCandidates_aggregationLevel16[CC_id];
+
+  bwp_dl_searchspace->searchSpaceType = CALLOC(1,sizeof(struct SearchSpace__searchSpaceType));
+  bwp_dl_searchspace->searchSpaceType->present = configuration->SearchSpace_searchSpaceType[CC_id];
+  if(bwp_dl_searchspace->searchSpaceType->present == SearchSpace__searchSpaceType_PR_common){
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0 = CALLOC(1,sizeof(struct SearchSpace__searchSpaceType__common__dci_Format2_0));
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel1   = CALLOC(1,sizeof(long)); 
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel2   = CALLOC(1,sizeof(long)); 
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel4   = CALLOC(1,sizeof(long)); 
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel8   = CALLOC(1,sizeof(long)); 
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel16  = CALLOC(1,sizeof(long)); 
+
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel1  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[CC_id];
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel2  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[CC_id];
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel4  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[CC_id];
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel8  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[CC_id];
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_0->nrofCandidates_SFI.aggregationLevel16 = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[CC_id];
+    
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_3 = CALLOC(1,sizeof(struct struct SearchSpace__searchSpaceType__common__dci_Format2_3));
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_3->monitoringPeriodicity = CALLOC(1,sizeof(long));
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_3->monitoringPeriodicity = configuration->Common_dci_Format2_3_monitoringPeriodicity[CC_id];
+    bwp_dl_searchspace->searchSpaceType->choice.common.dci_Format2_3->nrofPDCCH_Candidates  = configuration->Common_dci_Format2_3_nrofPDCCH_Candidates[CC_id];
+
+  }else if (bwp_dl_searchspace->searchSpaceType->present == SearchSpace__searchSpaceType_PR_ue_Specific){
+    bwp_dl_searchspace->searchSpaceType->choice.ue_Specific.dci_Formats = configuration->dci_Formats[CC_id];
+  }
+
+  ASN_SEQUENCE_ADD(&(*bwp_downlinkcommon)->pdcch_ConfigCommon->commonSearchSpaces->list,&bwp_dl_searchspace);
+
+  //Fill  BWP_DownlinkCommon  ->  pdsch_ConfigCommon  //
+  (*bwp_downlinkcommon)->pdsch_ConfigCommon = CALLOC(1,sizeof(struct PDSCH_ConfigCommon));
+  (*bwp_downlinkcommon)->pdsch_ConfigCommon->pdsch_AllocationList = CALLOC(1,sizeof(struct PDSCH_ConfigCommon__pdsch_AllocationList));
+  bwp_dl_timedomainresourceallocation->k0 = CALLOC(1,sizeof(long));
+  
+  bwp_dl_timedomainresourceallocation->k0                   = configuration->PDSCH_TimeDomainResourceAllocation_k0[CC_id];
+  bwp_dl_timedomainresourceallocation->mappingType          = configuration->PDSCH_TimeDomainResourceAllocation_mappingType[CC_id];
+  bwp_dl_timedomainresourceallocation->startSymbolAndLength.buf=MALLOC(1);
+  bwp_dl_timedomainresourceallocation->startSymbolAndLength.size=1;
+  bwp_dl_timedomainresourceallocation->startSymbolAndLength.bits_unused=1;
+  bwp_dl_timedomainresourceallocation->startSymbolAndLength.buf[0]=0x7f;
+
+  ASN_SEQUENCE_ADD(&(*bwp_downlinkcommon)->pdsch_ConfigCommon->pdsch_AllocationList->list,&bwp_dl_timedomainresourceallocation);
+
+  //Fill  UplinkConfigCommon //
+  //Fill  UplinkConfigCommon -> FrequencyInfoUL //
+  (*uplinkconfigcommon)->frequencyInfoUL = CALLOC(1,sizeof(struct FrequencyInfoUL));
+  (*uplinkconfigcommon)->frequencyInfoUL->frequencyBandList = CALLOC(1,sizeof(struct MultiFrequencyBandListNR));
+
+  ul_frequencyBandList = CALLOC(1,sizeof(FreqBandIndicatorNR_t));
+  memset(&ul_frequencyBandList,0,sizeof(FreqBandIndicatorNR_t)); 
+  ul_frequencyBandList = configuration->UL_FreqBandIndicatorNR[CC_id];
+  ASN_SEQUENCE_ADD(&(*uplinkconfigcommon)->frequencyInfoUL->frequencyBandList->list,&ul_frequencyBandList);
+
+  (*uplinkconfigcommon)->frequencyInfoUL->absoluteFrequencyPointA = CALLOC(1,sizeof(ARFCN_ValueNR_t));
+  (*uplinkconfigcommon)->frequencyInfoUL->absoluteFrequencyPointA = configuration->UL_absoluteFrequencyPointA[CC_id];
+
+  ul_scs_SpecificCarrierList = CALLOC(1,sizeof(struct SCS_SpecificCarrier));
+  memset(&dl_scs_SpecificCarrierList,0,sizeof(struct SCS_SpecificCarrier));
+  ul_scs_SpecificCarrierList->offsetToCarrier    = configuration->UL_offsetToCarrier[CC_id];
+  ul_scs_SpecificCarrierList->subcarrierSpacing  = configuration->UL_SCS_SubcarrierSpacing[CC_id];
+  ul_scs_SpecificCarrierList->k0                 = configuration->UL_SCS_SpecificCarrier_k0[CC_id];
+  ul_scs_SpecificCarrierList->carrierBandwidth   = configuration->UL_carrierBandwidth[CC_id];
+  ASN_SEQUENCE_ADD(&(*uplinkconfigcommon)->frequencyInfoUL->scs_SpecificCarriers.list,&ul_scs_SpecificCarrierList);  
+
+  (*uplinkconfigcommon)->frequencyInfoUL->additionalSpectrumEmission = CALLOC(1,sizeof(AdditionalSpectrumEmission_t));
+  (*uplinkconfigcommon)->frequencyInfoUL->p_Max                      = CALLOC(1,sizeof(P_Max_t));
+  (*uplinkconfigcommon)->frequencyInfoUL->frequencyShift7p5khz       = CALLOC(1,sizeof(long));
+
+  (*uplinkconfigcommon)->frequencyInfoUL->additionalSpectrumEmission = configuration->UL_additionalSpectrumEmission[CC_id];  
+  (*uplinkconfigcommon)->frequencyInfoUL->p_Max                      = configuration->UL_p_Max[CC_id];
+  (*uplinkconfigcommon)->frequencyInfoUL->frequencyShift7p5khz       = configuration->UL_frequencyShift7p5khz[CC_id];   
+
+  //Fill  UplinkConfigCommon -> BWP-UplinkCommon //
+  //Fill  UplinkConfigCommon -> BWP-UplinkCommon -> genericParameters//
+  (*uplinkconfigcommon)->initialUplinkBWP->genericParameters.locationAndBandwidth = configuration->UL_locationAndBandwidth[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->genericParameters.subcarrierSpacing    = configuration->UL_BWP_SubcarrierSpacing[CC_id];
+
+  if(configuration->UL_BWP_prefix_type[CC_id]){
+    (*uplinkconfigcommon)->initialUplinkBWP->genericParameters.cyclicPrefix = CALLOC(1,sizeof(long));
+    (*uplinkconfigcommon)->initialUplinkBWP->genericParameters.cyclicPrefix = BWP__cyclicPrefix_extended;
+  } 
+
+  //Fill  UplinkConfigCommon -> BWP-UplinkCommon -> RACH_ConfigCommon//
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon = CALLOC(1,sizeof(RACH_ConfigCommon_t));
+
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->totalNumberOfRA_Preambles = CALLOC(1,sizeof(long));
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->totalNumberOfRA_Preambles = configuration->rach_totalNumberOfRA_Preambles[CC_id];
+  
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB = CALLOC(1,sizeof(struct RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[CC_id];
+  
+  if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present       == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneEighth = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[CC_id];
+  }else if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneFourth = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[CC_id];
+  }else if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneHalf   = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[CC_id];
+  }else if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one       = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[CC_id];
+  }else if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.two       = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[CC_id];
+  }else if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.four      = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four[CC_id];
+  }else if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.eight     = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight[CC_id];
+  }else if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present == RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.sixteen   = configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen[CC_id];
+  }      
+
+  if(configuration->rach_groupBconfigured[CC_id]){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->groupBconfigured = CALLOC(1,sizeof(struct RACH_ConfigCommon__groupBconfigured));
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->groupBconfigured->ra_Msg3SizeGroupA            = configuration->numberOfRA_PreamblesGroupA[CC_id];
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->groupBconfigured->messagePowerOffsetGroupB     = configuration->rach_messagePowerOffsetGroupB[CC_id];
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->groupBconfigured->numberOfRA_PreamblesGroupA   = configuration->rach_numberOfRA_PreamblesGroupA[CC_id];
+  }
+
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->ra_ContentionResolutionTimer = configuration->rach_ra_ContentionResolutionTimer[CC_id];
+  
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rsrp_ThresholdSSB            = CALLOC(1,sizeof(RSRP_Range_t));
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rsrp_ThresholdSSB_SUL        = CALLOC(1,sizeof(RSRP_Range_t));
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rsrp_ThresholdSSB            = configuration->rsrp_ThresholdSSB[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rsrp_ThresholdSSB_SUL        = configuration->rsrp_ThresholdSSB_SUL[CC_id];
+
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->prach_RootSequenceIndex.present   = configuration->prach_RootSequenceIndex_choice[CC_id];  
+  if((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->prach_RootSequenceIndex.present == RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->prach_RootSequenceIndex.choice.l839 = configuration->prach_RootSequenceIndex_l839[CC_id];
+  }else if ((*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->prach_RootSequenceIndex.present == RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->prach_RootSequenceIndex.choice.l139 = configuration->prach_RootSequenceIndex_l139[CC_id];
+  }
+
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->msg1_SubcarrierSpacing       = configuration->prach_msg1_SubcarrierSpacing[CC_id]; 
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->restrictedSetConfig          = configuration->restrictedSetConfig[CC_id];
+
+  if(configuration->msg3_transformPrecoding[CC_id]){
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->msg3_transformPrecoding      = CALLOC(1,sizeof(long));    
+    (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->msg3_transformPrecoding      = RACH_ConfigCommon__msg3_transformPrecoding_enabled;
+  }
+
+  //Fill  UplinkConfigCommon -> BWP-UplinkCommon -> RACH_ConfigCommon -> RACH_ConfigGeneric_t//  
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex       = configuration->prach_ConfigurationIndex[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.msg1_FDM                       = configuration->prach_msg1_FDM[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.msg1_FrequencyStart            = configuration->prach_msg1_FrequencyStart[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.zeroCorrelationZoneConfig      = configuration->zeroCorrelationZoneConfig[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower    = configuration->preambleReceivedTargetPower[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.preambleTransMax               = configuration->preambleTransMax[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.powerRampingStep               = configuration->powerRampingStep[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->rach_ConfigCommon->rach_ConfigGeneric.ra_ResponseWindow              = configuration->ra_ResponseWindow[CC_id];
+
+  //Fill  UplinkConfigCommon -> BWP-UplinkCommon -> PUSCH_ConfigCommon//
+  (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon = CALLOC(1,sizeof(PUSCH_ConfigCommon_t));  
+
+  if(configuration->groupHoppingEnabledTransformPrecoding[CC_id]){
+    (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->groupHoppingEnabledTransformPrecoding = CALLOC(1,sizeof(long));
+    (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->groupHoppingEnabledTransformPrecoding = PUSCH_ConfigCommon__groupHoppingEnabledTransformPrecoding_enabled;
+  }
+
+  (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->pusch_AllocationList = CALLOC(1,sizeof(struct PUSCH_ConfigCommon__pusch_AllocationList));
+  pusch_configcommontimedomainresourceallocation = CALLOC(1,sizeof(struct PUSCH_TimeDomainResourceAllocation));
+  memset(&pusch_configcommontimedomainresourceallocation,0,sizeof(struct PUSCH_TimeDomainResourceAllocation));
+  pusch_configcommontimedomainresourceallocation->k2 = CALLOC(1,sizeof(long));
+
+  pusch_configcommontimedomainresourceallocation->k2             = configuration->PUSCH_TimeDomainResourceAllocation_k2[CC_id];
+  pusch_configcommontimedomainresourceallocation->mappingType    = configuration->PUSCH_TimeDomainResourceAllocation_mappingType[CC_id];
+  pusch_configcommontimedomainresourceallocation->startSymbolAndLength.buf  = MALLOC(1);
+  pusch_configcommontimedomainresourceallocation->startSymbolAndLength.size = 1;
+  pusch_configcommontimedomainresourceallocation->startSymbolAndLength.bits_unused = 1;
+  pusch_configcommontimedomainresourceallocation->startSymbolAndLength.buf[0]  = 0x7f;
+  ASN_SEQUENCE_ADD(&(*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->pusch_AllocationList->list,&pusch_configcommontimedomainresourceallocation); 
+
+  (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->msg3_DeltaPreamble  = CALLOC(1,sizeof(long));
+  (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->msg3_DeltaPreamble  = configuration->msg3_DeltaPreamble[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->p0_NominalWithGrant = CALLOC(1,sizeof(long));
+  (*uplinkconfigcommon)->initialUplinkBWP->pusch_ConfigCommon->p0_NominalWithGrant = configuration->p0_NominalWithGrant[CC_id];
+
+  //Fill  UplinkConfigCommon -> BWP-UplinkCommon -> PUCCH_ConfigCommon//
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon = CALLOC(1,sizeof(PUCCH_ConfigCommon_t));  
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->pucch_ResourceCommon = CALLOC(1,sizeof(BIT_STRING_t));
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->hoppingId = CALLOC(1,sizeof(BIT_STRING_t));
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->p0_nominal = CALLOC(1,sizeof(long));
+
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->pucch_GroupHopping   = configuration->pucch_GroupHopping[CC_id];
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->p0_nominal           = configuration->p0_nominal[CC_id];
+
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->pucch_ResourceCommon->buf = MALLOC(1);
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->pucch_ResourceCommon->size = 1;
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->pucch_ResourceCommon->bits_unused = 4;  
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->pucch_ResourceCommon->buf[0] = 0x0f;
+
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->hoppingId->buf = MALLOC(2);
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->hoppingId->size = 2
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->hoppingId->bits_unused = 6;
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->hoppingId->buf[0] = 0x03;
+  (*uplinkconfigcommon)->initialUplinkBWP->pucch_ConfigCommon->hoppingId->buf[1] = 0xff;
+
+
+   //Fill  supplementaryUplinkConfig //
+  memcpy(&(*uplinkconfigcommon), &(*supplementaryuplinkconfig), sizeof(UplinkConfigCommon_t));//The Same structre
+
+   //Fill  TDD_UL_DL_ConfigCommon //
+  (*tdd_ul_dl_configurationcommon)->referenceSubcarrierSpacing    = CALLOC(1,sizeof(SubcarrierSpacing_t));
+  (*tdd_ul_dl_configurationcommon)->dl_UL_TransmissionPeriodicity = CALLOC(1,sizeof(long));
+  (*tdd_ul_dl_configurationcommon)->nrofDownlinkSlots             = CALLOC(1,sizeof(long));
+  (*tdd_ul_dl_configurationcommon)->nrofDownlinkSymbols           = CALLOC(1,sizeof(long));
+  (*tdd_ul_dl_configurationcommon)->nrofUplinkSlots               = CALLOC(1,sizeof(long));
+  (*tdd_ul_dl_configurationcommon)->nrofUplinkSymbols             = CALLOC(1,sizeof(long));
+
+  (*tdd_ul_dl_configurationcommon)->referenceSubcarrierSpacing    = configuration->referenceSubcarrierSpacing[CC_id];
+  (*tdd_ul_dl_configurationcommon)->dl_UL_TransmissionPeriodicity = configuration->dl_UL_TransmissionPeriodicity[CC_id];
+  (*tdd_ul_dl_configurationcommon)->nrofDownlinkSlots             = configuration->nrofDownlinkSlots[CC_id];
+  (*tdd_ul_dl_configurationcommon)->nrofDownlinkSymbols           = configuration->nrofDownlinkSymbols[CC_id];
+  (*tdd_ul_dl_configurationcommon)->nrofUplinkSlots               = configuration->nrofUplinkSlots[CC_id];
+  (*tdd_ul_dl_configurationcommon)->nrofUplinkSymbols             = configuration->nrofUplinkSymbols[CC_id];
+
+  memcpy(&(*tdd_ul_dl_configurationcommon), &(*tdd_ul_dl_configurationcommon2), sizeof(struct TDD_UL_DL_ConfigCommon));//The Same structre
+
+
+}
+
+
+
+//------------------------------------------------------------------------------
+/*
+uint8_t do_SIB23(uint8_t Mod_id,
+
+                 int CC_id
+#if defined(ENABLE_ITTI)
+                 , RrcConfigurationReq *configuration
+#endif
+                )
+{
+  struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib2_part,*sib3_part;
+#if defined(Rel10) || defined(Rel14)
+  struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part;
+  MBSFN_SubframeConfigList_t *MBSFNSubframeConfigList;
+  MBSFN_AreaInfoList_r9_t *MBSFNArea_list;
+  struct 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;
+  BCCH_DL_SCH_Message_t             *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation;
+  SystemInformationBlockType2_t     **sib2        = &RC.rrc[Mod_id]->carrier[CC_id].sib2;
+  SystemInformationBlockType3_t     **sib3        = &RC.rrc[Mod_id]->carrier[CC_id].sib3;
+#if defined(Rel10) || defined(Rel14)
+  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;
+#endif
+
+  if (bcch_message) {
+    memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t));
+  } else {
+    LOG_E(RRC,"[eNB %d] BCCH_MESSAGE is null, exiting\n", Mod_id);
+    exit(-1);
+  }
+
+  if (!sib2) {
+    LOG_E(RRC,"[eNB %d] sib2 is null, exiting\n", Mod_id);
+    exit(-1);
+  }
+
+  if (!sib3) {
+    LOG_E(RRC,"[eNB %d] sib3 is null, exiting\n", Mod_id);
+    exit(-1);
+  }
+
+#if defined(Rel10) || defined(Rel14)
+  LOG_I(RRC,"[eNB %d] Configuration SIB2/3, MBMS = %d\n", Mod_id, MBMS_flag);
+#else
+  LOG_I(RRC,"[eNB %d] Configuration SIB2/3\n", Mod_id);
+#endif
+  sib2_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+  sib3_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+  memset(sib2_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+  memset(sib3_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+
+  sib2_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2;
+  sib3_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3;
+
+  *sib2 = &sib2_part->choice.sib2;
+  *sib3 = &sib3_part->choice.sib3;
+
+#if defined(Rel10) || defined(Rel14)
+
+  if (MBMS_flag > 0) {
+    sib13_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    memset(sib13_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    sib13_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920;
+    *sib13 = &sib13_part->choice.sib13_v920;
+  }
+
+#endif
+
+  // sib2
+
+  (*sib2)->ac_BarringInfo = NULL;
+#if defined(Rel10) || defined(Rel14)
+#if 0
+  (*sib2)->ssac_BarringForMMTEL_Voice_r9 = NULL;
+  (*sib2)->ssac_BarringForMMTEL_Video_r9 = NULL;
+  (*sib2)->ac_BarringForCSFB_r10 = NULL;
+#endif
+  (*sib2)->ext1 = NULL;
+  (*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.preamblesGroupAConfig                        = NULL;
+
+  if (configuration->rach_preamblesGroupAConfig[CC_id]) {
+    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig
+      = CALLOC(1,sizeof(struct RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig));
+    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA
+      = configuration->rach_sizeOfRA_PreamblesGroupA[CC_id];
+    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->messageSizeGroupA
+      = configuration->rach_messageSizeGroupA[CC_id];
+    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->messagePowerOffsetGroupB
+      = configuration->rach_messagePowerOffsetGroupB[CC_id];
+  }
+
+  (*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];
+
+  // PCCH-Config
+  (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle
+    = configuration->pcch_defaultPagingCycle[CC_id];
+  (*sib2)->radioResourceConfigCommon.pcch_Config.nB
+    = configuration->pcch_nB[CC_id];
+
+  // PRACH-Config
+  (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex
+    = configuration->prach_root[CC_id];
+  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex
+    = configuration->prach_config_index[CC_id];
+  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag
+    = configuration->prach_high_speed[CC_id];
+  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig
+    = configuration->prach_zero_correlation[CC_id];
+  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset
+    = configuration->prach_freq_offset[CC_id];
+
+  // PDSCH-Config
+  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower
+    = configuration->pdsch_referenceSignalPower[CC_id];
+  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b
+    = configuration->pdsch_p_b[CC_id];
+
+  // PUSCH-Config
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB
+    = configuration->pusch_n_SB[CC_id];
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode
+    = configuration->pusch_hoppingMode[CC_id];
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset
+    = configuration->pusch_hoppingOffset[CC_id];
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM
+    = configuration->pusch_enable64QAM[CC_id];
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled
+    = configuration->pusch_groupHoppingEnabled[CC_id];
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH
+    = configuration->pusch_groupAssignment[CC_id];
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled
+    = configuration->pusch_sequenceHoppingEnabled[CC_id];
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift
+    = configuration->pusch_nDMRS1[CC_id];
+
+  // PUCCH-Config
+
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift
+    = configuration->pucch_delta_shift[CC_id];
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI
+    = configuration->pucch_nRB_CQI[CC_id];
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN
+    = configuration->pucch_nCS_AN[CC_id];
+#if !defined(Rel10) && !defined(Rel14)
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN
+    = configuration->pucch_n1_AN[CC_id];
+#endif
+
+  // SRS Config
+  if (configuration->srs_enable[CC_id]==1) {
+    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present
+      = SoundingRS_UL_ConfigCommon_PR_setup;
+    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig
+      = configuration->srs_BandwidthConfig[CC_id];
+    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig
+      = configuration->srs_SubframeConfig[CC_id];
+    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission
+      = configuration->srs_ackNackST[CC_id];
+
+    if (configuration->srs_MaxUpPts[CC_id]) {
+      (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts
+        = 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;
+    }
+    RC.rrc[Mod_id]->srs_enable[CC_id] = 1;
+  } else {
+    RC.rrc[Mod_id]->srs_enable[CC_id] = 0;
+    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=SoundingRS_UL_ConfigCommon_PR_release;
+    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0;
+  }
+
+  // uplinkPowerControlCommon
+
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH
+    = configuration->pusch_p0_Nominal[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH
+    = configuration->pucch_p0_Nominal[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha
+    = configuration->pusch_alpha[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1
+    = configuration->pucch_deltaF_Format1[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b
+    = configuration->pucch_deltaF_Format1b[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2
+    = configuration->pucch_deltaF_Format2[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a
+    = configuration->pucch_deltaF_Format2a[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b
+    = configuration->pucch_deltaF_Format2b[CC_id];
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3
+    = configuration->msg3_delta_Preamble[CC_id];
+  (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength
+    = configuration->ul_CyclicPrefixLength[CC_id];
+
+  // UE Timers and Constants
+
+  (*sib2)->ue_TimersAndConstants.t300
+    = configuration->ue_TimersAndConstants_t300[CC_id];
+  (*sib2)->ue_TimersAndConstants.t301
+    = configuration->ue_TimersAndConstants_t301[CC_id];
+  (*sib2)->ue_TimersAndConstants.t310
+    = configuration->ue_TimersAndConstants_t310[CC_id];
+  (*sib2)->ue_TimersAndConstants.n310
+    = configuration->ue_TimersAndConstants_n310[CC_id];
+  (*sib2)->ue_TimersAndConstants.t311
+    = configuration->ue_TimersAndConstants_t311[CC_id];
+  (*sib2)->ue_TimersAndConstants.n311
+    = configuration->ue_TimersAndConstants_n311[CC_id];
+
+#else
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles=RACH_ConfigCommon__preambleInfo__numberOfRA_Preambles_n64;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep=RACH_ConfigCommon__powerRampingParameters__powerRampingStep_dB2;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower=
+    RACH_ConfigCommon__powerRampingParameters__preambleInitialReceivedTargetPower_dBm_100;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax=RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize=RACH_ConfigCommon__ra_SupervisionInfo__ra_ResponseWindowSize_sf10;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer=
+    RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = 4;
+
+  // BCCH-Config
+  (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff=BCCH_Config__modificationPeriodCoeff_n2;
+
+  // PCCH-Config
+  (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = PCCH_Config__defaultPagingCycle_rf128;
+  (*sib2)->radioResourceConfigCommon.pcch_Config.nB=PCCH_Config__nB_oneT;
+
+  // PRACH-Config
+  (*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;
+  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset = 2;
+
+  // PDSCH-Config
+  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower=0;  // corresponds to 24.7 dBm 5 MHz/ 27.7 10 MHz/ 30.7 20 MHz
+
+
+  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0;
+
+  // PUSCH-Config
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB=1;
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode=PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset=0;
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM=0;
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled=1;
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH=0;
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled=0;
+  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift=0;
+
+  // PUCCH-Config
+
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift=PUCCH_ConfigCommon__deltaPUCCH_Shift_ds1;
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI = 1;
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = 0;
+  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = 32;
+
+
+  (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=SoundingRS_UL_ConfigCommon_PR_release;
+  (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0;
+
+  // uplinkPowerControlCommon
+
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH = -108;
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH = -108;
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha=UplinkPowerControlCommon__alpha_al1;
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1=DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b=DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
+
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2=DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
+
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a=DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
+
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b=DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
+
+  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 = 6;
+
+  (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength=UL_CyclicPrefixLength_len1;
+
+  (*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;
+  (*sib2)->freqInfo.ul_Bandwidth = NULL;
+  //  (*sib2)->mbsfn_SubframeConfigList = NULL;
+
+#if defined(Rel10) || defined(Rel14)
+
+  if (MBMS_flag > 0) {
+    LOG_I(RRC,"Adding MBSFN subframe Configuration 1 to SIB2\n");
+    MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig1;
+    (*sib2)->mbsfn_SubframeConfigList = CALLOC(1,sizeof(struct MBSFN_SubframeConfigList));
+    MBSFNSubframeConfigList = (*sib2)->mbsfn_SubframeConfigList;
+
+    sib2_mbsfn_SubframeConfig1= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig1));
+    memset((void*)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1));
+
+    sib2_mbsfn_SubframeConfig1->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
+    sib2_mbsfn_SubframeConfig1->radioframeAllocationOffset= 1;
+    sib2_mbsfn_SubframeConfig1->subframeAllocation.present= MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
+    sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf= MALLOC(1);
+    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 ) {
+      LOG_I(RRC,"Adding MBSFN subframe Configuration 2 to SIB2\n");
+      MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig2;
+      sib2_mbsfn_SubframeConfig2= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig2));
+      memset((void*)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2));
+
+      sib2_mbsfn_SubframeConfig2->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
+      sib2_mbsfn_SubframeConfig2->radioframeAllocationOffset= 1;
+      sib2_mbsfn_SubframeConfig2->subframeAllocation.present= MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
+      sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf= MALLOC(1);
+      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);
+    }
+  }
+
+#else // no MBMS transmission
+  (*sib2)->mbsfn_SubframeConfigList = NULL;
+#endif
+
+  (*sib2)->timeAlignmentTimerCommon=TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120;
+
+  /// (*SIB3)
+#if defined(Rel10) || defined(Rel14)
+  (*sib3)->ext1 = NULL;
+#if 0
+  (*sib3)->s_IntraSearch_v920=NULL;
+  (*sib3)->s_NonIntraSearch_v920=NULL;
+  (*sib3)->q_QualMin_r9=NULL;
+  (*sib3)->threshServingLowQ_r9=NULL;
+#endif
+#endif
+  (*sib3)->cellReselectionInfoCommon.q_Hyst=SystemInformationBlockType3__cellReselectionInfoCommon__q_Hyst_dB4;
+
+  (*sib3)->cellReselectionInfoCommon.speedStateReselectionPars=NULL;
+
+  (*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));
+  *(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = 31;
+  (*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth=CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth));
+
+  *(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth = AllowedMeasBandwidth_mbw6;
+
+  (*sib3)->intraFreqCellReselectionInfo.presenceAntennaPort1 = 0;
+  (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.buf = CALLOC(8,1);
+  (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.size = 1;
+  (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.buf[0] = 1;
+  (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.bits_unused = 6;
+  (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA = 1;
+  (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA_SF = (struct SpeedStateScaleFactors *)NULL;
+
+  // SIB13
+  // fill in all elements of SIB13 if present
+#if defined(Rel10) || defined(Rel14)
+
+  if (MBMS_flag > 0 ) {
+    //  Notification for mcch change
+    (*sib13)->notificationConfig_r9.notificationRepetitionCoeff_r9= MBMS_NotificationConfig_r9__notificationRepetitionCoeff_r9_n2;
+    (*sib13)->notificationConfig_r9.notificationOffset_r9= 0;
+    (*sib13)->notificationConfig_r9.notificationSF_Index_r9= 1;
+
+    //  MBSFN-AreaInfoList
+    MBSFNArea_list= &(*sib13)->mbsfn_AreaInfoList_r9;//CALLOC(1,sizeof(*MBSFNArea_list));
+    memset(MBSFNArea_list,0,sizeof(*MBSFNArea_list));
+    // MBSFN Area 1
+    MBSFN_Area1= CALLOC(1, sizeof(*MBSFN_Area1));
+    MBSFN_Area1->mbsfn_AreaId_r9= 1;
+    MBSFN_Area1->non_MBSFNregionLength= MBSFN_AreaInfo_r9__non_MBSFNregionLength_s2;
+    MBSFN_Area1->notificationIndicator_r9= 0;
+    MBSFN_Area1->mcch_Config_r9.mcch_RepetitionPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_RepetitionPeriod_r9_rf32;
+    MBSFN_Area1->mcch_Config_r9.mcch_Offset_r9= 1; // in accordance with mbsfn subframe configuration in sib2
+    MBSFN_Area1->mcch_Config_r9.mcch_ModificationPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_ModificationPeriod_r9_rf512;
+    //  Subframe Allocation Info
+    MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1);
+    MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
+
+    MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x20<<2;  // FDD: SF1
+    
+
+    MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
+
+    MBSFN_Area1->mcch_Config_r9.signallingMCS_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7;
+
+    ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area1);
+
+    //MBSFN Area 2: currently only activated for eMBMS relaying
+    if (MBMS_flag == 4 ) {
+      MBSFN_Area2= CALLOC(1, sizeof(*MBSFN_Area2));
+      MBSFN_Area2->mbsfn_AreaId_r9= 2;
+      MBSFN_Area2->non_MBSFNregionLength= MBSFN_AreaInfo_r9__non_MBSFNregionLength_s2;
+      MBSFN_Area2->notificationIndicator_r9= 1;
+      MBSFN_Area2->mcch_Config_r9.mcch_RepetitionPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_RepetitionPeriod_r9_rf32;
+      MBSFN_Area2->mcch_Config_r9.mcch_Offset_r9= 1;
+      MBSFN_Area2->mcch_Config_r9.mcch_ModificationPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_ModificationPeriod_r9_rf512;
+      // Subframe Allocation Info
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1);
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
+
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x04<<2;  // FDD: SF6
+     
+
+      MBSFN_Area2->mcch_Config_r9.signallingMCS_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7;
+
+      ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area2);
+    }
+
+    //  end of adding for MBMS SIB13
+  }
+
+#endif
+
+  bcch_message->message.present = BCCH_DL_SCH_MessageType_PR_c1;
+  bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType__c1_PR_systemInformation;
+
+  //memcpy((void*)&bcch_message.message.choice.c1.choice.systemInformation,(void*)systemInformation,sizeof(SystemInformation_t));
+
+  bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = 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;
+  ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,
+                   sib2_part);
+  ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,
+                   sib3_part);
+#if defined(Rel10) || defined(Rel14)
+
+  if (MBMS_flag > 0) {
+    ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,sib13_part);
+  }
+
+#endif
+
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_DL_SCH_Message,
+                                   (void*)bcch_message,
+                                   buffer,
+                                   900);
+  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[15000];
+    size_t      message_string_size;
+
+    if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
+
+      itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"[eNB] SystemInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  if (enc_rval.encoded==-1) {
+    msg("[RRC] ASN1 : SI encoding failed for SIB23\n");
+    return(-1);
+  }
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv)
+{
+
+  asn_enc_rval_t enc_rval;
+  uint8_t buf[5],buf2=0;
+  uint8_t ecause=0;
+
+  UL_CCCH_Message_t ul_ccch_msg;
+
+  RRCConnectionRequest_t *rrcConnectionRequest;
+
+  memset((void *)&ul_ccch_msg,0,sizeof(UL_CCCH_Message_t));
+
+  ul_ccch_msg.message.present           = UL_CCCH_MessageType_PR_c1;
+  ul_ccch_msg.message.choice.c1.present = UL_CCCH_MessageType__c1_PR_rrcConnectionRequest;
+  rrcConnectionRequest          = &ul_ccch_msg.message.choice.c1.choice.rrcConnectionRequest;
+
+  rrcConnectionRequest->criticalExtensions.present = RRCConnectionRequest__criticalExtensions_PR_rrcConnectionRequest_r8;
+
+  if (1) {
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.present = InitialUE_Identity_PR_randomValue;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.size = 5;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.bits_unused = 0;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.buf = buf;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.buf[0] = rv[0];
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.buf[1] = rv[1];
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.buf[2] = rv[2];
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.buf[3] = rv[3];
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.randomValue.buf[4] = rv[4];
+  } else {
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.present = InitialUE_Identity_PR_s_TMSI;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.mmec.size = 1;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.mmec.bits_unused = 0;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.mmec.buf = buf;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.mmec.buf[0] = 0x12;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.m_TMSI.size = 4;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.m_TMSI.bits_unused = 0;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.m_TMSI.buf = &buf[1];
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.m_TMSI.buf[0] = 0x34;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.m_TMSI.buf[1] = 0x56;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.m_TMSI.buf[2] = 0x78;
+    rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.ue_Identity.choice.s_TMSI.m_TMSI.buf[3] = 0x9a;
+  }
+
+  rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.establishmentCause = EstablishmentCause_mo_Signalling; //EstablishmentCause_mo_Data;
+
+  rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.buf = &buf2;
+  rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.size=1;
+  rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.bits_unused = 7;
+
+
+  enc_rval = uper_encode_to_buffer(&asn_DEF_UL_CCCH_Message,
+                                   (void*)&ul_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_UL_CCCH_Message, (void *) &ul_ccch_msg)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_CCCH, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_ul_ccch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_ul_ccch.text, message_string, message_string_size);
+
+      itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"[UE] RRCConnectionRequest Encoded %zd bits (%zd bytes), ecause %d\n",enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
+#endif
+
+  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;
+
+  UL_DCCH_Message_t ul_dcch_msg;
+
+  RRCConnectionSetupComplete_t *rrcConnectionSetupComplete;
+
+  memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
+
+  ul_dcch_msg.message.present           = UL_DCCH_MessageType_PR_c1;
+  ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete;
+  rrcConnectionSetupComplete            = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionSetupComplete;
+
+  rrcConnectionSetupComplete->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionSetupComplete->criticalExtensions.present = RRCConnectionSetupComplete__criticalExtensions_PR_c1;
+  rrcConnectionSetupComplete->criticalExtensions.choice.c1.present = RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8;
+
+  rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension=CALLOC(1,
+      sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension));
+
+  if(usim_test == 0)
+      rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 2;
+  else
+      rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 1;
+
+  rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME =
+    NULL;//calloc(1,sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME));
+  
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->plmn_Identity=NULL;
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmegi.buf = calloc(2,1);
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmegi.buf[0] = 0x0;
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmegi.buf[1] = 0x1;
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmegi.size=2;
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmegi.bits_unused=0;
+  
+  memset(&rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.dedicatedInfoNAS,0,sizeof(OCTET_STRING_t));
+  OCTET_STRING_fromBuf(&rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.dedicatedInfoNAS,
+                       dedicatedInfoNAS, dedicatedInfoNASLength);
+
+  
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.buf = calloc(1,1);
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.buf[0] = 0x98;
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.size=1;
+    //rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.bits_unused=0;
+  
+
+  enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message,
+                                   (void*)&ul_dcch_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_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size);
+
+      itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"RRCConnectionSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  return((enc_rval.encoded+7)/8);
+
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t
+do_RRCConnectionReconfigurationComplete(
+  const protocol_ctxt_t* const ctxt_pP,
+  uint8_t* buffer,
+  const uint8_t Transaction_id
+)
+//------------------------------------------------------------------------------
+{
+
+
+  asn_enc_rval_t enc_rval;
+
+  UL_DCCH_Message_t ul_dcch_msg;
+
+  RRCConnectionReconfigurationComplete_t *rrcConnectionReconfigurationComplete;
+
+  memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
+
+  ul_dcch_msg.message.present                     = UL_DCCH_MessageType_PR_c1;
+  ul_dcch_msg.message.choice.c1.present           = UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete;
+  rrcConnectionReconfigurationComplete            = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionReconfigurationComplete;
+
+  rrcConnectionReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionReconfigurationComplete->criticalExtensions.present =
+    RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8;
+  rrcConnectionReconfigurationComplete->criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.nonCriticalExtension=NULL;
+
+  enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message,
+                                   (void*)&ul_dcch_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_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_ul_dcch.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,"RRCConnectionReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t
+do_RRCConnectionSetup(
+  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,
+  SRB_ToAddModList_t  **SRB_configList,
+  struct PhysicalConfigDedicated  **physicalConfigDedicated)
+{
+
+  asn_enc_rval_t enc_rval;
+  uint8_t ecause=0;
+  eNB_RRC_INST *rrc               = RC.rrc[ctxt_pP->module_id];
+  rrc_eNB_carrier_data_t *carrier = &rrc->carrier[CC_id];
+ 
+  long* logicalchannelgroup = NULL;
+  struct SRB_ToAddMod* SRB1_config = NULL;
+  struct SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL;
+  struct SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL;
+  struct LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL;
+
+#ifdef CBA
+  struct PUSCH_CBAConfigDedicated_vlola*  pusch_CBAConfigDedicated_vlola = NULL;
+  long* betaOffset_CBA_Index = NULL;
+  long* cShift_CBA = NULL;
+#endif
+  PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL;
+
+  DL_CCCH_Message_t dl_ccch_msg;
+
+  RRCConnectionSetup_t* rrcConnectionSetup = NULL;
+
+  memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t));
+  dl_ccch_msg.message.present           = DL_CCCH_MessageType_PR_c1;
+  dl_ccch_msg.message.choice.c1.present = 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);
+  }
+
+  *SRB_configList = CALLOC(1,sizeof(SRB_ToAddModList_t));
+
+  /// 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;
+
+  SRB1_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
+  SRB1_rlc_config->choice.explicitValue.present=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 = T_PollRetransmit_ms20;;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = PollPDU_p4;;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte         = PollByte_kBinfinity;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8;
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering     = T_Reordering_ms35;
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms0;
+#endif 
+
+  SRB1_lchan_config = CALLOC(1,sizeof(*SRB1_lchan_config));
+  SRB1_config->logicalChannelConfig   = SRB1_lchan_config;
+
+  SRB1_lchan_config->present = 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=LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
+
+  //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50);
+  SRB1_ul_SpecificParameters->bucketSizeDuration=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->uplinkPowerControlDedicated   = CALLOC(1,sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated));
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH));
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH));
+  physicalConfigDedicated2->cqi_ReportConfig              = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
+  if (rrc->srs_enable[CC_id]==1)
+    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));
+
+  // PDSCH
+  //assign_enum(&physicalConfigDedicated2->pdsch_ConfigDedicated->p_a,
+  //        PDSCH_ConfigDedicated__p_a_dB0);
+  if (carrier->p_eNB==2)
+    physicalConfigDedicated2->pdsch_ConfigDedicated->p_a=   PDSCH_ConfigDedicated__p_a_dB_3;
+  else
+    physicalConfigDedicated2->pdsch_ConfigDedicated->p_a=   PDSCH_ConfigDedicated__p_a_dB0;
+
+  // PUCCH
+  physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.present=PUCCH_ConfigDedicated__ackNackRepetition_PR_release;
+  physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.choice.release=0;
+
+  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) =
+      PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_bundling;//PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing;
+  }
+
+  // Pusch_config_dedicated
+  physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_ACK_Index = 0; // 2.00
+  physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_RI_Index  = 0; // 1.25
+  physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_CQI_Index = 8; // 2.25
+
+  // UplinkPowerControlDedicated
+  physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUSCH = 0; // 0 dB
+  //assign_enum(&physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled,
+  // UplinkPowerControlDedicated__deltaMCS_Enabled_en1);
+  physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled= 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=FilterCoefficient_fc4; // fc4 dB
+
+  // TPC-PDCCH-Config
+
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->present=TPC_PDCCH_Config_PR_setup;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.present = TPC_Index_PR_indexOfFormat3;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf=CALLOC(1,2);
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.size=2;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0]=0x12;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused=0;
+
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present=TPC_PDCCH_Config_PR_setup;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.present = TPC_Index_PR_indexOfFormat3;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf=CALLOC(1,2);
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.size=2;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0]=0x22;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused=0;
+
+  // CQI ReportConfig
+
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic));
+#if defined(Rel10) || defined(Rel14)
+  *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic= CQI_ReportModeAperiodic_rm30;
+#else
+  *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CQI_ReportConfig__cqi_ReportModeAperiodic_rm30; // HLC CQI, no PMI
+#endif
+  physicalConfigDedicated2->cqi_ReportConfig->nomPDSCH_RS_EPRE_Offset = 0; // 0 dB
+  //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=NULL;
+  
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic));
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present =  CQI_ReportPeriodic_PR_release;
+    
+    //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present =  CQI_ReportPeriodic_PR_setup;
+    //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0;  // n2_pucch
+    //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0;  // Icqi/pmi
+    //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI;  // subband CQI
+    //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4;
+
+    //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL;
+    //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0;
+    
+
+  //soundingRS-UL-ConfigDedicated
+  if (rrc->srs_enable[CC_id]==1) {
+    physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup;
+    physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth =
+                                                             SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0;
+    physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth =
+          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
+	  == 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 %zd. Expect undefined behaviour!\n",
+		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
+	  == 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 %zd and %zd. Expect undefined behaviour!\n",
+		carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig,
+		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 %zd, TransmissionComb %zd\n",ue_context_pP->local_uid,
+	  physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex,
+	  physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb);
+
+    physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift=
+          SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0;
+  }
+
+
+  //AntennaInfoDedicated
+  physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo));
+  physicalConfigDedicated2->antennaInfo->present = PhysicalConfigDedicated__antennaInfo_PR_explicitValue;
+  //assign_enum(&physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode,
+  //     AntennaInfoDedicated__transmissionMode_tm2);
+
+  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=     AntennaInfoDedicated__transmissionMode_tm1;
+    break;
+
+  case 2:
+    physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     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 = AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release;
+  physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0;
+
+  // SchedulingRequestConfig
+
+  physicalConfigDedicated2->schedulingRequestConfig->present = SchedulingRequestConfig_PR_setup;
+  physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid;
+
+  if (carrier->sib1->tdd_Config == NULL) { // FDD
+    physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5+(ue_context_pP->local_uid%10);  // Isr = 5 (every 10 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;
+    }
+  }
+
+  //  assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax,
+  //SchedulingRequestConfig__setup__dsr_TransMax_n4);
+  //  assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4;
+  physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4;
+
+  rrcConnectionSetup->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionSetup->criticalExtensions.present = RRCConnectionSetup__criticalExtensions_PR_c1;
+  rrcConnectionSetup->criticalExtensions.choice.c1.present =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 CBA
+  betaOffset_CBA_Index = CALLOC(1,sizeof(long));
+  cShift_CBA = CALLOC(1,sizeof(long));
+  *betaOffset_CBA_Index=10; // need to be changed by Kaijie
+  *cShift_CBA=4;
+  physicalConfigDedicated2->pusch_CBAConfigDedicated_vlola->betaOffset_CBA_Index=betaOffset_CBA_Index;
+  physicalConfigDedicated2->pusch_CBAConfigDedicated_vlola->cShift_CBA=cShift_CBA;
+  rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.sps_CBA_ConfigList_vlola = NULL;
+#endif
+
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message,
+                                   (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_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 Encoded %zd bits (%zd 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);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+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
+)
+//------------------------------------------------------------------------------
+{
+  DL_DCCH_Message_t dl_dcch_msg;
+  asn_enc_rval_t enc_rval;
+
+  memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
+
+  dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = 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 = SecurityModeCommand__criticalExtensions_PR_c1;
+
+  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present =
+    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
+    = (CipheringAlgorithm_r12_t)cipheringAlgorithm;
+  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm
+    = (e_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm;
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message, (void*)&dl_dcch_msg);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message,
+                                   (void*)&dl_dcch_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_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
+
+#ifdef USER_MODE
+  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);
+#endif
+
+  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
+)
+//------------------------------------------------------------------------------
+{
+
+  DL_DCCH_Message_t dl_dcch_msg;
+
+  RAT_Type_t rat=RAT_Type_eutra;
+  asn_enc_rval_t enc_rval;
+
+  memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
+
+  dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = 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 = UECapabilityEnquiry__criticalExtensions_PR_c1;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present =
+    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);
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_DL_DCCH_Message, (void*)&dl_dcch_msg);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message,
+                                   (void*)&dl_dcch_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_DL_DCCH_Message, (void *) &dl_dcch_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,"[eNB %d] UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n",
+        ctxt_pP->module_id,
+        ctxt_pP->rnti,
+        enc_rval.encoded,
+        (enc_rval.encoded+7)/8);
+#endif
+
+  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);
+    return(-1);
+  }
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint16_t
+do_RRCConnectionReconfiguration(
+  const protocol_ctxt_t*        const ctxt_pP,
+  uint8_t                            *buffer,
+  uint8_t                             Transaction_id,
+  SRB_ToAddModList_t                 *SRB_list,
+  DRB_ToAddModList_t                 *DRB_list,
+  DRB_ToReleaseList_t                *DRB_list2,
+  struct SPS_Config                  *sps_Config,
+  struct PhysicalConfigDedicated     *physicalConfigDedicated,
+  MeasObjectToAddModList_t           *MeasObj_list,
+  ReportConfigToAddModList_t         *ReportConfig_list,
+  QuantityConfig_t                   *quantityConfig,
+  MeasIdToAddModList_t               *MeasId_list,
+  MAC_MainConfig_t                   *mac_MainConfig,
+  MeasGapConfig_t                    *measGapConfig,
+  MobilityControlInfo_t              *mobilityInfo,
+  struct MeasConfig__speedStatePars  *speedStatePars,
+  RSRP_Range_t                       *rsrp,
+  C_RNTI_t                           *cba_rnti,
+  struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList
+  *dedicatedInfoNASList
+
+#if defined(Rel10) || defined(Rel14)
+  , SCellToAddMod_r10_t  *SCell_config
+#endif
+)
+//------------------------------------------------------------------------------
+{
+
+  asn_enc_rval_t enc_rval;
+
+  DL_DCCH_Message_t dl_dcch_msg;
+  RRCConnectionReconfiguration_t *rrcConnectionReconfiguration;
+
+
+  memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
+
+  dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration;
+  rrcConnectionReconfiguration          = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionReconfiguration;
+
+  // RRCConnectionReconfiguration
+  rrcConnectionReconfiguration->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionReconfiguration->criticalExtensions.present = RRCConnectionReconfiguration__criticalExtensions_PR_c1;
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.present =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;
+#ifdef CBA
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->cba_RNTI_vlola= cba_rnti;
+#endif
+
+  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
+      =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(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_DL_DCCH_Message,
+                                   (void*)&dl_dcch_msg,
+                                   buffer,
+                                   RRC_BUF_SIZE);
+  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %zd)!\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_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
+
+  //#ifdef USER_MODE
+  LOG_I(RRC,"RRCConnectionReconfiguration Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+  // for (i=0;i<30;i++)
+  //    msg("%x.",buffer[i]);
+  // msg("\n");
+
+  //#endif
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t
+do_RRCConnectionReestablishmentReject(
+  uint8_t                    Mod_id,
+  uint8_t*                   const buffer)
+//------------------------------------------------------------------------------
+{
+
+  asn_enc_rval_t enc_rval;
+
+  DL_CCCH_Message_t dl_ccch_msg;
+  RRCConnectionReestablishmentReject_t *rrcConnectionReestablishmentReject;
+
+  memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t));
+  dl_ccch_msg.message.present           = DL_CCCH_MessageType_PR_c1;
+  dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject;
+  rrcConnectionReestablishmentReject    = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReestablishmentReject;
+
+  // RRCConnectionReestablishmentReject
+  rrcConnectionReestablishmentReject->criticalExtensions.present = RRCConnectionReestablishmentReject__criticalExtensions_PR_rrcConnectionReestablishmentReject_r8;
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message,
+                                   (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_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, Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"RRCConnectionReestablishmentReject Encoded %zd bits (%zd bytes)\n",
+        enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t
+do_RRCConnectionReject(
+  uint8_t                    Mod_id,
+  uint8_t*                   const buffer)
+//------------------------------------------------------------------------------
+{
+
+  asn_enc_rval_t enc_rval;
+
+  DL_CCCH_Message_t dl_ccch_msg;
+  RRCConnectionReject_t *rrcConnectionReject;
+
+  memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t));
+  dl_ccch_msg.message.present           = DL_CCCH_MessageType_PR_c1;
+  dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionReject;
+  rrcConnectionReject                   = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReject;
+
+  // RRCConnectionReject
+  rrcConnectionReject->criticalExtensions.present = RRCConnectionReject__criticalExtensions_PR_c1;
+  rrcConnectionReject->criticalExtensions.choice.c1.present = RRCConnectionReject__criticalExtensions__c1_PR_rrcConnectionReject_r8;
+  /// let's put a wait time of 1s for the moment 
+  rrcConnectionReject->criticalExtensions.choice.c1.choice.rrcConnectionReject_r8.waitTime = 1;
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message,
+                                   (void*)&dl_ccch_msg,
+                                   buffer,
+                                   100);
+  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %ld)!\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_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, Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"RRCConnectionReject Encoded %zd bits (%zd bytes)\n",
+        enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t do_RRCConnectionRelease(
+  uint8_t                             Mod_id,
+  uint8_t                            *buffer,
+  uint8_t                             Transaction_id)
+{
+
+  asn_enc_rval_t enc_rval;
+
+  DL_DCCH_Message_t dl_dcch_msg;
+  RRCConnectionRelease_t *rrcConnectionRelease;
+
+
+  memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
+
+  dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = DL_DCCH_MessageType__c1_PR_rrcConnectionRelease;
+  rrcConnectionRelease                  = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionRelease;
+
+  // RRCConnectionRelease
+  rrcConnectionRelease->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionRelease->criticalExtensions.present = RRCConnectionRelease__criticalExtensions_PR_c1;
+  rrcConnectionRelease->criticalExtensions.choice.c1.present =RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8 ;
+
+  rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause = ReleaseCause_other;
+  rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.redirectedCarrierInfo = NULL;
+  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_DL_DCCH_Message,
+                                   (void*)&dl_dcch_msg,
+                                   buffer,
+                                   RRC_BUF_SIZE);
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+/*
+uint8_t TMGI[5] = {4,3,2,1,0};//TMGI is a string of octet, ref. TS 24.008 fig. 10.5.4a
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+#if defined(Rel10) || defined(Rel14)
+uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
+                           uint8_t sync_area,
+                           uint8_t *buffer,
+                           MCCH_Message_t *mcch_message,
+                           MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration)
+{
+
+  asn_enc_rval_t enc_rval;
+  MBSFN_SubframeConfig_t *mbsfn_SubframeConfig1;
+  PMCH_Info_r9_t *pmch_Info_1;
+  MBMS_SessionInfo_r9_t *mbms_Session_1;
+  // MBMS_SessionInfo_r9_t *mbms_Session_2;
+  eNB_RRC_INST *rrc               = RC.rrc[Mod_id];
+  rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0];
+ 
+
+  memset(mcch_message,0,sizeof(MCCH_Message_t));
+  mcch_message->message.present = MCCH_MessageType_PR_c1;
+  mcch_message->message.choice.c1.present = MCCH_MessageType__c1_PR_mbsfnAreaConfiguration_r9;
+  *mbsfnAreaConfiguration = &mcch_message->message.choice.c1.choice.mbsfnAreaConfiguration_r9;
+
+  // Common Subframe Allocation (CommonSF-Alloc-r9)
+
+  mbsfn_SubframeConfig1= CALLOC(1,sizeof(*mbsfn_SubframeConfig1));
+  memset((void*)mbsfn_SubframeConfig1,0,sizeof(*mbsfn_SubframeConfig1));
+  //
+  mbsfn_SubframeConfig1->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
+  mbsfn_SubframeConfig1->radioframeAllocationOffset= 1;
+  mbsfn_SubframeConfig1->subframeAllocation.present= MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
+  mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf= MALLOC(1);
+  mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.size= 1;
+  mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.bits_unused= 2;
+
+  // CURRENTLY WE ARE SUPPORITNG ONLY ONE sf ALLOCATION
+  switch (sync_area) {
+  case 0:
+    if (carrier->sib1->tdd_Config != NULL) {// pattern 001110 for TDD
+      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused.
+    } else { //111000
+      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2;
+    }
+
+    break;
+
+  case 1:
+    if (carrier->sib1->tdd_Config != NULL) {
+      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused.
+    } else { // 000111
+      mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2;
+    }
+
+  default :
+    break;
+  }
+
+  ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->commonSF_Alloc_r9.list,mbsfn_SubframeConfig1);
+
+  //  commonSF-AllocPeriod-r9
+  (*mbsfnAreaConfiguration)->commonSF_AllocPeriod_r9= MBSFNAreaConfiguration_r9__commonSF_AllocPeriod_r9_rf16;
+
+  // PMCHs Information List (PMCH-InfoList-r9)
+  // PMCH_1  Config
+  pmch_Info_1 = CALLOC(1,sizeof(PMCH_Info_r9_t));
+  memset((void*)pmch_Info_1,0,sizeof(PMCH_Info_r9_t));
+
+  
+   ///take the value of last mbsfn subframe in this CSA period because there is only one PMCH in this mbsfn area
+   ///Note: this has to be set based on the subframeAllocation and CSA
+   
+  pmch_Info_1->pmch_Config_r9.sf_AllocEnd_r9= 3;
+  pmch_Info_1->pmch_Config_r9.dataMCS_r9= 7;
+  pmch_Info_1->pmch_Config_r9.mch_SchedulingPeriod_r9= PMCH_Config_r9__mch_SchedulingPeriod_r9_rf16;
+
+  // MBMSs-SessionInfoList-r9
+  //  pmch_Info_1->mbms_SessionInfoList_r9 = CALLOC(1,sizeof(struct MBMS_SessionInfoList_r9));
+  //  Session 1
+  mbms_Session_1 = CALLOC(1,sizeof(MBMS_SessionInfo_r9_t));
+  memset(mbms_Session_1,0,sizeof(MBMS_SessionInfo_r9_t));
+  // TMGI value
+  mbms_Session_1->tmgi_r9.plmn_Id_r9.present= TMGI_r9__plmn_Id_r9_PR_plmn_Index_r9;
+  mbms_Session_1->tmgi_r9.plmn_Id_r9.choice.plmn_Index_r9= 1;
+  // Service ID
+  memset(&mbms_Session_1->tmgi_r9.serviceId_r9,0,sizeof(OCTET_STRING_t));// need to check
+  OCTET_STRING_fromBuf(&mbms_Session_1->tmgi_r9.serviceId_r9,(const char*)&TMGI[2],3);
+  // Session ID is still missing here, it can be used as an rab id or mrb id
+  mbms_Session_1->sessionId_r9 = CALLOC(1,sizeof(OCTET_STRING_t));
+  mbms_Session_1->sessionId_r9->buf= MALLOC(1);
+  mbms_Session_1->sessionId_r9->size= 1;
+  mbms_Session_1->sessionId_r9->buf[0]= MTCH;
+  // Logical Channel ID
+  mbms_Session_1->logicalChannelIdentity_r9= MTCH;
+  ASN_SEQUENCE_ADD(&pmch_Info_1->mbms_SessionInfoList_r9.list,mbms_Session_1);
+
+      ///  Session 2
+  //mbms_Session_2 = CALLOC(1,sizeof(MBMS_SessionInfo_r9_t));
+  //memset(mbms_Session_2,0,sizeof(MBMS_SessionInfo_r9_t));
+  /// TMGI value
+  //mbms_Session_2->tmgi_r9.plmn_Id_r9.present= TMGI_r9__plmn_Id_r9_PR_plmn_Index_r9;
+  //mbms_Session_2->tmgi_r9.plmn_Id_r9.choice.plmn_Index_r9= 1;
+  /// Service ID
+  //memset(&mbms_Session_2->tmgi_r9.serviceId_r9,0,sizeof(OCTET_STRING_t));// need to check
+  //OCTET_STRING_fromBuf(&mbms_Session_2->tmgi_r9.serviceId_r9,(const char*)&TMGI[3],3);
+  /// Session ID is still missing here
+  //mbms_Session_2->sessionID_r9->buf= MALLOC(1);
+  //mbms_Session_2->sessionID_r9->size= 1;
+  //mbms_Session_2->sessionID_r9->buf[0]= 0x11;
+  /// Logical Channel ID
+  //mbms_Session_2->logicalChannelIdentity_r9= 2;
+  //ASN_SEQUENCE_ADD(&pmch_Info_1->mbms_SessionInfoList_r9.list,mbms_Session_2);
+  
+  ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->pmch_InfoList_r9.list,pmch_Info_1);
+
+#ifdef XER_PRINT
+  xer_fprint(stdout,&asn_DEF_MCCH_Message,(void*)mcch_message);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_MCCH_Message,
+                                   (void*)mcch_message,
+                                   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_MCCH_Message, (void *) &mcch_message)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_MCCH, message_string_size);
+      msg_p->ittiMsg.rrc_dl_mcch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_dl_mcch.text, message_string, message_string_size);
+
+      itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"[eNB] MCCH Message Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  if (enc_rval.encoded==-1) {
+    msg("[RRC] ASN1 : MCCH  encoding failed for MBSFNAreaConfiguration\n");
+    return(-1);
+  }
+
+  return((enc_rval.encoded+7)/8);
+}
+#endif
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t)
+{
+
+  asn_enc_rval_t enc_rval;
+
+  UL_DCCH_Message_t ul_dcch_msg;
+
+  MeasurementReport_t  *measurementReport;
+
+  ul_dcch_msg.message.present                     = UL_DCCH_MessageType_PR_c1;
+  ul_dcch_msg.message.choice.c1.present           = UL_DCCH_MessageType__c1_PR_measurementReport;
+  measurementReport            = &ul_dcch_msg.message.choice.c1.choice.measurementReport;
+
+  measurementReport->criticalExtensions.present=MeasurementReport__criticalExtensions_PR_c1;
+  measurementReport->criticalExtensions.choice.c1.present=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 defined(Rel10) || defined(Rel14)
+  measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrpResult=rsrp_s;
+  measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrqResult=rsrq_s;
+#else
+  measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultServCell.rsrpResult=rsrp_s;
+  measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultServCell.rsrqResult=rsrq_s;
+#endif
+  measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells=CALLOC(1,
+      sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells));
+  measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->present=MeasResults__measResultNeighCells_PR_measResultListEUTRA;
+
+  MeasResultListEUTRA_t  *measResultListEUTRA2;
+  measResultListEUTRA2 = CALLOC(1,sizeof(*measResultListEUTRA2));
+
+  struct MeasResultEUTRA *measresulteutra2;
+  measresulteutra2 = CALLOC(1,sizeof(*measresulteutra2));
+  measresulteutra2->physCellId=phy_id;//1;
+
+  struct MeasResultEUTRA__cgi_Info *measresult_cgi2;
+  measresult_cgi2 = CALLOC(1,sizeof(*measresult_cgi2));
+
+  memset(&measresult_cgi2->cellGlobalId.plmn_Identity,0,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity));
+
+  // measresult_cgi2->cellGlobalId.plmn_Identity.mcc=CALLOC(1,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity.mcc));
+  measresult_cgi2->cellGlobalId.plmn_Identity.mcc = CALLOC(1, sizeof(*measresult_cgi2->cellGlobalId.plmn_Identity.mcc));
+
+  asn_set_empty(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list);//.size=0;
+
+  MCC_MNC_Digit_t dummy;
+  dummy=2;
+  ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy);
+  dummy=6;
+  ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy);
+  dummy=2;
+  ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy);
+
+  measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.size=0;
+  measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.count=0;
+  dummy=8;
+  ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy);
+  dummy=0;
+  ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy);
+
+  measresult_cgi2->cellGlobalId.cellIdentity.buf=MALLOC(8);
+  measresult_cgi2->cellGlobalId.cellIdentity.buf[0]=0x01;
+  measresult_cgi2->cellGlobalId.cellIdentity.buf[1]=0x48;
+  measresult_cgi2->cellGlobalId.cellIdentity.buf[2]=0x0f;
+  measresult_cgi2->cellGlobalId.cellIdentity.buf[3]=0x03;
+  measresult_cgi2->cellGlobalId.cellIdentity.size=4;
+  measresult_cgi2->cellGlobalId.cellIdentity.bits_unused=4;
+
+  measresult_cgi2->trackingAreaCode.buf = MALLOC(2);
+  measresult_cgi2->trackingAreaCode.buf[0]=0x00;
+  measresult_cgi2->trackingAreaCode.buf[1]=0x10;
+  measresult_cgi2->trackingAreaCode.size=2;
+  measresult_cgi2->trackingAreaCode.bits_unused=0;
+
+
+  measresulteutra2->cgi_Info=measresult_cgi2;
+
+  struct MeasResultEUTRA__measResult meas2;
+  //    int rsrp_va=10;
+
+  meas2.rsrpResult=&(rsrp_t);
+  //&rsrp_va;
+  meas2.rsrqResult=&(rsrq_t);
+
+  measresulteutra2->measResult=meas2;
+
+  ASN_SEQUENCE_ADD(&measResultListEUTRA2->list,measresulteutra2);
+
+  measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->choice.measResultListEUTRA=*(measResultListEUTRA2);
+
+  enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message,
+                                   (void*)&ul_dcch_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_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, 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, NB_eNB_INST + Mod_id, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  printf("Measurement Report Encoded %zu bits (%zu bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
+#endif
+
+  return((enc_rval.encoded+7)/8);
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer)
+{
+  ssize_t encoded;
+
+  DL_DCCH_Message_t dl_dcch_msg;
+
+  memset(&dl_dcch_msg, 0, sizeof(DL_DCCH_Message_t));
+
+  dl_dcch_msg.message.present           = DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = DL_DCCH_MessageType__c1_PR_dlInformationTransfer;
+  dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.rrc_TransactionIdentifier = transaction_id;
+  dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.present = DLInformationTransfer__criticalExtensions_PR_c1;
+  dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.present = DLInformationTransfer__criticalExtensions__c1_PR_dlInformationTransfer_r8;
+  dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.present =
+    DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS;
+  dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length;
+  dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer;
+
+  encoded = uper_encode_to_new_buffer (&asn_DEF_DL_DCCH_Message, NULL, (void*) &dl_dcch_msg, (void **) buffer);
+
+  
+// #if defined(ENABLE_ITTI)
+// # if !defined(DISABLE_XER_SPRINT)
+//   {
+//     char        message_string[10000];
+//     size_t      message_string_size;
+
+//     if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_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, Mod_id, msg_p);
+//     }
+//   }
+// # endif
+// #endif
+  
+
+  return encoded;
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer)
+{
+  ssize_t encoded;
+
+  UL_DCCH_Message_t ul_dcch_msg;
+
+  memset(&ul_dcch_msg, 0, sizeof(UL_DCCH_Message_t));
+
+  ul_dcch_msg.message.present           = UL_DCCH_MessageType_PR_c1;
+  ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_ulInformationTransfer;
+  ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.present = ULInformationTransfer__criticalExtensions_PR_c1;
+  ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.present = DLInformationTransfer__criticalExtensions__c1_PR_dlInformationTransfer_r8;
+  ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.present =
+    ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS;
+  ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length;
+  ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer;
+
+  encoded = uper_encode_to_new_buffer (&asn_DEF_UL_DCCH_Message, NULL, (void*) &ul_dcch_msg, (void **) buffer);
+
+  return encoded;
+}
+*/
+
+//------------------------------------------------------------------------------
+
+/*
+OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
+{
+  static OAI_UECapability_t UECapability; /// TODO declared static to allow returning this has an address should be allocated in a cleaner way. 
+  static SupportedBandEUTRA_t Bandlist[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
+  static InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
+  static BandInfoEUTRA_t BandInfoEUTRA[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
+
+  asn_enc_rval_t enc_rval;
+  asn_dec_rval_t dec_rval;
+
+  long maxNumberROHC_ContextSessions = PDCP_Parameters__maxNumberROHC_ContextSessions_cs16;
+  int i;
+
+  UE_EUTRA_Capability_t *UE_EUTRA_Capability;
+  char UE_EUTRA_Capability_xer[8192];
+  size_t size;
+
+  LOG_I(RRC,"Allocating %zu bytes for UE_EUTRA_Capability\n",sizeof(*UE_EUTRA_Capability));
+
+  UE_EUTRA_Capability = CALLOC(1, sizeof(*UE_EUTRA_Capability));
+
+  assert(UE_EUTRA_Capability);
+
+  if (!UE_EUTRA_Capability_xer_fname)  {
+    Bandlist[0].bandEUTRA  = 3;  // UL 1710-1785, DL 1805-1880 FDD
+    Bandlist[0].halfDuplex = 0;
+    Bandlist[1].bandEUTRA  = 20;  // UL 824-849 , DL 869-894 FDD
+    Bandlist[1].halfDuplex = 0;
+    Bandlist[2].bandEUTRA  = 7;   // UL 2500-2570, DL 2620-2690 FDD
+    Bandlist[2].halfDuplex = 0;
+    Bandlist[3].bandEUTRA  = 38;  // UL/DL 2570-2620, TDD
+    Bandlist[3].halfDuplex = 0;
+
+    memset((void*)InterFreqBandInfo, 0, sizeof(InterFreqBandInfo));
+    memset((void*)BandInfoEUTRA, 0, sizeof(BandInfoEUTRA));
+
+    InterFreqBandInfo[0][0].interFreqNeedForGaps = 0;
+    InterFreqBandInfo[0][1].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[0][2].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[0][3].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[1][0].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[1][1].interFreqNeedForGaps = 0;
+    InterFreqBandInfo[1][2].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[1][3].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[2][0].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[2][1].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[2][2].interFreqNeedForGaps = 0;
+    InterFreqBandInfo[2][3].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[3][0].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[3][1].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[3][2].interFreqNeedForGaps = 1;
+    InterFreqBandInfo[3][3].interFreqNeedForGaps = 0;
+
+
+    UE_EUTRA_Capability->accessStratumRelease = 0;//AccessStratumRelease_rel8;
+    UE_EUTRA_Capability->ue_Category          = 4;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0001=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0002=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0003=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0004=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0006=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0101=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0102=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0103=0;
+    UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0104=0;
+
+    UE_EUTRA_Capability->pdcp_Parameters.maxNumberROHC_ContextSessions = &maxNumberROHC_ContextSessions;
+
+    UE_EUTRA_Capability->phyLayerParameters.ue_TxAntennaSelectionSupported = 0;
+    UE_EUTRA_Capability->phyLayerParameters.ue_SpecificRefSigsSupported    = 0;
+    UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count                          = 0;
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[3]);
+
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[3]);
+
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][3]);
+
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][3]);
+
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][3]);
+
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][0]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][1]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][2]);
+    ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][3]);
+
+    // UE_EUTRA_Capability->measParameters.bandListEUTRA.list.count                         = 0;  // no measurements on other bands
+    // UE_EUTRA_Capability->featureGroupIndicators  // null
+
+    if(usim_test == 1)
+    {
+      // featureGroup is mandatory for CMW tests
+      // featureGroup is filled only for usim-test mode
+      BIT_STRING_t *bit_string = CALLOC(1, sizeof(*bit_string));
+      char featrG[4]           = { 0x00, 0x08, 0x00, 0x04 };
+      bit_string->buf          = CALLOC(1, 4);
+      memcpy(bit_string->buf, featrG, 4);
+      bit_string->size         = 4;
+      bit_string->bits_unused  = 0;
+      UE_EUTRA_Capability->featureGroupIndicators = bit_string;
+    }
+
+    // UE_EUTRA_Capability->interRAT_Parameters     // null
+  } else {
+
+    FILE* f = fopen(UE_EUTRA_Capability_xer_fname, "r");
+    assert(f);
+    size = fread(UE_EUTRA_Capability_xer, 1, sizeof UE_EUTRA_Capability_xer, f);
+    fclose(f);
+
+    if (size == 0 || size == sizeof UE_EUTRA_Capability_xer) {
+      LOG_E(RRC,"UE Capabilities XER file %s is too large\n", UE_EUTRA_Capability_xer_fname);
+      free( UE_EUTRA_Capability);
+      return(NULL);
+    }
+
+    dec_rval = xer_decode(0, &asn_DEF_UE_EUTRA_Capability, (void*)UE_EUTRA_Capability, UE_EUTRA_Capability_xer, size);
+    assert(dec_rval.code == RC_OK);
+  }
+
+  UECapability.UE_EUTRA_Capability = UE_EUTRA_Capability;
+#ifdef XER_PRINT
+  xer_fprint(stdout,&asn_DEF_UE_EUTRA_Capability,(void *)UE_EUTRA_Capability);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_UE_EUTRA_Capability,
+                                   (void*)UE_EUTRA_Capability,
+                                   &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);
+
+#if defined(ENABLE_ITTI)
+# if defined(DISABLE_XER_SPRINT)
+  {
+    MessageDef *msg_p;
+
+    msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_UE_EUTRA_CAPABILITY);
+    memcpy (&msg_p->ittiMsg, (void *) UE_EUTRA_Capability, sizeof(RrcUeEutraCapability));
+
+    itti_send_msg_to_task (TASK_UNKNOWN, NB_eNB_INST, msg_p);
+  }
+# else
+  {
+    char        message_string[10000];
+    size_t      message_string_size;
+
+    if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UE_EUTRA_CAPABILITY, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_ue_eutra_capability.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_ue_eutra_capability.text, message_string, message_string_size);
+
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, msg_p);
+    }
+  }
+# endif
+#endif
+
+  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);
+  {
+    char *sdu;
+    //sdu = malloc (3 * UECapability.sdu_size + 1 ); ///* For '\0' 
+
+    for (i = 0; i < UECapability.sdu_size; i++) {
+      sprintf (&sdu[3 * i], "%02x.", UECapability.sdu[i]);
+    }
+
+    LOG_D(PHY, "[RRC]UE Capability encoded, %s\n", sdu);
+    free(sdu);
+  }
+
+  return(&UECapability);
+}
+
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h
new file mode 100644
index 0000000000000000000000000000000000000000..640c86dade3cbb788ae3f1fc3e09abd3b78d0c56
--- /dev/null
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h
@@ -0,0 +1,274 @@
+/*
+ * 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 asn1_msg.h
+* \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
+*/
+
+#ifdef USER_MODE
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdlib.h> /* for atoi(3) */
+#include <unistd.h> /* for getopt(3) */
+#include <string.h> /* for strerror(3) */
+#include <sysexits.h> /* for EX_* exit codes */
+#include <errno.h>  /* for errno */
+#else
+#include <linux/module.h>  /* Needed by all modules */
+#endif
+
+#include <asn_application.h>
+#include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */
+
+#include "RRC/NR/defs_NR.h"
+
+/*
+ * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)
+ * output into the chosen string buffer.
+ * RETURN VALUES:
+ *       0: The structure is printed.
+ *      -1: Problem printing the structure.
+ * WARNING: No sensible errno value is returned.
+ */
+int xer_sprint_NR(char *string, size_t string_size, struct asn_TYPE_descriptor_s *td, void *sptr);
+
+uint16_t get_adjacent_cell_id_NR(uint8_t Mod_id,uint8_t index);
+
+uint8_t get_adjacent_cell_mod_id_NR(uint16_t phyCellId);
+
+/**
+\brief Generate configuration for SIB1 (eNB).
+@param carrier pointer to Carrier information
+@param N_RB_DL Number of downlink PRBs
+@param phich_Resource PHICH resoure parameter
+@param phich_duration PHICH duration parameter
+@param frame radio frame number
+@return size of encoded bit stream in bytes*/
+uint8_t do_MIB_NR(rrc_gNB_carrier_data_t *carrier, 
+                  uint32_t frame, 
+                  uint32_t ssb_SubcarrierOffset, 
+                  uint32_t pdcch_ConfigSIB1, 
+                  uint32_t subCarrierSpacingCommon, 
+                  uint32_t dmrs_TypeA_Position);
+/**
+\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  
+@return size of encoded bit stream in bytes*/
+
+uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier,int Mod_id,int CC_id, gNB_RrcConfigurationReq *configuration
+               );
+
+/**
+\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)
+@param buffer Pointer to PER-encoded ASN.1 description of SI PDU
+@param systemInformation Pointer to asn1c C representation of SI PDU
+@param sib2 Pointer (returned) to sib2 component withing SI PDU
+@param sib3 Pointer (returned) to sib3 component withing SI PDU
+@param sib13 Pointer (returned) to sib13 component withing SI PDU
+@param MBMS_flag Indicates presence of MBMS system information (when 1)
+@return size of encoded bit stream in bytes*/
+
+/*uint8_t do_SIB23(uint8_t Mod_id,
+                 int CC_id
+#if defined(ENABLE_ITTI)
+                 , RrcConfigurationReq *configuration
+#endif
+                );
+
+/**
+\brief Generate an RRCConnectionRequest UL-CCCH-Message (UE) based on random string or S-TMSI.  This
+routine only generates an mo-data establishment cause.
+@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
+@param rv 5 byte random string or S-TMSI
+@returns Size of encoded bit stream in bytes*/
+
+/*uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv);
+
+/** \brief Generate an RRCConnectionSetupComplete UL-DCCH-Message (UE)
+@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
+@returns Size of encoded bit stream in bytes*/
+
+/*uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t* buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength,
+                                      const char* dedicatedInfoNAS);
+
+/** \brief Generate an RRCConnectionReconfigurationComplete UL-DCCH-Message (UE)
+@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
+@returns Size of encoded bit stream in bytes*/
+
+/*uint8_t
+do_RRCConnectionReconfigurationComplete(
+  const protocol_ctxt_t* const ctxt_pP,
+  uint8_t* buffer,
+  const uint8_t Transaction_id
+);
+
+/**
+\brief Generate an RRCConnectionSetup DL-CCCH-Message (eNB).  This routine configures SRB_ToAddMod (SRB1/SRB2) and
+PhysicalConfigDedicated IEs.  The latter does not enable periodic CQI reporting (PUCCH format 2/2a/2b) or SRS.
+@param ctxt_pP Running context
+@param ue_context_pP UE context
+@param CC_id         Component Carrier ID
+@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
+@param transmission_mode Transmission mode for UE (1-9)
+@param UE_id UE index for this message
+@param Transaction_id Transaction_ID for this message
+@param SRB_configList Pointer (returned) to SRB1_config/SRB2_config(later) IEs for this UE
+@param physicalConfigDedicated Pointer (returned) to PhysicalConfigDedicated IE for this UE
+@returns Size of encoded bit stream in bytes*/
+/*uint8_t
+do_RRCConnectionSetup(
+  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,
+  SRB_ToAddModList_t**             SRB_configList,
+  struct PhysicalConfigDedicated** physicalConfigDedicated
+);
+
+/**
+\brief Generate an RRCConnectionReconfiguration DL-DCCH-Message (eNB).  This routine configures SRBToAddMod (SRB2) and one DRBToAddMod
+(DRB3).  PhysicalConfigDedicated is not updated.
+@param ctxt_pP Running context
+@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
+@param Transaction_id Transaction_ID for this message
+@param SRB_list Pointer to SRB List to be added/modified (NULL if no additions/modifications)
+@param DRB_list Pointer to DRB List to be added/modified (NULL if no additions/modifications)
+@param DRB_list2 Pointer to DRB List to be released      (NULL if none to be released)
+@param sps_Config Pointer to sps_Config to be modified (NULL if no modifications, or default if initial configuration)
+@param physicalConfigDedicated Pointer to PhysicalConfigDedicated to be modified (NULL if no modifications)
+@param MeasObj_list Pointer to MeasObj List to be added/modified (NULL if no additions/modifications)
+@param ReportConfig_list Pointer to ReportConfig List (NULL if no additions/modifications)
+@param QuantityConfig Pointer to QuantityConfig to be modified (NULL if no modifications)
+@param MeasId_list Pointer to MeasID List (NULL if no additions/modifications)
+@param mobilityInfo mobility control information for handover
+@param speedStatePars speed state parameteres for handover
+@param mac_MainConfig Pointer to Mac_MainConfig(NULL if no modifications)
+@param measGapConfig Pointer to MeasGapConfig (NULL if no modifications)
+@param cba_rnti RNTI for the cba transmission
+@returns Size of encoded bit stream in bytes*/
+
+/*uint16_t
+do_RRCConnectionReconfiguration(
+  const protocol_ctxt_t*        const ctxt_pP,
+    uint8_t                            *buffer,
+    uint8_t                             Transaction_id,
+    SRB_ToAddModList_t                 *SRB_list,
+    DRB_ToAddModList_t                 *DRB_list,
+    DRB_ToReleaseList_t                *DRB_list2,
+    struct SPS_Config                  *sps_Config,
+    struct PhysicalConfigDedicated     *physicalConfigDedicated,
+    MeasObjectToAddModList_t           *MeasObj_list,
+    ReportConfigToAddModList_t         *ReportConfig_list,
+    QuantityConfig_t                   *quantityConfig,
+    MeasIdToAddModList_t               *MeasId_list,
+    MAC_MainConfig_t                   *mac_MainConfig,
+    MeasGapConfig_t                    *measGapConfig,
+    MobilityControlInfo_t              *mobilityInfo,
+    struct MeasConfig__speedStatePars  *speedStatePars,
+    RSRP_Range_t                       *rsrp,
+    C_RNTI_t                           *cba_rnti,
+  struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList* dedicatedInfoNASList
+#if defined(Rel10) || defined(Rel14)
+    , SCellToAddMod_r10_t  *SCell_config
+#endif
+                                        );
+
+/**
+\brief Generate an RRCConnectionReestablishmentReject DL-CCCH-Message (eNB).
+@param Mod_id Module ID of eNB
+@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
+@returns Size of encoded bit stream in bytes*/
+/*uint8_t
+do_RRCConnectionReestablishmentReject(
+    uint8_t                    Mod_id,
+    uint8_t*                   const buffer);
+
+/**
+\brief Generate an RRCConnectionReject DL-CCCH-Message (eNB).
+@param Mod_id Module ID of eNB
+@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
+@returns Size of encoded bit stream in bytes*/
+/*uint8_t
+do_RRCConnectionReject(
+    uint8_t                    Mod_id,
+    uint8_t*                   const buffer);
+
+/**
+\brief Generate an RRCConnectionRequest UL-CCCH-Message (UE) based on random string or S-TMSI.  This
+routine only generates an mo-data establishment cause.
+@param Mod_id Module ID of eNB
+@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
+@param transaction_id Transaction index
+@returns Size of encoded bit stream in bytes*/
+
+/*uint8_t do_RRCConnectionRelease(uint8_t Mod_id, uint8_t *buffer,int Transaction_id);
+
+/***
+ * \brief Generate an MCCH-Message (eNB). This routine configures MBSFNAreaConfiguration (PMCH-InfoList and Subframe Allocation for MBMS data)
+ * @param buffer Pointer to PER-encoded ASN.1 description of MCCH-Message PDU
+ * @returns Size of encoded bit stream in bytes
+*/
+/*uint8_t do_MCCHMessage(uint8_t *buffer);
+#if defined(Rel10) || defined(Rel14)
+/***
+ * \brief Generate an MCCH-Message (eNB). This routine configures MBSFNAreaConfiguration (PMCH-InfoList and Subframe Allocation for MBMS data)
+ * @param buffer Pointer to PER-encoded ASN.1 description of MCCH-Message PDU
+ * @returns Size of encoded bit stream in bytes
+*/
+/*uint8_t do_MBSFNAreaConfig(uint8_t Mod_id,
+                           uint8_t sync_area,
+                           uint8_t *buffer,
+                           MCCH_Message_t *mcch_message,
+                           MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration);
+#endif
+
+uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t);
+
+uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer);
+
+uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer);
+
+OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer);
+
+uint8_t
+do_UECapabilityEnquiry(
+  const protocol_ctxt_t* const ctxt_pP,
+  uint8_t*               const buffer,
+  const uint8_t                Transaction_id
+);
+
+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);
diff --git a/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-InterNodeDefinitions.asn b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-InterNodeDefinitions.asn
new file mode 100644
index 0000000000000000000000000000000000000000..13cbb9258444b5cc4477adc5a1a9078e871aed0d
--- /dev/null
+++ b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-InterNodeDefinitions.asn
@@ -0,0 +1,282 @@
+NR-InterNodeDefinitions DEFINITIONS AUTOMATIC TAGS ::=
+ 
+BEGIN
+
+-- TAG-HANDOVER-COMMAND-START
+
+HandoverCommand ::=					SEQUENCE {
+	criticalExtensions					CHOICE {
+		c1									CHOICE{
+			handoverCommand					HandoverCommand-IEs,
+			spare3 NULL, spare2 NULL, spare1 NULL
+		},
+		criticalExtensionsFuture			SEQUENCE {}
+	}
+}
+
+HandoverCommand-IEs ::=				SEQUENCE {
+	handoverCommandMessage				OCTET STRING (CONTAINING RRCReconfiguration),
+	nonCriticalExtension				SEQUENCE {}							OPTIONAL
+}
+
+-- TAG-HANDOVER-COMMAND-STOP
+-- TAG-HANDOVER-PREPARATION-INFORMATION-START
+
+HandoverPreparationInformation ::=	SEQUENCE {
+	criticalExtensions					CHOICE {
+		c1									CHOICE{
+			handoverPreparationInformation		HandoverPreparationInformation-IEs,
+			spare3 NULL, spare2 NULL, spare1 NULL
+		},
+		criticalExtensionsFuture			SEQUENCE {}
+	}
+}
+
+HandoverPreparationInformation-IEs ::= SEQUENCE {
+	ue-CapabilityRAT-List				UE-CapabilityRAT-ContainerList,
+	sourceConfig						OCTET STRING (CONTAINING RRCReconfiguration),
+	rrm-Config							RRM-Config				OPTIONAL,
+	as-Context							AS-Context				OPTIONAL,
+	nonCriticalExtension				SEQUENCE {}				OPTIONAL
+}
+
+AS-Context ::=							SEQUENCE {
+	reestablishmentInfo						SEQUENCE {
+		sourcePhysCellId					PhysCellId,
+		targetCellShortMAC-I				ShortMAC-I,
+		additionalReestabInfoList			ReestabNCellInfoList					OPTIONAL
+	}																				OPTIONAL,
+	-- FFS Whether to change e.g. move all re-establishment info to Xx
+	configRestrictInfo					ConfigRestrictInfoSCG						OPTIONAL,
+	...
+}
+
+ReestabNCellInfoList ::=		SEQUENCE ( SIZE (1..maxCellPrep) ) OF ReestabNCellInfo
+
+ReestabNCellInfo::=	SEQUENCE{
+	cellIdentity							CellIdentity,
+	key-gNodeB-Star							BIT STRING (SIZE (256)),
+	shortMAC-I								ShortMAC-I
+}
+
+RRM-Config ::=				SEQUENCE {
+	ue-InactiveTime				ENUMERATED {
+									s1, s2, s3, s5, s7, s10, s15, s20,
+									s25, s30, s40, s50, min1, min1s20c, min1s40,
+									min2, min2s30, min3, min3s30, min4, min5, min6,
+									min7, min8, min9, min10, min12, min14, min17, min20,
+									min24, min28, min33, min38, min44, min50, hr1,
+									hr1min30, hr2, hr2min30, hr3, hr3min30, hr4, hr5, hr6,
+									hr8, hr10, hr13, hr16, hr20, day1, day1hr12, day2,
+									day2hr12, day3, day4, day5, day7, day10, day14, day19,
+									day24, day30, dayMoreThan30}		OPTIONAL ,
+	candidateCellInfoList		CandidateCellInfoList		OPTIONAL,
+	...
+}
+
+-- TAG-HANDOVER-PREPARATION-INFORMATION-STOP
+-- TAG-CG-CONFIG-START
+
+CG-Config ::=					SEQUENCE {
+	criticalExtensions					CHOICE {
+		c1									CHOICE{
+			cg-Config					CG-Config-IEs,
+			spare3 NULL, spare2 NULL, spare1 NULL
+		},
+		criticalExtensionsFuture			SEQUENCE {}
+	}
+}
+
+CG-Config-IEs ::=			SEQUENCE {
+	scg-CellGroupConfig					OCTET STRING (CONTAINING RRCReconfiguration)	OPTIONAL,
+	scg-RB-Config						OCTET STRING (CONTAINING RadioBearerConfig)		OPTIONAL,
+	configRestrictModReq				ConfigRestrictModReqSCG							OPTIONAL,
+	drx-InfoSCG							DRX-Info										OPTIONAL,
+	candidateCellInfoListSN				OCTET STRING (CONTAINING CandidateCellInfoList)	OPTIONAL,
+	measConfigSN						MeasConfigSN									OPTIONAL,
+	selectedBandCombinationNR			BandCombinationIndex							OPTIONAL,
+	nonCriticalExtension				SEQUENCE {}										OPTIONAL
+}
+
+MeasConfigSN ::= SEQUENCE {
+	measuredFrequenciesFR1				SEQUENCE (SIZE (1..maxMeasFreqsMN))	OF NR-FreqInfo	OPTIONAL,
+	...
+}
+
+NR-FreqInfo ::= SEQUENCE {
+	measuredFrequency 					ARFCN-ValueNR									OPTIONAL,
+	...
+}
+
+ConfigRestrictModReqSCG ::=			SEQUENCE {
+	requestedBC-MRDC					BandCombinationIndex							OPTIONAL,
+	requestedBPC-ListMRDC				BPC-IndexList									OPTIONAL,
+	requestedP-MaxFR1				P-Max												OPTIONAL,
+	...
+}
+
+BandCombinationIndex ::= INTEGER (1..maxBandComb)
+
+-- TAG-CG-CONFIG-STOP
+-- TAG-CG-CONFIG-INFO-START
+
+CG-ConfigInfo ::=				SEQUENCE {
+	criticalExtensions				CHOICE {
+		c1								CHOICE{
+			cg-ConfigInfo				CG-ConfigInfo-IEs,
+			spare3 NULL, spare2 NULL, spare1 NULL
+		},
+		criticalExtensionsFuture		SEQUENCE {}
+	}
+}
+
+CG-ConfigInfo-IEs ::=		SEQUENCE {
+	ue-CapabilityInfo			OCTET STRING (CONTAINING UE-CapabilityRAT-ContainerList)		OPTIONAL,-- Cond SN-Addition
+	candidateCellInfoListMN			CandidateCellInfoList									OPTIONAL,
+	candidateCellInfoListSN			OCTET STRING (CONTAINING CandidateCellInfoList)			OPTIONAL,
+	measResultCellListSFTD			MeasResultCellListSFTD									OPTIONAL,
+	scgFailureInfo					SEQUENCE {
+		failureType						ENUMERATED { t310-Expiry, randomAccessProblem,
+														rlc-MaxNumRetx, scg-ChangeFailure, 
+														scg-reconfigFailure,
+														srb3-IntegrityFailure},
+		measResultSCG					OCTET STRING (CONTAINING MeasResultSCG-Failure)
+	}																						OPTIONAL,
+	configRestrictInfo			ConfigRestrictInfoSCG										OPTIONAL,
+	drx-InfoMCG					DRX-Info													OPTIONAL,
+	measConfigMN				MeasConfigMN												OPTIONAL,
+	sourceConfigSCG				OCTET STRING (CONTAINING RRCReconfiguration)				OPTIONAL,
+	scg-RB-Config             	OCTET STRING (CONTAINING RadioBearerConfig)        			OPTIONAL,
+	mcg-RB-Config				OCTET STRING (CONTAINING RadioBearerConfig)					OPTIONAL,
+	nonCriticalExtension		SEQUENCE {}													OPTIONAL
+}
+
+ConfigRestrictInfoSCG ::=		SEQUENCE {
+	allowedBC-ListMRDC				BandCombinationIndexList								OPTIONAL,
+	allowedBPC-ListMRDC				BPC-IndexList											OPTIONAL,
+	powerCoordination-FR1				SEQUENCE {
+		p-maxNR							P-Max												OPTIONAL,
+		p-maxEUTRA						P-Max												OPTIONAL
+	}																						OPTIONAL,
+	servCellIndexRangeSCG			SEQUENCE {
+		lowBound						ServCellIndex,
+		upBound							ServCellIndex
+	}																						OPTIONAL,   -- Cond SN-Addition
+	maxMeasFreqsSCG-NR					INTEGER(1..maxMeasFreqsMN)								OPTIONAL,
+	...
+}
+
+BandCombinationIndexList ::= SEQUENCE (SIZE (1..maxBandComb)) OF BandCombinationIndex
+
+BPC-IndexList ::= SEQUENCE (SIZE (1..maxBasebandProcComb)) OF BPC-Index
+BPC-Index ::= INTEGER (1..maxBasebandProcComb)
+
+DRX-Info ::=					SEQUENCE {
+	drx-LongCycleStartOffset		CHOICE {
+		ms10							INTEGER(0..9),
+		ms20							INTEGER(0..19),
+		ms32							INTEGER(0..31),
+		ms40							INTEGER(0..39),
+		ms60							INTEGER(0..59),
+		ms64							INTEGER(0..63),
+		ms70							INTEGER(0..69),
+		ms80							INTEGER(0..79),
+		ms128							INTEGER(0..127),
+		ms160							INTEGER(0..159),
+		ms256							INTEGER(0..255),
+		ms320							INTEGER(0..319),
+		ms512							INTEGER(0..511),
+		ms640							INTEGER(0..639),
+		ms1024							INTEGER(0..1023),
+		ms1280							INTEGER(0..1279),
+		ms2048							INTEGER(0..2047),
+		ms2560							INTEGER(0..2559),
+		ms5120							INTEGER(0..5119),
+		ms10240							INTEGER(0..10239)
+	},
+	shortDRX							SEQUENCE {
+		drx-ShortCycle						ENUMERATED	{
+												ms2, ms3, ms4, ms5, ms6, ms7, ms8, ms10, ms14, ms16, ms20, ms30, ms32,
+												ms35, ms40, ms64, ms80, ms128, ms160, ms256, ms320, ms512, ms640, spare9,
+												spare8, spare7, spare6, spare5, spare4, spare3, spare2, spare1 },
+		drx-ShortCycleTimer					INTEGER (1..16)
+	}																					OPTIONAL
+}
+
+MeasConfigMN ::= SEQUENCE {
+	measuredFrequenciesMN				SEQUENCE (SIZE (1..maxMeasFreqsMN))	OF NR-FreqInfo	OPTIONAL,
+	measGapConfigFR1					GapConfig											OPTIONAL,
+	gapPurpose							ENUMERATED {perUE, perFR1}							OPTIONAL,
+	...
+}
+
+
+-- TAG-CG-CONFIG-INFO-STOP
+-- TAG-MEASUREMENT-TIMING-CONFIGURATION-START
+
+MeasurementTimingConfiguration ::=				SEQUENCE {
+	criticalExtensions				CHOICE {
+		c1								CHOICE{
+			measTimingConf					MeasurementTimingConfiguration-IEs,
+			spare3 NULL, spare2 NULL, spare1 NULL
+		},
+		criticalExtensionsFuture		SEQUENCE {}
+	}
+}
+
+MeasurementTimingConfiguration-IEs ::=	SEQUENCE {
+	measTiming								MeasTimingList							OPTIONAL,
+	nonCriticalExtension					SEQUENCE {}								OPTIONAL
+}
+
+MeasTimingList ::= SEQUENCE (SIZE (1..maxMeasFreqsMN)) OF MeasTiming  
+
+MeasTiming ::= SEQUENCE {
+	carrierFreq								ARFCN-ValueNR							OPTIONAL,         
+	ssb-MeasurementTimingConfiguration		ENUMERATED {ffsTypeAndValue}		OPTIONAL,
+	...
+}
+
+-- TAG-MEASUREMENT-TIMING-CONFIGURATION-STOP
+-- TAG-CANDIDATE-CELL-INFO-LIST-START
+
+CandidateCellInfoList ::=	SEQUENCE (SIZE (1.. maxNrofSCells)) OF CandidateCellInfo
+
+CandidateCellInfo ::=			SEQUENCE {
+	cellIdentification				SEQUENCE {
+		physCellId						PhysCellId,
+		dl-CarrierFreq					ARFCN-ValueNR
+	},
+	measResultCell					MeasQuantityResults											OPTIONAL,
+	candidateRS-IndexListSSB		CandidateRS-IndexInfoListSSB								OPTIONAL,
+	candidateRS-IndexListCSI-RS		CandidateRS-IndexInfoListCSI-RS								OPTIONAL,
+	...
+}
+
+CandidateRS-IndexInfoListSSB ::=	SEQUENCE (SIZE (1..maxNrofIndexesToReport)) OF CandidateRS-IndexInfoSSB
+
+CandidateRS-IndexInfoSSB ::=	SEQUENCE {
+	ssb-Index						SSB-Index,
+	measResultSSB					MeasQuantityResults											OPTIONAL,
+	...
+}
+
+CandidateRS-IndexInfoListCSI-RS ::=	SEQUENCE (SIZE (1..maxNrofIndexesToReport)) OF CandidateRS-IndexInfoCSI-RS
+
+CandidateRS-IndexInfoCSI-RS ::=		SEQUENCE {
+	csi-RS-Index							CSI-RS-Index,
+	measResultCSI-RS						MeasQuantityResults									OPTIONAL,
+	...
+}
+
+-- TAG-CANDIDATE-CELL-INFO-LIST-STOP
+-- TAG_NR-MULTIPLICITY-AND-CONSTRAINTS-START
+
+maxMeasFreqsMN				INTEGER ::= 32	-- Maximum number of MN-configured measurement frequencies
+maxCellPrep					INTEGER ::= 32	-- Maximum number of cells prepared for handover
+
+-- TAG_NR-MULTIPLICITY-AND-CONSTRAINTS-STOP
+-- TAG_NR-INTER-NODE-DEFINITIONS-END-START
+
+END
+
diff --git a/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-RRC-Definitions.asn b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-RRC-Definitions.asn
new file mode 100644
index 0000000000000000000000000000000000000000..dd6b0c56a7fd90fdc8133473bcbd1400497b4ae5
--- /dev/null
+++ b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-RRC-Definitions.asn
@@ -0,0 +1,5480 @@
+NR-RRC-Definitions DEFINITIONS AUTOMATIC TAGS ::=
+ 
+BEGIN
+
+-- TAG-BCCH-BCH-MESSAGE-START
+
+BCCH-BCH-Message ::= SEQUENCE {
+	message											BCCH-BCH-MessageType
+}
+
+BCCH-BCH-MessageType ::= CHOICE {
+	mib												MIB,
+	messageClassExtension	SEQUENCE {}
+}
+
+-- TAG-BCCH-BCH-MESSAGE-STOP
+-- TAG-DL-DCCH-MESSAGE-START
+
+DL-DCCH-Message ::= SEQUENCE {
+	message											DL-DCCH-MessageType
+}
+
+DL-DCCH-MessageType ::= CHOICE {
+	c1						CHOICE {
+		rrcReconfiguration							RRCReconfiguration,
+		spare15 NULL, spare14 NULL, spare13 NULL,
+		spare12 NULL, spare11 NULL, spare10 NULL,
+		spare9 NULL, spare8 NULL, spare7 NULL,
+		spare6 NULL, spare5 NULL, spare4 NULL,
+		spare3 NULL, spare2 NULL, spare1 NULL
+	},
+	messageClassExtension	SEQUENCE {}
+}
+
+-- TAG-DL-DCCH-MESSAGE-STOP
+-- TAG-UL-DCCH-MESSAGE-START
+
+UL-DCCH-Message ::= SEQUENCE {
+	message											UL-DCCH-MessageType
+}
+
+UL-DCCH-MessageType ::= CHOICE {
+	c1						CHOICE {
+		measurementReport							MeasurementReport,
+		rrcReconfigurationComplete					RRCReconfigurationComplete,
+		spare14 NULL, spare13 NULL, spare12 NULL,
+		spare11 NULL, spare10 NULL, spare9 NULL,
+		spare8 NULL, spare7 NULL, spare6 NULL,
+		spare5 NULL, spare4 NULL, spare3 NULL,
+		spare2 NULL, spare1 NULL
+	},
+	messageClassExtension	SEQUENCE {}
+}
+
+-- TAG-UL-DCCH-MESSAGE-STOP
+-- TAG-MIB-START
+
+MIB ::= SEQUENCE {
+	-- The 6 most significant bit (MSB) of the 10 bit System Frame Number. The 4 LSB of the SFN are conveyed in the PBCH transport block 
+	-- as well but outside the MIB. 
+	systemFrameNumber					BIT STRING (SIZE (6)),
+
+	-- Subcarrier spacing for SIB1, Msg.2/4 for initial access and broadcast SI-messages.
+	-- If the UE acquires this MIB on a carrier frequency <6GHz, the values 15 and 30 kHz are applicable. 
+	-- If the UE acquires this MIB on a carrier frequency >6GHz, the values 60 and 120 kHz are applicable. 
+	subCarrierSpacingCommon				ENUMERATED {scs15or60, scs30or120},
+
+	-- The frequency domain offset between SSB and the overall resource block grid in number of subcarriers. (See 38.211, section 7.4.3.1)
+	-- Note: For frequencies <6 GHz a fith, this field may comprise only the 4 least significant bits of the ssb-SubcarrierOffset.
+	-- The codepoint "FFS_RAN1" indicates that this cell does not provide SIB1 and that there is hence no common CORESET.
+	ssb-SubcarrierOffset				INTEGER (0..15),
+
+	-- Position of (first) DL DM-RS. Corresponds to L1 parameter 'DL-DMRS-typeA-pos' (see 38.211, section 7.4.1.1.1)
+	dmrs-TypeA-Position					ENUMERATED {pos2, pos3},
+
+	-- Determines a bandwidth for PDCCH/SIB, a common ControlResourceSet (CORESET) a common search space and necessary PDCCH parameters.
+	-- Corresponds to L1 parameter 'RMSI-PDCCH-Config' (see FFS_Specification, section FFS_Section)
+	pdcch-ConfigSIB1					INTEGER (0..255), 
+
+	-- Indicates that UE shall not camp on this cell
+	cellBarred							ENUMERATED {barred, notBarred}, 
+	
+	-- Controls cell reselection to intra-frequency cells when the highest ranked cell is barred, or treated as barred by the UE, 
+	-- as specified in TS 38.304.
+	intraFreqReselection				ENUMERATED {allowed, notAllowed},
+	spare								BIT STRING (SIZE (1))
+}
+
+-- TAG-MIB-STOP
+-- TAG-MEASUREMENTREPORT-START
+
+MeasurementReport ::=				SEQUENCE {
+	criticalExtensions					CHOICE {
+		measurementReport							MeasurementReport-IEs,
+		criticalExtensionsFuture					SEQUENCE {}
+	}
+}
+
+MeasurementReport-IEs ::=		SEQUENCE {
+	measResults						MeasResults,
+
+	lateNonCriticalExtension				OCTET STRING															OPTIONAL,
+	nonCriticalExtension					SEQUENCE{}																OPTIONAL
+}
+
+-- TAG-MEASUREMENTREPORT-STOP
+-- TAG-RRCRECONFIGURATION-START
+
+RRCReconfiguration ::= 				SEQUENCE {
+	rrc-TransactionIdentifier			RRC-TransactionIdentifier,
+	criticalExtensions					CHOICE {
+		rrcReconfiguration					RRCReconfiguration-IEs,
+		criticalExtensionsFuture			SEQUENCE {}
+	}
+}
+
+RRCReconfiguration-IEs ::= 			SEQUENCE {
+	-- Configuration of Radio Bearers (DRBs, SRBs) including SDAP/PDCP. 
+    -- In EN-DC this field may only be present if the RRCReconfiguration
+	-- is transmitted over SRB3. 
+	radioBearerConfig						RadioBearerConfig 														OPTIONAL, -- Need M
+
+	-- Configuration of secondary cell group (EN-DC):
+	secondaryCellGroup						OCTET STRING (CONTAINING CellGroupConfig)								OPTIONAL, -- Need M
+
+	measConfig								MeasConfig																OPTIONAL, -- Need M
+
+	lateNonCriticalExtension				OCTET STRING															OPTIONAL,
+	nonCriticalExtension					SEQUENCE {}																OPTIONAL 
+}
+
+-- TAG-RRCRECONFIGURATION-STOP
+-- TAG-RRCRECONFIGURATIONCOMPLETE-START
+
+RRCReconfigurationComplete ::= 			SEQUENCE {
+	rrc-TransactionIdentifier				RRC-TransactionIdentifier,
+	criticalExtensions						CHOICE {
+		rrcReconfigurationComplete				RRCReconfigurationComplete-IEs,
+		criticalExtensionsFuture				SEQUENCE {}
+	}
+}
+
+RRCReconfigurationComplete-IEs ::= SEQUENCE {
+	lateNonCriticalExtension				OCTET STRING															OPTIONAL,
+	nonCriticalExtension					SEQUENCE {}																OPTIONAL 
+}
+
+-- TAG-RRCRECONFIGURATIONCOMPLETE-STOP
+-- TAG-SIB1-START
+
+SIB1 ::=		SEQUENCE {
+
+	-- FFS / TODO: Add other parameters. 
+
+	-- Frequency offset for the SSB of -5kHz (M=-1) or +5kHz (M=1). When the field is absent, the UE applies no offset (M=0).
+	-- The offset is only applicable for the frequency range 0-2.65GHz. Corresponds to parameter 'M' (see 38.101, section FFS_Section)
+	frequencyOffsetSSB				ENUMERATED {khz-5, khz5}																OPTIONAL,	-- Need R
+
+	-- Time domain positions of the transmitted SS-blocks in an SS-Burst-Set (see 38.213, section 4.1)
+	ssb-PositionsInBurst				SEQUENCE {
+		-- Indicates the presence of the up to 8 SSBs in one group
+		inOneGroup							BIT STRING (SIZE (8)),
+		-- For above 6 GHz: indicates which groups of SSBs is present
+		groupPresence						BIT STRING (SIZE (8))										OPTIONAL -- Cond above6GHzOnly
+	},
+
+	-- The SSB periodicity in msec for the rate matching purpose (see 38.211, section [7.4.3.1])
+	ssb-PeriodicityServingCell			ENUMERATED {ms5, ms10, ms20, ms40, ms80, ms160, spare1, spare2},
+
+	-- TX power that the NW used for SSB transmission. The UE uses it to estimate the RA preamble TX power. 
+	-- (see 38.213, section 7.4)
+	ss-PBCH-BlockPower					INTEGER (-60..50),
+
+	uplinkConfigCommon						UplinkConfigCommon											OPTIONAL,
+	-- FFS: How to indicate the FrequencyInfoUL for the SUL
+	supplementaryUplink					SEQUENCE {
+		uplinkConfigCommon					UplinkConfigCommon											OPTIONAL 
+		-- FFS: Add additional (selection) criteria determining when/whether the UE shall use the SUL frequency 
+	}																									OPTIONAL, -- Cond SUL
+
+	tdd-UL-DL-Configuration				TDD-UL-DL-ConfigCommon											OPTIONAL, -- Cond TDD
+	tdd-UL-DL-configurationCommon2		TDD-UL-DL-ConfigCommon											OPTIONAL, -- Cond TDD
+
+	pdcch-ConfigCommon					PDCCH-ConfigCommon												OPTIONAL,
+	pucch-ConfigCommon					PUCCH-ConfigCommon												OPTIONAL,
+
+	lateNonCriticalExtension				OCTET STRING															OPTIONAL,
+	nonCriticalExtension					SEQUENCE{}																OPTIONAL 
+}
+
+-- TAG-SIB1-STOP
+-- TAG-SETUP-RELEASE-START
+
+SetupRelease { ElementTypeParam } ::= CHOICE {
+	release			NULL,
+	setup			ElementTypeParam
+}
+
+-- TAG-SETUP-RELEASE-STOP
+-- TAG-ADDITIONALSPECTRUMEMISSION-START
+
+AdditionalSpectrumEmission ::=				INTEGER (0..7)
+
+-- TAG-ADDITIONALSPECTRUMEMISSION-STOP
+-- TAG-ALPHA-START
+
+Alpha ::=						ENUMERATED {alpha0, alpha04, alpha05, alpha06, alpha07, alpha08, alpha09, alpha1}
+
+-- TAG-ALPHA-STOP
+-- TAG-ARFCN-VALUE-NR-START
+
+ARFCN-ValueNR ::=				INTEGER (0..3279165)
+
+-- TAG-ARFCN-VALUE-NR-STOP
+-- TAG-BANDWIDTH-PART-START
+
+
+-- Generic parameters used in Uplink- and Downlink bandwidth parts
+BWP ::= 					SEQUENCE {
+	-- Frequency domain location and bandwidth of this bandwidth part defined commonly in a table (FFS_Section). The location is given as 
+	-- distance (in number of PRBs) to point A (absoluteFrequencyPointA in FrequencyInfoDL). 
+	-- Corresponds to L1 parameter 'DL-BWP-loc'. (see 38.211, section FFS_Section).		
+	-- In case of TDD, a BWP-pair (UL BWP and DL BWP with the same bwp-Id) must have the same location (see 38.211, section REF)
+	locationAndBandwidth			INTEGER (0..37949),
+	-- Subcarrier spacing to be used in this BWP for all channels and 
+	-- reference signals unless explicitly configured elsewhere.
+	-- Corresponds to subcarrier spacing according to 38.211, Table 4.2-1. 
+	-- The value kHz15 corresponds to µ=0, kHz30 to µ=1, and so on. Only the values 15 or 30 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are 
+	-- applicable.
+	subcarrierSpacing				SubcarrierSpacing,
+	-- Indicates whether to use the extended cyclic prefix for this bandwidth part. If not set, the UE uses the normal cyclic prefix. 
+	-- Normal CP is supported for all numerologies and slot formats. Extended CP is supported only for 60 kHz subcarrier spacing. 
+	-- (see 38.211, section 4.2.2)
+	cyclicPrefix					ENUMERATED { extended }														OPTIONAL	-- Need R
+}
+
+BWP-Uplink ::= 			SEQUENCE {
+	-- An identifier for this bandwidth part. Other parts of the RRC configuration use the BWP-Id to associate themselves with a particular
+	-- bandwidth part. The BWP ID=0 is always associated with the initial BWP and may hence not be used here (in other bandwidth parts).
+	-- The NW may trigger the UE to swtich UL or DL BWP using a DCI field. The four code points in that DCI field map to the RRC-configured 
+	-- BWP-ID as follows: For up to 3 configured BWPs (in addition to the initial BWP) the DCI code point is equivalent to the BWP ID 
+	-- (initial = 0, first dedicated = 1, ...). If the NW configures 4 dedicated bandwidth parts, they are identified by DCI code 
+	-- points 0 to 3. In this case it is not possible to switch to the initial BWP using the DCI field.
+	-- Corresponds to L1 parameter 'UL-BWP-index'. (see 38.211, 38.213, section 12)
+	bwp-Id								BWP-Id,
+	bwp-Common							BWP-UplinkCommon														OPTIONAL,	-- Need M
+	bwp-Dedicated						BWP-UplinkDedicated														OPTIONAL,	-- Need M
+	...
+}
+
+BWP-UplinkCommon ::=				SEQUENCE {
+	genericParameters					BWP,
+	-- Configuration of cell specific random access parameters which the UE uses for contention based and contention free random access
+	-- as well as for contention based beam failure recovery. 
+	rach-ConfigCommon					 RACH-ConfigCommon 										OPTIONAL, 	-- Need M
+	-- Cell specific parameters for the PUSCH
+	pusch-ConfigCommon					 PUSCH-ConfigCommon 										OPTIONAL, 	-- Need M
+	
+	-- Cell specific parameters for the PUCCH
+	pucch-ConfigCommon					 PUCCH-ConfigCommon 										OPTIONAL, 	-- Need M
+	...
+}
+
+BWP-UplinkDedicated ::= 	SEQUENCE {
+	-- PUCCH configuration for one BWP of the regular UL or SUL of a serving cell. If the UE is configured with SUL, the network 
+	-- configures PUCCH only on the BWPs of one of the uplinks (UL or SUL).
+	pucch-Config						 PUCCH-Config 											OPTIONAL, 	-- Need M
+	-- PUSCH configuration for one BWP of the regular UL or SUL of a serving cell. If the UE is configured with SUL and
+	-- if it has a PUSCH-Config for both UL and SUL, a carrier indicator field in DCI indicates for which of the two to use an UL grant.
+	-- See also L1 parameter 'dynamicPUSCHSUL' (see 38.213, section FFS_Section)
+	pusch-Config						 PUSCH-Config 											OPTIONAL, 	-- Need M
+	-- A Configured-Grant of typ1 or type2. It may be configured for Ul or SUL but in case of type1 [FFS also type2] not for both at a time.
+	configuredGrantConfig				         ConfiguredGrantConfig 									        OPTIONAL, 	-- Need M
+	-- Uplink sounding reference signal configuration
+	srs-Config						 SRS-Config 											OPTIONAL, 	-- Need M
+	-- Determines how the UE performs Beam Failure Recovery upon detection of a Beam Failure (see RadioLinkMonitoringConfig)
+	beamFailureRecoveryConfig			         BeamFailureRecoveryConfig 								        OPTIONAL,	-- Need M
+	...
+}
+
+
+BWP-Downlink ::= 					SEQUENCE {
+	-- An identifier for this bandwidth part. Other parts of the RRC configuration use the BWP-Id to associate themselves with a particular
+	-- bandwidth part. The BWP ID=0 is always associated with the initial BWP and may hence not be used here. (in other bandwidth parts).
+	-- The NW may trigger the UE to swtich UL or DL BWP using a DCI field. The four code points in that DCI field map to the RRC-configured 
+	-- BWP-ID as follows: For up to 3 configured BWPs (in addition to the initial BWP) the DCI code point is equivalent to the BWP ID 
+	-- (initial = 0, first dedicated = 1, ...). If the NW configures 4 dedicated bandwidth parts, they are identified by DCI code 
+	-- points 0 to 3. In this case it is not possible to switch to the initial BWP using the DCI field.
+	-- Corresponds to L1 parameter 'DL-BWP-index'. (see 38.211, 38.213, section 12)
+	bwp-Id								BWP-Id,
+	bwp-Common							BWP-DownlinkCommon														OPTIONAL,	-- Need M
+	bwp-Dedicated						BWP-DownlinkDedicated													OPTIONAL,	-- Need M
+	...
+}
+
+
+BWP-DownlinkCommon ::=				SEQUENCE {
+	genericParameters					BWP,
+	pdcch-ConfigCommon				        PDCCH-ConfigCommon 										OPTIONAL,	-- Need M
+	pdsch-ConfigCommon					PDSCH-ConfigCommon 										OPTIONAL,	-- Need M
+	...
+}
+
+BWP-DownlinkDedicated ::= 			SEQUENCE {
+	pdcch-Config						PDCCH-Config 											OPTIONAL,	-- Need M
+	pdsch-Config						PDSCH-Config 											OPTIONAL,	-- Need M 
+	sps-Config						SPS-Config 											OPTIONAL, 	-- Need M
+	radioLinkMonitoringConfig			        RadioLinkMonitoringConfig 								        OPTIONAL,	-- Need M
+	...
+}
+
+
+-- TAG-BANDWIDTH-PART-STOP 
+-- TAG-BWP-ID-START
+
+BWP-Id ::=							INTEGER (0..maxNrofBWPs)
+
+-- TAG-BWP-ID-STOP
+-- TAG-BEAM-FAILURE-RECOVERY-CONFIG-START
+
+BeamFailureRecoveryConfig ::= 		SEQUENCE {
+	rootSequenceIndex-BFR				INTEGER (0..137)															OPTIONAL,	--	Need M
+	-- Configuration of contention free random access occasions for BFR
+	rach-ConfigBFR						RACH-ConfigGeneric															OPTIONAL,	--	Need M
+	-- L1-RSRP threshold used for determining whether a candidate beam may be used by the UE to attempt contention free 
+	-- Random Access to recover from beam failure. The signalled threshold is applied directly for SSB, a threshold for 
+	-- CSI-RS is determined by linearly scaling singalled value based on Pc_ss corresponding to the CSI-RS resource.
+	-- (see FFS_Specification, FFS_Section)
+	candidateBeamThreshold		RSRP-Range																			OPTIONAL,	--	Need M
+	-- A list of reference signals (CSI-RS and/or SSB) identifying the candidate beams for recover and the associated RA parameters
+	candidateBeamRSList					SEQUENCE (SIZE(1..maxNrofCandidateBeams)) OF PRACH-ResourceDedicatedBFR		OPTIONAL,	--	Need M
+	-- Explicitly signalled PRACH Mask Index for RA Resource selection in TS 36.321. The mask is valid for all SSB resources
+	ra-ssb-OccasionMaskIndex			INTEGER (0..15)																OPTIONAL, 	--	Need M
+	-- Control Resource Set that the UE uses to receive the random access response for beam failure recovery. 
+	-- If the field is absent the UE uses the initial CORESET (ControlResourceSetId = 0)
+	recoveryControlResourceSetId		ControlResourceSetId														OPTIONAL	,	-- Need S
+	-- Search space to use for BFR RAR. If the field is absent, the UE uses the initial Serach Space (SearchSpaceId = 0).
+	recoverySearchSpaceId				SearchSpaceId																OPTIONAL,	-- Need S
+	...
+}
+
+PRACH-ResourceDedicatedBFR ::= 		CHOICE {
+	ssb									BFR-SSB-Resource,
+	csi-RS								BFR-CSIRS-Resource
+}
+
+BFR-SSB-Resource ::= 			SEQUENCE {
+	-- The ID of an SSB transmitted by this serving cell. It determines a candidate beam for beam failure recovery (BFR)
+	ssb								SSB-Index,
+	-- The preamble index that the UE shall use when performing BFR upon selecting the candidate beams identified by this SSB.
+	ra-PreambleIndex				INTEGER (0..63),
+	...
+}
+
+BFR-CSIRS-Resource ::=			SEQUENCE {
+	-- The ID of a NZP-CSI-RS-Resource configured in the CSI-MeasConfig of this serving cell. This reference signal determines a candidate beam
+	-- for beam failure recovery (BFR).
+	csi-RS							NZP-CSI-RS-ResourceId,
+	-- RA occasions that the UE shall use when performing BFR upon selecting the candidate beam identified by this CSI-RS. If the field is absent
+	-- the UE uses the RA occasion associated with the SSB that is QCLed with this CSI-RS. 
+	-- The RA preamble index to use in the RA occasions associated with this CSI-RS. If the field is absent, the UE uses the preamble index
+	-- associated with the SSB that is QCLed with this CSI-RS. 
+	ra-PreambleIndex				INTEGER (0..63)																	OPTIONAL,	-- Need R
+	...
+}
+
+-- TAG-BEAM-FAILURE-RECOVERY-CONFIG-STOP
+-- TAG-CELL-GROUP-CONFIG-START
+
+-- Configuration of one Cell-Group:
+CellGroupConfig	::= 						SEQUENCE {
+	cellGroupId									CellGroupId,
+
+	-- Logical Channel configuration and association with radio bearers:
+	rlc-BearerToAddModList 						SEQUENCE (SIZE(1..maxLC-ID)) OF RLC-Bearer-Config				OPTIONAL,   -- Need N
+	rlc-BearerToReleaseList						SEQUENCE (SIZE(1..maxLC-ID)) OF LogicalChannelIdentity			OPTIONAL,   -- Need N
+
+	-- Parameters applicable for the entire cell group:
+	mac-CellGroupConfig							MAC-CellGroupConfig												OPTIONAL,	-- Need M
+	physicalCellGroupConfig						PhysicalCellGroupConfig											OPTIONAL,	-- Need M
+
+	-- Serving Cell specific parameters (SpCell and SCells)
+	spCellConfig								SpCellConfig													OPTIONAL, 	-- Need M
+	sCellToAddModList							SEQUENCE (SIZE (1..maxNrofSCells)) OF SCellConfig				OPTIONAL,	-- Need N
+	-- List of seconary serving cells to be released (not applicable for SpCells)
+	sCellToReleaseList							SEQUENCE (SIZE (1..maxNrofSCells)) OF SCellIndex				OPTIONAL,	-- Need N
+	...
+}
+
+-- The ID of a cell group. 0 identifies the master cell group. Other values identify secondary cell groups.
+-- In this version of the specification only values 0 and 1 are supported.
+-- FFS: This should be moved to be own IE section
+CellGroupId ::=									INTEGER (0.. maxSecondaryCellGroups)
+
+
+RLC-Bearer-Config ::=								SEQUENCE {
+	-- ID used commonly for the MAC logical channel and for the RLC bearer.
+	logicalChannelIdentity						LogicalChannelIdentity,
+
+	-- Associates the RLC Bearer with an SRB or a DRB. The UE shall deliver DL RLC SDUs received via the RLC entity of this
+	-- RLC bearer to the PDCP entity of the servedRadioBearer. Furthermore, the UE shall advertise and deliver uplink PDCP PDUs of the 
+	-- uplink PDCP entity of the servedRadioBearer to the uplink RLC entity of this RLC bearer unless the uplink scheduling 
+	-- restrictions ('moreThanOneRLC' in PDCP-Config and the restrictions in LogicalChannelConfig) forbid it to do so.
+	servedRadioBearer							CHOICE {
+		srb-Identity                           SRB-Identity,
+		drb-Identity                           DRB-Identity
+	}																											OPTIONAL,	-- Cond LCH-SetupOnly
+
+	reestablishRLC								ENUMERATED {true}												OPTIONAL, 	-- Need N
+	rlc-Config									RLC-Config														OPTIONAL,	-- Cond LCH-Setup
+
+	mac-LogicalChannelConfig					LogicalChannelConfig											OPTIONAL,	-- Cond LCH-Setup
+	...	
+}
+
+LogicalChannelIdentity ::= 					INTEGER (1..maxLC-ID)
+
+-- Cell-Group specific L1 parameters
+PhysicalCellGroupConfig ::=					SEQUENCE {
+	-- Enables spatial bundling of HARQ ACKs. It is configured per cell group (i.e. for all the cells within the cell group) for PUCCH 
+	-- reporting of HARQ-ACK. It is only applicable when more than 4 layers are possible to schedule.
+	-- Corresponds to L1 parameter 'HARQ-ACK-spatial-bundling' (see 38.213, section FFS_Section)
+	-- Absence indicates that spatial bundling is disabled.
+	harq-ACK-SpatialBundlingPUCCH				ENUMERATED {true}												OPTIONAL,	-- Need R
+
+	-- Enables spatial bundling of HARQ ACKs. It is configured per cell group (i.e. for all the cells within the cell group) for PUSCH 
+	-- reporting of HARQ-ACK. It is only applicable when more than 4 layers are possible to schedule.
+	-- Corresponds to L1 parameter 'HARQ-ACK-spatial-bundling' (see 38.213, section FFS_Section)
+	-- Absence indicates that spatial bundling is disabled.
+	harq-ACK-SpatialBundlingPUSCH				ENUMERATED {true}												OPTIONAL,	-- Need R
+	-- The maximum transmit power to be used by the UE in this NR cell group. 
+	p-NR										P-Max															OPTIONAL,	-- Need R
+	-- The PDSCH HARQ-ACK codebook is either semi-static of dynamic. This is applicable to both CA and none CA operation.
+	-- Corresponds to L1 parameter 'HARQ-ACK-codebook' (see 38.213, section FFS_Section)
+	pdsch-HARQ-ACK-Codebook						ENUMERATED {semiStatic, dynamic},
+	-- RNTI used for SRS TPC commands on DCI. Corresponds to L1 parameter 'TPC-SRS-RNTI' (see 38.213, section 10)
+	tpc-SRS-RNTI								RNTI-Value														OPTIONAL,	-- Need R
+	-- RNTI used for PUCCH TPC commands on DCI. Corresponds to L1 parameter 'TPC-PUCCH-RNTI' (see 38.213, section 10).
+	tpc-PUCCH-RNTI								RNTI-Value														OPTIONAL,	-- Need R
+	-- RNTI used for PUSCH TPC commands on DCI. Corresponds to L1 parameter 'TPC-PUSCH-RNTI' (see 38.213, section 10)
+	tpc-PUSCH-RNTI	RNTI-Value																					OPTIONAL,-- Need R
+	...
+}
+
+
+-- Serving cell specific MAC and PHY parameters for a SpCell:
+SpCellConfig ::=						SEQUENCE {
+	-- Serving cell ID of a PSCell (the PCell of the Master Cell Group uses ID = 0)
+	servCellIndex						ServCellIndex															OPTIONAL,	-- Cond SCG
+	-- Parameters for the synchronous reconfiguration to the target SpCell:
+	reconfigurationWithSync 			ReconfigurationWithSync 												OPTIONAL,	-- Cond ReconfWithSync
+	rlf-TimersAndConstants				RLF-TimersAndConstants 									        OPTIONAL,	-- Need M
+	rlmInSyncOutOfSyncThreshold         INTEGER (0..1)                         									OPTIONAL,	-- Need M
+	spCellConfigDedicated				ServingCellConfig														OPTIONAL,	-- Need M
+	...
+}
+
+ReconfigurationWithSync ::=			SEQUENCE {
+	spCellConfigCommon					ServingCellConfigCommon													OPTIONAL,	-- Need M
+	newUE-Identity						RNTI-Value,
+	t304								ENUMERATED {ms50, ms100, ms150, ms200, ms500, ms1000, ms2000, ms10000},
+		rach-ConfigDedicated				CHOICE {
+			uplink								RACH-ConfigDedicated,
+			supplementaryUplink					RACH-ConfigDedicated
+	}																											OPTIONAL,	-- Need N
+	...
+}			
+
+SCellConfig ::=						SEQUENCE {
+	sCellIndex							SCellIndex,
+	sCellConfigCommon					ServingCellConfigCommon													OPTIONAL,	-- Cond SCellAdd
+	sCellConfigDedicated				ServingCellConfig														OPTIONAL,	-- Cond SCellAddMod
+	...
+}
+
+-- TAG-CELL-GROUP-CONFIG-STOP 
+-- TAG-CODEBOOKCONFIG-START
+CodebookConfig ::= 									SEQUENCE {
+	-- CodebookType including possibly sub-types and the corresponding parameters for each. Corresponds to L1 parameter 'CodebookType'
+	-- (see 38.214, section 5.2.2.2)
+	codebookType 										CHOICE {
+		type1 												SEQUENCE {
+			subType										CHOICE {
+				typeI-SinglePanel									SEQUENCE {
+					nrOfAntennaPorts									CHOICE {
+						two													SEQUENCE {
+							-- Codebook subset restriction for 2TX codebook 
+							-- Corresponds to L1 parameter ' TypeI-SinglePanel-2Tx-CodebookSubsetRestriction' (see 38.214 section 5.2.2.2.1)
+							twoTX-CodebookSubsetRestriction						BIT STRING (SIZE (6))
+						},
+						moreThanTwo											SEQUENCE {
+							-- Number of antenna ports in first (n1) and second (n2) dimension and codebook subset restriction
+							-- Corresponds to L1 parameters 'CodebookConfig-N1', 'CodebookConfig-N2'
+							-- 'TypeI-SinglePanel-CodebookSubsetRestriction ' (see 38.214 section 5.2.2.2.1)
+							n1-n2												CHOICE {
+								two-one-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (8)),
+								two-two-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (64)),
+								four-one-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (16)),
+								three-two-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (96)),
+								six-one-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (24)),
+								four-two-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (128)),
+								eight-one-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (32)),
+								four-three-TypeI-SinglePanel-Restriction			BIT STRING (SIZE (192)),
+								six-two-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (192)),
+								twelve-one-TypeI-SinglePanel-Restriction			BIT STRING (SIZE (48)),
+								four-four-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (256)),
+								eight-two-TypeI-SinglePanel-Restriction				BIT STRING (SIZE (256)),
+								sixteen-one-TypeI-SinglePanel-Restriction			BIT STRING (SIZE (64))
+							},
+							-- i2 codebook subset restriction for Type I Single-panel codebook used when reportQuantity is CRI/Ri/i1/CQI
+							-- Corresponds to L1 parameter 'TypeI-SinglePanel-CodebookSubsetRestriction-i2' (see 38.214 section 5.2.2.2.1)
+							typeI-SinglePanel-codebookSubsetRestriction-i2		BIT STRING (SIZE (16))	OPTIONAL
+						}
+					},
+					-- Restriction for RI for TypeI-SinglePanel-RI-Restriction
+					-- Corresponds to L1 parameter 'TypeI-SinglePanel-RI-Restriction' (see 38.214, section 5.2.2.2.1)
+					typeI-SinglePanel-ri-Restriction					BIT STRING (SIZE (8))
+				}, 
+				typeI-MultiPanel									SEQUENCE {
+					-- Codebook subset restriction for Type I Multi-panel codebook
+					-- Corresponds to L1 parameter 'TypeI-MultiPanel-CodebookSubsetRestriction' (see 38.214, section 5.2.2.2.2)
+					ng-n1-n2												CHOICE {
+						two-two-one-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (8)),
+						two-four-one-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (32)),
+						four-two-one-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (32)),
+						two-two-two-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (128)),
+						two-eight-one-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (64)),
+						four-four-one-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (64)),
+						two-four-two-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (256)),
+						four-two-two-TypeI-MultiPanel-Restriction				BIT STRING (SIZE (256))
+					},
+					-- Restriction for RI for TypeI-MultiPanel-RI-Restriction
+					-- Corresponds to L1 parameter 'TypeI-MultiPanel-RI-Restriction' (see 38.214, section 5.2.2.2.2)
+					ri-Restriction							BIT STRING (SIZE (4))
+				}
+			},
+			-- CodebookMode as specified in 38.214 section 5.2.2.2.2
+			codebookMode										INTEGER (1..2)
+
+		},
+		type2									SEQUENCE {
+			subType									CHOICE {
+				typeII									SEQUENCE {
+					-- Number of antenna ports in first (n1) and second (n2) dimension and codebook subset restriction
+					-- Corresponds to L1 parameters 'CodebookConfig-N1', 'CodebookConfig-N2'
+					-- The CHOICE name indicates the value of n1 and n2, the CHOICE contents is the codebook subset restriction bitmap
+					-- Corresponds to L1 parameter ' TypeII-CodebookSubsetRestriction' (see 38.214 section 5.2.2.2.3)
+					-- Number of bits for codebook subset restriction is ceil(log2(nchoosek(O1*O2,4)))+8*n1*n2 where nchoosek(a,b) = a!/(b!(a-b)!)
+					n1-n2-codebookSubsetRestriction			CHOICE {
+						two-one									BIT STRING (SIZE (16)),
+						two-two									BIT STRING (SIZE (139)),
+						four-one								BIT STRING (SIZE (32)),
+						three-two								BIT STRING (SIZE (59)),
+						six-one									BIT STRING (SIZE (49)),
+						four-two								BIT STRING (SIZE (75)),
+						eight-one								BIT STRING (SIZE (65)),
+						four-three								BIT STRING (SIZE (107)),
+						six-two									BIT STRING (SIZE (107)),
+						twelve-one								BIT STRING (SIZE (129)),
+						four-four								BIT STRING (SIZE (139)),
+						eight-two								BIT STRING (SIZE (139)),
+						sixteen-one								BIT STRING (SIZE (129))
+					},
+					-- Restriction for RI for TypeII-RI-Restriction
+					-- Corresponds to L1 parameter 'TypeII-RI-Restriction' (see 38.214, section 5.2.2.2.3)
+					typeII-RI-Restriction					BIT STRING (SIZE (2))
+				}, 
+				typeII-PortSelection					SEQUENCE {
+					-- The size of the port selection codebook (parameter d)
+					portSelectionSamplingSize				ENUMERATED {n1, n2, n3, n4}					OPTIONAL,		-- Cond TypeII-PortSelection
+					-- Restriction for RI for TypeII-PortSelection-RI-Restriction
+					-- Corresponds to L1 parameter 'TypeII-PortSelection-RI-Restriction' (see 38.214, section 5.2.2.4)
+					typeII-PortSelectionRI-Restriction		BIT STRING (SIZE (2))
+				}
+			},
+			-- The size of the PSK alphabet, QPSK or 8-PSK
+			phaseAlphabetSize						ENUMERATED {n4, n8},
+			-- If subband amplitude reporting is activated (true)
+			subbandAmplitude						BOOLEAN,
+			-- Number of beams, L,  used for linear combination
+			numberOfBeams							ENUMERATED {two, three, four}
+		}
+	}
+}
+
+-- TAG-CODEBOOKCONFIG-STOP
+-- TAG-CONFIGUREDGRANTCONFIG-START
+
+ConfiguredGrantConfig ::=				SEQUENCE {
+
+	-- Frequency hopping as agreed in RAN1-AH18776
+	frequencyHopping             ENUMERATED {mode1, mode2},
+	-- DMRS configuration, as agreed in RAN1-AH18776
+	cg-DMRS-Configuration		DMRS-UplinkConfig,
+
+	-- Indicates the MCS table the UE shall use for PUSCH without transform precoding, as agreed in RAN1-AH18776
+	mcs-Table					ENUMERATED {qam64, qam256},
+	-- Indicates the MCS table the UE shall use for PUSCH with transform precoding, as agreed in RAN1-AH18776
+	-- When the field is absent the UE applies the value 64QAM
+	mcs-TableTransformPrecoder		ENUMERATED {qam256}																	OPTIONAL,	-- Need S
+	-- Selection between and configuration of dynamic and semi-static beta-offset, as agreed in RAN1-AH18776
+	-- Note: For Type 1 UL data transmission without grant, "uci-on-PUSCH" should be set to semiStatic
+	uci-OnPUSCH							CG-UCI-OnPUSCH ,
+	-- Configuration of resource allocation type 0 and resource allocation type 1, as agreed in RAN1-AH18776
+	-- Note: For Type 1 UL data transmission without grant, "resourceAllocation" should be resourceAllocationType0 or resourceAllocationType1
+	resourceAllocation					ENUMERATED { resourceAllocationType0, resourceAllocationType1, dynamicSwitch },
+	-- Selection between config 1 and config 2 for RBG size for PUSCH. When the field is absent the UE applies the value config1.
+	-- Note: rbg-Size is used when the transformPrecoder parameter is disabled.
+	rbg-Size								ENUMERATED {config2}														OPTIONAL,	-- Need S
+									
+	-- Closed control loop to apply. Corresponds to L1 parameter 'PUSCH-closed-loop-index' (see 38.213, section FFS_Section)
+	powerControlLoopToUse					ENUMERATED {n0, n1},
+	-- Index of the P0-PUSCH-AlphaSet to be used for this configuration
+	p0-PUSCH-Alpha							P0-PUSCH-AlphaSetId,
+	-- Enable transformer precoder for type1 and type2. Absence indicates that it is disabled.
+	-- Corresponds to L1 parameter 'UL-TWG-tp' (see 38.214, section 6.1.3)
+	transformPrecoder						ENUMERATED {enabled}														OPTIONAL,	-- Need R
+	-- The number of HARQ processes configured. It applies for both Type 1 and Type 2
+	-- Corresponds to L1 parameter 'UL-TWG-numbHARQproc' (see 38.321, section 5.8.2)
+	nrofHARQ-Processes						INTEGER(1..16),
+	-- 	The number or repetitions of K:
+	repK									ENUMERATED {n1, n2, n4, n8},
+	-- If repetitions is used, this field indicates the redundancy version (RV) sequence to use.
+	-- Corresponds to L1 parameter 'UL-TWG-RV-rep' (see 38.321, section 5.8.2)
+	repK-RV									ENUMERATED {s1-0231, s2-0303, s3-0000}										OPTIONAL,	-- Cond RepK
+	-- Periodicity for UL transmission without UL grant for type 1 and type 2
+	-- Corresponds to L1 parameter 'UL-TWG-periodicity' (see 38.321, section 5.8.2)
+
+	-- The following periodicities are supported depending on the configured subcarrier spacing [symbols]:
+	--	15kHz: 2, 7, n*14, where n={1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 128, 160, 320, 640}
+	--	30kHz: 2, 7, n*14, where n={1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 128, 160, 256, 320, 640, 1280}
+	--	60kHz with normal CP: 2, 7, n*14, where n={1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 128, 160, 256, 320, 512, 640, 1280, 2560}
+	--	60kHz with ECP: 2, 6, n*12, where n={1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 128, 160, 256, 320, 512, 640, 1280, 2560}
+	--	120kHz: 2, 7, n*14, where n={1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 128, 160, 256, 320, 512, 640, 1024, 1280, 2560, 5120}
+	-- (see 38.214, Table 6.1.2.3-1)
+	periodicity								ENUMERATED {
+												sym2, sym7, sym1x14, sym2x14, sym4x14, sym5x14, sym8x14, sym10x14, sym16x14, sym20x14,
+												sym32x14, sym40x14, sym64x14, sym80x14, sym128x14, sym160x14, sym256x14, sym320x14, sym512x14,
+												sym640x14, sym1024x14, sym1280x14, sym2560x14, sym5120x14,
+
+												sym6, sym1x12, sym2x12, sym4x12, sym5x12, sym8x12, sym10x12, sym16x12, sym20x12, sym32x12,
+												sym40x12, sym64x12, sym80x12, sym128x12, sym160x12, sym256x12, sym320x12, sym512x12, sym640x12,
+												sym1280x12, sym2560x12
+											},
+
+	-- If configured, the UE uses the configured grant timer (see 38.321, section 5.8.2) with this initial timer value.
+	-- Supported values are as follows in units of symbols:
+	-- For normal CP: 2, 7, {1, 2, 4, 5, 8, 10, 20, 32, 40, 64, 80, 128, 160, 256, 512, 640 } x 14
+	-- For extended CP: 2, 6, {1, 2, 4, 8, 20, 40, 80, 128, 160, 256, 320, 512, 640 } x 12
+	configuredGrantTimer					ENUMERATED {
+												sym2, sym7, sym1x14, sym2x14, sym4x14, sym5x14, sym8x14, sym10x14, sym16x14, sym20x14, sym32x14,
+												sym40x14, sym64x14, sym80x14, sym128x14, sym160x14, sym256x14, sym512x14, sym640x14,
+
+												sym6, sym1x12, sym2x12, sym4x12, sym5x12, sym8x12, sym10x12, sym16x12, sym20x12, sym32x12,
+												sym40x12, sym64x12, sym80x12, sym128x12, sym256x12, sym320x12, sym512x12, sym640x12
+											}																			OPTIONAL,	-- Need R
+	-- Selection between "configured grant" transmission with fully RRC-configured UL grant (Type1) 
+	-- or with UL grant configured by DCI addressed to CS-RNTI (Type2).
+	rrc-ConfiguredUplinkGrant		SEQUENCE {
+			-- Offset related to SFN=0
+			timeDomainOffset						INTEGER  (0..5119),
+			-- Corresponding to the DCI field of time domain resource assignment, and the maximum bit width is 4.
+			--(see 38.214, section 6.1.2 and 38.212, section 7.3.1)
+			timeDomainAllocation					 INTEGER  (0..15), -- RAN1 indicated just "Mapping-type,Index-start-len"
+            -- Corresponding to the DCI field of freq domain resource assignment. 
+			-- (see 38.214, section 6.1.2, and 38.212, section 7.3.1)
+			frequencyDomainAllocation				BIT STRING (SIZE(18)),
+			-- UE-specific DMRS configuration: corresponding to the DCI field of antenna ports, and the maximum bitwidth is 5. 
+			-- (see 38.214, section 6.1.2, and 38.212, section 7.3.1)
+            antennaPort								INTEGER   (0..31),
+            dmrs-SeqInitialization					INTEGER   (0..1)          					  OPTIONAL,  -- Cond NoTransformPrecoder
+            precodingAndNumberOfLayers				INTEGER   (0..63),
+            srs-ResourceIndicator					INTEGER   (0..15),
+			-- The modulation order, target code rate and TB size (see 38.214, section 6.1.2)
+			mcsAndTBS								INTEGER (0..31),
+			-- Enables intra-slot frequency hopping with the given frequency hopping offset
+			-- Corresponds to L1 parameter 'UL-TWG-hopping' (see 38.214, section FFS_Section)
+
+			frequencyHoppingOffset					INTEGER (1.. maxNrofPhysicalResourceBlocks-1),
+			pathlossReferenceIndex					INTEGER (0..maxNrofPUSCH-PathlossReferenceRSs-1),
+			...
+	}																								OPTIONAL  -- Cond Type1
+}
+
+CG-UCI-OnPUSCH ::= CHOICE {
+	dynamic									SEQUENCE (SIZE (1..4)) OF BetaOffsets,
+	semiStatic								BetaOffsets
+}
+
+-- TAG-CONFIGUREDGRANTCONFIG-STOP
+-- TAG-CONTROLRESOURCESET-START
+
+ControlResourceSet ::= 					SEQUENCE {
+	-- Corresponds to L1 parameter 'CORESET-ID'
+	-- Value 0 identifies the common CORESET configured in MIB and in ServingCellConfigCommon
+	-- Values 1..maxNrofControlResourceSets-1 identify CORESETs configured by dedicated signalling
+	-- The controlResourceSetId is unique among the BWPs of a ServingCell.
+	controlResourceSetId					ControlResourceSetId,
+
+
+	-- Frequency domain resources for the CORESET. Each bit corresponds a group of 6 RBs, with grouping starting from PRB 0, which is fully 
+	-- contained in the bandwidth part within which the CORESET is configured. 
+	-- The most significant bit corresponds to the group of lowest frequency which is fully contained in the bandwidth part within which the 
+	-- CORESET is configured, each next subsequent lower significance bit corresponds to the next lowest frequency group fully contained within
+	-- the bandwidth part within which the CORESET is configured, if any. 
+	-- Bits corresponding to a group not fully contained within the bandwidth part within which the CORESET is configured are set to zero. 
+	-- Corresponds to L1 parameter 'CORESET-freq-dom'(see 38.211, section 7.3.2.2)
+	frequencyDomainResources				BIT STRING (SIZE (45)),
+	-- Contiguous time duration of the CORESET in number of symbols 
+	-- Corresponds to L1 parameter 'CORESET-time-duration' (see 38.211, section 7.3.2.2FFS_Section)
+	duration								INTEGER (1..maxCoReSetDuration),
+	-- Mapping of Control Channel Elements (CCE) to Resource Element Groups (REG). 
+	-- Corresponds to L1 parameter 'CORESET-CCE-REG-mapping-type' (see 38.211Section sections 7.3.2.2 and 7.4.1.3.2)
+	cce-REG-MappingType							CHOICE { 
+		interleaved								SEQUENCE {
+			-- Resource Element Groups (REGs) can be bundled to create REG bundles. This parameter defines the size of such bundles. 
+			-- Corresponds to L1 parameter 'CORESET-REG-bundle-size' (see 38.211, section FFS_Section)
+			reg-BundleSize							ENUMERATED {n2, n3, n6},
+			-- Corresponds to L1 parameter 'CORESET-interleaver-size' (see 38.211, 38.213, section FFS_Section)
+			interleaverSize							ENUMERATED {n2, n3, n6}, 
+			-- Corresponds to L1 parameter 'CORESET-shift-index' (see 38.211, section 7.3.2.2)
+			shiftIndex								INTEGER(0..maxNrofPhysicalResourceBlocks-1)
+		}, 
+		nonInterleaved 							NULL
+	},
+	-- Precoder granularity in frequency domain. 
+	-- Corresponds to L1 parameter 'CORESET-precoder-granuality' (see 38.211, sections 7.3.2.2 and 7.4.1.3.2)
+	precoderGranularity						ENUMERATED {sameAsREG-bundle, allContiguousRBs},
+
+	-- A subset of the TCI states defined in TCI-States used for providing QCL relationships between the DL RS(s) in one RS Set 
+	-- (TCI-State) and the PDCCH DMRS ports. Corresponds to L1 parameter 'TCI-StatesPDCCH' (see 38.214, section FFS_Section)
+	tci-StatesPDCCH							SEQUENCE(SIZE (1..maxNrofTCI-StatesPDCCH)) OF TCI-StateId				OPTIONAL,	-- Need R
+
+	-- If at least spatial QCL is configured/indicated, this field indicates if TCI field is present or not present in DL-related DCI.
+	-- When the field is absent the UE considers the TCI to be absent/disabled.
+	-- Corresponds to L1 parameter 'TCI-PresentInDCI' (see 38,213, section 5.1.5)
+	tci-PresentInDCI						ENUMERATED {enabled}													OPTIONAL, 	-- Need S
+
+	-- PDCCH DMRS scrambling initalization. Corresponds to L1 parameter 'PDCCH-DMRS-Scrambling-ID' (see 38.214, section 5.1)
+	-- When the field is absent the UE applies the value '0'.
+	pdcch-DMRS-ScramblingID					BIT STRING (SIZE (16))													OPTIONAL 	-- Need S
+}
+
+-- TAG-CONTROLRESOURCESET-STOP
+-- TAG-CONTROL-RESOURCE-SET-ID-START
+
+ControlResourceSetId ::=				INTEGER (0..maxNrofControlResourceSets-1)
+
+-- TAG-CONTROL-RESOURCE-SET-ID-STOP
+
+CrossCarrierSchedulingConfig ::=		SEQUENCE {
+	schedulingCellInfo						CHOICE {
+		own										SEQUENCE {					-- No cross carrier scheduling
+			cif-Presence							BOOLEAN
+		},
+		other									SEQUENCE {					-- Cross carrier scheduling
+			schedulingCellId						ServCellIndex,
+			cif-InSchedulingCell					INTEGER (1..7)
+		}																	-- Cond SCellOnly
+	},
+	...
+}
+
+-- TAG-CSI-APERIODICTRIGGERSTATELIST-START
+
+CSI-AperiodicTriggerStateList ::=	SEQUENCE (SIZE (1..maxNrOfCSI-AperiodicTriggers)) OF CSI-AperiodicTriggerState 
+
+CSI-AperiodicTriggerState ::=		SEQUENCE {
+	associatedReportConfigInfoList		SEQUENCE (SIZE(1..maxNrofReportConfigPerAperiodicTrigger)) OF CSI-AssociatedReportConfigInfo,
+	...	
+}
+
+CSI-AssociatedReportConfigInfo ::=		SEQUENCE {
+	-- The reportConfigId of one of the CSI-ReportConfigToAddMod configured in CSI-MeasConfig
+	reportConfigId						CSI-ReportConfigId,
+
+	resourcesForChannel					CHOICE {
+       nzp-CSI-RS							SEQUENCE {
+			-- NZP-CSI-RS-ResourceSet for channel measurements. Entry number in nzp-CSI-RS-ResourceSetList in the CSI-ResourceConfig 
+			-- indicated by resourcesForChannelMeasurement in the CSI-ReportConfig indicated by reportConfigId above 
+			-- (1 corresponds to the first entry, 2 to thesecond entry, and so on).
+			resourceSet		INTEGER (1..maxNrofNZP-CSI-RS-ResourceSetsPerConfig),
+
+			-- List of references to TCI-States for providing the QCL source and QCL type for for each NZP-CSI-RS-Resource 
+			-- listed in nzp-CSI-RS-Resources of the NZP-CSI-RS-ResourceSet indicated by nzp-CSI-RS-ResourcesforChannel. 
+			-- First entry in qcl-info-forChannel corresponds to first entry in nzp-CSI-RS-Resources of that NZP-CSI-RS-ResourceSet, 
+			-- second entry in qcl-info-forChannel corresponds to second entry in nzp-CSI-RS-Resources,
+			-- and so on. Corresponds to L1 parameter 'QCL-Info-aPeriodicReportingTrigger' (see 38.214, section 5.2.1.5.1)
+			qcl-info						SEQUENCE (SIZE(1..maxNrofAP-CSI-RS-ResourcesPerSet)) OF TCI-StateId
+		},
+		-- CSI-SSB-ResourceSet for channel measurements. Entry number in csi-SSB-ResourceSetList in the CSI-ResourceConfig indicated by
+		-- resourcesForChannelMeasurement in the CSI-ReportConfig indicated by reportConfigId above (1 corresponds to the first entry, 2 to 
+		-- the second entry, and so on).
+		csi-SSB-ResourceSet					INTEGER (1..maxNrofCSI-SSB-ResourceSetsPerConfig)
+	},
+
+	-- CSI-IM-ResourceSet for interference measurement. Entry number in csi-IM-ResourceSetList in the CSI-ResourceConfig indicated by 
+	-- csi-IM-ResourcesForInterference in the CSI-ReportConfig indicated by reportConfigId above (1 corresponds to the first entry, 2 to the second
+	-- entry, and so on).
+	-- The indicated CSI-IM-ResourceSet should have exactly the same number of resources like the NZP-CSI-RS-ResourceSet indicated in 
+	-- nzp-CSI-RS-ResourcesforChannel.
+	-- This field can only be present if the CSI-ReportConfig identified by reportConfigId includes csi-IM-ResourcesForInterference.
+	csi-IM-ResourcesforInteference				INTEGER(1..maxNrofCSI-IM-ResourceSetsPerConfig)			OPTIONAL, --Cond CSI-IM-forInterference
+
+
+	-- NZP-CSI-RS-ResourceSet for interference measurement. Entry number in nzp-CSI-RS-ResourceSetList in the CSI-ResourceConfig indicated by 
+	-- nzp-CSI-RS-ResourcesForInterference in the CSI-ReportConfig indicated by reportConfigId above (1 corresponds to the first entry,
+	-- 2 to the second entry, and so on).
+	-- The indicated NZP-CSI-RS-ResourceSet should have exactly the same number of resources like the NZP-CSI-RS-ResourceSet indicated in 
+	-- nzp-CSI-RS-ResourcesforChannel.
+	-- This field can only be present if the CSI-ReportConfig identified by reportConfigId includes nzp-CSI-RS-ResourcesForInterference.
+	nzp-CSI-RS-ResourcesforInterference			INTEGER (1..maxNrofNZP-CSI-RS-ResourceSetsPerConfig)	OPTIONAL, --Cond LinkedNZP-CSI-RS-forInterference
+	...
+}
+
+-- TAG-CSI-APERIODICTRIGGERSTATELIST-STOP 
+-- TAG-CSI-FREQUENCYOCCUPATION-START
+
+CSI-FrequencyOccupation ::=				SEQUENCE {
+	-- PRB where this CSI resource starts in relation to PRB 0 of the associated BWP. 
+	-- Only multiples of 4 are allowed (0, 4, ...)
+	startingRB								INTEGER (0..maxNrofPhysicalResourceBlocks-1),
+	-- Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. The smallest configurable 
+	-- number is the minimum of 24 and the width of the associated BWP.
+	nrofRBs									INTEGER (24..maxNrofPhysicalResourceBlocks),
+	...
+}
+
+-- TAG-CSI-FREQUENCYOCCUPATION-STOP
+-- TAG-CSI-IM-RESOURCE-START
+CSI-IM-Resource ::= 			SEQUENCE {
+	csi-IM-ResourceId						CSI-IM-ResourceId,
+
+	-- The resource element pattern (Pattern0 (2,2) or Pattern1 (4,1)) with corresponding parameters.
+	-- Corresponds to L1 parameter 'CSI-IM-RE-pattern' (see 38.214, section 5.2.2.3.4)
+	csi-IM-ResourceElementPattern				CHOICE {
+		pattern0									SEQUENCE {
+			-- OFDM subcarrier occupancy of the CSI-IM resource for Pattern0
+			-- Corresponds to L1 parameter 'CSI-IM-ResourceMapping' (see 38.214, section 5.2.2.3.4)
+			subcarrierLocation-p0						ENUMERATED { s0, s2, s4, s6, s8, s10 },
+			-- OFDM symbol location of the CSI-IM resource for Pattern0 
+			-- Corresponds to L1 parameter 'CSI-IM-ResourceMapping' (see 38.214, section 5.2.2.3.4)
+			symbolLocation-p0							INTEGER (0..12)
+		},
+		pattern1									SEQUENCE {
+			-- OFDM subcarrier occupancy of the CSI-IM resource for Pattern1
+			-- Corresponds to L1 parameter 'CSI-IM-ResourceMapping' (see 38.214, section 5.2.2.3.4)
+			subcarrierLocation-p1						ENUMERATED { s0, s4, s8 },
+			-- OFDM symbol location of the CSI-IM resource for Pattern1 
+			-- Corresponds to L1 parameter 'CSI-IM-ResourceMapping' (see 38.214, section 5.2.2.3.4)
+			symbolLocation-p1							INTEGER (0..13)
+		}
+	}																										OPTIONAL,	--Need M
+
+	-- Frequency-occupancy of CSI-IM. Corresponds to L1 parameter 'CSI-IM-FreqBand' (see 38.214, section 5.2.2.3.2)
+	freqBand									CSI-FrequencyOccupation										OPTIONAL,	-- Need M
+
+	-- Periodicity and slot offset for periodic/semi-persistent CSI-IM. Corresponds to L1 parameter 'CSI-IM-timeConfig' 
+	periodicityAndOffset					CSI-ResourcePeriodicityAndOffset								OPTIONAL, --Cond PeriodicOrSemiPersistent
+	...
+}
+
+-- TAG-CSI-IM-RESOURCE-STOP
+-- TAG-CSI-IM-RESOURCEID-START
+CSI-IM-ResourceId ::= 			INTEGER (0..maxNrofCSI-IM-Resources-1) 
+
+-- TAG-CSI-IM-RESOURCEID-STOP
+-- TAG-CSI-IM-RESOURCESET-START
+CSI-IM-ResourceSet ::=			SEQUENCE {
+
+	csi-IM-ResourceSetId					CSI-IM-ResourceSetId,
+	-- CSI-IM-Resources associated with this CSI-IM-ResourceSet
+	-- Corresponds to L1 parameter 'CSI-IM-ResourceConfigList' (see 38.214, section 5.2)
+	csi-IM-Resources						SEQUENCE (SIZE(1..maxNrofCSI-IM-ResourcesPerSet)) OF CSI-IM-ResourceId,
+	...
+}
+-- TAG-CSI-IM-RESOURCESET-STOP
+-- TAG-CSI-IM-RESOURCESETID-START
+
+CSI-IM-ResourceSetId ::=				INTEGER (0..maxNrofCSI-IM-ResourceSets-1)
+
+-- TAG-CSI-IM-RESOURCESETID-STOP
+-- TAG-CSI-MEAS-CONFIG-START
+
+CSI-MeasConfig ::=					SEQUENCE {
+	-- Pool of NZP-CSI-RS-Resource which can be referred to from NZP-CSI-RS-ResourceSet
+    nzp-CSI-RS-ResourceToAddModList		SEQUENCE (SIZE (1..maxNrofNZP-CSI-RS-Resources)) OF NZP-CSI-RS-Resource					OPTIONAL, -- Need N
+	nzp-CSI-RS-ResourceToReleaseList	SEQUENCE (SIZE (1..maxNrofNZP-CSI-RS-Resources)) OF NZP-CSI-RS-ResourceId				OPTIONAL, -- Need N
+
+	-- Pool of NZP-CSI-RS-ResourceSet which can be referred to from CSI-ResourceConfig or from MAC CEs
+	nzp-CSI-RS-ResourceSetToAddModList	SEQUENCE (SIZE (1..maxNrofNZP-CSI-RS-ResourceSets)) OF NZP-CSI-RS-ResourceSet			OPTIONAL, -- Need N
+	nzp-CSI-RS-ResourceSetToReleaseList	SEQUENCE (SIZE (1..maxNrofNZP-CSI-RS-ResourceSets)) OF NZP-CSI-RS-ResourceSetId			OPTIONAL, -- Need N
+
+	-- Pool of CSI-IM-Resource which can be referred to from CSI-IM-ResourceSet
+	csi-IM-ResourceToAddModList			SEQUENCE (SIZE (1..maxNrofCSI-IM-Resources)) OF CSI-IM-Resource							OPTIONAL, -- Need N
+	csi-IM-ResourceToReleaseList		SEQUENCE (SIZE (1..maxNrofCSI-IM-Resources)) OF CSI-IM-ResourceId						OPTIONAL, -- Need N
+
+	-- Pool of CSI-IM-ResourceSet which can be referred to from CSI-ResourceConfig or from MAC CEs
+	csi-IM-ResourceSetToAddModList		SEQUENCE (SIZE (1..maxNrofCSI-IM-ResourceSets)) OF CSI-IM-ResourceSet					OPTIONAL, -- Need N
+	csi-IM-ResourceSetToReleaseList		SEQUENCE (SIZE (1..maxNrofCSI-IM-ResourceSets)) OF CSI-IM-ResourceSetId					OPTIONAL, -- Need N
+
+	-- Pool of CSI-SSB-ResourceSet which can be referred to from CSI-ResourceConfig
+	csi-SSB-ResourceSetToAddModList		SEQUENCE (SIZE (1..maxNrofCSI-SSB-ResourceSets)) OF CSI-SSB-ResourceSet					OPTIONAL, -- Need N
+	csi-SSB-ResourceSetToAddReleaseList	SEQUENCE (SIZE (1..maxNrofCSI-SSB-ResourceSets)) OF CSI-SSB-ResourceSetId				OPTIONAL, -- Need N
+
+	-- Configured CSI resource settings as specified in TS 38.214 section 5.2.1.2
+	csi-ResourceConfigToAddModList 		SEQUENCE (SIZE (1..maxNrofCSI-ResourceConfigurations)) OF CSI-ResourceConfig			OPTIONAL, -- Need N
+	csi-ResourceConfigToReleaseList 	SEQUENCE (SIZE (1..maxNrofCSI-ResourceConfigurations)) OF CSI-ResourceConfigId			OPTIONAL, -- Need N
+
+	-- Configured CSI report settings as specified in TS 38.214 section 5.2.1.1
+	csi-ReportConfigToAddModList		SEQUENCE (SIZE (1..maxNrofCSI-ReportConfigurations)) OF CSI-ReportConfig				OPTIONAL, -- Need N
+	csi-ReportConfigToReleaseList		SEQUENCE (SIZE (1..maxNrofCSI-ReportConfigurations)) OF CSI-ReportConfigId				OPTIONAL, -- Need N
+	
+
+	-- Size of CSI request field in DCI (bits). Corresponds to L1 parameter 'ReportTriggerSize' (see 38.214, section 5.2)
+	reportTriggerSize				INTEGER (0..6)																				OPTIONAL,
+
+	-- Contains trigger states for dynamically selecting one or more aperiodic and semi-persistent reporting configurations
+	-- and/or triggering one or more aperiodic CSI-RS resource sets for channel and/or interference measurement.
+	-- FFS: How to address the MAC-CE configuration
+	aperiodicTriggerStateList			CSI-AperiodicTriggerStateList 											OPTIONAL, -- Need M
+	semiPersistentOnPUSCH-TriggerStateList		CSI-SemiPersistentOnPUSCH-TriggerStateList 					                                OPTIONAL, -- Need M
+	...
+}
+
+maxNrofNZP-CSI-RS-ResourceSets		INTEGER ::= 		64
+maxNrofNZP-CSI-RS-ResourceSets-1	INTEGER ::= 		63
+
+maxNrofCSI-SSB-ResourceSets 		INTEGER ::=			64
+maxNrofCSI-SSB-ResourceSets-1 		INTEGER ::=			63
+
+maxNrofCSI-IM-ResourceSets 			INTEGER ::=			64
+maxNrofCSI-IM-ResourceSets-1		INTEGER ::=			63
+
+-- TAG-CSI-MEAS-CONFIG-STOP 
+-- TAG-CSI-REPORTCONFIG-START
+-- Configuration of a CSI-Report sent on L1 (e.g. PUCCH) (see 38.214, section 5.2.1)
+CSI-ReportConfig ::=			SEQUENCE {
+	reportConfigId							CSI-ReportConfigId,
+
+	-- Indicates in which serving cell the CSI-ResourceConfigToAddMod(s) below are to be found.
+	-- If the field is absent, the resources are on the same serving cell as this report configuration.
+	carrier									ServCellIndex			OPTIONAL,	-- Need S
+
+	-- Resources for channel measurement. csi-ResourceConfigId of a CSI-ResourceConfig included in the configuration of the serving cell
+	-- indicated with the field "carrier" above. This CSI-ReportConfig is associated with the DL BWP indicated by bwp-Id in that CSI-ResourceConfig.
+	resourcesForChannelMeasurement			CSI-ResourceConfigId,
+
+	-- CSI IM resources for interference measurement. csi-ResourceConfigId of a CSI-ResourceConfig included in the configuration of the serving cell
+	-- indicated with the field "carrier" above. The bwp-Id in that CSI-ResourceConfigToAddMod is the same value like the bwp-Id in the
+	-- CSI-ResourceConfig indicated by resourcesForChannelMeasurement.
+	csi-IM-ResourcesForInterference			CSI-ResourceConfigId	OPTIONAL,	-- Need R
+
+	-- NZP CSI RS resources for interference measurement. csi-ResourceConfigId of a CSI-ResourceConfigToAddMod included in the configuration of the 
+	-- serving cell indicated with the field "carrier" above. The bwp-Id in that CSI-ResourceConfigToAddMod is the same value like the bwp-Id in the
+	-- CSI-ResourceConfigToAddMod indicated by resourcesForChannelMeasurement.
+	nzp-CSI-RS-ResourcesForInterference		CSI-ResourceConfigId	OPTIONAL, 	-- Need R
+
+	-- Time domain behavior of reporting configuration
+	reportConfigType						CHOICE {
+		periodic								SEQUENCE {
+			-- Periodicity and slot offset. Corresponds to L1 parameter 'ReportPeriodicity'and 'ReportSlotOffset' 
+			-- (see 38.214, section section 5.2.1.4).
+			reportSlotConfig						CSI-ReportPeriodicityAndOffset,
+			-- Indicates which PUCCH resource to use for reporting on PUCCH.
+			pucch-CSI-ResourceList					SEQUENCE (SIZE (1..maxNrofBWPs)) OF PUCCH-CSI-Resource
+		},
+		semiPersistentOnPUCCH					SEQUENCE {
+			-- Periodicity and slot offset. Corresponds to L1 parameter 'ReportPeriodicity' and 'ReportSlotOffset' 
+			-- (see 38.214, section section 5.2.1.4). 
+			reportSlotConfig						CSI-ReportPeriodicityAndOffset,
+			-- Indicates which PUCCH resource to use for reporting on PUCCH.
+			pucch-CSI-ResourceList					SEQUENCE (SIZE (1..maxNrofBWPs)) OF PUCCH-CSI-Resource
+		},
+		semiPersistentOnPUSCH					SEQUENCE {
+			-- Periodicity. Corresponds to L1 parameter 'Reportperiodicity-spCSI'. (see 38.214, section 5.2.1.1?FFS_Section)
+			reportSlotConfig						ENUMERATED {sl5, sl10, sl20, sl40, sl80, sl160, sl320},
+			-- Timing offset Y for aperiodic reporting using PUSCH. This field lists the allowed offset values. 
+			-- A particular value is indicated in DCI. The first report is transmitted in slot n+Y, second report in n+Y+P,
+			-- where P is the configured periodicity.
+			reportSlotOffsetList				SEQUENCE (SIZE (1..4)) OF INTEGER (0..7),
+			-- RNTI for SP CSI-RNTI, Corresponds to L1 parameter 'SPCSI-RNTI' (see 38.214, section 5.2.1.5.2)
+			-- FFS: RAN1 models different RNTIs as different Search Spaces with independent configurations. Align the configuration 
+			-- of this one (e.g. group with monitoring periodicity, PDCCH candidate configuration, DCI-Payload size...)?
+			csi-RNTI								RNTI-Value,
+			-- Index of the p0-alpha set determining the power control for this CSI report transmission. 
+			-- Corresponds to L1 parameter 'SPCSI-p0alpha' (see 38.214, section FFS_Section)
+			p0alpha									P0-PUSCH-AlphaSetId
+		},
+		aperiodic								SEQUENCE {
+			-- Timing offset Y for aperiodic reporting using PUSCH. This field lists the allowed offset values. A particular value is indicated in DCI. 
+			-- (see 38.214, section 5.2.3)
+			-- FFS_Value: Range wasn’t final in RAN1 table. 
+			-- FFS_FIXME: How are the DCI codepoints mapped to the allowed offsets?
+			reportSlotOffsetList				SEQUENCE (SIZE (1..16)) OF INTEGER (0..7)
+		}
+	},
+	-- The CSI related quanities to report. Corresponds to L1 parameter 'ReportQuantity' (see 38.214, section REF)
+	reportQuantity							CHOICE {
+		none									NULL,
+		cri-RI-PMI-CQI							NULL, 
+		cri-RI-i1								NULL, 
+		cri-RI-i1-CQI							SEQUENCE {
+			-- PRB bundling size to assume for CQI calcuation when reportQuantity is CRI/RI/i1/CQI
+			-- Corresponds to L1 parameter 'PDSCH-bundle-size-for-CSI' (see 38.214, section 5.2.1.4)
+			pdsch-BundleSizeForCSI					ENUMERATED {n2, n4}		OPTIONAL
+		}, 
+		cri-RI-CQI								NULL, 
+		cri-RSRP								NULL, 
+		ssb-Index-RSRP							NULL,
+		cri-RI-LI-PMI-CQI						NULL
+	},
+	-- Reporting configuration in the frequency domain. (see 38.214, section 5.2.1.4)
+	reportFreqConfiguration					 SEQUENCE {
+		-- Indicates whether the UE shall report a single (wideband) or multiple (subband) CQI. (see 38.214, section 5.2.1.4)
+		cqi-FormatIndicator						ENUMERATED { widebandCQI, subbandCQI },
+		-- Indicates whether the UE shall report a single (wideband) or multiple (subband) PMI. (see 38.214, section 5.2.1.4)
+		pmi-FormatIndicator						ENUMERATED { widebandPMI, subbandPMI },
+		-- Indicates a contiguous or non-contigous subset of subbands in the bandwidth part which CSI shall be reported 
+		-- for. Each bit in the bit-string represents one subband. The right-most bit in the bit string represents the 
+		-- lowest subband in the BWP. (see 38.214, section 5.2.1.4)
+		-- The number of subbands is determined according to 38.214 section 5.2.1.4. It is absent if there are less than 24 PRBs (no sub band)
+		-- and present otherwise, the number of sub bands can be from 3 (24 PRBs, sub band size 8) to 18 (72 PRBs, sub band size 4).
+		csi-ReportingBand						CHOICE {
+			subbands3								BIT STRING(SIZE(3)),
+			subbands4								BIT STRING(SIZE(4)),
+			subbands5								BIT STRING(SIZE(5)),
+			subbands6								BIT STRING(SIZE(6)),
+			subbands7								BIT STRING(SIZE(7)),
+			subbands8								BIT STRING(SIZE(8)),
+			subbands9								BIT STRING(SIZE(9)),
+			subbands10								BIT STRING(SIZE(10)),
+			subbands11								BIT STRING(SIZE(11)),
+			subbands12								BIT STRING(SIZE(12)),
+			subbands13								BIT STRING(SIZE(13)),
+			subbands14								BIT STRING(SIZE(14)),
+			subbands15								BIT STRING(SIZE(15)),
+			subbands16								BIT STRING(SIZE(16)),
+			subbands17								BIT STRING(SIZE(17)),
+			subbands18								BIT STRING(SIZE(18)),
+			...
+		}	OPTIONAL	-- Need S
+
+	},
+	-- Time domain measurement restriction for the channel (signal) measurements. 
+	-- Corresponds to L1 parameter 'MeasRestrictionConfig-time-channel' (see 38.214, section 5.2.1.1)
+	timeRestrictionForChannelMeasurements				ENUMERATED {configured, notConfigured},
+	-- Time domain measurement restriction for interference measurements. 
+	-- Corresponds to L1 parameter 'MeasRestrictionConfig-time-interference' (see 38.214, section 5.2.1.1)
+	timeRestrictionForInterferenceMeasurements			ENUMERATED {configured, notConfigured},
+	-- Codebook configuration for Type-1 or Type-II including codebook subset restriction
+	codebookConfig								CodebookConfig,
+	-- Maximum number of CQIs per CSI report (cf. 1 for 1-CW, 2 for 2-CW)	
+	nrofCQIsPerReport							ENUMERATED {n1, n2},
+	-- Turning on/off group beam based reporting (see 38.214, section 5.2.1.4)	
+	groupBasedBeamReporting						CHOICE {
+		enabled										NULL,
+		disabled 									SEQUENCE {
+			-- The number (N) of measured RS resources to be reported per report setting in a non-group-based report. 
+			-- N <= N_max, where N_max is either 2 or 4 depending on UE capability. 
+			-- FFS: The signaling mechanism for the gNB to select a subset of N beams for the UE to measure and report. 
+			-- FFS: Note: this parameter may not be needed for certain resource and/or report settings
+			-- FFS_ASN1: Change groupBasedBeamReporting into a CHOICE and include this field into the "no" option?
+			-- (see 38.214, section FFS_Section)
+			-- When the field is absent the UE applies the value 1
+			nrofReportedRS							ENUMERATED {n1, n2, n3, n4}												OPTIONAL	-- Need S
+		}
+	},
+
+	-- Which CQI table to use for CQI calculation. Corresponds to L1 parameter 'CQI-table' (see 38.214, section 5.2.2.1)
+	cqi-Table								ENUMERATED {table1, table2, spare2, spare1}										OPTIONAL,
+	-- Indicates one out of two possible BWP-dependent values for the subband size as indicated in 38.214 table 5.2.1.4-2
+	-- Corresponds to L1 parameter 'SubbandSize' (see 38.214, section 5.2.1.4)
+	subbandSize								ENUMERATED {value1, value2},
+	-- BLER target that the UE shall be assume in its CQI calculation.
+	-- Corresponds to L1 parameter 'BLER-Target' (see 38.214, section 5.2.2.1)
+	-- FFS_Values (now filled with spares)
+	bler-Target								ENUMERATED {zerodot1, spare3, space2, spare1}										OPTIONAL,
+	-- Port indication for RI/CQI calculation. For each  CSI-RS resource in the linked ResourceConfig for channel measurement, 
+	-- a port indication for each rank R, indicating which R ports to use. Applicable only for non-PMI feedback.
+	-- Corresponds to L1 parameter 'Non-PMI-PortIndication' (see 38.214, section FFS_Section)
+	-- The first entry in non-PMI-PortIndication corresponds to the NZP-CSI-RS-Resource indicated by the first entry in
+	-- nzp-CSI-RS-Resources in the NZP-CSI-RS-ResourceSet indicated in the first entry of nzp-CSI-RS-ResourceSetList of the
+	-- CSI-ResourceConfig whose CSI-ResourceConfigId is indicated in a CSI-MeasId together with the above CSI-ReportConfigId,
+	-- the second entry in non-PMI-PortIndication corresponds to the NZP-CSI-RS-Resource indicated by the second entry in
+	-- nzp-CSI-RS-Resources in the NZP-CSI-RS-ResourceSet indicated in the first entry of nzp-CSI-RS-ResourceSetList of the
+	-- same CSI-ResourceConfig, and so on until the NZP-CSI-RS-Resource indicated by the last entry in nzp-CSI-RS-Resources
+	-- in the in the NZP-CSI-RS-ResourceSet indicated in the first entry of nzp-CSI-RS-ResourceSetList of the
+	-- same CSI-ResourceConfig, then the next entry corresponds to the NZP-CSI-RS-Resource indicated by the first entry
+	-- in nzp-CSI-RS-Resources in the NZP-CSI-RS-ResourceSet indicated in the second entry of nzp-CSI-RS-ResourceSetList of the
+	-- same CSI-ResourceConfig and so on.
+	non-PMI-PortIndication					SEQUENCE (SIZE (1..maxNrofNZP-CSI-RS-ResourcesPerConfig)) OF PortIndexFor8Ranks		OPTIONAL,	...
+}
+
+CSI-ReportPeriodicityAndOffset ::= CHOICE {
+	slots4								INTEGER(0..3),
+	slots5								INTEGER(0..4),
+	slots8								INTEGER(0..7),
+	slots10								INTEGER(0..9),
+	slots16								INTEGER(0..15),
+	slots20								INTEGER(0..19),
+	slots40								INTEGER(0..39),
+	slots80								INTEGER(0..79),
+	slots160							INTEGER(0..159),
+	slots320							INTEGER(0..319)
+}
+
+PUCCH-CSI-Resource ::= 				CHOICE {
+	uplinkBandwidthPartId				BWP-Id,
+	-- PUCCH resource for the associated uplink BWP. Only PUCCH-Resource of format 2, 3 and 4 is supported.
+	pucch-Resource						PUCCH-Resource
+}
+
+-- The PortIndexFor8Ranks allows to indicate port indexes for 1 to 8 ranks using a port index ranges from 0 to 31, or from 0 to 15, or from 0
+-- to 7, or from 0 to 3, or from 0 to 1, or with 0 only.
+
+PortIndexFor8Ranks ::=	CHOICE {
+	portIndex8				SEQUENCE{
+		rank1-8					PortIndex8,
+		rank2-8					SEQUENCE(SIZE(1..2)) OF PortIndex8,
+		rank3-8					SEQUENCE(SIZE(1..3)) OF PortIndex8,
+		rank4-8					SEQUENCE(SIZE(1..4)) OF PortIndex8,
+		rank5-8					SEQUENCE(SIZE(1..5)) OF PortIndex8,
+		rank6-8					SEQUENCE(SIZE(1..6)) OF PortIndex8,
+		rank7-8					SEQUENCE(SIZE(1..7)) OF PortIndex8,
+		rank8-8					SEQUENCE(SIZE(1..8)) OF PortIndex8
+	},
+	portIndex4				SEQUENCE{
+		rank1-4					PortIndex4,
+		rank2-4					SEQUENCE(SIZE(1..2)) OF PortIndex4,
+		rank3-4					SEQUENCE(SIZE(1..3)) OF PortIndex4,
+		rank4-4					SEQUENCE(SIZE(1..4)) OF PortIndex4
+	},
+	portIndex2				SEQUENCE{
+		rank1-2					PortIndex2,
+		rank2-2					SEQUENCE(SIZE(1..2)) OF PortIndex2
+	},
+	portIndex1				NULL
+}
+
+PortIndex8::=	INTEGER (0..7)
+PortIndex4::=	INTEGER (0..3)
+PortIndex2::=	INTEGER (0..1)
+
+maxNrofNZP-CSI-RS-ResourcesPerConfig	INTEGER ::=	128
+-- TAG-CSI-REPORTCONFIG-STOP
+-- TAG-CSI-REPORTCONFIGID-START
+CSI-ReportConfigId ::= 					INTEGER (0..maxNrofCSI-ReportConfigurations-1)
+
+-- TAG-CSI-REPORTCONFIGID-STOP
+-- TAG-CSI-RESOURCECONFIG-START
+
+-- One CSI resource configuration comprising of one or more resource sets
+CSI-ResourceConfig ::= 		SEQUENCE {
+
+	-- Used in CSI-ReportConfig to refer to an instance of CSI-ResourceConfig
+	csi-ResourceConfigId				CSI-ResourceConfigId,
+
+	-- Contains up to maxNrofNZP-CSI-RS-ResourceSetsPerConfig resource sets if ResourceConfigType is 'aperiodic' and 1 otherwise.
+	-- Corresponds to L1 parameter 'ResourceSetConfigList' (see 38.214, section 5.2.1.3.1)	
+	csi-RS-ResourceSetList 	 			CHOICE {
+		nzp-CSI-RS-SSB 						SEQUENCE {
+			nzp-CSI-RS-ResourceSetList			SEQUENCE (SIZE (1..maxNrofNZP-CSI-RS-ResourceSetsPerConfig)) OF NZP-CSI-RS-ResourceSetId OPTIONAL,
+			-- List of SSB resources used for beam measurement and reporting in a resource set
+			-- Corresponds to L1 parameter 'resource-config-SS-list' (see 38,214, section FFS_Section)
+			csi-SSB-ResourceSetList				SEQUENCE (SIZE (1..maxNrofCSI-SSB-ResourceSetsPerConfig)) OF CSI-SSB-ResourceSetId	OPTIONAL
+		},			
+		csi-IM-ResourceSetList				SEQUENCE (SIZE (1..maxNrofCSI-IM-ResourceSetsPerConfig)) OF CSI-IM-ResourceSetId
+	},
+
+
+	-- The DL BWP which the CSI-RS associated with this CSI-ResourceConfig are located in. 
+	-- Corresponds to L1 parameter 'BWP-Info' (see 38.214, section 5.2.1.2
+	bwp-Id								BWP-Id,
+
+	-- Time domain behavior of resource configuration. Corresponds to L1 parameter 'ResourceConfigType' (see 38.214, section 5.2.2.3.5)	
+	resourceType						ENUMERATED { aperiodic, semiPersistent, periodic },
+	...
+}
+
+-- TAG-CSI-RESOURCECONFIGTOADDMOD-STOP
+-- TAG-CSI-RESOURCECONFIGID-START
+CSI-ResourceConfigId ::= INTEGER (0..maxNrofCSI-ResourceConfigurations-1)
+
+-- TAG-CSI-RESOURCECONFIGID-STOP
+-- TAG-CSI-RESOURCEPERIODICITYANDOFFSET-START
+
+CSI-ResourcePeriodicityAndOffset ::=	CHOICE {
+	slots4							INTEGER (0..3), 
+	slots5							INTEGER (0..4), 
+	slots8							INTEGER (0..7), 
+	slots10							INTEGER (0..9), 
+	slots16							INTEGER (0..15), 
+	slots20							INTEGER (0..19), 
+	slots32							INTEGER (0..31), 
+	slots40							INTEGER (0..39), 
+	slots64							INTEGER (0..63), 
+	slots80							INTEGER (0..79), 
+	slots160						INTEGER (0..159), 
+	slots320						INTEGER (0..319), 
+	slots640						INTEGER (0..639)
+}
+
+-- TAG-CSI-RESIYRCEPERIODICITYANDOFFSET-STOP
+-- TAG-CSI-RS-RESOURCEMAPPING-START
+
+CSI-RS-ResourceMapping ::= 				SEQUENCE {
+	-- Frequency domain allocation within a physical resource block in accordance with 38.211, section 7.4.1.5.3 including table 7.4.1.5.2-1.
+	-- The number of bits that may be set to one depend on the chosen row in that table. For the choice "other", the row can be determined from
+	-- the parmeters below and from the number of bits set to 1 in frequencyDomainAllocation.
+	frequencyDomainAllocation			CHOICE {
+		row1								BIT STRING (SIZE (4)),
+		row2								BIT STRING (SIZE (12)),
+		row4								BIT STRING (SIZE (3)),
+		other								BIT STRING (SIZE (6))
+	},
+	-- Number of ports (see 38.214, section 5.2.2.3.1)
+	nrofPorts							ENUMERATED {p1,p2,p4,p8,p12,p16,p24,p32},
+	-- Time domain allocation within a physical resource block. The field indicates the first OFDM symbol in the PRB used for CSI-RS.
+	-- Parameter l0 in 38.211, section 7.4.1.5.3. Value 2 is supported only when DL-DMRS-typeA-pos equals 3.
+	firstOFDMSymbolInTimeDomain			INTEGER (0..13),
+	-- Time domain allocation within a physical resource block. Parameter l1 in 38.211, section 7.4.1.5.3.
+	firstOFDMSymbolInTimeDomain2		INTEGER (0..13)																OPTIONAL,	-- Need R
+	-- CDM type (see 38.214, section 5.2.2.3.1)	
+	cdm-Type								ENUMERATED {noCDM, fd-CDM2, cdm4-FD2-TD2, cdm8-FD2-TD4},
+	-- Density of CSI-RS resource measured in RE/port/PRB. Corresponds to L1 parameter 'CSI-RS-Density'  (see 38.211, section 7.4.1.5.3)
+	-- Values 0.5 (dot5), 1 (one) and 3 (three) are allowed for X=1,
+	-- values 0.5 (dot5) and 1 (one) are allowed for X=2, 16, 24 and 32,
+	-- value 1 (one) is allowed for X=4, 8, 12.
+	-- For density = 1/2, includes 1 bit indication for RB level comb offset indicating  whether odd or even RBs are occupied by CSI-RS
+	density									CHOICE {
+		dot5									ENUMERATED {evenPRBs, oddPRBs}, 
+		one										NULL, 
+		three									NULL, 
+		spare									NULL
+	},
+	-- Wideband or partial band CSI-RS. Corresponds to L1 parameter 'CSI-RS-FreqBand' (see 38.214, section 5.2.2.3.1)	
+	freqBand								CSI-FrequencyOccupation,
+	...
+}
+
+-- TAG-CSI-RS-RESOURCEMAPPING-STOP
+-- TAG-CSI-SEMIPERSISTENTONPUSCHTRIGGERSTATELIST-START
+
+CSI-SemiPersistentOnPUSCH-TriggerStateList ::=	SEQUENCE(SIZE (1..maxNrOfSemiPersistentPUSCH-Triggers)) OF CSI-SemiPersistentOnPUSCH-TriggerState
+CSI-SemiPersistentOnPUSCH-TriggerState ::=		SEQUENCE {
+	associatedReportConfigInfo						CSI-ReportConfigId,
+	...
+}
+
+maxNrOfSemiPersistentPUSCH-Triggers					INTEGER ::= 64		-- Maximum number of triggers for semi persistent reporting on PUSCH
+
+-- TAG-CSI-SEMIPERSISTENTONPUSCHTRIGGERSTATELIST-STOP 
+-- TAG-CSI-SSB-RESOURCESETID-START
+
+CSI-SSB-ResourceSetId ::=	INTEGER (0..maxNrofCSI-SSB-ResourceSets-1)
+
+-- TAG-CSI-SSB-RESOURCESETID-STOP
+-- TAG-CSI-SSB-RESOURCESET-START
+
+CSI-SSB-ResourceSet ::=						SEQUENCE {
+	csi-SSB-ResourceSetId						CSI-SSB-ResourceSetId,
+	csi-SSB-ResourceList						SEQUENCE (SIZE(1..maxNrofCSI-SSB-ResourcePerSet)) OF SSB-Index,
+	...
+}
+
+-- TAG-CSI-SSB-RESOURCESET-STOP
+-- TAG-DMRS-DOWNLINKCONFIG-START
+
+DMRS-DownlinkConfig ::=					SEQUENCE {
+	-- Selection of the DMRS type to be used for DL (see 38.211, section 7.4.1.1.1).
+	-- If the field is absent, the UE uses DMRS type 1.
+	dmrs-Type								ENUMERATED {type2}													OPTIONAL,	-- Need R
+	-- Position for additional DM-RS in DL, see Table 7.4.1.1.2-4 in 38.211. 
+	-- The four values represent the cases of 1+0, 1+1, 1+1+1. 1+1+1+1 non-adjacent OFDM symbols for DL.
+	-- If the field is absent, the UE applies the value pos2.
+	dmrs-AdditionalPosition					ENUMERATED {pos0, pos1, pos3}										OPTIONAL,	-- Need R
+	-- DM-RS groups that are QCL:ed, i.e. group 1 (see 38.214, section 5.1)
+	dmrs-group1								BIT STRING (SIZE (12))												OPTIONAL,	-- Need R
+	-- DM-RS groups that are QCL:ed, i.e. group 2 (see 38.214, section 5.1)
+	dmrs-group2								BIT STRING (SIZE (12))												OPTIONAL,	-- Need R
+	-- The maximum number of OFDM symbols for DL front loaded DMRS. 'len1' corresponds to value 1. 'len2 corresponds to value 2.
+	-- If the field is absent, the UE applies value len1.
+	-- Corresponds to L1 parameter 'DL-DMRS-max-len' (see 38.214, section 5.1)
+	maxLength								ENUMERATED {len2}													OPTIONAL, 	-- Need R
+	-- DL DMRS scrambling initalization
+	-- Corresponds to L1 parameter 'n_SCID 0' (see 38.211, section 7.4.1)
+	-- When the field is absent the UE applies the value Physical cell ID (physCellId) configured for this serving cell."
+	scramblingID0							INTEGER (0..65535)													OPTIONAL, 	-- Need S
+	-- DL DMRS scrambling initalization. Corresponds to L1 parameter 'n_SCID 1' (see 38.211, section 7.4.1)
+	-- When the field is absent the UE applies the value (physCellId) configured for this serving cell.
+	scramblingID1							INTEGER (0..65535)													OPTIONAL, 	-- Need S
+
+	-- Configures downlink PTRS. If absent of released, the UE assumes that downlink PTRS are not present. See 38.214 section 5.1.6.3
+	phaseTrackingRS						        PTRS-DownlinkConfig									    OPTIONAL,	-- Need M
+
+	...
+}
+
+-- TAG-DMRS-DOWNLINKCONFIG-STOP
+-- TAG-DMRS-UPLINKCONFIG-START
+
+DMRS-UplinkConfig ::=					SEQUENCE {
+	-- Selection of the DMRS type to be used for UL (see section 38.211, section 6.4.1.1.3)
+	-- If the field is absent, the UE uses DMRS type 1.
+	dmrs-Type								ENUMERATED {type2} 													OPTIONAL,	-- Need R
+	-- Position for additional DM-RS in UL. Corresponds to L1 parameter 'UL-DMRS-add-pos' (see Table 7.4.1.1.2-4 in 38.211) 
+	-- The four values represent the cases of 1+0, 1+1, 1+1+1. 1+1+1+1 non-adjacent OFDM symbols for UL. 
+	-- If the field is absent, the UE applies the value pos2.
+	dmrs-AdditionalPosition					ENUMERATED {pos0, pos1, pos3}										OPTIONAL,	-- Need R
+	-- Configures uplink PTRS (see 38.211, section x.x.x.x) FFS_Ref
+	phaseTrackingRS						 PTRS-UplinkConfig 										OPTIONAL,	-- Need M
+	-- The maximum number of OFDM symbols for UL front loaded DMRS. 'len1' corresponds to value 1. 'len2 corresponds to value 2.
+	-- If the field is absent, the UE applies value len1.
+	-- Corresponds to L1 parameter 'UL-DMRS-max-len' (see 38.214, section 6.4.1.1.2)
+	maxLength								ENUMERATED {len2}													OPTIONAL, 	-- Need R
+
+	transformPrecoding					CHOICE {
+		-- DMRS related parameters for Cyclic Prefix OFDM
+		disabled									SEQUENCE {
+			-- UL DMRS scrambling initalization for CP-OFDM
+			-- Corresponds to L1 parameter 'n_SCID 0' (see 38.214, section 6.4.1.1.2)
+			-- When the field is absent the UE applies the value Physical cell ID (physCellId)
+			scramblingID0							INTEGER (0..65535)											OPTIONAL,	-- Need S
+			-- UL DMRS scrambling initalization for CP-OFDM.
+			-- Corresponds to L1 parameter 'n_SCID 1' (see 38.214, section 6.4.1.1.2)
+			-- When the field is absent the UE applies the value Physical cell ID (physCellId)
+			scramblingID1							INTEGER (0..65535)											OPTIONAL		-- Need S
+
+		},
+		-- DMRS related parameters for DFT-s-OFDM (Transform Precoding)
+		enabled								SEQUENCE {
+			-- Parameter: N_ID^(PUSCH) for DFT-s-OFDM DMRS. If the value is absent or released, the UE uses the Physical cell ID.
+			-- Corresponds to L1 parameter 'nPUSCH-Identity-Transform precoding' (see 38.211, section FFS_Section)
+			nPUSCH-Identity							INTEGER(0..1007)											OPTIONAL,	-- Need S
+			-- Sequence-group hopping for PUSCH can be disabled for a certain UE despite being enabled on a cell basis. For DFT-s-OFDM DMRS
+			-- If the field is released, the UE considers group hopping to be enabled.
+			-- Corresponds to L1 parameter 'Disable-sequence-group-hopping-Transform-precoding' (see 38.211, section FFS_Section)
+			disableSequenceGroupHopping				ENUMERATED {disabled}										OPTIONAL,	-- Need S
+			-- Determines if sequence hopping is enabled or not. For DFT-s-OFDM DMRS. 
+			-- If the field is released, the UE considers sequence hopping to be disabled.
+			-- Corresponds to L1 parameter 'Sequence-hopping-enabled-Transform-precoding' (see 38.211, section FFS_Section)
+			sequenceHoppingEnabled					ENUMERATED {enabled}										OPTIONAL	-- Need S
+		}
+	},
+	...
+}
+
+-- TAG-DMRS-UPLINKCONFIG-STOP
+-- TAG-DOWNLINKPREEMPTION-START
+
+-- Configuration of downlink preemption indication on PDCCH.
+DownlinkPreemption ::=						SEQUENCE {
+	-- RNTI used for indication pre-emption in DL. 
+	-- Corresponds to L1 parameter 'INT-RNTI', where ”INT” stands for ”interruption” (see 38.213, section 10)
+	int-RNTI								RNTI-Value,
+
+	-- Set selection for DL-preemption indication. Corresponds to L1 parameter 'int-TF-unit' (see 38.213, section 10.1)
+	-- The set determines how the UE interprets the DL preemption DCI payload.
+	timeFrequencySet						ENUMERATED {set0, set1},
+
+	-- Total length of the DCI payload scrambled with INT-RNTI. The value must be an integer multiple of 14 bit.
+	-- Corresponds to L1 parameter 'INT-DCI-payload-length' (see 38.213, section 11.2)
+	dci-PayloadSize							INTEGER (0..maxINT-DCI-PayloadSize),
+
+	-- Indicates (per serving cell) the position of the 14 bit INT values inside the DCI payload. 
+	-- Corresponds to L1 parameter 'INT-cell-to-INT' and 'cell-to-INT' (see 38.213, section 11.2)
+	int-ConfigurationPerServingCell			SEQUENCE (SIZE (1..maxNrofServingCells)) OF INT-ConfigurationPerServingCell,
+	...
+}
+
+INT-ConfigurationPerServingCell ::= 		SEQUENCE {
+	servingCellId							ServCellIndex,
+	-- Starting position (in number of bit) of the 14 bit INT value applicable for this serving cell (servingCellId) within the DCI 
+	-- payload. Must be multiples of 14 (bit). Corresponds to L1 parameter 'INT-values' (see 38.213, section 11.2)
+	positionInDCI							INTEGER (0..maxINT-DCI-PayloadSize-1)
+}
+
+-- TAG-DOWNLINKPREEMPTION-STOP
+-- TAG-DRB-IDENTITY-START
+
+DRB-Identity ::=					INTEGER (1..32)
+
+-- TAG-DRB-IDENTITY-STOP
+-- TAG-EUTRA-MBSFN-SUBFRAMECONFIGLIST-START
+
+EUTRA-MBSFN-SubframeConfigList ::= 		SEQUENCE (SIZE (1..maxMBSFN-Allocations)) OF EUTRA-MBSFN-SubframeConfig
+
+EUTRA-MBSFN-SubframeConfig ::=			SEQUENCE {
+	-- Field as defined in MBSFN-SubframeConfig in 36.331 
+	radioframeAllocationPeriod			ENUMERATED {n1, n2, n4, n8, n16, n32},
+	-- Field as defined in MBSFN-SubframeConfig in 36.331 
+	radioframeAllocationOffset			INTEGER (0..7),
+	-- Field as defined in MBSFN-SubframeConfig in 36.331 
+	subframeAllocation					CHOICE {
+		-- Field as defined in MBSFN-SubframeConfig in 36.331 
+		oneFrame							BIT STRING (SIZE(6)),
+		-- Field as defined in MBSFN-SubframeConfig in 36.331 
+		fourFrames							BIT STRING (SIZE(24))
+	},
+	subframeAllocation-v1430			CHOICE {
+		-- Field as defined in MBSFN-SubframeConfig in 36.331 
+		oneFrame-v1430						BIT STRING (SIZE(2)),
+		-- Field as defined in MBSFN-SubframeConfig in 36.331 
+		fourFrames-v1430					BIT STRING (SIZE(8))
+	}																														OPTIONAL,	-- Need R
+	...
+}
+
+-- TAG-EUTRA-MBSFN-SUBFRAMECONFIGLIST-STOP
+
+FilterCoefficient ::=					ENUMERATED {
+											fc0, fc1, fc2, fc3, fc4, fc5,
+											fc6, fc7, fc8, fc9, fc11, fc13, 
+											fc15, fc17, fc19, spare1, ...}
+
+-- TAG-FREQBANDINDICATORNR-START
+
+FreqBandIndicatorNR ::=     		INTEGER (1..1024)
+
+-- TAG-FREQBANDINDICATORNR-STOP
+-- TAG-FREQUENCY-INFO-DL-START
+
+FrequencyInfoDL ::= 				SEQUENCE {
+	-- Frequency of the SSB to be used for this serving cell. The frequency provided in this field identifies the position of 
+	-- resource element RE=#0 (subcarrier #0) of resource block RB#10 of the SS block. The cell-defining SSB of an SpCell is always on
+	-- the sync raster. Frequencies are considered to be on the sync raster if they are also identifiable with a GSCN value (see 38.101).
+	absoluteFrequencySSB					ARFCN-ValueNR,
+	-- The frequency domain offset between SSB and the overall resource block grid in number of subcarriers. 
+	-- Absence of the field indicates that no offset is applied (offset = 0). For FR2 only values up to 11 are applicable. 
+	-- Corresponds to L1 parameter kssb (See 38.211, section 7.4.3.1)
+	ssb-SubcarrierOffset					INTEGER (1..23)																OPTIONAL,	-- Need S
+	-- List of one or multiple frequency bands to which this carrier(s) belongs. Multiple values are only supported in 
+	-- system information but not when the FrequencyInfoDL is provided in dedicated signalling (HO or S(p)Cell addition).
+	frequencyBandList					MultiFrequencyBandListNR,
+	-- Absolute frequency position of the reference resource block (Common RB 0). Its lowest subcarrier is also known as Point A. 
+	-- Note that the lower edge of the actual carrier is not defined by this field but rather in the scs-SpecificCarrierList.
+	-- Corresponds to L1 parameter 'offset-ref-low-scs-ref-PRB' (see 38.211, section FFS_Section)
+	absoluteFrequencyPointA					ARFCN-ValueNR,
+
+	-- A set of carriers for different subcarrier spacings (numerologies). Defined in relation to Point A.
+	-- Corresponds to L1 parameter 'offset-pointA-set' (see 38.211, section FFS_Section)
+	scs-SpecificCarrierList					SEQUENCE (SIZE (1..maxSCSs)) OF SCS-SpecificCarrier,
+	...
+}
+
+-- TAG-FREQUENCY-INFO-UL-STOP
+-- TAG-FREQUENCY-INFO-UL-START
+
+FrequencyInfoUL ::= 				SEQUENCE {
+	-- List of one or multiple frequency bands to which this carrier(s) belongs. Multiple values are only supported in 
+	-- system information but not when the FrequencyInfoDL is provided in dedicated signalling (HO or S(p)Cell addition).
+	frequencyBandList					MultiFrequencyBandListNR										OPTIONAL,	-- Cond FDD-OrSUL
+	-- Absolute frequency of the reference resource block (Common RB 0). Its lowest subcarrier is also known as Point A.
+	-- Corresponds to L1 parameter 'offset-ref-low-scs-ref-PRB' (see 38.211, section FFS_Section)
+	absoluteFrequencyPointA						ARFCN-ValueNR					OPTIONAL,	-- Cond FDD-OrSUL
+	-- A set of virtual carriers for different subcarrier spacings (numerologies). Defined in relation to Point A.
+	-- Note that the lower edge of the actual carrier is not defined by this field but rather in the scs-SpecificCarrierList.
+	-- Corresponds to L1 parameter 'offset-pointA-set' (see 38.211, section FFS_Section)
+	scs-SpecificCarriers				SEQUENCE (SIZE (1..maxSCSs)) OF SCS-SpecificCarrier,
+
+	-- The additional spectrum emission requirements to be applied by the UE on this uplink. 
+	-- If the field is absent, the UE applies the value FFS_RAN4. (see FFS_section, section FFS_Section)
+	additionalSpectrumEmission			AdditionalSpectrumEmission										OPTIONAL,	-- Need S
+	-- FFS_Definition. Corresponds to parameter FFS_RAN4. (see FFS_Spec, section FFS_Section)
+	-- If the field is absent, the UE applies the value FFS_RAN4.
+	p-Max								P-Max															OPTIONAL,	-- Need S
+	-- Enable the NR UL transmission with a 7.5KHz shift to the LTE raster. If the field is absent, the frequency shift is disabled.
+	frequencyShift7p5khz				ENUMERATED {true}												OPTIONAL,	-- Cond FDD-OrSUL-Optional
+	...
+}
+
+-- TAG-FREQUENCY-INFO-UL-STOP
+-- TAG-GSCN-VALUE-NR-START
+
+GSCN-ValueNR ::=				INTEGER (1..28557)
+
+
+-- TAG-GSCN-VALUE-NR-STOP
+
+Hysteresis ::=							INTEGER (0..30)
+
+-- TAG-LOGICAL-CHANNEL-CONFIG-START
+
+LogicalChannelConfig ::=		SEQUENCE {
+	ul-SpecificParameters			SEQUENCE {
+		priority						INTEGER (1..16),
+		prioritisedBitRate				ENUMERATED {kBps0, kBps8, kBps16, kBps32, kBps64, kBps128, kBps256, kBps512, 
+											kBps1024, kBps2048, kBps4096, kBps8192, kBps16384, kBps32768, kBps65536, infinity},
+		bucketSizeDuration				ENUMERATED {ms50, ms100, ms150, ms300, ms500, ms1000, spare2, spare1},
+
+		allowedServingCells				SEQUENCE (SIZE (1..maxNrofServingCells-1)) OF ServCellIndex					OPTIONAL,	-- Need R
+		allowedSCS-List					SEQUENCE (SIZE (1..maxSCSs)) OF SubcarrierSpacing							OPTIONAL,	-- Need R
+		maxPUSCH-Duration				ENUMERATED { ms0p02, ms0p04, ms0p0625, ms0p125, ms0p25, ms0p5, spare2, spare1 }												OPTIONAL,	-- Need R
+		configuredGrantType1Allowed		ENUMERATED {true}															OPTIONAL,	-- Need R
+
+		logicalChannelGroup				INTEGER (0..maxLCG-ID)														OPTIONAL, 	-- Need R
+		schedulingRequestID				SchedulingRequestId															OPTIONAL,	-- Need R
+		logicalChannelSR-Mask			BOOLEAN,
+		logicalChannelSR-DelayTimerApplied	BOOLEAN
+	}																												OPTIONAL,		-- Cond UL
+
+	-- other parameters
+	...
+}
+
+-- TAG-LOGICAL-CHANNEL-CONFIG-STOP
+-- TAG-MAC-CELL-GROUP-CONFIG-START
+
+MAC-CellGroupConfig ::= 			SEQUENCE {
+	drx-Config					DRX-Config 																OPTIONAL, -- Need M
+
+	schedulingRequestConfig				SchedulingRequestConfig																OPTIONAL, -- Need M
+	bsr-Config					BSR-Config																	OPTIONAL,	-- Need M
+	tag-Config					TAG-Config																	OPTIONAL,	-- Need M	
+	phr-Config					PHR-Config 																OPTIONAL,	-- Need M
+	-- FFS : configurable per SCell?
+	skipUplinkTxDynamic					BOOLEAN,
+	-- RNTI value for downlink SPS (see SPS-config) and uplink configured scheduling (see ConfiguredSchedulingConfig).
+	cs-RNTI						RNTI-Value 															OPTIONAL	-- Need M
+}
+
+DRX-Config ::=						SEQUENCE {
+	drx-onDurationTimer					CHOICE {
+											subMilliSeconds	INTEGER (1..31),
+											milliSeconds	ENUMERATED {
+											ms1, ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, ms40, ms50, ms60, 
+											ms80, ms100, ms200, ms300, ms400, ms500, ms600, ms800, ms1000, ms1200, 
+											ms1600, spare9, spare8, spare7, spare6, spare5, spare4, spare3, spare2, spare1 }
+											},
+	drx-InactivityTimer					ENUMERATED { 
+											ms0, ms1, ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, ms40, ms50, ms60, ms80, 
+											ms100, ms200, ms300, ms500, ms750, ms1280, ms1920, ms2560, spare9, spare8, 
+											spare7, spare6, spare5, spare4, spare3, spare2, spare1},
+	drx-HARQ-RTT-TimerDL				INTEGER (0..56),
+	drx-HARQ-RTT-TimerUL				INTEGER (0..56),
+	drx-RetransmissionTimerDL			ENUMERATED { 
+											sl0, sl1, sl2, sl4, sl6, sl8, sl16, sl24, sl33, sl40, sl64, sl80, sl96, sl112, sl128, 
+											sl160, sl320, spare15, spare14, spare13, spare12, spare11, spare10, spare9, 
+											spare8, spare7, spare6, spare5, spare4, spare3, spare2, spare1},
+	drx-RetransmissionTimerUL			ENUMERATED {
+											sl0, sl1, sl2, sl4, sl6, sl8, sl16, sl24, sl33, sl40, sl64, sl80, sl96, sl112, sl128, 
+											sl160, sl320, spare15, spare14, spare13, spare12, spare11, spare10, spare9, 
+											spare8, spare7, spare6, spare5, spare4, spare3, spare2, spare1 },
+	drx-LongCycleStartOffset		CHOICE {
+		ms10							INTEGER(0..9),
+		ms20							INTEGER(0..19),
+		ms32							INTEGER(0..31),
+		ms40							INTEGER(0..39),
+		ms60							INTEGER(0..59),
+		ms64							INTEGER(0..63),
+		ms70							INTEGER(0..69),
+		ms80							INTEGER(0..79),
+		ms128							INTEGER(0..127),
+		ms160							INTEGER(0..159),
+		ms256							INTEGER(0..255),
+		ms320							INTEGER(0..319),
+		ms512							INTEGER(0..511),
+		ms640							INTEGER(0..639),
+		ms1024							INTEGER(0..1023),
+		ms1280							INTEGER(0..1279),
+		ms2048							INTEGER(0..2047),
+		ms2560							INTEGER(0..2559),
+		ms5120							INTEGER(0..5119),
+		ms10240							INTEGER(0..10239)
+	},
+	-- FFS need for finer offset granulary
+	-- FFS need for shorter values for long and short cycles
+	shortDRX							SEQUENCE {
+		drx-ShortCycle						ENUMERATED	{
+												ms2, ms3, ms4, ms5, ms6, ms7, ms8, ms10, ms14, ms16, ms20, ms30, ms32,
+												ms35, ms40, ms64, ms80, ms128, ms160, ms256, ms320, ms512, ms640, spare9,
+												spare8, spare7, spare6, spare5, spare4, spare3, spare2, spare1 },
+		drx-ShortCycleTimer					INTEGER (1..16)
+	}		OPTIONAL,													-- Need R
+	drx-SlotOffset						INTEGER (0..31)
+
+}
+
+PHR-Config ::=						SEQUENCE {
+	phr-PeriodicTimer					ENUMERATED {sf10, sf20, sf50, sf100, sf200,sf500, sf1000, infinity},
+	phr-ProhibitTimer					ENUMERATED {sf0, sf10, sf20, sf50, sf100,sf200, sf500, sf1000},
+	phr-Tx-PowerFactorChange			ENUMERATED {dB1, dB3, dB6, infinity},
+	multiplePHR							BOOLEAN,
+	phr-Type2PCell						BOOLEAN,
+	phr-Type2OtherCell					BOOLEAN,
+	phr-ModeOtherCG						ENUMERATED {real, virtual}
+
+}
+
+
+TAG-Config ::=				SEQUENCE {
+	tag-ToReleaseList			SEQUENCE (SIZE (1..maxNrofTAGs)) OF TAG-Id											OPTIONAL,	-- Need N
+	tag-ToAddModList			SEQUENCE (SIZE (1..maxNrofTAGs)) OF TAG-ToAddMod											OPTIONAL		-- Need N
+}
+
+TAG-ToAddMod ::= 			SEQUENCE {
+	tag-Id						TAG-Id,
+	timeAlignmentTimer			TimeAlignmentTimer,
+	...
+}
+
+TAG-Id ::=					INTEGER (0..maxNrofTAGs-1)
+
+TimeAlignmentTimer ::= 		ENUMERATED {ms500, ms750, ms1280, ms1920, ms2560, ms5120, ms10240, infinity}
+
+BSR-Config ::=				SEQUENCE {
+	periodicBSR-Timer			ENUMERATED {
+									sf1, sf5, sf10, sf16, sf20, sf32, sf40, sf64, sf80, sf128, sf160, sf320, sf640, sf1280, sf2560, infinity},
+	retxBSR-Timer				ENUMERATED { sf10, sf20, sf40, sf80, sf160, sf320, sf640, sf1280, sf2560, sf5120, sf10240, spare5, spare4,
+											spare3, spare2, spare1},
+	logicalChannelSR-DelayTimer		ENUMERATED { sf20, sf40, sf64, sf128, sf512, sf1024, sf2560, spare1}	OPTIONAL	-- Need R
+}
+
+
+
+-- TAG-MAC-CELL-GROUP-CONFIG-STOP
+-- TAG-MEAS-CONFIG-START
+
+MeasConfig ::=							SEQUENCE {
+	-- Measurement objects
+	measObjectToRemoveList					MeasObjectToRemoveList											OPTIONAL,	-- Need N
+	measObjectToAddModList					MeasObjectToAddModList											OPTIONAL,	-- Need N
+
+	-- Reporting configurations
+	reportConfigToRemoveList				ReportConfigToRemoveList										OPTIONAL,	-- Need N
+	reportConfigToAddModList				ReportConfigToAddModList										OPTIONAL,	-- Need N
+
+	-- Measurement identities
+	measIdToRemoveList						MeasIdToRemoveList												OPTIONAL,	-- Need N
+	measIdToAddModList						MeasIdToAddModList												OPTIONAL,	-- Need N
+
+	-- Other parameters
+	--s-Measure config
+	s-MeasureConfig							CHOICE {
+		ssb-RSRP								RSRP-Range,						
+		csi-RSRP								RSRP-Range						
+	} 																										OPTIONAL,	-- Need M
+
+	quantityConfig						QuantityConfig														OPTIONAL,	-- Need M
+
+	--Placehold for measGapConfig
+	measGapConfig							MeasGapConfig													OPTIONAL,	-- Need M
+	...
+}
+
+MeasObjectToRemoveList ::=				SEQUENCE (SIZE (1..maxNrofObjectId)) OF MeasObjectId
+
+MeasIdToRemoveList ::=					SEQUENCE (SIZE (1..maxNrofMeasId)) OF MeasId
+
+ReportConfigToRemoveList ::=			SEQUENCE (SIZE (1..maxReportConfigId)) OF ReportConfigId
+
+-- TAG-MEAS-CONFIG-STOP
+--TAG-MEAS-GAP-CONFIG-START
+
+MeasGapConfig ::=				SEQUENCE {
+		gapFR2 						GapConfig 				OPTIONAL,
+		...
+}
+
+GapConfig ::=					SEQUENCE {
+		gapOffset 					INTEGER (0..159),
+		mgl 						ENUMERATED {ms1dot5, ms3, ms3dot5, ms4, ms5dot5, ms6},
+		mgrp 						ENUMERATED {ms20, ms40, ms80, ms160},
+		mgta						ENUMERATED {ms0, ms0dot25, ms0dot5},
+		...
+}
+
+-- TAG-MEAS-GAP-CONFIG-STOP
+-- TAG-MEAS-ID-START
+
+MeasId ::=							INTEGER (1..maxNrofMeasId)
+
+-- TAG-MEAS-ID-STOP
+-- TAG-MEAS-ID-TO-ADD-MOD-LIST-START
+
+MeasIdToAddModList ::=				SEQUENCE (SIZE (1..maxNrofMeasId)) OF MeasIdToAddMod
+
+MeasIdToAddMod ::=					SEQUENCE {
+	measId								MeasId,
+	measObjectId						MeasObjectId,
+	reportConfigId						ReportConfigId
+}
+
+-- TAG-MEAS-ID-TO-ADD-MOD-LIST-STOP
+-- TAG-MEAS-OBJECT-ID-START
+
+MeasObjectId ::=							INTEGER (1..maxNrofObjectId)
+
+-- TAG-MEAS-OBJECT-ID-STOP
+-- TAG-MEAS-OBJECT-NR-START
+
+MeasObjectNR ::=							SEQUENCE {
+	ssbFrequency								ARFCN-ValueNR															OPTIONAL,
+	refFreqCSI-RS								ARFCN-ValueNR															OPTIONAL,
+
+	--RS configuration (e.g. SMTC window, CSI-RS resource, etc.)
+	referenceSignalConfig						ReferenceSignalConfig,													
+
+	--Consolidation of L1 measurements per RS index
+	absThreshSS-BlocksConsolidation			ThresholdNR																	OPTIONAL,	-- Need R
+	absThreshCSI-RS-Consolidation			ThresholdNR																	OPTIONAL,	-- Need R
+																													
+	--Config for cell measurement derivation
+	nrofSS-BlocksToAverage					INTEGER (2..maxNrofSS-BlocksToAverage)										OPTIONAL,	-- Need R
+	nrofCSI-RS-ResourcesToAverage			INTEGER (2..maxNrofCSI-RS-ResourcesToAverage)								OPTIONAL,	-- Need R
+																															
+	-- Filter coefficients applicable to this measurement object
+	quantityConfigIndex							INTEGER (1..maxNrofQuantityConfig),
+
+	--Frequency-specific offsets 
+	offsetFreq									Q-OffsetRangeList,
+
+	-- Cell list
+	cellsToRemoveList							PCI-List																OPTIONAL,	-- Need N
+	cellsToAddModList							CellsToAddModList														OPTIONAL,	-- Need N
+
+	-- Black list
+	blackCellsToRemoveList						PCI-RangeIndexList														OPTIONAL,	-- Need N
+	blackCellsToAddModList						BlackCellsToAddModList													OPTIONAL,	-- Need N
+
+	-- White list
+	whiteCellsToRemoveList						PCI-RangeIndexList														OPTIONAL,	-- Need N
+	whiteCellsToAddModList						WhiteCellsToAddModList													OPTIONAL,	-- Need N
+	...
+}
+
+ReferenceSignalConfig::=     			SEQUENCE {
+	
+
+	-- SSB configuration for mobility (nominal SSBs, timing configuration)
+	ssb-ConfigMobility						SSB-ConfigMobility				OPTIONAL,	-- Need M
+	-- CSI-RS resources to be used for CSI-RS based RRM measurements
+	csi-rs-ResourceConfigMobility			CSI-RS-ResourceConfigMobility  OPTIONAL-- Need M		
+
+}
+
+-- A measurement timing configuration
+SSB-ConfigMobility::= 	SEQUENCE {
+		--Only the values 15, 30 or 60 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are applicable
+		subcarrierSpacing                    SubcarrierSpacing,
+		-- The set of SS blocks to be measured within the SMTC measurement duration. 
+		-- Corresponds to L1 parameter 'SSB-measured' (see FFS_Spec, section FFS_Section)
+		-- When the field is absent the UE measures on all SS-blocks 
+		-- FFS_CHECK: Is this IE placed correctly.
+		ssb-ToMeasure							SSB-ToMeasure 								OPTIONAL,	-- Need M
+
+	-- Indicates whether the UE can utilize serving cell timing to derive the index of SS block transmitted by neighbour cell:
+	useServingCellTimingForSync				BOOLEAN,
+																									
+	-- Primary measurement timing configuration. Applicable for intra- and inter-frequency measurements. 
+	smtc1									SEQUENCE {
+		-- Periodicity and offset of the measurement window in which to receive SS/PBCH blocks. 
+		-- Periodicity and offset are given in number of subframes.
+		-- FFS_FIXME: This does not match the L1 parameter table! They seem to intend an index to a hidden table in L1 specs. 
+		-- (see 38.213, section REF):
+		periodicityAndOffset					CHOICE {
+			sf5										INTEGER (0..4),
+			sf10									INTEGER (0..9),
+			sf20									INTEGER (0..19),
+			sf40									INTEGER (0..39),
+			sf80									INTEGER (0..79),
+			sf160									INTEGER (0..159)
+		},
+		-- Duration of the measurement window in which to receive SS/PBCH blocks. It is given in number of subframes 
+		-- (see 38.213, section 4.1)
+		duration								ENUMERATED { sf1, sf2, sf3, sf4, sf5 }
+	},
+
+	-- Secondary measurement timing confguration for explicitly signalled PCIs. It uses the offset and duration from smtc1.
+	-- It is supported only for intra-frequency measurements in RRC CONNECTED. 
+	smtc2 									SEQUENCE {
+		-- PCIs that are known to follow this SMTC.
+		pci-List								SEQUENCE (SIZE (1..maxNrofPCIsPerSMTC)) OF PhysCellId		OPTIONAL,	-- Need M
+		-- Periodicity for the given PCIs. Timing offset and Duration as provided in smtc1.
+		periodicity								ENUMERATED {sf5, sf10, sf20, sf40, sf80, sf160, spare2, spare1}
+	}																										OPTIONAL,-- Cond IntraFreqConnected
+	ss-RSSI-Measurement							SEQUENCE {
+		measurementSlots							CHOICE {
+			kHz15										BIT STRING (SIZE(1)),
+			kHz30										BIT STRING (SIZE(2)),
+			kHz60										BIT STRING (SIZE(4)),
+			kHz120										BIT STRING (SIZE(8))
+		},
+		endSymbol									INTEGER(0..13)
+	}																										OPTIONAL				
+}
+
+CSI-RS-ResourceConfigMobility ::= 		SEQUENCE {
+	-- MO specific values
+		isServingCellMO						BOOLEAN,
+	-- Subcarrier spacing of CSI-RS. 
+	-- Only the values 15, 30 or 60 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are applicable.
+	-- Corresponds to L1 parameter 'Numerology' (see 38.211, section FFS_Section)
+	subcarrierSpacing						SubcarrierSpacing,
+	-- List of cells
+	csi-RS-CellList-Mobility 	SEQUENCE (SIZE (1..maxNrofCSI-RS-CellsRRM))	OF CSI-RS-CellMobility
+
+}
+
+CSI-RS-CellMobility ::=				SEQUENCE {
+	cellId									PhysCellId,
+
+	csi-rs-MeasurementBW					SEQUENCE {
+		-- Allowed size of the measurement BW in PRBs
+		-- Corresponds to L1 parameter 'CSI-RS-measurementBW-size' (see FFS_Spec, section FFS_Section)
+		nrofPRBs			ENUMERATED { size24, size48, size96, size192, size264},
+		-- Starting PRB index of the measurement bandwidth
+		-- Corresponds to L1 parameter 'CSI-RS-measurement-BW-start' (see FFS_Spec, section FFS_Section)
+		-- FFS_Value: Upper edge of value range unclear in RAN1
+		startPRB			INTEGER(0..2169)
+	},
+
+	-- Frequency domain density for the 1-port CSI-RS for L3 mobility
+	-- Corresponds to L1 parameter 'Density' (see FFS_Spec, section FFS_Section)
+	density									ENUMERATED {d1,d3}												OPTIONAL,
+
+
+-- List of resources
+	csi-rs-ResourceList-Mobility 	SEQUENCE (SIZE (1..maxNrofCSI-RS-ResourcesRRM))	OF CSI-RS-Resource-Mobility
+}
+
+
+CSI-RS-Resource-Mobility ::=			SEQUENCE {
+	csi-RS-Index							CSI-RS-Index,
+	-- Contains periodicity and slot offset for periodic/semi-persistent CSI-RS (see 38.211, section x.x.x.x)FFS_Ref
+	slotConfig								CHOICE {
+		ms4										INTEGER (0..31),
+		ms5										INTEGER (0..39),
+		ms10									INTEGER (0..79),
+		ms20									INTEGER (0..159),
+		ms40									INTEGER (0..319)
+	},
+	-- Each CSI-RS resource may be associated with one SSB. If such SSB is indicated, the NW also indicates whether the UE may assume 
+	-- quasi-colocation of this SSB with this CSI-RS reosurce. 
+	-- Corresponds to L1 parameter 'Associated-SSB' (see FFS_Spec, section FFS_Section)
+	
+	associatedSSB							SEQUENCE {
+		ssb-Index								SSB-Index,
+		-- The CSI-RS resource is either QCL’ed not QCL’ed with the associated SSB in spatial parameters
+		-- Corresponds to L1 parameter 'QCLed-SSB' (see FFS_Spec, section FFS_Section)
+		isQuasiColocated						BOOLEAN
+	}					OPTIONAL, -- Cond AssociatedSSB
+
+	
+	-- Frequency domain allocation within a physical resource block in accordance with 38.211, section 7.4.1.5.3 including table 7.4.1.5.2-1.
+	-- The number of bits that may be set to one depend on the chosen row in that table. For the choice "other", the row can be determined from
+	-- the parmeters below and from the number of bits set to 1 in frequencyDomainAllocation.
+	frequencyDomainAllocation			CHOICE {
+		row1								BIT STRING (SIZE (4)),
+		row2								BIT STRING (SIZE (12))
+	},
+
+	
+	-- Time domain allocation within a physical resource block. The field indicates the first OFDM symbol in the PRB used for CSI-RS.
+	-- Parameter l0 in 38.211, section 7.4.1.5.3. Value 2 is supported only when DL-DMRS-typeA-pos equals 3.
+	firstOFDMSymbolInTimeDomain			INTEGER (0..13),	
+	-- Scrambling ID for CSI-RS(see 38.211, section 7.4.1.5.2)
+	sequenceGenerationConfig				INTEGER (0..1023),
+	...
+}
+
+CSI-RS-Index ::= 				INTEGER (0..maxNrofCSI-RS-ResourcesRRM-1)
+
+Q-OffsetRangeList ::=					SEQUENCE {
+	rsrpOffsetSSB							Q-OffsetRange				DEFAULT dB0,
+	rsrqOffsetSSB							Q-OffsetRange				DEFAULT dB0,
+	sinrOffsetSSB							Q-OffsetRange				DEFAULT dB0,
+	rsrpOffsetCSI-RS						Q-OffsetRange				DEFAULT dB0,
+	rsrqOffsetCSI-RS						Q-OffsetRange				DEFAULT dB0,
+	sinrOffsetCSI-RS						Q-OffsetRange				DEFAULT dB0
+}
+
+SSB-ToMeasure ::=			CHOICE {
+	-- bitmap for sub 3 GHz
+	shortBitmap							BIT STRING (SIZE (4)),
+	-- bitmap for 3-6 GHz
+	mediumBitmap						BIT STRING (SIZE (8)),
+	-- bitmap for above 6 GHz
+	longBitmap							BIT STRING (SIZE (64))
+}
+
+
+ThresholdNR ::=							SEQUENCE{
+	thresholdRSRP							RSRP-Range					OPTIONAL,
+	thresholdRSRQ						RSRQ-Range					OPTIONAL,
+	thresholdSINR						SINR-Range					OPTIONAL
+}
+
+CellsToAddModList ::=					SEQUENCE (SIZE (1..maxNrofCellMeas)) OF CellsToAddMod
+
+CellsToAddMod ::=						SEQUENCE {
+	physCellId								PhysCellId,
+	cellIndividualOffset					Q-OffsetRangeList
+}
+
+BlackCellsToAddModList ::=				SEQUENCE (SIZE (1..maxNrofPCI-Ranges)) OF BlackCellsToAddMod
+
+BlackCellsToAddMod ::=					SEQUENCE {
+	pci-RangeIndex							PCI-RangeIndex,		
+	pci-Range								PCI-Range
+}
+
+
+WhiteCellsToAddModList ::=				SEQUENCE (SIZE (1..maxNrofPCI-Ranges)) OF WhiteCellsToAddMod
+
+WhiteCellsToAddMod ::=					SEQUENCE {
+	pci-RangeIndex							PCI-RangeIndex,
+	pci-Range							PCI-Range
+}
+
+-- TAG-MEAS-OBJECT-NR-STOP
+-- TAG-MEAS-OBJECT-TO-ADD-MOD-LIST-START
+
+MeasObjectToAddModList ::=					SEQUENCE (SIZE (1..maxNrofObjectId)) OF MeasObjectToAddMod
+
+MeasObjectToAddMod ::=						SEQUENCE {
+	measObjectId								MeasObjectId,
+	measObject									CHOICE {
+		measObjectNR								MeasObjectNR,
+		...
+	}
+}
+
+-- TAG-MEAS-OBJECT-TO-ADD-MOD-LIST-STOP 
+-- TAG-MEAS-RESULTS-START
+
+MeasResults ::=								SEQUENCE {
+	measId										MeasId,
+	measResultServingFreqList					MeasResultServFreqList,
+	measResultNeighCells						CHOICE {
+		measResultListNR							MeasResultListNR,
+		...
+	}																														OPTIONAL,
+	...
+}
+
+MeasResultServFreqList ::=					SEQUENCE (SIZE (1..maxNrofServingCells)) OF MeasResultServFreq
+
+MeasResultServFreq ::=						SEQUENCE {
+	servFreqId									ServCellIndex,																
+	measResultServingCell						MeasResultNR,
+	measResultBestNeighCell						MeasResultNR,
+	...															
+}
+
+MeasResultListNR ::=						SEQUENCE (SIZE (1..maxCellReport)) OF MeasResultNR
+
+MeasResultNR ::=							SEQUENCE {
+	physCellId									PhysCellId																	OPTIONAL,
+	--FFS: Details of cgi info 
+	cgi-Info									ENUMERATED {ffsTypeAndValue}												OPTIONAL,
+	measResult									SEQUENCE {
+		cellResults									SEQUENCE{
+			resultsSSB-Cell								MeasQuantityResults													OPTIONAL,
+			resultsCSI-RS-Cell							MeasQuantityResults													OPTIONAL
+		},
+		rsIndexResults								SEQUENCE{
+			resultsSSB-Indexes							ResultsPerSSB-IndexList												OPTIONAL, 
+			resultsCSI-RS-Indexes						ResultsPerCSI-RS-IndexList											OPTIONAL
+		}																													OPTIONAL
+	},
+	...
+}
+
+
+MeasQuantityResults ::= 		SEQUENCE {
+	rsrp							RSRP-Range													OPTIONAL,
+	rsrq							RSRQ-Range													OPTIONAL,
+	sinr							SINR-Range													OPTIONAL
+}
+
+ResultsPerSSB-IndexList::= 				SEQUENCE (SIZE (1..maxNrofSSBs)) OF ResultsPerSSB-Index
+
+ResultsPerSSB-Index ::= 					SEQUENCE {
+	ssb-Index									SSB-Index,
+	ssb-Results									MeasQuantityResults							OPTIONAL
+}
+
+ResultsPerCSI-RS-IndexList::= 				SEQUENCE (SIZE (1..maxNrofCSI-RS)) OF ResultsPerCSI-RS-Index
+
+ResultsPerCSI-RS-Index ::= 					SEQUENCE {
+	csi-RS-Index								CSI-RS-Index,
+	csi-RS-Results								MeasQuantityResults							OPTIONAL
+}
+
+-- TAG-MEAS-RESULTS-STOP
+-- TAG-MEAS-RESULT-SCG-FAILURE-START
+
+MeasResultSCG-Failure ::= 			SEQUENCE {
+	measResultServFreqList					MeasResultServFreqList2NR,
+	measResultNeighCells						MeasResultList2NR,
+	...
+}
+
+MeasResultServFreqList2NR ::=			SEQUENCE (SIZE (1..maxNrofServingCells)) OF MeasResultServFreq2NR
+
+MeasResultServFreq2NR ::=				SEQUENCE {
+	ssbFrequency							ARFCN-ValueNR			OPTIONAL,
+	refFreqCSI-RS							ARFCN-ValueNR			OPTIONAL,
+	measResultServingCell					MeasResultNR,
+	measResultBestNeighCell					MeasResultNR		OPTIONAL
+}
+
+MeasResultList2NR ::=					SEQUENCE (SIZE (1..maxFreq)) OF MeasResult2NR
+
+MeasResult2NR ::=						SEQUENCE {	
+	ssbFrequency							ARFCN-ValueNR			OPTIONAL,
+	refFreqCSI-RS							ARFCN-ValueNR			OPTIONAL,
+	measResultListNR						MeasResultListNR
+}
+
+-- TAG-MEAS-RESULT-SCG-FAILURE-STOP
+-- TAG-MEASRESULT-CELL-LIST-SFTD-START
+
+MeasResultCellListSFTD ::=			SEQUENCE (SIZE (1..maxCellSFTD)) OF MeasResultCellSFTD
+
+MeasResultCellSFTD ::=	SEQUENCE {
+	physCellId							PhysCellId,
+	sfn-OffsetResult					INTEGER (0..1023),
+	frameBoundaryOffsetResult			INTEGER (-30720..30719),
+	rsrp-Result							RSRP-Range						OPTIONAL
+}
+
+-- TAG-MEASRESULT-CELL-LIST-SFTD-STOP
+-- TAG-MULTIFREQUENCYBANDLISTNR-START
+
+MultiFrequencyBandListNR ::= 		SEQUENCE (SIZE (1..maxNrofMultiBands)) OF FreqBandIndicatorNR
+
+-- TAG-MULTIFREQUENCYBANDLISTNR-STOP
+-- TAG-NZP-CSI-RS-RESOURCESET-START
+NZP-CSI-RS-ResourceSet ::= 		SEQUENCE {
+	nzp-CSI-ResourceSetId					NZP-CSI-RS-ResourceSetId,	
+
+	-- NZP-CSI-RS-Resources assocaited with this NZP-CSI-RS resource set.
+	-- Corresponds to L1 parameter 'CSI-RS-ResourceConfigList' (see 38.214, section 5.2)
+	-- For CSI, there are at most 8 NZP CSI RS resources per resource set
+	nzp-CSI-RS-Resources						SEQUENCE (SIZE (1..maxNrofNZP-CSI-RS-ResourcesPerSet)) OF NZP-CSI-RS-ResourceId,
+
+	-- Indicates whether repetition is on/off. If set to set to 'OFF', the UE may not assume that the 
+	-- NZP-CSI-RS resources within the resource set are transmitted with the same downlink spatial domain transmission filter 
+	-- and with same NrofPorts in every symbol.
+	-- Corresponds to L1 parameter 'CSI-RS-ResourceRep' (see 38.214, sections 5.2.2.3.1 and 5.1.6.1.2)
+	-- Can only be configured for CSI-RS resource sets which are associated with CSI-ReportConfig with report of L1 RSRP or “no report”	
+	repetition									ENUMERATED { on, off }				OPTIONAL,
+
+	-- Offset X between the slot containing the DCI that triggers a set of aperiodic NZP CSI-RS resources and the slot in which the 
+	-- CSI-RS resource set is transmitted. When the field is absent the UE applies the value 0.
+	-- Corresponds to L1 parameter 'Aperiodic-NZP-CSI-RS-TriggeringOffset' (see 38,214, section FFS_Section)
+	aperiodicTriggeringOffset			 		INTEGER(0..4)																		OPTIONAL,	-- Need S
+
+	-- Indicates that the antenna port for all NZP-CSI-RS resources in the CSI-RS resource set is same.
+	-- Corresponds to L1 parameter 'TRS-Info' (see 38.214, section 5.2.2.3.1)
+	trs-Info								ENUMERATED {true}																OPTIONAL,
+	...
+}
+
+-- TAG-NZP-CSI-RS-RESOURCESET-STOP
+-- TAG-NZP-CSI-RS-RESOURCESETID-START
+NZP-CSI-RS-ResourceSetId ::= INTEGER (0..maxNrofNZP-CSI-RS-ResourceSets-1)
+
+-- TAG-NZP-CSI-RS-RESOURCESETID-STOP
+-- TAG-NZP-CSI-RS-RESOURCE-START
+NZP-CSI-RS-Resource ::=		SEQUENCE {
+	nzp-CSI-RS-ResourceId				NZP-CSI-RS-ResourceId,
+
+	-- OFDM symbol location(s) in a slot and subcarrier occupancy in a PRB of the CSI-RS resource	
+	resourceMapping							CSI-RS-ResourceMapping,
+	-- Power offset of NZP CSI-RS RE to PDSCH RE. Value in dB. Corresponds to L1 parameter Pc (see 38.214, sections 5.2.2.3.1 and 4.1)
+	powerControlOffset						INTEGER(-8..15),
+	-- Power offset of NZP CSI-RS RE to SS RE. Value in dB. Corresponds to L1 parameter 'Pc_SS' (see 38.214, section 5.2.2.3.1)
+	powerControlOffsetSS					ENUMERATED{db-3, db0, db3, db6}								OPTIONAL,	
+	-- Scrambling ID (see 38.214, section 5.2.2.3.1)
+	scramblingID							ScramblingId,
+
+	-- Periodicity and slot offset sl1 corresponds to a periodicity of 1 slot, sl2 to a periodicity of two slots, and so on. 
+	-- The corresponding offset is also given in number of slots. Corresponds to L1 parameter 'CSI-RS-timeConfig' (see 38.214, section 5.2.2.3.1)
+	periodicityAndOffset					CSI-ResourcePeriodicityAndOffset							OPTIONAL, --Cond PeriodicOrSemiPersistent
+
+	-- For a target periodic CSI-RS, contains a reference to one TCI-State in TCI-States for providing the QCL source and 
+	-- QCL type. For periodic CSI-RS, the source can be SSB or another periodic-CSI-RS.
+	-- Corresponds to L1 parameter 'QCL-Info-PeriodicCSI-RS' (see 38.214, section 5.2.2.3.1)
+	qcl-InfoPeriodicCSI-RS						TCI-StateId												OPTIONAL, --Cond Periodic
+	...
+}
+
+-- TAG-NZP-CSI-RS-RESOURCE-STOP
+-- TAG-NZP-CSI-RS-RESOURCEID-START
+NZP-CSI-RS-ResourceId ::= 					INTEGER (0..maxNrofNZP-CSI-RS-Resources-1)
+
+-- TAG-NZP-CSI-RS-RESOURCEID-STOP
+-- TAG-P-MAX-START
+
+P-Max ::=				INTEGER (-30..33)
+
+-- TAG-P-MAX-STOP
+-- TAG-PCI-LIST-START
+
+PCI-List ::=						SEQUENCE (SIZE (1..maxNrofCellMeas)) OF PhysCellId
+
+-- TAG-PCI-LIST-STOP
+-- TAG-PCI-RANGE-START
+
+PCI-Range ::=				SEQUENCE {
+	start							PhysCellId,
+	range							ENUMERATED {
+										n4, n8, n12, n16, n24, n32, n48, n64, n84,
+										n96, n128, n168, n252, n504, n1008,
+										spare1} 					OPTIONAL	-- Need Nss
+}
+
+-- TAG-PCI-RANGE-STOP
+-- TAG-PCI-RANGE-INDEX-START
+
+PCI-RangeIndex ::=						INTEGER (1..maxNrofPCI-Ranges)
+
+
+-- TAG-PCI-RANGE-INDEX-STOP
+-- TAG-PCI-RANGE-INDEX-LIST-START
+
+PCI-RangeIndexList ::=						SEQUENCE (SIZE (1..maxNrofPCI-Ranges)) OF PCI-RangeIndex
+
+-- TAG-PCI-Range-INDEX-LIST-STOP
+-- TAG-PDCCH-CONFIG-START
+
+PDCCH-Config ::= 						SEQUENCE {
+	-- List of UE specifically configured Control Resource Sets (CORESETs) to be used by the UE.
+	-- The network configures at most 3 CORESETs per BWP per cell (including the initial CORESET).
+	controlResourceSetToAddModList			SEQUENCE(SIZE (1..3)) OF ControlResourceSet 		OPTIONAL,
+	controlResourceSetToReleaseList			SEQUENCE(SIZE (1..3)) OF ControlResourceSetId			OPTIONAL,
+
+	-- List of UE specifically configured Control Resource Sets (CORESETs).
+	-- The network configures at most 10 Search Spaces per BWP per cell (including the initial Search Space).
+	searchSpacesToAddModList				SEQUENCE(SIZE (1..10)) OF SearchSpace						OPTIONAL,
+	searchSpacesToReleaseList				SEQUENCE(SIZE (1..10)) OF SearchSpaceId						OPTIONAL,
+
+	-- Configuration of downlink preemtption indications to be monitored in this cell. 
+	-- Corresponds to L1 parameter 'Preemp-DL' (see 38.214, section 11.2)
+	-- FFS_RAN1: LS R1-1801281 indicates this is "Per Cell (but association with each configured BWP is needed)" => Unclear, keep on BWP for now.
+	downlinkPreemption					  DownlinkPreemption 															OPTIONAL,	-- Need M
+
+	-- Configuration of Slot-Format-Indicators to be monitored in this cell
+
+	-- FFS_RAN1 discusses still whether this SFI payload configuration is BWP- or Cell-Specific. 
+	slotFormatIndicator				          SlotFormatIndicator 															OPTIONAL,	-- Need M
+	-- Enable and configure reception of group TPC commands for PUSCH
+	tpc-PUSCH								PUSCH-TPC-CommandConfig 							OPTIONAL,   -- Need M
+
+	-- Enable and configure reception of group TPC commands fpr PUCCH
+	tpc-PUCCH								PUCCH-TPC-CommandConfig 							OPTIONAL,   -- Cond PUCCH-CellOnly
+
+	...
+}
+
+-- TAG-PDCCH-CONFIG-STOP 
+-- TAG-PDCCH-CONFIGCOMMON-START
+
+PDCCH-ConfigCommon ::=					SEQUENCE {
+
+	-- A list of common control resource sets. Only CORESETs with ControlResourceSetId = 0 or 1 are allowed. The CORESET#0 
+	-- corresponds to the CORESET configured in MIB (see pdcch-ConfigSIB1) and is used to provide that information to the UE
+	-- by dedicated signalling during handover and (P)SCell addition. The CORESET#1 may be configured an used for RAR 
+	-- (see ra-ControlResourceSet).
+	commonControlResourcesSets					SEQUENCE (SIZE(1..2)) OF ControlResourceSet							OPTIONAL, 	-- Need R
+
+	-- A list of additional common search spaces.
+	commonSearchSpaces							SEQUENCE (SIZE(1..4)) OF SearchSpace								OPTIONAL,	-- Need R
+
+	-- ID of the search space for SIB1 message.
+	
+	-- Corresponds to L1 parameter 'rmsi-SearchSpace' (see 38.213, section 10)
+	searchSpaceSIB1								SearchSpaceId														OPTIONAL,	-- Need R
+	-- ID of the Search space for other system information, i.e., SIB2 and beyond. 
+	-- Corresponds to L1 parameter 'osi-SearchSpace' (see 38.213, section 10)
+	-- If the field is absent, the monitoring occasions are derived as described in 38.213, section 10.1 and section 13.
+	searchSpaceOtherSystemInformation			SearchSpaceId														OPTIONAL,	-- Need R
+	
+	-- ID of the Search space for paging. Corresponds to L1 parameter 'paging-SearchSpace' (see 38.213, section 10)
+	-- If the field is absent, the monitoring occasions are derived as described in 38.213, section 10.1 and section 13.
+	pagingSearchSpace							SearchSpaceId														OPTIONAL, 	-- Need R
+
+	-- CORESET configured for random access. When the field is absent the UE uses the CORESET according to pdcch-ConfigSIB1
+	-- which is associated with ControlResourceSetId = 0.
+	-- Corresponds to L1 parameter 'rach-coreset-configuration' (see 38.211?, section FFS_Section)
+	ra-ControlResourceSet					ControlResourceSetId																OPTIONAL, 	-- Need S
+	-- ID of the Search space for random access procedure. Corresponds to L1 parameter 'ra-SearchSpace' (see 38.214?, section FFS_Section)
+	-- If the field is absent, the monitoring occasions are derived as described in 38.213, section 10.1 and section 13.
+	ra-SearchSpace							SearchSpaceId																	OPTIONAL, 	-- Need R
+	...
+
+}
+
+-- TAG-PDCCH-CONFIGCOMMON-STOP
+-- TAG-PDCP-CONFIG-START
+
+PDCP-Config ::=			SEQUENCE {
+	drb						SEQUENCE {
+		discardTimer			ENUMERATED {ms10, ms20, ms30, ms40, ms50, ms60, ms75, ms100, ms150, ms200, ms250, ms300, ms500, ms750, ms1500, infinity} 													OPTIONAL, -- Cond Setup
+		pdcp-SN-SizeUL			ENUMERATED {len12bits, len18bits}				OPTIONAL, -- Cond Setup2
+		pdcp-SN-SizeDL			ENUMERATED {len12bits, len18bits}				OPTIONAL, -- Cond Setup2
+		headerCompression		CHOICE {
+			notUsed					NULL,
+			rohc					SEQUENCE {
+				maxCID					INTEGER (1..16383)				DEFAULT 15,
+				profiles				SEQUENCE {
+					profile0x0001			BOOLEAN,
+					profile0x0002			BOOLEAN,
+					profile0x0003			BOOLEAN,
+					profile0x0004			BOOLEAN,
+					profile0x0006			BOOLEAN,
+					profile0x0101			BOOLEAN,
+					profile0x0102			BOOLEAN,
+					profile0x0103			BOOLEAN,
+					profile0x0104			BOOLEAN
+				},
+				drb-ContinueROHC			BOOLEAN 
+			},
+			uplinkOnlyROHC			SEQUENCE {
+				maxCID					INTEGER (1..16383)				DEFAULT 15,
+				profiles				SEQUENCE {
+					profile0x0006			BOOLEAN
+				},
+				drb-ContinueROHC			BOOLEAN 
+			},
+			...
+		},
+		integrityProtection		ENUMERATED { enabled }														OPTIONAL,	-- Cond ConnectedTo5GC
+		statusReportRequired	ENUMERATED { true }															OPTIONAL,	-- Cond Rlc-AM
+		outOfOrderDelivery		BOOLEAN
+	}																											OPTIONAL,	-- Cond DRB
+	-- FFS / TODO: Handle more than two secondary cell groups
+	moreThanOneRLC			SEQUENCE {
+		primaryPath				SEQUENCE {
+			cellGroup				CellGroupId											OPTIONAL,	-- Need R
+			logicalChannel			LogicalChannelIdentity								OPTIONAL	-- Need R
+		},
+		ul-DataSplitThreshold	UL-DataSplitThreshold 									OPTIONAL, -- Cond SplitBearer						
+		pdcp-Duplication			ENUMERATED { true }													OPTIONAL	-- Need R
+	}																										OPTIONAL, -- Cond MoreThanOneRLC
+
+	t-Reordering				ENUMERATED {
+									ms0, ms1, ms2, ms4, ms5, ms8, ms10, ms15, ms20, ms30, ms40, ms50, ms60, ms80, ms100, ms120, ms140, ms160, ms180, ms200, ms220, 
+									ms240, ms260, ms280, ms300,	ms500, ms750, ms1000, ms1250, ms1500, ms1750, ms2000, ms2250, ms2500, ms2750,
+									ms3000, spare28, spare27, spare26, spare25, spare24, spare23, spare22, spare21, spare20,
+									spare19, spare18, spare17, spare16, spare15, spare14, spare13, spare12, spare11, spare10, spare09,
+									spare08, spare07, spare06, spare05, spare04, spare03, spare02, spare01 }		OPTIONAL, -- Need S
+
+	
+	...
+}
+
+UL-DataSplitThreshold ::= ENUMERATED { 
+											b0, b100, b200, b400, b800, b1600, b3200, b6400, b12800, b25600, b51200, b102400, b204800, 
+											b409600, b819200, b1228800, b1638400, b2457600, b3276800, b4096000, b4915200, b5734400, 
+											b6553600, infinity, spare8, spare7, spare6, spare5, spare4, spare3, spare2, spare1}
+
+-- TAG-PDCP-CONFIG-STOP
+-- TAG-PDSCH-CONFIG-START
+
+PDSCH-Config ::= 						SEQUENCE {
+	-- Identifer used to initalite data scrambling (c_init) for both PDSCH.
+	-- Corresponds to L1 parameter 'Data-scrambling-Identity' (see 38,214, section FFS_Section)
+	-- FFS:_Replace by tye ScramblingId used in other places?
+	dataScramblingIdentityPDSCH			INTEGER (0..1007)															OPTIONAL,
+
+	-- DMRS configuration for PDSCH transmissions using PDSCH mapping type A (chosen dynamically via PDSCH-TimeDomainResourceAllocation).
+	dmrs-DownlinkForPDSCH-MappingTypeA			DMRS-DownlinkConfig 										OPTIONAL,	-- Need M
+	-- DMRS configuration for PDSCH transmissions using PDSCH mapping type B (chosen dynamically via PDSCH-TimeDomainResourceAllocation).
+	dmrs-DownlinkForPDSCH-MappingTypeB			DMRS-DownlinkConfig  							OPTIONAL,	-- Need M
+
+
+	-- A list of Transmission Configuration Indicator (TCI) states for dynamically indicating (over DCI) a transmission configuration 
+	-- which includes QCL-relationships between the DL RSs in one RS set and the PDSCH DMRS ports 
+	-- (see 38.214, section 5.1.4)
+	tci-StatesToAddModList					SEQUENCE (SIZE(1..maxNrofTCI-States)) OF TCI-State					OPTIONAL,	-- Need N
+	tci-StatesToReleaseList					SEQUENCE (SIZE(1..maxNrofTCI-States)) OF TCI-StateId						OPTIONAL,	-- Need N
+
+	-- Interleaving unit configurable between 2 and 4 PRBs
+	-- Corresponds to L1 parameter 'VRB-to-PRB-interleaver' (see 38.211, section 6.3.1.6)
+	vrb-ToPRB-Interleaver					ENUMERATED {n2, n4},
+
+	-- Configuration of resource allocation type 0 and resource allocation type 1 for non-fallback DCI
+	-- Corresponds to L1 parameter 'Resouce-allocation-config' (see 38.214, section 5.1.2)
+	resourceAllocation						ENUMERATED { resourceAllocationType0, 
+resourceAllocationType1, 
+dynamicSwitch},
+
+	-- List of time-domain configurations for timing of DL assignment to DL data. If configured, the values provided herein 
+	-- override the values received in corresponding PDSCH-ConfigCommon.
+	pdsch-AllocationList			SEQUENCE (SIZE(1..maxNrofDL-Allocations)) OF PDSCH-TimeDomainResourceAllocation		OPTIONAL,	-- Need R
+	-- Number of repetitions for data. Corresponds to L1 parameter 'aggregation-factor-DL' (see 38.214, section FFS_Section)
+	-- When the field is absent the UE applies the value 1
+	pdsch-AggregationFactor					ENUMERATED { n2, n4, n8 }													OPTIONAL,	-- Need S
+
+	-- Resources patterns which the UE should rate match PDSCH around. The UE rate matches around the union of all resources 
+	-- indicated in the nexted bitmaps. Corresponds to L1 parameter 'Resource-set-BWP' (see 38.214, section 5.1.2.2.3)
+	-- FFS: RAN1 indicates that there should be a set of patterns per cell and one per BWP => Having both seems unnecessary.
+
+	rateMatchPatternToAddModList			SEQUENCE (SIZE (1..maxNrofRateMatchPatterns)) OF RateMatchPattern											OPTIONAL, -- Need N
+	rateMatchPatternToReleaseList			SEQUENCE (SIZE (1..maxNrofRateMatchPatterns)) OF RateMatchPatternId		OPTIONAL, -- Need N
+
+	-- The IDs of a first group of RateMatchPatterns defined in the rateMatchPatternToAddModList.
+	-- Corresponds to L1 parameter 'Resource-set-group-1'. (see 38.214, section FFS_Section)
+	rateMatchPatternGroup1					SEQUENCE (SIZE (1..maxNrofRateMatchPatterns)) OF RateMatchPatternId		OPTIONAL, -- Need R
+	-- The IDs of a second group of RateMatchPatterns defined in the rateMatchPatternToAddModList
+	-- Corresponds to L1 parameter 'Resource-set-group-2'. (see 38.214, section FFS_Section)
+	rateMatchPatternGroup2					SEQUENCE (SIZE (1..maxNrofRateMatchPatterns)) OF RateMatchPatternId		OPTIONAL, -- Need R
+
+
+	-- Selection between config 1 and config 2 for RBG size for PDSCH. Corresponds to L1 parameter 'RBG-size-PDSCH' (see 38.214, section 5.1.2.2.1)
+	rbg-Size								ENUMERATED {config1, config2},
+
+	-- Indicates which MCS table the UE shall use for PDSCH. Corresponds to L1 parameter 'MCS-Table-PDSCH' (see 38.214, section 5.1.3.1).
+	mcs-Table								ENUMERATED {qam64, qam256},
+
+	-- Maximum number of code words that a single DCI may schedule. This changes the number of MCS/RV/NDI bits in the DCI message from 1 to 2.
+	maxNrofCodeWordsScheduledByDCI			ENUMERATED {n1, n2}															OPTIONAL, 	-- Need R
+
+
+	-- Indicates the PRB bundle type and bundle size(s). If "dynamic" is chosen, the actual BundleSizeSet to use is indicated via DCI. 
+	-- If a bundleSize(Set) value is absent, the UE applies the value n2. Corresponds to L1 parameter 'PRB_bundling' 
+	-- (see 38.214, section 5.1.2.3)
+	prb-BundlingType					CHOICE {
+		static									SEQUENCE {
+			bundleSize								ENUMERATED { n4, wideband }											OPTIONAL	-- Need S
+		},
+		dynamic 								SEQUENCE {
+			bundleSizeSet1							ENUMERATED { n4, wideband, n2-wideband, n4-wideband }				OPTIONAL,	-- Need S
+			bundleSizeSet2							ENUMERATED { n4, wideband }											OPTIONAL	-- Need S
+		}
+	},
+
+	-- A list of Zero-Power (ZP) CSI-RS resources used for PDSCH rate-matching.
+	-- Corresponds to L1 parameter 'ZP-CSI-RS-ResourceConfigList' (see 38.214, section FFS_Section)
+	zp-CSI-RS-ResourceToAddModList			SEQUENCE (SIZE (1..maxNrofZP-CSI-RS-Resources)) OF ZP-CSI-RS-Resource	OPTIONAL,	-- Need N
+	zp-CSI-RS-ResourceToReleaseList			SEQUENCE (SIZE (1..maxNrofZP-CSI-RS-Resources)) OF ZP-CSI-RS-ResourceId	OPTIONAL,	-- Need M
+
+	-- A list of sets. Each set contains a set-ID and the IDs of one or more ZP-CSI-RS-Resources (the actual resources are defined in the 
+	-- zp-CSI-RS-ResourceToAddModList). The network triggers a set by indicating its set-ID (ZP-CSI-RS-ResourceSetId) in the DCI payload.
+	-- The resources referenced in these sets are confgiured with resourceType 'aperiodic'.
+	-- Corresponds to L1 parameter ' ZP-CSI-RS-ResourceSetConfigList' (see 38.214, section FFS_Section)
+	aperiodic-ZP-CSI-RS-ResourceSetsToAddModList	SEQUENCE (SIZE (1..maxNrofZP-CSI-RS-Sets)) OF ZP-CSI-RS-ResourceSet		OPTIONAL,	-- Need N
+	aperiodic-ZP-CSI-RS-ResourceSetsToReleaseList	SEQUENCE (SIZE (1..maxNrofZP-CSI-RS-Sets)) OF ZP-CSI-RS-ResourceSetId	OPTIONAL,	-- Need N
+	
+	-- A list of sets. Each set contains a set-ID and the IDs of one or more ZP-CSI-RS-Resources (the actual resources are defined in the 
+	-- zp-CSI-RS-ResourceToAddModList). The network triggers a set by indicating its set-ID (ZP-CSI-RS-ResourceSetId) in the MAC CE.
+	-- The resources referenced in these sets are confgiured with resourceType 'semi-persistent'.
+	-- Corresponds to L1 parameter 'SP-ZP-CSI-RS-Resource-List' (see 38.214, section 5.1.4_Section)
+	sp-ZP-CSI-RS-ResourceSetsToAddModList	SEQUENCE (SIZE (1..maxNrofZP-CSI-RS-Sets)) OF ZP-CSI-RS-ResourceSet		OPTIONAL,	-- Need N
+	sp-ZP-CSI-RS-ResourceSetsToReleaseList	SEQUENCE (SIZE (1..maxNrofZP-CSI-RS-Sets)) OF ZP-CSI-RS-ResourceSetId	OPTIONAL,	-- Need N
+
+	...
+}
+
+
+
+
+-- TAG-PDSCH-CONFIG-STOP
+-- TAG-PDSCH-CONFIGCOMMON-START
+
+PDSCH-ConfigCommon ::=					SEQUENCE {
+
+	-- List of time-domain configurations for timing of DL assignment to DL data 
+	pdsch-AllocationList			SEQUENCE (SIZE(1..maxNrofDL-Allocations)) OF PDSCH-TimeDomainResourceAllocation			OPTIONAL,	-- Need R
+
+	...
+}
+
+-- TAG-PDSCH-CONFIGCOMMON-STOP
+-- TAG-PDSCH-SERVINGCELLCONFIG-START
+
+PDSCH-ServingCellConfig ::= 			SEQUENCE {
+	-- Enables and configures code-block-group (CBG) based transmission (see 38.213, section 9.1.1)
+	codeBlockGroupTransmission				PDSCH-CodeBlockGroupTransmission 						OPTIONAL,	-- Need M
+	-- Accounts for overhead from CSI-RS, CORESET, etc. If the field is absent, the UE applies value xOh0.
+	-- Corresponds to L1 parameter 'Xoh-PDSCH' (see 38.214, section 5.1.3.2)
+	xOverhead								ENUMERATED { xOh6, xOh12, xOh18 }										OPTIONAL,	-- Need S
+	-- The number of HARQ processes to be used on the PDSCH of a serving cell. n2 corresponds to 2 HARQ processes, n4 to 4 HARQ processes 
+	-- and so on. If the field is absent, the UE uses 8 HARQ processes. 
+	-- Corresponds to L1 parameter 'number-HARQ-process-PDSCH' (see 38.214, section REF) 
+	nrofHARQ-ProcessesForPDSCH				ENUMERATED {n2, n4, n6, n10, n12, n16}									OPTIONAL,	-- Need S
+	-- The ID of the serving cell (of the same cell group) to use for PUCCH. 
+	-- If the field is absent, the UE sends the HARQ feedback on the PUCCH of the SpCell of this cell group. 
+	pucch-Cell								ServCellIndex															OPTIONAL	,	-- Cond SCellAddOnly
+	...
+}
+
+PDSCH-CodeBlockGroupTransmission ::=		SEQUENCE {
+	-- Maximum number of code-block-groups (CBGs) per TB. In case of multiple CW the maximum CBG is 4 (see 38.213, section 9.1.1)
+	maxCodeBlockGroupsPerTransportBlock		ENUMERATED {n2, n4, n6, n8},
+	-- Indicates whether CBGFI for CBG based (re)transmission in DL is enabled (true). (see 38.212, section 7.3.1.2.2)
+	codeBlockGroupFlushIndicator			BOOLEAN,
+	...
+}
+
+-- TAG-PDSCH-SERVINGCELLCONFIG-STOP
+-- TAG-PDSCH-TIMEDOMAINRESOURCEALLOCATION-START
+
+PDSCH-TimeDomainResourceAllocation ::= 		SEQUENCE {
+	-- Corresponds to L1 parameter 'K0' (see 38.214, section FFS_Section)
+	-- When the field is absent the UE applies the value 0
+	k0									INTEGER (1..3)																OPTIONAL,	-- Need S
+	-- PDSCH mapping type. Corresponds to L1 parameter 'Mapping-type' (see 38.214, section FFS_Section)
+	mappingType							ENUMERATED {typeA, typeB},
+	-- An index into a table/equation in RAN1 specs capturing valid combinations of start symbol and length (jointly encoded)
+	-- Corresponds to L1 parameter 'Index-start-len' (see 38.214, section FFS_Section)
+	startSymbolAndLength				BIT STRING (SIZE (7))
+}
+
+-- TAG-PDSCH-TIMEDOMAINRESOURCEALLOCATION-STOP
+-- TAG-PHYS-CELL-ID-START
+
+PhysCellId ::=						INTEGER (0..1007)
+
+-- TAG-PHYS-CELL-ID-STOP
+-- TAG-PRB-ID-START
+
+PRB-Id ::=						INTEGER (0..maxNrofPhysicalResourceBlocks-1)
+
+-- TAG-PRB-ID-STOP
+-- TAG-PTRS-DOWNLINKCONFIG-START
+
+PTRS-DownlinkConfig ::= 					SEQUENCE {
+	-- Presence and  frequency density of DL PT-RS as a function of Scheduled BW 
+	-- If the field is absent, the UE uses K_PT-RS = 2.
+	-- Corresponds to L1 parameter 'DL-PTRS-frequency-density-table' (see 38.214, section 5.1)
+	frequencyDensity							SEQUENCE (SIZE (2)) OF INTEGER (1..276)			OPTIONAL,	-- Need S
+	-- Presence and time density of DL PT-RS  as a function of MCS. The value 29 is only applicable for MCS Table 5.1.3.1-1 (38.214)
+	-- If the field is absent, the UE uses L_PT-RS = 1.
+	-- Corresponds to L1 parameter 'DL-PTRS-time-density-table' (see 38.214, section 5.1)
+	timeDensity									SEQUENCE (SIZE (3)) OF INTEGER (0..29)		OPTIONAL, 	-- Need S
+	-- EPRE ratio between PTRS and PDSCH. Value 0 correspond to the codepoint ”00” in table 4.1-2. Value 1 corresponds to codepoint ”01” 
+	-- If the field is not provided, the UE applies value 0. Corresponds to L1 parameter 'DL-PTRS-EPRE-ratio' (see 38.214, section 4.1)
+	epre-RatioPort1								INTEGER (0..3)															OPTIONAL,	-- Need S
+	-- EPRE ratio between PTRS and PDSCH. Value 0 correspond to the codepoint ”00” in table 4.1-2. Value 1 corresponds to codepoint ”01”.
+	-- If the field is not provided, the UE applies value 0. Corresponds to L1 parameter 'DL-PTRS-EPRE-ratio' (see 38.214, section 4.1)
+	epre-RatioPort2								SEQUENCE (SIZE (1..2)) OF INTEGER (0..3)								OPTIONAL,	-- Cond TwoPorts
+	-- Indicates the subcarrier offset for DL PTRS. If the field is absent, the UE applies the value offset00.
+	-- Corresponds to L1 parameter 'DL-PTRS-RE-offset' (see 38.214, section 5.1.6.3)
+	resourceElementOffset						ENUMERATED { offset01, offset10, offset11 }							OPTIONAL,	-- Need S
+	...
+}
+
+-- TAG-PTRS-DOWNLINKCONFIG-STOP
+-- TAG-PTRS-UPLINKCONFIG-START
+
+PTRS-UplinkConfig ::= 					SEQUENCE { 
+
+	modeSpecificParameters					CHOICE {
+		-- Configuration of UL PTRS for CP-OFDM
+		cp-OFDM									SEQUENCE {
+			-- Presence and  frequency density of UL PT-RS for CP-OFDM waveform as a function of scheduled BW 
+			-- If the field is absent, the UE uses K_PT-RS = 2.
+			-- Corresponds to L1 parameter 'UL-PTRS-frequency-density-table' (see 38.214, section 6.1)
+			frequencyDensity						SEQUENCE (SIZE (2)) OF INTEGER (1..276)		OPTIONAL,	-- Need S
+			-- Presence and time density of UL PT-RS for CP-OFDM waveform as a function of MCS 
+				-- If the field is absent, the UE uses L_PT-RS = 1.
+			-- Corresponds to L1 parameter 'UL-PTRS-time-density-table' (see 38.214, section 6.1)
+			timeDensity								SEQUENCE (SIZE (3)) OF INTEGER (0..29)		OPTIONAL, 	-- Need S
+			-- The maximum number of UL PTRS ports for CP-OFDM. 
+			-- Corresponds to L1 parameter 'UL-PTRS-ports' (see 38.214, section 6.2.3.1)
+			maxNrofPorts								ENUMERATED {n1, n2},
+			-- Indicates the subcarrier offset for UL PTRS for CP-OFDM. 
+			-- Corresponds to L1 parameter 'UL-PTRS-RE-offset' (see 38.214, section 6.1)
+			resourceElementOffset					ENUMERATED {offset01, offset10, offset11 }			OPTIONAL,	-- Need S
+			-- UL PTRS power boosting factor per PTRS port. Corresponds to L1 parameter 'UL-PTRS-power' (see 38.214, section 6.1, table 6.2.3-5)
+			ptrs-Power								ENUMERATED {p00, p01, p10, p11}
+		},
+		-- Configuration of UL PTRS for DFT-S-OFDM. 
+		dft-S-OFDM								SEQUENCE {
+			-- Sample density of PT-RS for DFT-s-OFDM, pre-DFT, indicating a set of thresholds T={NRBn,n=0,1,2,3,4},
+			-- that indicates dependency between presence of PT-RS and scheduled BW and the values of X and K the UE should 
+			-- use depending on the scheduled BW according to the table in 38.214 FFS_Section. 
+			-- Corresponds to L1 parameter 'UL-PTRS-pre-DFT-density' (see 38.214, section 6.1, 6.2.3-3)
+			sampleDensity						SEQUENCE (SIZE (5)) OF INTEGER (1..276),
+			-- Time density (OFDM symbol level) of PT-RS for DFT-s-OFDM. If the value is absent, the UE applies value d1.
+			-- Corresponds to L1 parameter 'UL-PTRS-time-density-transform-precoding' (see 38.214, section 6.1)
+			timeDensity							ENUMERATED {d2}														OPTIONAL	-- Need S
+		}
+	}																													OPTIONAL,	-- Cond M
+	...
+}
+
+-- TAG-PTRS-UPLINKCONFIG-STOP
+-- TAG-PUCCH-CONFIG-START
+
+PUCCH-Config ::= 						SEQUENCE {
+	-- Lists for adding and releasing PUCCH resource sets (see 38.213, section 9.2)
+	resourceSetToAddModList					SEQUENCE (SIZE (1..maxNrofPUCCH-ResourceSets)) OF PUCCH-ResourceSet				OPTIONAL,	-- Need N
+	resourceSetToReleaseList				SEQUENCE (SIZE (1..maxNrofPUCCH-ResourceSets)) OF PUCCH-ResourceSetId			OPTIONAL,	-- Need N
+
+	-- Lists for adding and releasing PUCCH resources applicable for the UL BWP and serving cell in which the PUCCH-Config 
+	-- is defined. The resources defined herein are referred to from other parts of the configuration to determine which 
+	-- resource the UE shall use for which report. 
+	resourceToAddModList					SEQUENCE (SIZE (1..maxNrofPUCCH-Resources)) OF PUCCH-Resource				OPTIONAL,	-- Need N
+	resourceToReleaseList					SEQUENCE (SIZE (1..maxNrofPUCCH-Resources)) OF PUCCH-ResourceId				OPTIONAL,	-- Need N
+
+	-- Parameters that are common for all PUCCH resources of format 1
+	format1									PUCCH-FormatConfig 												OPTIONAL,	-- Need M
+	-- Parameters that are common for all PUCCH resources of format 2
+	format2									PUCCH-FormatConfig 												OPTIONAL,	-- Need M
+	-- Parameters that are common for all PUCCH resources of format 3
+	format3									PUCCH-FormatConfig 												OPTIONAL,	-- Need M
+	-- Parameters that are common for all PUCCH resources of format 4
+	format4									PUCCH-FormatConfig 												OPTIONAL,	-- Need M
+
+	schedulingRequestResourceToAddModList	SEQUENCE (SIZE (1..maxNrofSR-Resources)) OF SchedulingRequestResourceConfig		OPTIONAL, -- Need M
+	schedulingRequestResourceToReleaseList	SEQUENCE (SIZE (1..maxNrofSR-Resources)) OF SchedulingRequestResourceId			OPTIONAL, -- Need M
+
+	multi-CSI-PUCCH-ResourceList			SEQUENCE (SIZE (1..2)) OF PUCCH-ResourceId										OPTIONAL,-- Need M
+
+	-- List of timiing for given PDSCH to the DL ACK. In this version of the specification only the values [0..8] are applicable.
+	-- Corresponds to L1 parameter 'Slot-timing-value-K1' (see 38.213, section FFS_Section)
+	dl-DataToUL-ACK							SEQUENCE (SIZE (8)) OF INTEGER (0..15)											OPTIONAL,	-- Need M
+
+	-- Configuration of the spatial relation between a reference RS and PUCCH. Reference RS can be SSB/CSI-RS/SRS.
+	-- If the list has more than one element, MAC-CE selects a single element (see 38.321, section FFS_Section).
+	-- Corresponds to L1 parameter 'PUCCH-SpatialRelationInfo' (see 38.213, section FFS_Section)
+	spatialRelationInfoToAddModList			SEQUENCE (SIZE (1..maxNrofSpatialRelationInfos)) OF PUCCH-SpatialRelationInfo	OPTIONAL,	-- Need N
+	spatialRelationInfoToReleaseList		SEQUENCE (SIZE (1..maxNrofSpatialRelationInfos)) OF PUCCH-SpatialRelationInfoId	OPTIONAL,	-- Need N
+
+	pucch-PowerControl						PUCCH-PowerControl																OPTIONAL,	-- Need M
+	...
+}
+
+PUCCH-FormatConfig ::=					SEQUENCE {
+	-- Enabling inter-slot frequency hopping when PUCCH Format 1, 3 or 4 is repetead over multiple slots.
+	-- The field is not applicable for format 2.
+	interslotFrequencyHopping				ENUMERATED {enabled}														OPTIONAL, 	-- Need R
+	-- Enabling 2 DMRS symbols per hop of a PUCCH Format 3 or 4 if both hops are more than X symbols when FH is enabled (X=4).
+	-- Enabling 4 DMRS sybmols for a PUCCH Format 3 or 4 with more than 2X+1 symbols when FH is disabled (X=4).
+	-- Corresponds to L1 parameter 'PUCCH-F3-F4-additional-DMRS' (see 38.213, section 9.2.1)
+	-- The field is not applicable for format 1 and 2.
+	additionalDMRS							ENUMERATED {true}															OPTIONAL,	-- Need R
+	-- Max coding rate to determine how to feedback UCI on PUCCH for format 2, 3 or 4
+	-- Corresponds to L1 parameter 'PUCCH-F2-maximum-coderate', 'PUCCH-F3-maximum-coderate' and 'PUCCH-F4-maximum-coderate' 
+	-- (see 38.213, section 9.2.5)
+	-- The field is not applicable for format 1.
+	maxCodeRate								PUCCH-MaxCodeRate															OPTIONAL,	-- Need R
+	-- Number of slots with the same PUCCH F1, F3 or F4. When the field is absent the UE applies the value n1.
+	-- Corresponds to L1 parameter 'PUCCH-F1-number-of-slots', 'PUCCH-F3-number-of-slots' and 'PUCCH-F4-number-of-slots'
+	-- (see 38.213, section 9.2.6)
+	-- The field is not applicable for format 2.
+	nrofSlots								ENUMERATED {n2,n4,n8}													OPTIONAL, 	-- Need S
+	-- Enabling pi/2 BPSK for UCI symbols instead of QPSK for PUCCH. 
+	-- Corresponds to L1 parameter 'PUCCH-PF3-PF4-pi/2PBSK' (see 38.213, section 9.2.5)
+	-- The field is not applicable for format 1 and 2.
+	pi2PBSK									ENUMERATED {enabled}														OPTIONAL, 	-- Need R
+	-- Enabling simultaneous transmission of CSI and HARQ-ACK feedback with or without SR with PUCCH Format 2, 3 or 4
+	-- Corresponds to L1 parameter 'PUCCH-F2-Simultaneous-HARQ-ACK-CSI', 'PUCCH-F3-Simultaneous-HARQ-ACK-CSI' and
+	-- 'PUCCH-F4-Simultaneous-HARQ-ACK-CSI' (see 38.213, section 9.2.5)
+	-- When the field is absent the UE applies the value OFF
+	-- The field is not applicable for format 1.
+	simultaneousHARQ-ACK-CSI				ENUMERATED {true}															OPTIONAL	-- Need R
+}
+
+PUCCH-MaxCodeRate ::= 						ENUMERATED {zeroDot08, zeroDot15, zeroDot25, zeroDot35, zeroDot45, zeroDot60, zeroDot80}
+
+PUCCH-SpatialRelationInfo ::=				SEQUENCE {
+	pucch-SpatialRelationInfoId					PUCCH-SpatialRelationInfoId,
+	referenceSignal 							CHOICE {
+		ssb-Index									SSB-Index,
+		csi-RS-Index								NZP-CSI-RS-ResourceId,
+		srs											SRS-ResourceId
+	},
+	pucch-PathlossReferenceRS-Id 				PUCCH-PathlossReferenceRS-Id,
+	p0-PUCCH-Id									P0-PUCCH-Id,
+	closedLoopIndex								ENUMERATED { i0, i1 }
+}
+
+PUCCH-SpatialRelationInfoId ::= 			INTEGER (1..maxNrofSpatialRelationInfos)
+
+-- A set with one or more PUCCH resources
+PUCCH-ResourceSet ::=							SEQUENCE {
+	pucch-ResourceSetId								PUCCH-ResourceSetId,
+
+	-- PUCCH resources of format0 and format1 are only allowed in the first PUCCH reosurce set,
+	-- i.e., in a PUCCH-ResourceSet with pucch-ResourceSetId = 0. This set may contain between 8 and 32 resources. 
+	-- PUCCH resources of format2, format3 and format4 are only allowed  in a PUCCH-ReosurceSet with pucch-ResourceSetId > 0. If present, these sets must contain 8 resources each.
+	-- The UE chooses a PUCCH-Resource from this list based on the 3-bit PUCCH resource indicator field in DCI as 
+	-- speciied in 38.213, FFS_section.
+	-- Note that this list contains only a list of resource IDs. The actual resources are configured in PUCCH-Config.
+	resources										SEQUENCE (SIZE (8..maxNrofPUCCH-ResourcesPerSet)) OF PUCCH-ResourceId,
+
+	-- Maximum number of payload bits minus 1 that the UE may transmit using this PUCCH resource set. In a PUCCH occurrence, the UE 
+	-- chooses the first of its PUCCH-ResourceSet which supports the number of bits that the UE wants to transmit. 
+	-- The field is not present in the first set (Set0) since the maximum Size of Set0 is specified to be 3 bit.
+	-- The field is not present in the last configured set since the UE derives its maximum payload size as specified in 38.213.
+	-- This field can take integer values that are multiples of 4. Corresponds to L1 parameter 'N_2' or 'N_3' (see 38.213, section 9.2)
+	maxPayloadMinus1								INTEGER (4..256)														OPTIONAL	-- Need R
+}
+
+PUCCH-ResourceSetId ::=							INTEGER (0..maxNrofPUCCH-ResourceSets-1)
+
+PUCCH-Resource ::= 								SEQUENCE {
+	pucch-ResourceId								PUCCH-ResourceId,
+
+	startingPRB										PRB-Id, 
+	-- Corresponds to the L1 parameter 'PUCCH-frequency-hopping' (see 38.213, section 9.2)
+	intraSlotFrequencyHopping						ENUMERATED { enabled }													OPTIONAL,	-- Need R
+	-- Index of starting PRB for second hop of PUCCH in case of FH. This value is appliable for intra-slot frequency hopping.
+	-- Corresponds to L1 parameter 'PUCCH-2nd-hop-PRB' (see 38.213, section 9.2)
+	secondHopPRB									PRB-Id																	OPTIONAL,	-- Need R
+
+	-- Selection of the PUCCH format and format-specific parameters
+	format											CHOICE {
+		format0											PUCCH-format0,														-- Cond InFirstSetOnly
+		format1											PUCCH-format1,														-- Cond InFirstSetOnly
+		format2											PUCCH-format2,														-- Cond NotInFirstSet
+		format3											PUCCH-format3,														-- Cond NotInFirstSet
+		format4											PUCCH-format4														-- Cond NotInFirstSet
+	}
+}
+
+PUCCH-ResourceId ::=							INTEGER (0..maxNrofPUCCH-Resources-1)
+
+
+-- A PUCCH Format 0 resource configuration (see 38.213, section 9.2)
+-- Corresponds to L1 parameter 'PUCCH-format0' (see 38.213, section 9.2.1)
+PUCCH-format0 ::=								SEQUENCE {
+	initialCyclicShift								INTEGER(0..11),
+	nrofSymbols										INTEGER (1..2), 
+	startingSymbolIndex								INTEGER(0..13) 
+}
+
+-- A PUCCH Format 1 resource configuration (see 38.213, section 9.2)
+-- Corresponds to L1 parameter 'PUCCH-format1' (see 38.213, section 9.2.1)
+PUCCH-format1 ::= 								SEQUENCE {
+	initialCyclicShift								INTEGER(0..11), 
+	nrofSymbols										INTEGER (4..14), 
+	startingSymbolIndex								INTEGER(0..10), 
+	timeDomainOCC									INTEGER(0..6)
+}
+
+-- A PUCCH Format 2 resource configuration (see 38.213, section 9.2)
+-- Corresponds to L1 parameter 'PUCCH-format2onfig' (see 38.213, section 9.2.1)
+PUCCH-format2 ::= 								SEQUENCE {
+	nrofPRBs										INTEGER (1..16), 
+	nrofSymbols										INTEGER (1..2), 
+	startingSymbolIndex								INTEGER(0..13) 
+}
+
+-- A PUCCH Format 3 resource configuration(see 38.213, section 9.2)
+-- Corresponds to L1 parameter 'PUCCH-format3' (see 38.213, section 9.2.1)
+PUCCH-format3 ::= 								SEQUENCE {
+	-- The supported values are 1,2,3,4,5,6,8,9,10,12,15 and 16
+	nrofPRBs										INTEGER (1..16), 
+	nrofSymbols										INTEGER (4..14), 
+	startingSymbolIndex								INTEGER(0..10) 
+}
+
+-- A PUCCH Format 4 resource configuration (see 38.213, section 9.2)
+-- Corresponds to L1 parameter 'PUCCH-format4' (see 38.213, section 9.2.1)
+PUCCH-format4 ::= 								SEQUENCE {
+	nrofSymbols										INTEGER (4..14), 
+	occ-Length										ENUMERATED {n2,n4}, 
+	occ-Index										ENUMERATED {n0,n1,n2,n3},
+	startingSymbolIndex								INTEGER(0..10) 
+}
+
+-- TAG-PUCCH-CONFIG-STOP 
+-- TAG-PUCCH-CONFIGCOMMON-START
+
+PUCCH-ConfigCommon ::=					SEQUENCE {
+	-- An entry into a 16-row table where each row configures a set of cell-specific PUCCH resources/parameters. The UE uses 
+	-- those PUCCH resources during initial access on the initial uplink BWP. Once the network provides a dedicated PUCCH-Config 
+	-- for that bandwidth part the UE applies that one instead of the one provided in this field.   
+	-- Corresponds to L1 parameter 'PUCCH-resource-common' (see 38.213, section 9.2)
+	pucch-ResourceCommon					BIT STRING (SIZE (4))															OPTIONAL,	-- Need R
+
+	-- Configuration of group- and sequence hopping for all the PUCCH formats 0, 1, 3 and 4. "neither" implies neither group 
+	-- or sequence hopping is enabled. "enable" enables group hopping and disables sequence hopping. "disable"” disables group 
+	-- hopping and enables sequence hopping. Corresponds to L1 parameter 'PUCCH-GroupHopping' (see 38.211, section 6.4.1.3)
+	pucch-GroupHopping						ENUMERATED { neither, enable, disable },
+	-- Cell-Specific scrambling ID for group hoppping and sequence hopping if enabled.
+	-- Corresponds to L1 parameter 'HoppingID' (see 38.211, section 6.3.2.2)
+	hoppingId								BIT STRING (SIZE (10))															OPTIONAL, 	-- Need R
+
+	-- Power control parameter P0 for PUCCH transmissions. Value in dBm. Only even values (step size 2) allowed. 
+	-- Corresponds to L1 parameter 'p0-nominal-pucch' (see 38.213, section 7.2)
+	p0-nominal								INTEGER (-202..24)																OPTIONAL, 	-- Need R
+
+	...
+}
+
+-- TAG-PUCCH-CONFIGCOMMON-STOP
+-- TAG-PUCCH-POWERCONTROL-START
+PUCCH-PowerControl ::= 				SEQUENCE {
+
+	-- deltaF for PUCCH format 0 with 1dB step size (see 38.213, section 7.2)
+	deltaF-PUCCH-f0							INTEGER (-16..15)																	OPTIONAL, 	-- Need R
+	-- deltaF for PUCCH format 1 with 1dB step size (see 38.213, section 7.2)
+	deltaF-PUCCH-f1							INTEGER (-16..15)																	OPTIONAL, 	-- Need R
+	-- deltaF for PUCCH format 2 with 1dB step size (see 38.213, section 7.2)
+	deltaF-PUCCH-f2							INTEGER (-16..15)																	OPTIONAL, 	-- Need R
+	-- deltaF for PUCCH format 3 with 1dB step size (see 38.213, section 7.2)
+	deltaF-PUCCH-f3							INTEGER (-16..15)																	OPTIONAL, 	-- Need R
+	-- deltaF for PUCCH format 4 with 1dB step size (see 38.213, section 7.2)
+	deltaF-PUCCH-f4							INTEGER (-16..15)																	OPTIONAL, 	-- Need R
+
+	-- A set with dedicated P0 values for PUCCH, i.e.,  {P01, P02,... }. Corresponds to L1 parameter 'p0-pucch-set' (see 38.213, section 7.2)
+	p0-Set								SEQUENCE (SIZE (1..maxNrofPUCCH-P0-PerSet)) OF P0-PUCCH									OPTIONAL, -- Need M
+
+	-- A set of Reference Signals (e.g. a CSI-RS config or a SSblock) to be used for PUCCH pathloss estimation. 
+	-- Up to maxNrofPUCCH-PathlossReference-RSs may be configured
+	-- FFS_CHECK: Is it possible not to configure it at all? What does the UE use then? Any SSB?
+	-- Corresponds to L1 parameter 'pucch-pathlossReference-rs-config' (see 38.213, section 7.2)
+	pathlossReferenceRSs				SEQUENCE (SIZE (1..maxNrofPUCCH-PathlossReferenceRSs)) OF PUCCH-PathlossReferenceRS	OPTIONAL, -- Need M
+	-- Number of PUCCH power control adjustment states maintained by the UE (i.e., g(i)). If the field is present (n2) the UE maintains
+	-- two power control states (i.e., g(i,0) and g(i,1)). Otherwise, it applies one (i.e., g(i,0)). 
+	-- Corresponds to L1 parameter 'num-pucch-pcadjustment-states' (see 38.213, section 7.2)
+	twoPUCCH-PC-AdjustmentStates		ENUMERATED {twoStates}																	OPTIONAL, -- Need R
+	...
+}
+
+-- P0 value for PUCCH. Corresponds to L1 parameter 'p0-pucch' (see 3,213, section 7.2)
+P0-PUCCH ::=							SEQUENCE {
+	p0-PUCCH-Id								P0-PUCCH-Id,
+	-- P0 value for PUCCH with 1dB step size.
+	p0-PUCCH-Value							INTEGER (-16..15)
+}
+
+P0-PUCCH-Id ::=							INTEGER (1..8)
+
+-- A reference signal (RS) configured as pathloss reference signal for PUCCH power control
+-- Corresponds to L1 parameter 'pucch-pathlossReference-rs' (see 38.213, section 7.2)
+PUCCH-PathlossReferenceRS ::=					SEQUENCE {
+	pucch-PathlossReferenceRS-Id 				PUCCH-PathlossReferenceRS-Id, 
+	referenceSignal								CHOICE {
+		ssb-Index									SSB-Index,
+		csi-RS-Index								NZP-CSI-RS-ResourceId
+	}
+}
+
+-- ID for a referemce signal (RS) configured as PUCCH pathloss reference 
+-- Corresponds to L1 parameter 'pucch-pathlossreference-index' (see 38.213, section 7.2)
+-- FFS_CHECK: Is this ID used anywhere except inside the PUCCH-PathlossReference-RS	itself? If not, remove.
+PUCCH-PathlossReferenceRS-Id ::=			INTEGER (0..maxNrofPUCCH-PathlossReferenceRSs-1)
+
+-- TAG-PUCCH-POWERCONTROL-STOP
+-- TAG-PUCCH-TPC-COMMANDCONFIG-START
+
+PUCCH-TPC-CommandConfig ::=				SEQUENCE {
+	-- An index determining the position of the first bit of TPC command (applicable to the SpCell) inside the DCI format 2-2 payload. 
+	tpc-IndexPCell							INTEGER (1..15)													OPTIONAL,	-- Cond PUCCH-SCell
+	-- An index determining the position of the first bit of TPC command (applicable to the PUCCH-SCell) inside the DCI format 2-2 payload. 
+	tpc-IndexPUCCH-SCell					INTEGER (1..15)													OPTIONAL,	-- Cond PUCCH-SCellOnly
+    ...
+}
+
+-- TAG-PUCCH-TPC-COMMANDCONFIG-STOP
+-- TAG-PUSCH-CONFIG-START
+
+PUSCH-Config ::= 						SEQUENCE {
+	-- Identifer used to initalite data scrambling (c_init) for both PUSCH.
+	-- Corresponds to L1 parameter 'Data-scrambling-Identity' (see 38,214, section FFS_Section)
+	dataScramblingIdentityPUSCH			INTEGER (0..1007)															OPTIONAL,	-- Need M
+	-- Whether UE uses codebook based or non-codebook based transmission. Corresponds to L1 parameter 'ulTxConfig' (see 38.214, section 6.1.1)
+	txConfig								ENUMERATED {codebook, nonCodebook},
+
+	-- DMRS configuration for PUSCH transmissions using PUSCH mapping type A (chosen dynamically via PUSCH-TimeDomainResourceAllocation).
+	dmrs-UplinkForPUSCH-MappingTypeA		DMRS-UplinkConfig 											OPTIONAL,	-- Need M
+	-- DMRS configuration for PUSCH transmissions using PUSCH mapping type B (chosen dynamically via PUSCH-TimeDomainResourceAllocation)
+	dmrs-UplinkForPUSCH-MappingTypeB		DMRS-UplinkConfig 									OPTIONAL,	-- Need M
+
+	pusch-PowerControl						PUSCH-PowerControl															OPTIONAL, -- Need M
+	-- Configured one of two supported frequency hopping mode. If not configured frequency hopping is not configured
+	-- Corresponds to L1 parameter 'Frequency-hopping-PUSCH' (see 38.214, section 6)
+	-- When the field is absent the UE applies the value Not configured
+	frequencyHopping						ENUMERATED {mode1, mode2}													OPTIONAL,	-- Need S
+	-- Set of frequency hopping offsets used when frequency hopping is enabled for granted transmission (not msg3) and type 2
+	-- Corresponds to L1 parameter 'Frequency-hopping-offsets-set' (see 38.214, section 6.3)
+	frequencyHoppingOffsetLists				SEQUENCE (SIZE (1..4)) OF INTEGER (1.. maxNrofPhysicalResourceBlocks-1)	OPTIONAL,	-- Need M
+	-- Configuration of resource allocation type 0 and resource allocation type 1 for non-fallback DCI
+	-- Corresponds to L1 parameter 'Resouce-allocation-config' (see 38.214, section 6.1.2)
+	resourceAllocation						ENUMERATED { resourceAllocationType0, resourceAllocationType1, dynamicSwitch},
+
+	-- List of time domain allocations for timing of UL assignment to UL data. If configured, the values provided herein 
+	-- override the values received in corresponding PUSCH-ConfigCommon.
+	pusch-AllocationList					SEQUENCE (SIZE(1..maxNrofUL-Allocations)) OF PUSCH-TimeDomainResourceAllocation	OPTIONAL, 	-- Need R,
+	-- Number of repetitions for data. Corresponds to L1 parameter 'aggregation-factor-UL' (see 38.214, section FFS_Section)
+	-- When the field is absent the UE applies the value 1.
+	pusch-AggregationFactor					ENUMERATED { n2, n4, n8 }													OPTIONAL, 	-- Need S
+
+	-- Indicates which MCS table the UE shall use for PUSCH without transform precoder
+	-- Corresponds to L1 parameter 'MCS-Table-PUSCH' (see 38.214, section 6.1.4)
+	-- When the field is absent the UE applies the value 64QAM
+	mcs-Table								ENUMERATED {qam256}													OPTIONAL,	-- Need S
+	-- Indicates which MCS table the UE shall use for PUSCH with transform precoding
+	-- Corresponds to L1 parameter 'MCS-Table-PUSCH-transform-precoding' (see 38.214, section 6.1.4)
+	-- When the field is absent the UE applies the value 64QAM
+	mcs-TableTransformPrecoder				ENUMERATED { qam256}													OPTIONAL,	-- Need S
+	-- The UE specific selection of transformer precoder for PUSCH. When the field is absent the UE applies the value msg3-tp.
+	-- Corresponds to L1 parameter 'PUSCH-tp' (see 38.211, section 6.3.1.4)
+	transformPrecoder						ENUMERATED {enabled, disabled}												OPTIONAL,	-- Need S
+	-- Subset of PMIs addressed by TPMI, where PMIs are those supported by UEs with maximum coherence capabilities 
+	-- Corresponds to L1 parameter 'ULCodebookSubset' (see 38.211, section 6.3.1.5)
+	codebookSubset			ENUMERATED {fullyAndPartialAndNonCoherent, partialAndNonCoherent, nonCoherent},
+	-- Subset of PMIs addressed by TRIs from 1 to ULmaxRank. Corresponds to L1 parameter 'ULmaxRank' (see 38.211, section 6.3.1.5)
+	maxRank									INTEGER (1..4),
+
+	-- Selection between config 1 and config 2 for RBG size for PUSCH. When the field is absent the UE applies the value config1.
+	-- Corresponds to L1 parameter 'RBG-size-PUSCH' (see 38.214, section 6.1.2.2.1)
+	rbg-Size								ENUMERATED { config2}												OPTIONAL,	-- Need S
+
+	-- Selection between and configuration of dynamic and semi-static beta-offset.
+	-- If the field is absent or released, the UE applies the value 'semiStatic' and the BetaOffsets according to 
+	-- FFS [BetaOffsets and/or section 9.x.x).
+	-- Corresponds to L1 parameter 'UCI-on-PUSCH' (see 38.213, section 9.3)
+	uci-OnPUSCH							UCI-OnPUSCH									OPTIONAL, -- Need M
+	-- Interleaving unit configurable between 2 and 4 PRBs
+	-- Corresponds to L1 parameter 'VRB-to-PRB-interleaver' (see 38.211, section 6.3.1.6)
+	vrb-ToPRB-Interleaver					ENUMERATED {n2, n4},
+	...
+}
+
+UCI-OnPUSCH ::= 						SEQUENCE {
+	betaOffsets								CHOICE {
+			dynamic									SEQUENCE (SIZE (4)) OF BetaOffsets,
+			semiStatic								BetaOffsets
+	}																													OPTIONAL, -- Need M
+	-- Indicates a scaling factor to limit the number of resource elements assigned to UCI on PUSCH.
+	-- Value f0p5 corresponds to 0.5, value f0p65 corresponds to 0.65, and so on. 
+	-- Corresponds to L1 parameter 'uci-on-pusch-scaling' (see 38.212, section 6.3)
+	scaling						ENUMERATED { f0p5, f0p65, f0p8, f1 }
+}
+
+-- TAG-PUSCH-CONFIG-STOP
+-- TAG-PUSCH-CONFIGCOMMON-START
+
+PUSCH-ConfigCommon ::= 					SEQUENCE {
+	-- Sequence-group hopping can be enabled or disabled by means of this cell-specific parameter. 
+	-- Corresponds to L1 parameter 'Group-hopping-enabled-Transform-precoding' (see 38.211, section FFS_Section)
+	-- This field is Cell specific
+	groupHoppingEnabledTransformPrecoding	ENUMERATED {enabled}															OPTIONAL,	-- Need R
+
+	-- List of time domain allocations for timing of UL assignment to UL data
+	pusch-AllocationList					SEQUENCE (SIZE(1..maxNrofUL-Allocations)) OF PUSCH-TimeDomainResourceAllocation	OPTIONAL,	-- Need R
+
+	-- ------------------------
+	-- Power control parameters
+
+	-- Power offset between msg3 and RACH preamble transmission in steps of 1dB. 
+	-- Corresponds to L1 parameter 'Delta-preamble-msg3' (see 38.213, section 7.1)
+	msg3-DeltaPreamble							INTEGER (-1..6)															OPTIONAL,	-- Need R
+
+	-- P0 value for PUSCH with grant (except msg3). Value in dBm. Only even values (step size 2) allowed.
+	-- Corresponds to L1 parameter 'p0-nominal-pusch-withgrant' (see 38.213, section 7.1)
+	-- This field is cell specific
+	p0-NominalWithGrant						INTEGER (-202..24)																OPTIONAL,	-- Need R
+	...
+}
+
+-- TAG-PUSCH-CONFIGCOMMON-STOP
+-- TAG-PUSCH-POWERCONTROL-START
+
+PUSCH-PowerControl ::= 						SEQUENCE {
+
+	-- If enabled, UE applies TPC commands via accumulation. If not enabled, UE applies the TPC command without accumulation. 
+	-- If absent, TPC accumulation is enabled. Corresponds to L1 parameter 'Accumulation-enabled' (see 38.213, section 7.1)
+	tpc-Accumulation							ENUMERATED { disabled }													OPTIONAL,	-- Need R
+
+	-- Dedicated alpha value for msg3 PUSCH. Corresponds to L1 parameter 'alpha-ue-pusch-msg3' (see 38.213, section 7.1)
+	-- When the field is absent the UE applies the value 1.
+	msg3-Alpha									Alpha																	OPTIONAL, 	-- Need S
+
+	-- P0 value for UL grant-free/SPS based PUSCH. Value in dBm. Only even values (step size 2) allowed.
+	-- Corresponds to L1 parameter 'p0-nominal-pusch-withoutgrant' (see 38.213, section 7.1)
+	p0-NominalWithoutGrant						INTEGER (-202..24)														OPTIONAL,	-- Need M,
+	-- configuration {p0-pusch,alpha} sets for PUSCH (except msg3), i.e., { {p0,alpha,index1}, {p0,alpha,index2},...}.
+	-- Corresponds to L1 parameter 'p0-push-alpha-setconfig' (see 38,213, section 7.1)
+	p0-AlphaSets								SEQUENCE (SIZE (1..maxNrofP0-PUSCH-AlphaSets)) OF P0-PUSCH-AlphaSet		OPTIONAL,	-- Need M,
+
+	-- A set of Reference Signals (e.g. a CSI-RS config or a SSblock) to be used for PUSCH path loss estimation. 
+	-- Up to maxNrofPUSCH-PathlossReferenceRSs may be configured when 'PUSCH beam indication' is present (FFS: in DCI???). 
+	-- Otherwise, there may be only one entry. 
+	-- Corresponds to L1 parameter 'pusch-pathlossReference-rs-config' (see 38.213, section 7.1)
+	pathlossReferenceRSToAddModList				SEQUENCE (SIZE (1..maxNrofPUSCH-PathlossReferenceRSs)) OF PUSCH-PathlossReferenceRS	
+																														OPTIONAL,	-- Need N
+	pathlossReferenceRSToReleaseList			SEQUENCE (SIZE (1..maxNrofPUSCH-PathlossReferenceRSs)) OF PUSCH-PathlossReferenceRS-Id	
+																														OPTIONAL,	-- Need N
+
+	-- Number of PUSCH power control adjustment states maintained by the UE (i.e., fc(i)). If the field is present (n2) the UE maintains
+	-- two power control states (i.e., fc(i,1) and fc(i,2)). Otherwise, it applies one (i.e., fc(i,1)). 
+	-- Corresponds to L1 parameter 'num-pusch-pcadjustment-states' (see 38.213, section 7.1)
+	twoPUSCH-PC-AdjustmentStates				ENUMERATED {twoStates}													OPTIONAL, -- Need S
+
+	-- Indicates whether to apply dela MCS. When the field is absent, the UE applies Ks = 0 in delta_TFC formula for PUSCH. 
+	-- Corresponds to L1 parameter 'deltaMCS-Enabled' (see 38.213, section 7.1)
+	deltaMCS									ENUMERATED {enabled}													OPTIONAL, -- Need S
+
+	-- A list of SRI-PUSCH-PowerControl elements among which one is selected by the SRI field in DCI. 
+	-- Corresponds to L1 parameter 'SRI-PUSCHPowerControl-mapping' (see 38.213, section 7.1)
+	sri-PUSCH-MappingToAddModList			SEQUENCE (SIZE (1..maxNrofSRI-PUSCH-Mappings)) OF SRI-PUSCH-PowerControl		OPTIONAL, -- Need M
+	sri-PUSCH-MappingToReleaseList				SEQUENCE (SIZE (1..maxNrofSRI-PUSCH-Mappings)) OF SRI-PUSCH-PowerControlId	OPTIONAL -- Need M 
+}
+
+-- A set of p0-pusch and alpha used for PUSCH with grant. 'PUSCH beam indication' (if present) gives the index of the set to 
+-- be used for a particular PUSCH transmission.
+-- FFS_CHECK: Is the ”PUSCH beam indication” in DCI which schedules the PUSCH? If so, clarify in field description
+-- Corresponds to L1 parameter 'p0-pusch-alpha-set' (see 38.213, section 7.1)
+P0-PUSCH-AlphaSet ::= 						SEQUENCE {
+	p0-PUSCH-AlphaSetId 						P0-PUSCH-AlphaSetId,
+	-- P0 value for PUSCH with grant (except msg3) in steps of 1dB. Corresponds to L1 parameter 'p0-pusch' (see 38,213, section 7.1)
+	p0											INTEGER (-16..15)															OPTIONAL,
+	-- alpha value for PUSCH with grant (except msg3) (see 38.213, section 7.1)
+	-- When the field is absent the UE applies the value 1
+	alpha 										Alpha																	OPTIONAL	-- Need S
+}
+
+-- ID for a P0-PUSCH-AlphaSet. Corresponds to L1 parameter 'p0alphasetindex' (see 38.213, section 7.1)
+P0-PUSCH-AlphaSetId ::= 					INTEGER (0..maxNrofP0-PUSCH-AlphaSets-1)
+
+-- A reference signal (RS) configured as pathloss reference signal for PUSCH power control
+-- Corresponds to L1 parameter 'pusch-pathlossReference-rs' (see 38.213, section 7.1)
+PUSCH-PathlossReferenceRS ::=				SEQUENCE {
+	pusch-PathlossReferenceRS-Id 				PUSCH-PathlossReferenceRS-Id, 
+	referenceSignal								CHOICE {
+		ssb-Index									SSB-Index,
+		csi-RS-Index									NZP-CSI-RS-ResourceId
+	}
+}
+
+-- ID for a referemce signal (RS) configured as PUSCH pathloss reference 
+-- Corresponds to L1 parameter 'pathlossreference-index' (see 38.213, section 7.1)
+-- FFS_CHECK: Is this ID used anywhere except inside the PUSCH-PathlossReference-RS	itself?
+PUSCH-PathlossReferenceRS-Id ::=			INTEGER (0..maxNrofPUSCH-PathlossReferenceRSs-1)
+
+
+-- A set of PUSCH power control parameters associated with one SRS-ResourceIndex (SRI)
+SRI-PUSCH-PowerControl ::=					SEQUENCE {
+	-- The ID of this SRI-PUSCH-PowerControl configuration. It is used as the codepoint (payload) in the SRI DCI field.
+	sri-PUSCH-PowerControlId					SRI-PUSCH-PowerControlId,
+	-- The ID of PUSCH-PathlossReferenceRS as configured in the pathlossReferenceRSToAddModList in PUSCH-PowerControl.
+	sri-PUSCH-PathlossReferenceRS-Id 			PUSCH-PathlossReferenceRS-Id,
+	-- The ID of a P0-PUSCH-AlphaSet as configured in p0-AlphaSets in PUSCH-PowerControl.
+	sri-P0-PUSCH-AlphaSetId 					P0-PUSCH-AlphaSetId,
+	-- The index of the closed power control loop associated with this SRI-PUSCH-PowerControl
+	sri-PUSCH-ClosedLoopIndex					ENUMERATED { i0, i1 }
+}
+
+SRI-PUSCH-PowerControlId ::=				INTEGER (0..maxNrofSRI-PUSCH-Mappings-1)
+
+-- A set of beta-offset values
+BetaOffsets ::= 							SEQUENCE {
+	-- Up to 2 bits HARQ-ACK. Corresponds to L1 parameter 'betaOffset-ACK-Index-1' (see 38.213, section 9.3)
+	-- When the field is absent the UE applies the value 11
+	betaOffsetACK-Index1						INTEGER(0..31)															OPTIONAL, -- Need S
+	-- Up to 11 bits HARQ-ACK. Corresponds to L1 parameter 'betaOffset-ACK-Index-2' (see 38.213, section 9.3)
+	-- When the field is absent the UE applies the value 11
+	betaOffsetACK-Index2						INTEGER(0..31)															OPTIONAL, -- Need S
+	-- Above 11 bits HARQ-ACK. Corresponds to L1 parameter 'betaOffset-ACK-Index-3' (see 38.213, section 9.3)
+	-- When the field is absent the UE applies the value 11
+	betaOffsetACK-Index3						INTEGER(0..31)															OPTIONAL, -- Need S
+	-- Up to 11 bits of CSI part 1 bits. Corresponds to L1 parameter 'betaOffset-CSI-part-1-Index-1' (see 38.213, section 9.3)
+	-- When the field is absent the UE applies the value 13
+	betaOffsetCSI-Part1-Index1						INTEGER(0..31)															OPTIONAL, -- Need S
+	-- Above 11 bits of CSI part 1 bits. Corresponds to L1 parameter 'betaOffset-CSI-part-1-Index-2' (see 38.213, section 9.3)
+	-- When the field is absent the UE applies the value 13
+	betaOffsetCSI-Part1-Index2						INTEGER(0..31)															OPTIONAL, -- Need S
+	-- Up to 11 bits of CSI part 2 bits. Corresponds to L1 parameter 'betaOffset-CSI-part-2-Index-1' (see 38.213, section 9.3)
+	-- When the field is absent the UE applies the value 13
+	betaOffsetCSI-Part2-Index1						INTEGER(0..31)															OPTIONAL, -- Need S
+	-- Above 11 bits of CSI part 2 bits. Corresponds to L1 parameter 'betaOffset-CSI-part-2-Index-2' (see 38.213, section 9.3)
+	-- When the field is absent the UE applies the value 13
+	betaOffsetCSI-Part2-Index2						INTEGER(0..31)															OPTIONAL -- Need S
+}
+
+-- TAG-PUSCH-POWERCONTROL-STOP
+-- TAG-PUSCH-SERVINGCELLCONFIG-START
+
+PUSCH-ServingCellConfig ::=				SEQUENCE {
+	-- Enables and configures code-block-group (CBG) based transmission (see 38.214, section FFS_Section)
+	codeBlockGroupTransmission				PUSCH-CodeBlockGroupGransmission								OPTIONAL,	-- Need M
+	-- Enables LBRM (Limited buffer rate-matching). When the field is absent the UE applies FBRM (Full buffer rate-matchingLBRM).
+	-- Corresponds to L1 parameter 'LBRM-FBRM-selection' (see 38.212, section 5.4.2)
+	rateMatching							ENUMERATED {limitedBufferRM}												OPTIONAL,	-- Need S
+	-- Accounts for overhead from CSI-RS, CORESET, etc. If the field is absent, the UE applies the value 'xoh0'.
+	-- Corresponds to L1 parameter 'Xoh-PUSCH' (see 38.214, section 5.1.3.2)
+	xOverhead								ENUMERATED {xoh6, xoh12, xoh18}												OPTIONAL,	-- Need S
+	...
+}
+
+PUSCH-CodeBlockGroupGransmission ::=	SEQUENCE {
+	-- Maximum number of code-block-groups (CBGs) per TB (see 38.xxx, section x.x.x, FFS_Ref)
+	-- For 2 codewords, only the values { n2, n4 } are valid.
+	maxCodeBlockGroupsPerTransportBlock		ENUMERATED {n2, n4, n6, n8},
+	...
+}
+
+-- TAG-PUSCH-SERVINGCELLCONFIG-STOP
+-- TAG-PUSCH-TIMEDOMAINRESOURCEALLOCATION-START
+
+PUSCH-TimeDomainResourceAllocation ::= 	SEQUENCE {
+	-- Corresponds to L1 parameter 'K2' (see 38.214, section FFS_Section)
+	-- When the field is absent the UE applies the value 01 when PUSCH SCS is 15/30KHz; 2 when PUSCH SCS is 60KHz and 3 when PUSCH SCS is 120KHz.
+	k2									INTEGER (0..7)																OPTIONAL,	-- Need S
+	-- Mapping type. Corresponds to L1 parameter 'Mapping-type' (see 38.214, section FFS_Section)
+	mappingType							ENUMERATED {typeA, typeB},
+	-- An index into a table/equation in RAN1 specs capturing valid combinations of start symbol and length (jointly encoded)
+	-- Corresponds to L1 parameter 'Index-start-len' (see 38.214, section FFS_Section)
+	startSymbolAndLength				BIT STRING (SIZE (7))
+}
+
+-- TAG-PUSCH-TIMEDOMAINRESOURCEALLOCATION-STOP
+-- TAG-PUSCH-TPC-COMMANDCONFIG-START
+
+PUSCH-TPC-CommandConfig ::=			SEQUENCE {
+	-- An index determining the position of the first bit of TPC command inside the DCI format 2-2 payload. 
+	tpc-Index							INTEGER (1..15)															OPTIONAL,	-- Cond SUL
+	-- An index determining the position of the first bit of TPC command inside the DCI format 2-2 payload. 
+	tpc-IndexSUL						INTEGER (1..15)															OPTIONAL,	-- Cond SUL-Only
+	-- The serving cell to which the acquired power control commands are applicable. If the value is absent, the UE applies the 
+	-- TPC commands to the serving cell on which the command has been received. 
+	targetCell							ServCellIndex															OPTIONAL,	-- Need S
+	...
+}
+
+-- TAG-PUSCH-TPC-COMMANDCONFIG-STOP
+
+Q-OffsetRange ::=						ENUMERATED {
+												dB-24, dB-22, dB-20, dB-18, dB-16, dB-14,
+												dB-12, dB-10, dB-8, dB-6, dB-5, dB-4, dB-3,
+												dB-2, dB-1, dB0, dB1, dB2, dB3, dB4, dB5,
+												dB6, dB8, dB10, dB12, dB14, dB16, dB18,
+												dB20, dB22, dB24}
+
+-- TAG-QUANTITY-CONFIG-START
+
+	
+QuantityConfig ::=							SEQUENCE {
+	quantityConfigNR-List						QuantityConfigNR-List						OPTIONAL,	-- Need M
+	...
+}
+
+QuantityConfigNR-List::=						SEQUENCE (SIZE (1..maxNrofQuantityConfig)) OF QuantityConfigNR
+
+QuantityConfigNR::=							SEQUENCE {
+	quantityConfigCell							QuantityConfigRS,
+	quantityConfigRS-Index						QuantityConfigRS								OPTIONAL	-- Need M
+}
+
+QuantityConfigRS ::=						SEQUENCE {
+	-- SS Block based L3 filter configurations:
+	ssb-FilterConfig				FilterConfig,
+
+	-- CSI-RS basedL3 filter configurations:
+	cs-RS-FilterConfig				FilterConfig
+}
+
+FilterConfig ::=				SEQUENCE {
+	filterCoefficientRSRP			FilterCoefficient										DEFAULT fc4,
+	filterCoefficientRSRQ			FilterCoefficient										DEFAULT fc4,
+	filterCoefficientRS-SINR		FilterCoefficient										DEFAULT fc4
+}
+
+-- TAG-QUANTITY-CONFIG-STOP
+-- TAG-RACH-CONFIG-COMMON-START
+
+RACH-ConfigCommon ::= 				SEQUENCE {
+	-- Generic RACH parameters 
+	rach-ConfigGeneric			RACH-ConfigGeneric,
+
+	-- Total number of preambles used for contention based and contention free random access, excluding	
+	-- preambles used for other purposes (e.g. for SI request). If the field is absent, the UE may use all 64 preambles for RA.
+	totalNumberOfRA-Preambles			INTEGER (1..63)																		OPTIONAL,	-- Need S
+
+	-- Number of SSBs per RACH occasion (L1 parameter 'SSB-per-rach-occasion') and the number of Contention Based preambles per SSB
+	-- (L1 parameter 'CB-preambles-per-SSB'). By multiplying the two values, the UE determines the total number of CB preambles.
+	ssb-perRACH-OccasionAndCB-PreamblesPerSSB	CHOICE { 
+		oneEighth								ENUMERATED {n4,n8,n12,n16,n20,n24,n28,n32,n36,n40,n44,n48,n52,n56,n60,n64}, 
+		oneFourth								ENUMERATED {n4,n8,n12,n16,n20,n24,n28,n32,n36,n40,n44,n48,n52,n56,n60,n64}, 
+		oneHalf									ENUMERATED {n4,n8,n12,n16,n20,n24,n28,n32,n36,n40,n44,n48,n52,n56,n60,n64}, 
+		one										ENUMERATED {n4,n8,n12,n16,n20,n24,n28,n32,n36,n40,n44,n48,n52,n56,n60,n64}, 
+		two										ENUMERATED {n4,n8,n12,n16,n20,n24,n28,n32}, 
+		four									INTEGER (1..16), 
+		eight									INTEGER (1..8), 
+		sixteen									INTEGER (1..4)
+	}																														OPTIONAL,	-- Need M
+
+	groupBconfigured 					SEQUENCE {
+		-- Transport Blocks size threshold in bit below which the UE shall use a contention based RA premable 
+		-- of group A. (see 38.321, section 5.1.2)
+		ra-Msg3SizeGroupA					ENUMERATED {b56, b144, b208, b256, b282, b480, b640, b800, b1000, spare7, spare6, spare5,
+											spare4, spare3, spare2, spare1},
+		-- Threshold for preamble selection.  Value in dB.  Value minusinfinity corresponds to –infinity.  
+		-- Value dB0 corresponds to 0 dB, dB5 corresponds to 5 dB and so on. (see FFS_Spec, section FFS_Section)
+		messagePowerOffsetGroupB			ENUMERATED { minusinfinity, dB0, dB5, dB8, dB10, dB12, dB15, dB18},
+		-- The number of CB preambles per SSB in group A. This determines implicitly the number of CB preambles per SSB available in group B.
+		-- (see 38.321, section 5.1.1)
+		numberOfRA-PreamblesGroupA			INTEGER (1..64)
+	}																														OPTIONAL,	-- Need R
+
+	-- The initial value for the contention resolution timer (see 38.321, section 5.1.5)	
+	ra-ContentionResolutionTimer			ENUMERATED { sf8, sf16, sf24, sf32, sf40, sf48, sf56, sf64},
+
+	-- UE may select the SS block and corresponding PRACH resource for path-loss estimation and (re)transmission 
+	-- based on SS blocks that satisfy the threshold (see 38.213, section REF)
+	rsrp-ThresholdSSB						RSRP-Range																		OPTIONAL,	-- Need R
+	-- UE may select the SS block and corresponding PRACH resource for path-loss estimation and (re)transmission on the SUL carrier
+	-- based on SS blocks that satisfy the threshold
+	-- Corresponds to L1 parameter 'SUL-RSRP-Threshold' (see FFS_Spec, section FFS_Section)
+	rsrp-ThresholdSSB-SUL					RSRP-Range																		OPTIONAL,	-- Need R
+
+	-- PRACH root sequence index. Corresponds to L1 parameter 'PRACHRootSequenceIndex' (see 38.211, section 6.3.3.1).
+	-- The value range depends on whether L=839 or L=139
+	prach-RootSequenceIndex					CHOICE {
+		l839									INTEGER (0..837),
+		l139									INTEGER (0..137)
+	},
+
+	-- Subcarrier spacing of PRACH. Only the values 15 or 30 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are applicable.
+	-- Corresponds to L1 parameter 'prach-Msg1SubcarrierSpacing' (see 38.211, section FFS_Section)
+	msg1-SubcarrierSpacing					SubcarrierSpacing,
+
+	-- Configuration of an unrestricted set or one of two types of restricted sets, see 38.211	6.3.3.1 
+	restrictedSetConfig						ENUMERATED {unrestrictedSet, restrictedSetTypeA, restrictedSetTypeB},
+	-- Indicates to a UE whether transform precoding is enabled for Msg3 transmission. 
+	-- Corresponds to L1 parameter 'msg3-tp' (see 38.213, section 8.1)
+	msg3-transformPrecoding					ENUMERATED {enabled}															OPTIONAL,	-- Need R
+	...
+}
+
+-- TAG-RACH-CONFIG-COMMON-STOP 
+-- TAG-RACH-CONFIG-GENERIC-START
+
+RACH-ConfigGeneric ::= 			SEQUENCE {
+	-- PRACH configuration index. Corresponds to L1 parameter 'PRACHConfigurationIndex' (see 38.211, section 6.3.3.2)
+	prach-ConfigurationIndex				INTEGER (0..255),
+	-- The number of PRACH transmission occasions FDMed in one time instance. 
+	-- Corresponds to L1 parameter 'prach-FDM' (see 38.211, section FFS_Section)
+	msg1-FDM								ENUMERATED {one, two, four, eight},
+	-- Offset of lowest PRACH transmission occasion in frequency domain with respective to PRB 0.
+	-- The value is configured so that the corresponding RACH resource is entirely within the bandwidth of the UL BWP.
+	-- Corresponds to L1 parameter 'prach-frequency-start' (see 38,211, section FFS_Section)
+	msg1-FrequencyStart						INTEGER (0..maxNrofPhysicalResourceBlocks-1),
+	-- N-CS configuration, see Table 6.3.3.1-3 in 38.211
+	zeroCorrelationZoneConfig				INTEGER(0..15),
+	-- The target power level at the network receiver side (see 38.213, section 7.4, 38.321, section 5.1.2, 5.1.3)
+	-- Only multiples of 2 dBm may be chosen (e.g. -200, -198, ...).
+	-- FFS-Value: Actual values to be updated based on input from RAN4 (see LS in R2-1800004 and R4-1803466).
+	preambleReceivedTargetPower				INTEGER (-200..-74),
+	-- Max number of RA preamble transmission perfomed before declaring a failure (see 38.321, section 5.1.4, 5.1.5)
+	preambleTransMax 						ENUMERATED {n3, n4, n5, n6, n7,	n8, n10, n20, n50, n100, n200},
+	-- Power ramping steps for PRACH (see 38.321,5.1.3)
+	powerRampingStep						ENUMERATED {dB0, dB2, dB4, dB6},
+	-- Msg2 (RAR) window length in number of slots. The network configures a value lower than or euqal to 10 ms (see 38.321, section 5.1.4)
+	ra-ResponseWindow						ENUMERATED {sl1, sl2, sl4, sl8, sl10, sl20, sl40, sl80}
+}
+
+-- TAG-RACH-CONFIG-GENERIC-STOP 
+-- TAG-RACH-CONFIG-DEDICATED-START
+
+-- FFS_Standlone: resources for msg1-based on-demand SI request
+
+RACH-ConfigDedicated ::=		SEQUENCE {
+	-- Resources for contention free random access to a given target cell
+	cfra-Resources					CFRA-Resources, 
+	...
+}
+
+CFRA-Resources ::= 				CHOICE {
+	ssb								SEQUENCE {
+		ssb-ResourceList				SEQUENCE (SIZE(1..maxRA-SSB-Resources)) OF CFRA-SSB-Resource,
+		-- Explicitly signalled PRACH Mask Index for RA Resource selection in TS 36.321. The mask is valid for all SSB
+		-- resources signalled in ssb-ResourceList
+		ra-ssb-OccasionMaskIndex		INTEGER (0..15)
+	},
+	csirs							SEQUENCE {
+		csirs-ResourceList				SEQUENCE (SIZE(1..maxRA-CSIRS-Resources)) OF CFRA-CSIRS-Resource,
+		cfra-csirs-DedicatedRACH-Threshold	RSRP-Range
+	}
+}
+
+CFRA-SSB-Resource ::= 			SEQUENCE {
+	-- The ID of an SSB transmitted by this serving cell. 
+	ssb								SSB-Index,
+	-- The preamble index that the UE shall use when performing CF-RA upon selecting the candidate beams identified by this SSB.
+	ra-PreambleIndex				INTEGER (0..63),
+	...
+}
+
+CFRA-CSIRS-Resource ::= 		SEQUENCE {
+	-- The ID of a CSI-RS resource defined in the measurement object associated with this serving cell.
+	csi-RS							CSI-RS-Index,
+	-- RA occasions that the UE shall use when performing CF-RA upon selecting the candidate beam identified by this CSI-RS.
+	ra-OccasionList					SEQUENCE (SIZE(1..maxRA-OccasionsPerCSIRS)) OF INTEGER (0..maxRA-Occasions-1),
+	-- The RA preamble index to use in the RA occasions assoicated with this CSI-RS.
+	ra-PreambleIndex				INTEGER (0..63),	
+	...
+}
+
+-- TAG-RACH-CONFIG-DEDICATED-STOP
+-- TAG-RADIO-BEARER-CONFIG-START
+
+RadioBearerConfig ::=					SEQUENCE {
+	srb-ToAddModList						SRB-ToAddModList										OPTIONAL, -- Need N
+	srb3-ToRelease							ENUMERATED{true}										OPTIONAL, -- Need N
+	drb-ToAddModList						DRB-ToAddModList										OPTIONAL, -- Need N
+	drb-ToReleaseList						DRB-ToReleaseList										OPTIONAL, -- Need N
+	securityConfig 							SecurityConfig											OPTIONAL, -- Cond M
+	...
+}
+
+SRB-ToAddModList ::=					SEQUENCE (SIZE (1..2)) OF SRB-ToAddMod
+SRB-ToAddMod ::=						SEQUENCE {
+	srb-Identity							SRB-Identity,
+	-- may only be set if the cell groups of all linked logical channels are reset or released
+	reestablishPDCP							ENUMERATED{true}										OPTIONAL, 		-- Need N
+	discardOnPDCP                           ENUMERATED{true}										OPTIONAL,		-- Need N
+	pdcp-Config								PDCP-Config												OPTIONAL,		-- Cond PDCP
+	...
+}
+
+
+DRB-ToAddModList ::=					SEQUENCE (SIZE (1..maxDRB)) OF DRB-ToAddMod
+DRB-ToAddMod ::=						SEQUENCE {
+	cnAssociation							CHOICE {
+		-- The EPS bearer ID determines the EPS bearer when NR connects to EPC using EN-DC
+		eps-BearerIdentity						INTEGER (0..15),												-- EPS-DRB-Setup
+		--	The SDAP configuration determines how to map QoS flows to DRBs when NR connects to the 5GC
+		sdap-Config								SDAP-Config													-- 5GC
+	} 										OPTIONAL, -- Cond DRBSetup
+	drb-Identity							DRB-Identity,
+
+	-- may only be set if the cell groups of all linked logical channels are reset or released
+	reestablishPDCP						ENUMERATED{true}										OPTIONAL, 		-- Need N
+	recoverPDCP							ENUMERATED{true}										OPTIONAL, 		-- Need N
+	pdcp-Config							PDCP-Config												OPTIONAL,		-- Cond PDCP
+	...
+}
+
+DRB-ToReleaseList ::=					SEQUENCE (SIZE (1..maxDRB)) OF DRB-Identity
+
+
+SecurityConfig ::=						SEQUENCE {	
+	securityAlgorithmConfig				SecurityAlgorithmConfig									OPTIONAL,	-- Cond RBTermChange
+	keyToUse							ENUMERATED{keNB, s-KgNB}								OPTIONAL,	-- Cond RBTermChange
+	...
+}
+
+-- TAG-RADIO-BEARER-CONFIG-STOP
+-- TAG-RADIOLINKMONITORINGCONFIG-START
+
+RadioLinkMonitoringConfig ::=			SEQUENCE {
+	-- A list of reference signals for detecting beam failure and/or cell level radio link failure (RLF).
+	-- The network configures at most two detectionResources per BWP for the purpose "beamFailure" or "both". 
+	-- If no RSs are provided for the purpose of beam failure detection, the UE performs beam monitoring based on the activated TCI-State 
+	-- for PDCCH. However, if the activated TCI state refers to an aperiodic or semi-persistent CSI-RS, the gNB configures the failure
+	-- detection resources explicitly (FFS_RAN1: TBC by RAN1).
+	-- If no RSs are provided in this list at all (neither for Cell- nor for Beam-RLM), the UE performs also Cell-RLM based 
+	-- on the activated TCI-State of PDCCH (FFS_RAN1: TBC by RAN1).
+	-- When the network reconfigures this field, the UE resets on-going RLF timers and counters.
+	failureDetectionResources				SEQUENCE (SIZE(1..maxNrofFailureDetectionResources)) OF RadioLinkMonitoringRS	OPTIONAL, 	-- Need M
+	-- This field determines after how many beam failure events the UE triggers beam failure recovery (see 38.321, section 5.17). 
+	-- Value n1 corresponds to 1 beam failure instance, n2 corresponds to 2 beam failure instances and so on. 
+	-- When the network reconfigures this field, the UE resets on-going RLF timers and counters. 
+	-- If the field is absent, the UE does not trigger beam failure recovery.
+	beamFailureInstanceMaxCount				ENUMERATED {n1, n2, n3, n4, n5, n6, n8, n10}									OPTIONAL,	-- Need S
+	-- Timer for beam failure detection (see 38.321, section FFS_Section). See also the BeamFailureRecoveryConfig IE.
+	-- Value in number of "periods of Beam Failure Detection" Reference Signal. Value pbfd1 corresponds to 1 period of Beam Failure 
+	-- Detection Reference Signal, value pbfd2 corresponds to 2 periods of Beam Failure Detection Reference Signal and so on.
+	-- When the network reconfigures this field, the UE resets on-going RLF timers and counters.
+	beamFailureDetectionTimer      			ENUMERATED {pbfd1, pbfd2, pbfd3, pbfd4, pbfd5, pbfd6, pbfd8, pbfd10}			OPTIONAL,	-- Need R
+	...
+}
+
+RadioLinkMonitoringRS ::=				SEQUENCE {
+	-- Determines whether the UE shall monitor the associated reference signal for the purpose of cell- and/or beam failure detection.
+	purpose									ENUMERATED {beamFailure, rlf, both},
+	-- A reference signal that the UE shall use for radio link monitoring. The network provides an ssb-Index only if
+	-- the purpose is set to rlf.
+	detectionResource						CHOICE {
+		ssb-Index								SSB-Index,
+		csi-RS-Index							NZP-CSI-RS-ResourceId
+	},
+	...
+}
+
+-- TAG-RADIOLINKMONITORINGCONFIG-STOP
+-- TAG-RATEMATCHPATTERN-START
+RateMatchPattern ::= 						SEQUENCE {
+	rateMatchPatternId							RateMatchPatternId,
+
+	patternType									CHOICE {
+		bitmaps										SEQUENCE {
+			-- A resource block level bitmap in the frequency domain. It indicates the PRBs to which the symbolsInResourceBlock bitmap applies.
+			-- Corresponds to L1 parameter 'rate-match-PDSCH-bitmap1' (see 38.214, section FFS_Section)
+			-- FFS_ASN1: Consider multiple options with different number of bits (for narrower carriers)
+			resourceBlocks								BIT STRING (SIZE (275)),
+
+			-- A symbol level bitmap in time domain. It indicates (FFS: with a bit set to true) the symbols which the UE shall rate match around.
+			-- This pattern recurs (in time domain) with the configured periodicityAndOffset. 
+			-- Corresponds to L1 parameter 'rate-match-PDSCH-bitmap2' (see 38.214, section FFS_Section)
+			-- FFS: Why not split it into two BIT STRINGs of 14 bit each?
+			symbolsInResourceBlock						CHOICE {
+				oneSlot										BIT STRING (SIZE (14)),
+				twoSlots									BIT STRING (SIZE (28))
+			},
+
+			-- A time domain repetition pattern. at which the symbolsInResourceBlock 
+			-- pattern recurs. This slot pattern repeats itself continuously. Absence of this field indicates the value n1, i.e., the
+			-- symbolsInResourceBlock recurs every 14 symbols. 
+			-- Corresponds to L1 parameter 'rate-match-PDSCH-bitmap3' (see 38.214, section FFS_Section)
+			periodicityAndPattern						CHOICE {
+				n2											BIT STRING (SIZE (2)), 
+				n4											BIT STRING (SIZE (4)), 
+				n5											BIT STRING (SIZE (5)), 
+				n8											BIT STRING (SIZE (8)), 
+				n10											BIT STRING (SIZE (10)), 
+				n20											BIT STRING (SIZE (20)), 
+				n40											BIT STRING (SIZE (40))
+			}																										OPTIONAL, 	-- Need S
+			...
+		},
+		-- This ControlResourceSet us used as a PDSCH rate matching pattern, i.e., PDSCH reception rate matches around it. 
+		controlResourceSet							ControlResourceSetId
+	},
+	-- The SubcarrierSpacing for this resource pattern. If the field is absent, the UE applies the SCS of the associcated BWP. 
+	-- The value kHz15 corresponds to µ=0, kHz30 to µ=1, and so on. Only the values 15 or 30 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are 
+	-- applicable. Corresponds to L1 parameter 'resource-pattern-scs' (see 38.214, section FFS_Section)
+	subcarrierSpacing							SubcarrierSpacing 													OPTIONAL,	-- Cond CellLevel
+	-- FFS_Description, FFS_Section
+	mode										ENUMERATED { dynamic, semiStatic },
+	...
+}
+
+-- TAG-RATEMATCHPATTERN-STOP
+-- TAG-RATEMATCHPATTERNID-START
+
+RateMatchPatternId ::=						INTEGER (0..maxNrofRateMatchPatterns-1)
+
+-- TAG-RATEMATCHPATTERNID-STOP
+-- TAG-RATEMATCHPATTERNLTE-CRS-START
+
+RateMatchPatternLTE-CRS ::=				SEQUENCE {
+	-- Center of the LTE carrier. Corresponds to L1 parameter 'center-subcarrier-location' (see 38.214, section 5.1.4)
+	carrierFreqDL							INTEGER (0..16383),
+	-- BW of the LTE carrier in numbewr of PRBs. Corresponds to L1 parameter 'BW' (see 38.214, section 5.1.4)
+	carrierBandwidthDL						ENUMERATED {n6, n15, n25, n50, n75, n100, spare2, spare1},
+	-- LTE MBSFN subframe configuration. Corresponds to L1 parameter 'MBSFN-subframconfig' (see 38.214, section 5.1.4)
+	-- FFS_ASN1: Import the LTE MBSFN-SubframeConfigList
+	mbsfn-SubframeConfigList				EUTRA-MBSFN-SubframeConfigList						OPTIONAL,	-- Need M
+	-- Number of LTE CRS antenna port to rate-match around. 
+	-- Corresponds to L1 parameter 'rate-match-resources-numb-LTE-CRS-antenna-port' (see 38.214, section 5.1.4)
+	nrofCRS-Ports							ENUMERATED {n1, n2, n4},
+	-- Shifting value v-shift in LTE to rate match around LTE CRS
+	-- Corresponds to L1 parameter 'rate-match-resources-LTE-CRS-v-shift' (see 38.214, section 5.1.4)
+	v-Shift									ENUMERATED {n0, n1, n2, n3, n4, n5}			
+}
+
+-- TAG-RATEMATCHPATTERNLTE-CRS-STOP
+-- TAG-REPORT-CONFIG-ID-START
+
+ReportConfigId ::=							INTEGER (1..maxReportConfigId)
+
+-- TAG-REPORT-CONFIG-ID-STOP
+-- TAG-REPORT-CONFIG-START
+
+ReportConfigNR ::=							SEQUENCE {
+	reportType									CHOICE {
+		periodical									PeriodicalReportConfig, 
+		eventTriggered								EventTriggerConfig,
+-- reportCGI is to be completed before the end of Rel-15.
+		reportCGI									ENUMERATED {ffsTypeAndValue},
+		...
+	}
+}
+
+-- FFS / TODO: Consider separating trgger configuration (trigger, periodic, ...) from report configuration.
+-- Current structure allows easier definiton of new events and new report types e.g. CGI, etc.
+EventTriggerConfig::=						SEQUENCE {
+	eventId										CHOICE {
+		eventA1										SEQUENCE {
+			a1-Threshold								MeasTriggerQuantity,
+			reportOnLeave								BOOLEAN,
+			hysteresis									Hysteresis,
+			timeToTrigger								TimeToTrigger
+		},
+		eventA2										SEQUENCE {
+			a2-Threshold								MeasTriggerQuantity,
+			reportOnLeave								BOOLEAN,
+			hysteresis									Hysteresis,
+			timeToTrigger								TimeToTrigger
+		},
+		eventA3										SEQUENCE {
+			a3-Offset									MeasTriggerQuantityOffset,
+			reportOnLeave								BOOLEAN,
+			hysteresis									Hysteresis,
+			timeToTrigger								TimeToTrigger,
+			useWhiteCellList							BOOLEAN														
+		},
+		eventA4										SEQUENCE {
+			a4-Threshold								MeasTriggerQuantity,
+			reportOnLeave								BOOLEAN,
+			hysteresis									Hysteresis,
+			timeToTrigger								TimeToTrigger,
+			useWhiteCellList							BOOLEAN														
+		},
+		eventA5										SEQUENCE {
+			a5-Threshold1								MeasTriggerQuantity,
+			a5-Threshold2								MeasTriggerQuantity,
+			reportOnLeave								BOOLEAN,
+			hysteresis									Hysteresis,
+			timeToTrigger								TimeToTrigger,
+			useWhiteCellList							BOOLEAN														
+		},
+		eventA6										SEQUENCE {
+			a6-Offset									MeasTriggerQuantityOffset,
+			reportOnLeave								BOOLEAN,
+			hysteresis									Hysteresis,
+			timeToTrigger								TimeToTrigger,
+			useWhiteCellList							BOOLEAN														
+		},
+		...
+	},
+
+	rsType										NR-RS-Type,
+
+	-- Common reporting config (at least to periodical and eventTriggered)
+	reportInterval								ReportInterval,
+	reportAmount								ENUMERATED {r1, r2, r4, r8, r16, r32, r64, infinity},
+
+	-- Cell reporting configuration
+	reportQuantityCell							MeasReportQuantity,
+	maxReportCells								INTEGER (1..maxCellReport),
+
+	-- RS index reporting configuration
+	reportQuantityRsIndexes						MeasReportQuantity													OPTIONAL,	-- Need M
+	maxNrofRSIndexesToReport					INTEGER (1..maxNrofIndexesToReport) 								OPTIONAL,	-- Need M
+	includeBeamMeasurements						BOOLEAN,
+	-- If configured the UE includes the best neighbour cells per serving frequency
+	reportAddNeighMeas							ENUMERATED {setup}									OPTIONAL,		-- Need R
+	...
+
+}
+
+PeriodicalReportConfig ::=					SEQUENCE {
+	rsType										NR-RS-Type,
+
+	-- Common reporting config (at least to periodical and eventTriggered)
+	reportInterval								ReportInterval,
+	reportAmount								ENUMERATED {r1, r2, r4, r8, r16, r32, r64, infinity},
+
+	-- Cell reporting configuration
+	reportQuantityCell							MeasReportQuantity,
+	maxReportCells								INTEGER (1..maxCellReport),
+
+	-- RS index reporting configuration
+	reportQuantityRsIndexes						MeasReportQuantity													OPTIONAL,	-- Need R
+	maxNrofRsIndexesToReport					INTEGER (1..maxNrofIndexesToReport) 									OPTIONAL,	-- Need R
+	includeBeamMeasurements						BOOLEAN,
+	useWhiteCellList							BOOLEAN,
+	...
+
+}
+
+NR-RS-Type ::= ENUMERATED {ssb, csi-rs}
+
+MeasTriggerQuantity ::=						CHOICE {
+	rsrp										RSRP-Range,
+	rsrq										RSRQ-Range,
+	sinr										SINR-Range
+}
+
+MeasTriggerQuantityOffset ::=				CHOICE {
+	rsrp										INTEGER (-30..30),														
+	rsrq										INTEGER (-30..30),														
+	sinr										INTEGER (-30..30)														
+}
+
+			
+MeasReportQuantity ::=						SEQUENCE {
+	rsrp										BOOLEAN,
+	rsrq										BOOLEAN,
+	sinr										BOOLEAN
+}
+
+
+-- TAG-REPORT-CONFIG-START
+-- TAG-REPORT-CONFIG-TO-ADD-MOD-LIST-START
+
+ReportConfigToAddModList ::=		SEQUENCE (SIZE (1..maxReportConfigId)) OF ReportConfigToAddMod
+
+ReportConfigToAddMod ::=	SEQUENCE {
+	reportConfigId						ReportConfigId,
+	reportConfig						CHOICE {
+		reportConfigNR						ReportConfigNR,
+		...
+	}
+}
+
+-- TAG- REPORT-CONFIG-TO-ADD-MOD-LIST-STOP
+
+ReportInterval ::=					ENUMERATED {ms120, ms240, ms480, ms640, ms1024, ms2048, ms5120, ms10240, ms20480, ms40960, min1,
+													min6, min12, min30 }
+
+-- TAG-RLC-CONFIG-START
+
+RLC-Config ::=						CHOICE {
+	am									SEQUENCE {
+		ul-AM-RLC							UL-AM-RLC,
+		dl-AM-RLC							DL-AM-RLC
+	},
+	um-Bi-Directional					SEQUENCE {
+		ul-UM-RLC							UL-UM-RLC,
+		dl-UM-RLC							DL-UM-RLC
+	},
+	um-Uni-Directional-UL				SEQUENCE {
+		ul-UM-RLC							UL-UM-RLC
+	},
+	um-Uni-Directional-DL				SEQUENCE {
+		dl-UM-RLC							DL-UM-RLC
+	},
+	...
+}
+
+UL-AM-RLC ::=						SEQUENCE {
+	sn-FieldLength						SN-FieldLengthAM,
+	t-PollRetransmit					T-PollRetransmit,
+	pollPDU								PollPDU,
+	pollByte							PollByte,
+	maxRetxThreshold					ENUMERATED { t1, t2, t3, t4, t6, t8, t16, t32 }
+}
+
+DL-AM-RLC ::=						SEQUENCE {
+	sn-FieldLength						SN-FieldLengthAM,
+	t-Reassembly						T-Reassembly,
+	t-StatusProhibit					T-StatusProhibit
+}
+
+UL-UM-RLC ::=						SEQUENCE {
+	sn-FieldLength						SN-FieldLengthUM
+}
+
+DL-UM-RLC ::=						SEQUENCE {
+	sn-FieldLength						SN-FieldLengthUM,
+	t-Reassembly						T-Reassembly
+}
+
+T-PollRetransmit ::=				ENUMERATED {
+										ms5, ms10, ms15, ms20, ms25, ms30, ms35,
+										ms40, ms45, ms50, ms55, ms60, ms65, ms70,
+										ms75, ms80, ms85, ms90, ms95, ms100, ms105,
+										ms110, ms115, ms120, ms125, ms130, ms135,
+										ms140, ms145, ms150, ms155, ms160, ms165,
+										ms170, ms175, ms180, ms185, ms190, ms195,
+										ms200, ms205, ms210, ms215, ms220, ms225,
+										ms230, ms235, ms240, ms245, ms250, ms300,
+										ms350, ms400, ms450, ms500, ms800, ms1000,
+										ms2000, ms4000, spare5, spare4, spare3,
+										spare2, spare1}
+
+
+PollPDU ::=							ENUMERATED {
+										p4, p8, p16, p32, p64, p128, p256, p512, p1024, p2048, p4096, p6144, p8192, p12288, p16384, p20480,
+										p24576, p28672, p32768, p40960, p49152, p57344, p65536, infinity, spare8, spare7, spare6, spare5, spare4,
+										spare3, spare2, spare1}
+
+PollByte ::=						ENUMERATED {
+										kB1, kB2, kB5, kB8, kB10, kB15, kB25, kB50, kB75,
+										kB100, kB125, kB250, kB375, kB500, kB750, kB1000,
+										kB1250, kB1500, kB2000, kB3000, kB4000, kB4500,
+										kB5000, kB5500, kB6000, kB6500, kB7000, kB7500,
+										mB8, mB9, mB10, mB11, mB12, mB13, mB14, mB15,
+										mB16, mB17, mB18, mB20, mB25, mB30, mB40, infinity,
+										spare20, spare19, spare18, spare17, spare16,
+										spare15, spare14, spare13, spare12, spare11,
+										spare10, spare9, spare8, spare7, spare6, spare5,
+										spare4, spare3, spare2, spare1}
+
+T-Reassembly ::=					ENUMERATED {
+										ms0, ms5, ms10, ms15, ms20, ms25, ms30, ms35,
+										ms40, ms45, ms50, ms55, ms60, ms65, ms70,
+										ms75, ms80, ms85, ms90, ms95, ms100, ms110,
+										ms120, ms130, ms140, ms150, ms160, ms170,
+										ms180, ms190, ms200, spare1}
+
+T-StatusProhibit ::=				ENUMERATED {
+										ms0, ms5, ms10, ms15, ms20, ms25, ms30, ms35,
+										ms40, ms45, ms50, ms55, ms60, ms65, ms70,
+										ms75, ms80, ms85, ms90, ms95, ms100, ms105,
+										ms110, ms115, ms120, ms125, ms130, ms135,
+										ms140, ms145, ms150, ms155, ms160, ms165,
+										ms170, ms175, ms180, ms185, ms190, ms195,
+										ms200, ms205, ms210, ms215, ms220, ms225,
+										ms230, ms235, ms240, ms245, ms250, ms300,
+										ms350, ms400, ms450, ms500, ms800, ms1000,
+										ms1200, ms1600, ms2000, ms2400, spare2, spare1}
+
+SN-FieldLengthUM ::=				ENUMERATED {size6, size12}
+SN-FieldLengthAM ::=				ENUMERATED {size12, size18}
+
+-- TAG-RLC-CONFIG-STOP
+-- TAG-RLF-TIMERS-AND-CONSTANTS-START
+
+RLF-TimersAndConstants ::= 			SEQUENCE {
+	t310								ENUMERATED {ms0, ms50, ms100, ms200, ms500, ms1000, ms2000, ms4000, ms6000},
+	n310								ENUMERATED {n1, n2, n3, n4, n6, n8, n10, n20},
+	n311								ENUMERATED {n1, n2, n3, n4, n5, n6, n8, n10},
+	...
+}
+
+-- TAG-RLF-TIMERS-AND-CONSTANTS-STOP
+-- TAG-RNTI-VALUE-START
+
+RNTI-Value ::=						INTEGER (0..65535)
+
+-- TAG-RNTI-VALUE-STOP
+-- TAG-RSRP-RANGE-START
+
+RSRP-Range ::=						INTEGER(0..124)
+
+-- TAG-RSRP-RANGE-STOP
+-- TAG-RSRQ-RANGE-START
+
+RSRQ-Range ::=						INTEGER(0..127)
+
+-- TAG-RSRQ-RANGE-STOP
+-- TAG-SCELL-INDEX-START
+
+-- The value range is shared across the Cell Groups 
+SCellIndex ::=						INTEGER (1..31)
+
+-- TAG-SCELL-INDEX-STOP
+-- TAG-SCHEDULING-REQUEST-CONFIG-START
+
+SchedulingRequestConfig ::= 		SEQUENCE {
+	schedulingRequestToAddModList		SEQUENCE (SIZE (1..maxNrofSR-ConfigPerCellGroup)) OF SchedulingRequestToAddMod			OPTIONAL, -- Need N
+	schedulingRequestToReleaseList		SEQUENCE (SIZE (1..maxNrofSR-ConfigPerCellGroup)) OF SchedulingRequestId				OPTIONAL  -- Need N
+}
+
+SchedulingRequestToAddMod ::=		SEQUENCE {
+	sr-ConfigIndex		SchedulingRequestId,
+
+	sr-ProhibitTimer					ENUMERATED {ms1, ms2, ms4, ms8, ms16, ms32, ms64, ms128}					OPTIONAL,	-- Need S
+	sr-TransMax							ENUMERATED { n4, n8, n16, n32, n64, spare3, spare2, spare1}
+}
+
+SchedulingRequestId ::=	INTEGER (0..7)
+
+-- FFS_TODO: provide resources for each SchedulingRequestID in ServingCellConfig (TBD whether directly, in PUCCH-Config, in each BWP)
+
+-- TAG-SCHEDULING-REQUEST-CONFIG-STOP
+-- TAG-SCHEDULING-REQUEST-RESOURCE-CONFIG-START
+
+SchedulingRequestResourceConfig ::=			SEQUENCE {
+	schedulingRequestResourceId						SchedulingRequestResourceId,
+	-- The ID of the SchedulingRequestConfig that uses this scheduling request resource.
+	schedulingRequestID								SchedulingRequestId,
+	-- SR periodicity and offset in number of slots. Corresponds to L1 parameter 'SR-periodicity' and 'SR-offset' (see 38.213, section 9.2.2)	
+	-- The following periodicities may be configured depending on the chosen subcarrier spacing:
+	-- SCS =  15 kHz: 2sym, 7sym, 1sl, 2sl, 4sl, 5sl, 8sl, 10sl, 16sl, 20sl, 40sl, 80sl
+	-- SCS =  30 kHz: 2sym, 7sym, 1sl, 2sl, 4sl, 8sl, 10sl, 16sl, 20sl, 40sl, 80sl, 160sl
+	-- SCS =  60 kHz: 2sym, 7sym/6sym, 1sl, 2sl, 4sl, 8sl, 16sl, 20sl, 40sl, 80sl, 160sl, 320sl
+	-- SCS = 120 kHz: 2sym, 7sym, 1sl, 2sl, 4sl, 8sl, 16sl, 40sl, 80sl, 160sl, 320sl, sl640
+	-- sym6or7 corresponds to 6 symbols if extended cyclic prefix and a SCS of 60 kHz are configured, otherwise it corresponds to 7 symbols.
+	-- For periodicities sym2, sym7 and sl1 the UE assumes an offset of 0 slots.
+	periodicityAndOffset							CHOICE {
+		sym2											NULL,						
+		sym6or7											NULL,						
+		sl1												NULL,						-- Recurs in every slot
+		sl2												INTEGER (0..1),
+		sl4												INTEGER (0..3),
+		sl5												INTEGER (0..4),
+		sl8												INTEGER (0..7),
+		sl10											INTEGER (0..9),
+		sl16											INTEGER (0..15),
+		sl20											INTEGER (0..19),
+		sl40											INTEGER (0..39),
+		sl80											INTEGER (0..79),
+		sl160											INTEGER (0..159),
+		sl320											INTEGER (0..319),
+		sl640											INTEGER (0..639)
+	}																														OPTIONAL,	-- Need M
+	-- ID of the PUCCH resource in which the UE shall send the scheduling request. The 
+	-- actual PUCCH-Resource is configured in PUCCH-Config of the same UL BWP and serving cell as this SchedulingRequestResourceConfig. 
+	-- The network configures a PUCCH-Resource of PUCCH-format0 or PUCCH-format1 
+	-- (other formats not supported). Corresponds to L1 parameter 'SR-resource' (see 38.213, section 9.2.2)
+	resource										PUCCH-ResourceId														OPTIONAL	-- Need M
+}
+
+-- TAG-SCHEDULING-REQUEST-RESOURCE-CONFIG-STOP
+-- TAG-SCHEDULINGREQUESTRESOURCEID-START
+
+SchedulingRequestResourceId ::=					INTEGER (1..maxNrofSR-Resources)
+
+-- TAG-SCHEDULINGREQUESTRESOURCEID-STOP
+-- TAG-SCRAMBLING-ID-START
+
+ScramblingId ::=					INTEGER (0..1023)
+
+-- TAG-SCRAMBLING-ID-STOP
+-- TAG-SCS-SPECIFIC-CARRIER-START
+
+SCS-SpecificCarrier ::=			SEQUENCE {
+	-- Offset in frequency domain between Point A (lowest subcarrier of common RB 0) and the lowest usable subcarrier on this carrier
+	-- in number of PRBs (using the subcarrierSpacing defined for this carrier). The maximum value corresponds to 275*8-1. 
+	-- Corresponds to L1 parameter 'offset-pointA-low-scs' (see 38.211, section FFS_Section)
+	offsetToCarrier				INTEGER (0..2199),
+	-- Subcarrier spacing of this carrier. It is used to convert the offsetToCarrier into an actual frequency. 
+	-- Only the values 15 or 30 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are applicable.
+	-- Corresponds to L1 parameter 'ref-scs' (see 38.211, section FFS_Section)
+	subcarrierSpacing					SubcarrierSpacing,
+	-- Corresponds to L1 parameter k0 (see 38.211, section 5.3.1). n-6 corresponds to value -6, n0 corresponds to value 0 and n6 corresponds
+	-- to value +6.
+	k0									ENUMERATED {n-6, n0, n6}, 
+	-- Width of this carrier in number of PRBs (using the subcarrierSpacing defined for this carrier)
+	-- Corresponds to L1 parameter 'BW' (see 38.211, section FFS_Section)
+	carrierBandwidth					INTEGER (1..maxNrofPhysicalResourceBlocks),
+	...
+}
+
+-- TAG-SCS-SPECIFIC-CARRIER-STOP 
+-- TAG-SDAP-CONFIG-START
+
+SDAP-Config ::=						SEQUENCE {
+	pdu-Session							PDU-SessionID,
+
+	-- FFS: separate configuration for UL and DL
+	sdap-HeaderDL 						ENUMERATED {present, absent},
+	sdap-HeaderUL 						ENUMERATED {present, absent},
+	defaultDRB							BOOLEAN,
+
+	-- A list of QoS-Flow-IDs that the UE shall map to the DRB of this SDAP-Config.
+	mappedQoS-FlowsToAdd				SEQUENCE (SIZE (1..maxNrofQFIs)) OF QFI 									OPTIONAL, -- Need N
+	-- A list of QoS-Flow-IDs that the UE shall no longer map to the DRB of this SDAP-Config.
+	mappedQoS-FlowsToRelease			SEQUENCE (SIZE (1..maxNrofQFIs)) OF QFI 									OPTIONAL, -- Need N
+	...
+}
+
+QFI ::= 							INTEGER (0..maxQFI)
+
+PDU-SessionID ::= INTEGER (0..255)
+
+-- TAG-SDAP-CONFIG-STOP
+-- TAG-SEARCHSPACE-START
+
+SearchSpace ::= 						SEQUENCE {
+	-- Identity of the search space. SearchSpaceId = 0 identifies the SearchSpace configured via PBCH (MIB) or ServingCellConfigCommon.
+	-- The searchSpaceId is unique among the BWPs of a Serving Cell. 
+	searchSpaceId							SearchSpaceId,
+
+	-- The CORESET applicable for this SearchSpace. 
+	-- Value 0 identifies the common CORESET configured in MIB and in ServingCellConfigCommon
+	-- Values 1..maxNrofControlResourceSets-1 identify CORESETs configured by dedicated signalling
+	controlResourceSetId					ControlResourceSetId														OPTIONAL, 	-- Cond SetupOnly
+
+	-- Slots for PDCCH Monitoring configured as periodicity and offset. Corresponds to L1 parameters 'Montoring-periodicity-PDCCH-slot' and 
+	-- 'Montoring-offset-PDCCH-slot' (see 38.213, section 10)
+	monitoringSlotPeriodicityAndOffset		CHOICE {
+		sl1										NULL, 
+		sl2										INTEGER (0..1), 
+		sl4										INTEGER (0..3), 
+		sl5 									INTEGER (0..4),
+		sl8										INTEGER (0..7), 
+		sl10 									INTEGER (0..9),
+		sl16 									INTEGER (0..15),
+		sl20 									INTEGER (0..19)
+	}																													OPTIONAL,	-- Cond Setup
+
+	-- Symbols for PDCCH monitoring in the slots configured for PDCCH monitoring (see monitoringSlotPeriodicityAndOffset).
+	-- The most significant (left) bit represents the first OFDM in a slot. The least significant (right) bit represents the last symbol. 
+	-- Corresponds to L1 parameter 'Montoring-symbols-PDCCH-within-slot' (see 38.213, section 10)
+	monitoringSymbolsWithinSlot					BIT STRING (SIZE (14))													OPTIONAL, 	-- Cond Setup
+
+	-- Number of PDCCH candidates per aggregation level. Corresponds to L1 parameter 'Aggregation-level-1' to 'Aggregation-level-8'.
+	-- The number of candidates and aggregation levels configured here applies to all formats unless a particular value is specified or
+	-- a format-specific value is provided (see inside searchSpaceType). 
+	-- (see 38.213, section 10)
+	nrofCandidates							SEQUENCE {
+		aggregationLevel1						ENUMERATED {n0, n1, n2, n3, n4, n5, n6, n8},
+		aggregationLevel2						ENUMERATED {n0, n1, n2, n3, n4, n5, n6, n8},
+		aggregationLevel4						ENUMERATED {n0, n1, n2, n3, n4, n5, n6, n8},
+		aggregationLevel8						ENUMERATED {n0, n1, n2, n3, n4, n5, n6, n8},
+		aggregationLevel16						ENUMERATED {n0, n1, n2, n3, n4, n5, n6, n8}
+	}																													OPTIONAL,	-- Cond Setup
+
+	-- Indicates whether this is a common search space (present) or a UE specific search space as well as DCI formats to monitor for.
+	searchSpaceType							CHOICE {
+		-- Configures this search space as common search space (CSS) and DCI formats to monitor.
+		common									SEQUENCE {
+			-- If configured, the UE monitors the DCI formats 0_0 and 1_0 with CRC scrambled by C-RNTI, CS-RNTI (if configured), 
+			-- SP-CSI-RNTI (if configured), RA-RNTI, TC-RNTI, P-RNTI, SI-RNTI
+			dci-Format0-0-AndFormat1-0					SEQUENCE {
+				...
+			}																											OPTIONAL,	-- Need R
+			-- If configured, UE monitors the DCI format format 2_0 with CRC scrambled by SFI-RNTI
+			dci-Format2-0								SEQUENCE {
+				-- The number of PDCCH candidates specifically for format 2-0 for the configured aggregation level.
+				-- If an aggregation level is absent, the UE does not search for any candidates with that aggregation level.
+				-- Corresponds to L1 parameters 'SFI-Num-PDCCH-cand' and 'SFI-Aggregation-Level' (see 38.213, section 11.1.1).
+				nrofCandidates-SFI							SEQUENCE {
+					aggregationLevel1							ENUMERATED {n1, n2}										OPTIONAL,	-- Need R
+					aggregationLevel2							ENUMERATED {n1, n2}										OPTIONAL,	-- Need R
+					aggregationLevel4							ENUMERATED {n1, n2}										OPTIONAL,	-- Need R
+					aggregationLevel8							ENUMERATED {n1, n2}										OPTIONAL,	-- Need R
+					aggregationLevel16							ENUMERATED {n1, n2}										OPTIONAL	-- Need R
+				},
+				...
+			}																											OPTIONAL,	-- Need R
+			-- If configured, UE monitors the DCI format format 2_1 with CRC scrambled by INT-RNTI
+			dci-Format2-1								SEQUENCE {
+				...
+			}																											OPTIONAL,	-- Need R
+			-- If configured, UE monitors the DCI format 2_2 with CRC scrambled by TPC-PUSCH-RNTI or TPC-PUCCH-RNTI
+			dci-Format2-2								SEQUENCE {
+				...
+			}																											OPTIONAL,	-- Need R
+			-- If configured, UE monitors the DCI format 2_3 with CRC scrambled by TPC-SRS-RNTI
+			dci-Format2-3								SEQUENCE {
+				-- Monitoring periodicity of SRS PDCCH in number of slots for DCI format 2-3. 
+				-- Corresponds to L1 parameter 'SRS-monitoring-periodicity' (see 38.212, 38.213, section 7.3.1, 11.3)
+				monitoringPeriodicity				ENUMERATED {n1, n2, n4, n5, n8, n10, n16, n20 }						OPTIONAL, 	-- Cond Setup
+
+				-- The number of PDCCH candidates for DCI format 2-3 for the configured aggregation level.
+				-- Corresponds to L1 parameter 'SRS-Num-PDCCH-cand' (see 38.212, 38.213, section 7.3.1, 11.3)
+				nrofPDCCH-Candidates				ENUMERATED {n1, n2},
+				...
+			}																											OPTIONAL	-- Need R
+		},
+		-- Configures this search space as UE specific search space (USS). The UE monitors the DCI format with CRC scrambled 
+		-- by C-RNTI, CS-RNTI (if configured), TC-RNTI (if a certain condition is met), and SP-CSI-RNTI (if configured)
+		ue-Specific								SEQUENCE {
+			-- Indicates whether the UE monitors in this USS for DCI formats 0-0 and 1-0 or for formats 0-1 and 1-1.
+			dci-Formats									ENUMERATED {formats0-0-And-1-0, formats0-1-And-1-1},
+			... 
+		}
+	}																													OPTIONAL	-- Cond Setup
+}
+-- TAG-SEARCHSPACE-STOP
+-- TAG-SEARCHSPACEID-START
+
+SearchSpaceId ::= 							INTEGER (0..maxNrofSearchSpaces-1)
+
+-- TAG-SEARCHSPACEID-STOP
+-- TAG-SECURITY-ALGORITHM-CONFIG-START
+
+SecurityAlgorithmConfig ::=			SEQUENCE {
+	cipheringAlgorithm					CipheringAlgorithm,
+	integrityProtAlgorithm				IntegrityProtAlgorithm			OPTIONAL,	-- Need R	
+	...
+}
+
+IntegrityProtAlgorithm ::=			ENUMERATED {
+											nia0, nia1, nia2, nia3, spare4, spare3,
+											spare2, spare1, ...}
+
+CipheringAlgorithm ::=				ENUMERATED {
+											nea0, nea1, nea2, nea3, spare4, spare3,
+											spare2, spare1, ...}
+
+-- TAG-SECURITY-ALGORITHM-CONFIG-STOP
+-- TAG-SERV-CELL-INDEX-START
+
+ServCellIndex ::=					INTEGER (0..maxNrofServingCells-1)
+
+-- TAG-SERV-CELL-INDEX-STOP
+-- TAG-SERVING-CELL-CONFIG-START
+
+ServingCellConfig ::=		SEQUENCE {
+	-- L1 parameters:
+
+	tdd-UL-DL-ConfigurationDedicated	TDD-UL-DL-ConfigDedicated												OPTIONAL, -- Cond TDD
+
+	-- The dedicated (UE-specific) configuration for the initial downlink bandwidth-part.
+	initialDownlinkBWP					BWP-DownlinkDedicated													OPTIONAL,	-- Cond ServCellAdd
+
+	-- List of additional downlink bandwidth parts to be released. (see 38.211, 38.213, section 12). 
+	downlinkBWP-ToReleaseList			SEQUENCE (SIZE (1..maxNrofBWPs)) OF BWP-Id								OPTIONAL,	-- Need N
+	-- List of additional downlink bandwidth parts to be added or modified. (see 38.211, 38.213, section 12). 
+	downlinkBWP-ToAddModList			SEQUENCE (SIZE (1..maxNrofBWPs)) OF BWP-Downlink						OPTIONAL, 	-- Need N
+
+	-- If configured for an SpCell, this field contains the ID of the DL BWP to be activated upon performing the reconfiguration 
+	-- in which it is received. If the field is absent, the RRC reconfiguration does not impose a BWP switch (corresponds to L1 
+	-- parameter 'active-BWP-DL-Pcell'). 
+	-- If configured for an SCell, this field contains the ID of the downlink bandwidth part to be used upon MAC-activation of an  SCell. 
+	-- If not provided, the UE uses the default BWP.
+	-- The initial bandwidth part is referred to by BWP-Id = 0.
+	firstActiveDownlinkBWP-Id			BWP-Id																	OPTIONAL,	-- Need R
+
+	-- The duration in ms after which the UE falls back to the default Bandwidth Part. (see 38.321, section 5.15) 
+	-- The value 0.5 ms is only applicable for carriers >6 GHz. 
+	-- When the network releases the timer configuration, the UE stops the timer without swithching to the default BWP.
+	bwp-InactivityTimer					ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, ms40,ms50, ms60, ms80,
+													ms100, ms200, ms300, ms500, ms750, ms1280, ms1920, ms2560, spare10, spare9, 
+													spare8, spare7, spare6, spare5, spare4, spare3, spare2, spare1 } OPTIONAL,	--	Need R	
+
+	-- Corresponds to L1 parameter 'default-DL-BWP'. The initial bandwidth part is referred to by BWP-Id = 0.
+	-- ID of the downlink bandwidth part to be used upon expiry of txxx.
+	-- This field is UE specific. When the field is absent the UE uses the the initial BWP as default BWP.
+	-- (see 38.211, 38.213, section 12 and 38.321, section 5.15)
+	defaultDownlinkBWP-Id				BWP-Id																	OPTIONAL, 	-- Need M
+
+	uplinkConfig						UplinkConfig															OPTIONAL,	-- Cond ServCellAdd-UL
+	supplementaryUplink					UplinkConfig 															OPTIONAL, 	-- Cond ServCellAdd-SUL
+
+
+	-- PDSCH releated parameters that are not BWP-specific.
+	pdsch-ServingCellConfig				PDSCH-ServingCellConfig 								OPTIONAL,	-- Need M
+	csi-MeasConfig					CSI-MeasConfig 											OPTIONAL,	-- Need M
+	
+	-- Includes parameters for configuration of carrier based SRS switching
+	-- Corresponds to L1 parameter 'SRS-CarrierSwitching' (see 38,214, section FFS_Section)
+	carrierSwitching				SRS-CarrierSwitching										OPTIONAL,	-- Need M
+	-- MAC parameters:
+	sCellDeactivationTimer				ENUMERATED {ms20, ms40, ms80, ms160, ms200, ms240, ms320, ms400, ms480, ms520, ms640, 
+												ms720, ms840, ms1280, spare2,spare1}				OPTIONAL,	-- Cond ServingCellWithoutPUCCH
+
+	-- Indicates whether this SCell is cross-carrier scheduled by another serving cell.
+	crossCarrierSchedulingConfig		CrossCarrierSchedulingConfig											OPTIONAL,	-- Need M
+
+	-- Timing Advance Group ID, as specified in TS 38.321 [3],  which this cell belongs to. 
+	tag-Id								TAG-Id,
+	-- Enables the "UE beam lock function (UBF)", which disable changes to the UE beamforming configuration when in NR_RRC_CONNECTED.
+	-- FFS: Parameter added preliminary based on RAN4 LS in R4-1711823. Decide where to place it (maybe ServingCellConfigCommon or 
+	-- in a BeamManagement IE??)
+	ue-BeamLockFunction					ENUMERATED {enabled}													OPTIONAL,	-- Need R
+
+	-- Indicates whether UE shall apply as pathloss reference either the downlink of PCell or of SCell that corresponds with this uplink
+	-- (see 38.213, section 7)
+	pathlossReferenceLinking			ENUMERATED {pCell, sCell}												OPTIONAL		-- Cond SCellOnly
+}
+
+UplinkConfig ::=					SEQUENCE {
+	-- Configuration of UL BWPs (including BWP-specific parameters:
+
+	-- The dedicated (UE-specific) configuration for the initial uplink bandwidth-part.
+	initialUplinkBWP					BWP-UplinkDedicated														OPTIONAL, 	-- Cond ServCellAdd
+
+	-- The additional bandwidth parts for uplink. In case of TDD uplink- and downlink BWP with the same bandwidthPartId are considered 
+	-- as a BWP pair and must have the same center frequency. 
+	uplinkBWP-ToReleaseList				SEQUENCE (SIZE (1..maxNrofBWPs)) OF BWP-Id								OPTIONAL,	-- Need N
+	uplinkBWP-ToAddModList				SEQUENCE (SIZE (1..maxNrofBWPs)) OF BWP-Uplink							OPTIONAL, 	-- Need N
+
+	-- If configured for an SpCell, this field contains the ID of the DL BWP to be activated upon performing the reconfiguration 
+	-- in which it is received. If the field is absent, the RRC reconfiguration does not impose a BWP switch (corresponds to 
+	-- L1 parameter 'active-BWP-UL-Pcell').
+	-- If configured for an SCell, this field contains the ID of the uplink bandwidth part to be used upon MAC-activation of an  SCell. 
+	-- If not provided, the UE uses the FFS: default BWP.
+	-- The initial bandwidth part is referred to by BandiwdthPartId = 0.
+	firstActiveUplinkBWP-Id				BWP-Id																	OPTIONAL,	-- Need R
+
+	-- Configuration that is common across the UL BWPs:
+
+	-- PUSCH related parameters that are not BWP-specific.
+	pusch-ServingCellConfig				PUSCH-ServingCellConfig 								OPTIONAL,	-- Need M
+	...
+}
+
+-- TAG-SERVING-CELL-CONFIG-STOP
+-- TAG-SERVING-CELL-CONFIG-COMMON-START
+
+ServingCellConfigCommon ::=		SEQUENCE {
+	physCellId							PhysCellId													OPTIONAL, -- Cond HOAndServCellAdd,
+	frequencyInfoDL						FrequencyInfoDL												OPTIONAL, -- Cond InterFreqHOAndServCellAdd
+	-- The initial downlink BWP configuration for a SpCell (PCell of MCG or SCG). 
+	initialDownlinkBWP					BWP-DownlinkCommon											OPTIONAL,	-- Cond ServCellAdd
+
+	uplinkConfigCommon					UplinkConfigCommon											OPTIONAL, -- Cond ServCellAdd-UL 
+	supplementaryUplinkConfig					UplinkConfigCommon									OPTIONAL, -- Cond ServCellAdd-SUL
+
+
+	-- Indicates the time domain positions of the transmitted SS-blocks in an SS-burst. The first/ leftmost bit corresponds to SS/PBCH 
+	-- block index 0, the second bit corresponds to SS/PBCH block index 1, and so on. Value 0 in the bitmap indicates that the 
+	-- corresponding SS/PBCH block is not transmitted while value 1 indicates that the corresponding SS/PBCH block is transmitted.
+	-- Corresponds to L1 parameter 'SSB-Transmitted' (see 38.213, section 4.1)
+	ssb-PositionsInBurst				CHOICE {
+		-- bitmap for sub 3 GHz
+		shortBitmap							BIT STRING (SIZE (4)),
+		-- bitmap for 3-6 GHz
+		mediumBitmap						BIT STRING (SIZE (8)),
+		-- bitmap for above 6 GHz
+		longBitmap							BIT STRING (SIZE (64))
+	}																								OPTIONAL, -- Need R,
+	-- The SSB periodicity in msec for the rate matching purpose. If the field is absent, the UE applies the value ms5.
+	-- (see 38.211, section [7.4.3.1])
+	ssb-periodicityServingCell			ENUMERATED { ms5, ms10, ms20, ms40, ms80, ms160, spare2, spare1 }			OPTIONAL,	-- Need S
+	-- Position of (first) DL DM-RS (see 38.211, section 7.4.1.1.1)
+	dmrs-TypeA-Position					ENUMERATED {pos2, pos3},
+
+	-- Parameters to determine an LTE CRS pattern that the UE shall rate match around.
+	lte-CRS-ToMatchAround					RateMatchPatternLTE-CRS  				OPTIONAL,	-- Need M
+
+	-- Resources patterns which the UE should rate match PDSCH around. The UE rate matches around the union of all resources 
+	-- indicated in the nested bitmaps. Rate match patterns defined here on cell level apply only to PDSCH of the same numerology.
+	-- Corresponds to L1 parameter 'Resource-set-cekk' (see 38.214, section 5.1.2.2.3)
+	rateMatchPatternToAddModList			SEQUENCE (SIZE (1..maxNrofRateMatchPatterns)) OF RateMatchPattern		OPTIONAL, -- Need N
+	rateMatchPatternToReleaseList			SEQUENCE (SIZE (1..maxNrofRateMatchPatterns)) OF RateMatchPatternId		OPTIONAL, -- Need N
+
+	-- Subcarrier spacing of SSB. Used only for non-initial access (e.g. SCells, PCell of SCG).
+	-- If the field is absent the UE shall assume the default value of the band. 
+	-- Only the values 15 or 30 kHz (<6GHz), 120 or 240 kHz (>6GHz) are applicable.
+	subcarrierSpacing				SubcarrierSpacing												OPTIONAL, -- Need S
+	-- A cell-specific TDD UL/DL configuration. Corresponds to L1 parameter 'UL-DL-configuration-common' (see 38.213, section 11.1)
+	tdd-UL-DL-ConfigurationCommon		TDD-UL-DL-ConfigCommon										OPTIONAL, -- Cond TDD
+	-- A second cell-specific TDD UL/DL configuration. When tdd-UL-DL-ConfigurationCommon2 is configured, the cell specific DL/UL 
+	-- pattern is a concatenation of the pattern specified in tdd-UL-DL-ConfigurationCommon and the pattern specified in 
+	-- tdd-UL-DL-ConfigurationCommon2. Corresponds to L1 parameter 'UL-DL-configuration-common-Set2' (see 38.211, section 11.1)
+	tdd-UL-DL-ConfigurationCommon2		TDD-UL-DL-ConfigCommon										OPTIONAL, -- Cond TDD
+	-- TX power that the NW used for SSB transmission. The UE uses it to estimate the RA preamble TX power. 
+	-- (see 38.213, section 7.4)
+	ss-PBCH-BlockPower					INTEGER (-60..50),
+	...
+}
+
+UplinkConfigCommon ::=				SEQUENCE {
+	-- Absolute uplink frequency configuration and subcarrier specific virtual carriers.
+	frequencyInfoUL						FrequencyInfoUL												OPTIONAL, -- Cond InterFreqHOAndServCellAdd
+	-- The initial uplink BWP configuration for a SpCell (PCell of MCG or SCG). Corresponds to L1 parameter 'initial-UL-BWP'. 
+	-- (see 38.331, section FFS_Section).
+	initialUplinkBWP			BWP-UplinkCommon													OPTIONAL	-- Cond ServCellAdd
+}
+
+-- TAG-SERVING-CELL-CONFIG-COMMON-STOP 
+-- TAG-SINR-RANGE-START
+
+SINR-Range ::=						INTEGER(0..127)
+
+-- TAG-SINR-RANGE-STOP
+-- TAG-SLOTFORMATCOMBINATIONSPERCELL-START
+
+-- The SlotFormatCombinations applicable for one serving cell. Corresponds to L1 parameter 'cell-to-SFI' (see 38.213, section 11.1.1)
+SlotFormatCombinationsPerCell ::=								SEQUENCE {
+	-- The ID of the serving cell for which the slotFormatCombinations are applicable
+	servingCellId								ServCellIndex,
+
+	-- Reference subcarrier spacing for this Slot Format Combination. Corresponds to L1 parameter 'SFI-scs' (see 38.213, section FFS_Section)
+	subcarrierSpacing							SubcarrierSpacing,
+	-- Reference subcarrier spacing for a Slot Format Combination on an FDD or SUL cell. 
+	-- Corresponds to L1 parameter 'SFI-scs2' (see 38.213, section FFS_Section).
+	-- For FDD, subcarrierSpacing (SFI-scs) is the reference SCS for DL BWP and subcarrierSpacing2 (SFI-scs2) is the reference SCS for UL BWP.
+	-- For SUL, subcarrierSpacing (SFI-scs) is the reference SCS for non-SUL carrier and subcarrierSpacing2 (SFI-scs2) is the reference 
+	-- SCS for SUL carrier. 
+	subcarrierSpacing2							SubcarrierSpacing															OPTIONAL,	-- Need R
+
+	-- A list with SlotFormatCombinations. Each SlotFormatCombination comprises of one or more SlotFormats (see 38.211, section 4.3.2)
+	-- FFS_CHECK: RAN1 indicates that the combinations could be of two different types... but they don't specify the second
+	slotFormatCombinations						SEQUENCE (SIZE (1..maxNrofSlotFormatCombinationsPerSet)) OF SlotFormatCombination	OPTIONAL,
+
+	-- The (starting) position (bit) of the slotFormatCombinationId (SFI-Index) for this serving cell (servingCellId) within the DCI payload. 
+	-- Corresponds to L1 parameter 'SFI-values' (see 38.213, section FFS_Section)
+	positionInDCI							INTEGER(0..maxSFI-DCI-PayloadSize-1)													OPTIONAL,
+	...
+}
+
+SlotFormatCombination ::= 					SEQUENCE {
+	-- This ID is used in the DCI payload to dynamically select this SlotFormatCombination.
+	-- Corresponds to L1 parameter 'SFI-index' (see 38.213, section FFS_Section)
+	slotFormatCombinationId						SlotFormatCombinationId,
+	-- Slot formats that occur in consecutive slots in time domain order as listed here. The the slot formats are 
+	-- defined in 38.211, table 4.3.2-3 and numbered with 0..255.
+	slotFormats									SEQUENCE (SIZE (1..maxNrofSlotFormatsPerCombination)) OF INTEGER (0..255)
+}
+
+-- SFI index that is assoicated with a certian slot-format-combination
+-- Corresponds to L1 parameter 'SFI-index' (see 38.213, section FFS_Section)
+SlotFormatCombinationId	::=					INTEGER (0..maxNrofSlotFormatCombinationsPerSet-1)
+
+-- TAG-SLOTFORMATCOMBINATIONSPERCELL-STOP
+-- TAG-SLOTFORMATINDICATOR-START
+
+SlotFormatIndicator ::= 		SEQUENCE {
+	-- RNTI used for SFI on the given cell
+	-- Corresponds to L1 parameter 'SFI-RNTI' (see 38.213, section 11.1.1)
+	sfi-RNTI						RNTI-Value,
+
+	-- Total length of the DCI payload scrambled with SFI-RNTI. 
+	-- Corresponds to L1 parameter 'SFI-DCI-payload-length' (see 38.213, section 11.1.1)
+	dci-PayloadSize					INTEGER (1..maxSFI-DCI-PayloadSize),
+
+	-- A list of SlotFormatCombinations for the UE's serving cells.
+	-- Corresponds to L1 parameter 'SFI-cell-to-SFI' (see 38.213, section 11.1.1)
+	slotFormatCombToAddModList		SEQUENCE (SIZE(1..maxNrofAggregatedCellsPerCellGroup)) OF SlotFormatCombinationsPerCell	OPTIONAL,	-- Need N
+	slotFormatCombToReleaseList		SEQUENCE (SIZE(1..maxNrofAggregatedCellsPerCellGroup)) OF ServCellIndex					OPTIONAL,	-- Need N
+	...
+}
+
+-- TAG-SLOTFORMATINDICATOR-STOP
+-- TAG-SPS-CONFIG-START
+
+-- Downlink SPS may be configured on the PCell as well as on SCells. But it shall not be configured for more than
+-- one serving cell of a cell group at once.
+SPS-Config ::= 							SEQUENCE {
+	-- Periodicity for DL SPS
+	-- Corresponds to L1 parameter 'semiPersistSchedIntervalDL' (see 38.214 and 38.321, section FFS_Section)
+	-- FFS-Value: Support also shorter periodicities for DL?
+	periodicity								ENUMERATED {ms10, ms20, ms32, ms40, ms64, ms80, ms128, ms160, ms320, ms640,
+														spare6, spare5, spare4, spare3, spare2, spare1},
+	-- Number of configured HARQ processes for SPS DL. Corresponds to L1 parameter 'numberOfConfSPS-Processes' (see 38.214, section FFS_Section)
+	nrofHARQ-Processes						INTEGER (1..8),
+	-- HARQ resource for PUCCH for DL SPS. The network configures the resource either as format0 or format1. (see 38.214, section FFS_Section)
+	n1PUCCH-AN									PUCCH-Resource																OPTIONAL	-- Need M
+}
+
+-- TAG-SPS-CONFIG-STOP
+-- TAG-SRB-IDENTITY-START
+
+SRB-Identity ::=					INTEGER (1..3)
+
+-- TAG-SRB-IDENTITY-STOP
+-- TAG-SRS-CONFIG-START
+
+SRS-Config ::= 							SEQUENCE {
+	srs-ResourceSetToReleaseList 			SEQUENCE (SIZE(0..maxNrofSRS-ResourceSets)) OF SRS-ResourceSetId			OPTIONAL, 	-- Need N
+	srs-ResourceSetToAddModList 			SEQUENCE (SIZE(0..maxNrofSRS-ResourceSets)) OF SRS-ResourceSet				OPTIONAL, 	-- Need N
+
+	srs-ResourceToReleaseList 	 			SEQUENCE (SIZE(1..maxNrofSRS-Resources)) OF SRS-ResourceId					OPTIONAL,	-- Need N
+	srs-ResourceToAddModList 	 			SEQUENCE (SIZE(1..maxNrofSRS-Resources)) OF SRS-Resource					OPTIONAL, 	-- Need N
+
+
+	-- If absent, UE applies TPC commands via accumulation. If disabled, UE applies the TPC command without accumulation 
+	-- (this applies to SRS when a separate closed loop is configured for SRS)
+	-- Corresponds to L1 parameter 'Accumulation-enabled-srs' (see 38,213, section 7.3)
+	tpc-Accumulation							ENUMERATED {disabled}													OPTIONAL,	-- Need S
+	...
+}
+
+SRS-ResourceSet ::= 					SEQUENCE {
+	-- The ID of this resource set. It is unique in the context of the BWP in which the parent SRS-Config is defined.
+	srs-ResourceSetId						SRS-ResourceSetId,
+	-- The IDs of the SRS-Reosurces used in this SRS-ResourceSet
+	srs-ResourceIdList						SEQUENCE (SIZE(1..maxNrofSRS-ResourcesPerSet)) OF SRS-ResourceId		OPTIONAL,	-- Cond Setup
+
+	resourceType							CHOICE {
+		aperiodic								SEQUENCE {
+			-- The DCI "code point" upon which the UE shall transmit SRS according to this SRS resource set configuration.
+			-- Corresponds to L1 parameter 'AperiodicSRS-ResourceTrigger' (see 38.214, section 6.1.1.2)
+			aperiodicSRS-ResourceTrigger			INTEGER (0..maxNrofSRS-TriggerStates-1),
+			-- ID of CSI-RS resource associated with this SRS resource set. (see 38.214, section 6.1.1.2)
+			csi-RS									NZP-CSI-RS-ResourceId,
+			-- An offset in number of slots between the triggering DCI and the actual transmission of this SRS-ResourceSet.
+			-- If the field is absent the UE applies no offset (value 0)
+			slotOffset								INTEGER (1..8)													OPTIONAL,	-- Need S
+			...
+		},
+		semi-persistent							SEQUENCE {
+			-- ID of CSI-RS resource associated with this SRS resource set in non-codebook based operation.
+			-- Corresponds to L1 parameter 'SRS-AssocCSIRS' (see 38.214, section 6.2.1)
+			associatedCSI-RS		NZP-CSI-RS-ResourceId															OPTIONAL, -- Cond nonCodebook
+			...
+		},
+		periodic								SEQUENCE {
+			-- ID of CSI-RS resource associated with this SRS resource set in non-codebook based operation.
+			-- Corresponds to L1 parameter 'SRS-AssocCSIRS' (see 38.214, section 6.2.1)
+			associatedCSI-RS		NZP-CSI-RS-ResourceId															OPTIONAL, -- Cond nonCodebook
+			...
+		}
+	},
+	-- Indicates if the SRS resource set is used for beam management vs. used for either codebook based or non-codebook based transmission.
+	-- Corresponds to L1 parameter 'SRS-SetUse' (see 38.214, section 6.2.1)
+	-- FFS_CHECK: Isn't codebook/noncodebook already known from the ulTxConfig in the SRS-Config? If so, isn't the only distinction 
+	-- in the set between BeamManagement, AtennaSwitching and "Other”? Or what happens if SRS-Config=Codebook but a Set=NonCodebook?
+	usage									ENUMERATED {beamManagement, codebook, nonCodebook, antennaSwitching},
+
+	-- alpha value for SRS power control. Corresponds to L1 parameter 'alpha-srs' (see 38.213, section 7.3)
+	-- When the field is absent the UE applies the value 1
+	alpha									Alpha																		OPTIONAL, -- Need S
+	-- P0 value for SRS power control. The value is in dBm. Only even values (step size 2) are allowed.
+	-- Corresponds to L1 parameter 'p0-srs' (see 38.213, section 7.3)
+	p0										INTEGER (-202..24)															OPTIONAL, -- Cond Setup
+	-- A reference signal (e.g. a CSI-RS config or a SSblock) to be used for SRS path loss estimation. 
+	-- Corresponds to L1 parameter 'srs-pathlossReference-rs-config' (see 38.213, section 7.3)
+	pathlossReferenceRS						CHOICE {
+		ssb-Index								SSB-Index,
+		csi-RS-Index							NZP-CSI-RS-ResourceId
+	}																													OPTIONAL, -- Need M
+	-- Indicates whether hsrs,c(i) = fc(i,1) or hsrs,c(i) = fc(i,2) (if twoPUSCH-PC-AdjustmentStates are configured) 
+	-- or serarate close loop is configured for SRS. This parameter is applicable only for Uls on which UE also transmits PUSCH.
+	-- If absent or release, the UE applies the value sameAs-Fci1
+	-- Corresponds to L1 parameter 'srs-pcadjustment-state-config' (see 38.213, section 7.3)
+	srs-PowerControlAdjustmentStates		ENUMERATED { sameAsFci2, separateClosedLoop}					OPTIONAL, -- Need S
+	...
+}
+
+SRS-ResourceSetId ::= 					INTEGER (0..maxNrofSRS-ResourceSets-1)
+
+SRS-Resource ::= 						SEQUENCE {
+	srs-ResourceId							SRS-ResourceId,
+	nrofSRS-Ports							ENUMERATED {port1, ports2, ports4},
+	-- The PTRS port index for this SRS resource for non-codebook based UL MIMO. This is only applicable when the corresponding 
+	-- PTRS-UplinkConfig is set to CP-OFDM. The ptrs-PortIndex configured here must be smaller than or equal to the maxNnrofPorts  
+	-- configured in the PTRS-UplinkConfig.
+	-- Corresponds to L1 parameter 'UL-PTRS-SRS-mapping-non-CB' (see 38.214, section 6.1)
+	ptrs-PortIndex							ENUMERATED {n0, n1 }														OPTIONAL,	-- Need R  
+	-- Comb value (2 or 4) and comb offset (0..combValue-1). Corresponds to L1 parameter 'SRS-TransmissionComb' (see 38.214, section 6.2.1)
+	transmissionComb						CHOICE {
+		n2										SEQUENCE {
+			combOffset-n2							INTEGER (0..1),
+			-- Cyclic shift configuration. Corresponds to L1 parameter 'SRS-CyclicShiftConfig' (see 38.214, section 6.2.1)
+			cyclicShift-n2							INTEGER (0..7)
+		}, 
+		n4										SEQUENCE {
+			combOffset-n4							INTEGER (0..3),
+			-- Cyclic shift configuration. Corresponds to L1 parameter 'SRS-CyclicShiftConfig' (see 38.214, section 6.2.1)
+			cyclicShift-n4							INTEGER (0..11)
+		}
+	},
+	-- OFDM symbol location of the SRS resource within a slot including number of OFDM symbols (N = 1, 2 or 4 per SRS resource),
+	-- startPosition (SRSSymbolStartPosition = 0..5; "0" refers to the last symbol, "1" refers to the second last symbol) and 
+	-- RepetitionFactor (r = 1, 2 or 4).	
+	-- Corresponds to L1 parameter 'SRS-ResourceMapping' (see 38.214, section 6.2.1 and 38.211, section 6.4.1.4). 
+	-- FFS: Apparently, RAN1 considers replacing these three fields by a table in RAN1 specs and a corresponding index in ASN.1?!
+	resourceMapping							SEQUENCE {
+		startPosition							INTEGER (0..5),
+		nrofSymbols								ENUMERATED {n1, n2, n4},
+		repetitionFactor						ENUMERATED {n1, n2, n4}
+	},
+	-- Parameter(s) defining frequency domain position and configurable shift to align SRS allocation to 4 PRB grid.
+	-- Corresponds to L1 parameter 'SRS-FreqDomainPosition' (see 38.214, section 6.2.1)
+	freqDomainPosition						INTEGER (0..67),
+	freqDomainShift							INTEGER (0..268), 
+	-- Includes  parameters capturing SRS frequency hopping 
+	-- Corresponds to L1 parameter 'SRS-FreqHopping' (see 38.214, section 6.2.1)
+	freqHopping								SEQUENCE {
+		c-SRS									INTEGER (0..63),
+		b-SRS									INTEGER (0..3), 
+		b-hop									INTEGER (0..3)
+	},
+	-- Parameter(s) for configuring group or sequence hopping
+	-- Corresponds to L1 parameter 'SRS-GroupSequenceHopping' (see 38.211, section FFS_Section)
+	groupOrSequenceHopping					ENUMERATED { neither, groupHopping, sequenceHopping },
+	-- Time domain behavior of SRS resource configuration.  
+	-- Corresponds to L1 parameter 'SRS-ResourceConfigType' (see 38.214, section 6.2.1).
+	-- For codebook based uplink transmission, the network configures SRS resources in the same resource set with the same 
+	-- time domain behavior on periodic, aperiodic and semi-persistent SRS.
+	-- FFS: Add configuration parameters for the different SRS resource types?
+	resourceType							CHOICE {
+		aperiodic								SEQUENCE {
+			...
+		}, 
+		semi-persistent							SEQUENCE {
+			-- Periodicity and slot offset for for this SRS resource. All values in "number of slots".
+			-- sl1 corresponds to a periodicity of 1 slot, value sl2 corresponds to a periodicity of 2 slots, and so on. 
+			-- For each periodicity the corresponding offset is given in number of slots. For periodicity sl1 the offset is 0 slots.   
+			-- Corresponds to L1 parameter 'SRS-SlotConfig' (see 38.214, section 6.2.1)
+			periodicityAndOffset-sp						SRS-PeriodicityAndOffset,
+			...
+		},
+		periodic								SEQUENCE {
+			-- Periodicity and slot offset for for this SRS resource. All values in "number of slots" 
+			-- sl1 corresponds to a periodicity of 1 slot, value sl2 corresponds to a periodicity of 2 slots, and so on. 
+			-- For each periodicity the corresponding offset is given in number of slots. For periodicity sl1 the offset is 0 slots.   
+			-- Corresponds to L1 parameter 'SRS-SlotConfig' (see 38.214, section 6.2.1)
+			periodicityAndOffset-p						SRS-PeriodicityAndOffset,
+			...
+		}
+	},
+	-- Sequence ID used to initialize psedo random group and sequence hopping. 
+	-- Corresponds to L1 parameter 'SRS-SequenceId' (see 38.214, section 6.2.1)
+	sequenceId								BIT STRING (SIZE (10)),
+
+	-- Configuration of the spatial relation between a reference RS and the target SRS. Reference RS can be SSB/CSI-RS/SRS
+	-- Corresponds to L1 parameter 'SRS-SpatialRelationInfo' (see 38.214, section 6.2.1)
+	spatialRelationInfo						CHOICE {
+		ssb-Index								SSB-Index,
+		csi-RS-Index									NZP-CSI-RS-ResourceId,
+		srs										SRS-ResourceId
+	}																													OPTIONAL,	-- Need R
+	...
+}
+
+SRS-ResourceId ::= 						INTEGER (0..maxNrofSRS-Resources-1)
+
+SRS-PeriodicityAndOffset ::=			CHOICE {
+	sl1										NULL, 
+	sl2										INTEGER(0..1), 
+	sl4										INTEGER(0..3), 
+	sl5										INTEGER(0..4), 
+	sl8										INTEGER(0..7), 
+	sl10									INTEGER(0..9), 
+	sl16									INTEGER(0..15), 
+	sl20									INTEGER(0..19), 
+	sl32									INTEGER(0..31), 
+	sl40									INTEGER(0..39), 
+	sl64									INTEGER(0..63), 
+	sl80									INTEGER(0..79), 
+	sl160									INTEGER(0..159), 
+	sl320									INTEGER(0..319),
+	sl640									INTEGER(0..639),
+	sl1280									INTEGER(0..1279),
+	sl2560									INTEGER(0..2559)
+}
+
+-- TAG-SRS-CONFIG-STOP
+-- TAG-SRS-CARRIERSWITCHING-START
+SRS-CarrierSwitching ::=				SEQUENCE {
+
+	-- Indicates the serving cell whose UL transmission may be interrupted during SRS transmission on a PUSCH-less cell. 
+	-- During SRS transmission on a PUSCH-less cell, the UE may temporarily suspend the UL transmission on a serving cell with PUSCH 
+	-- in the same CG to allow the PUSCH-less cell to transmit SRS. (see 38.214, section 6.2.1.3)
+	srs-SwitchFromServCellIndex				INTEGER (0..31)																OPTIONAL,	-- Cond Setup
+
+	-- Network configures the UE with either typeA-SRS-TPC-PDCCH-Group or typeB-SRS-TPC-PDCCH-Group, if any.
+	srs-TPC-PDCCH-Group					CHOICE {
+		-- Type A trigger configuration for SRS transmission on a PUSCH-less SCell. 
+		-- Corresponds to L1 parameter 'typeA-SRS-TPC-PDCCH-Group' (see 38.212, 38.213, section 7.3.1, 11.3)
+		typeA								SEQUENCE (SIZE (1..32)) OF SRS-TPC-PDCCH-Config,
+		-- Type B trigger configuration for SRS transmission on a PUSCH-less SCell. 
+		-- Corresponds to L1 parameter 'typeB-SRS-TPC-PDCCH-Config' (see 38.212, 38.213, section 7.3.1, 11.3)
+		typeB								SRS-TPC-PDCCH-Config
+	}																													OPTIONAL, 	-- Cond Setup
+
+	-- Maps a specific cell to a given SFI value within the DCI message
+	-- Corresponds to L1 parameter 'SRS-cell-to-SFI' (see 38.212, 38.213, section 7.3.1, 11.3)
+	srs-CellToSFI						SEQUENCE (SIZE (1..maxNrofServingCells)) OF SlotFormatCombinationsPerCell			OPTIONAL, 	-- Cond Setup
+	
+	-- A set of serving cells for monitoring PDCCH conveying SRS DCI format with CRC scrambled by TPC-SRS-RNTI
+	-- Corresponds to L1 parameter 'SRS-monitoring-cells' (see 38.212, 38.213, section 7.3.1, 11.3)
+	monitoringCells		SEQUENCE (SIZE (1..maxNrofServingCells)) OF ServCellIndex						OPTIONAL,	-- Cond Setup
+	...
+}
+
+-- One trigger configuration for SRS-Carrier Switching. (see 38.212, 38.213, section 7.3.1, 11.3)
+SRS-TPC-PDCCH-Config ::=				SEQUENCE {
+	-- The starting bit position of a block within the group DCI with SRS request fields (optional) and TPC commands 
+	-- for a PUSCH-less SCell. (see 38.212, 38.213, section 7.3.1, 11.3)
+	startingBitOfFormat2-3					INTEGER (1..31)																OPTIONAL, 	-- Cond Setup
+	-- The type of a field within the group DCI with SRS request fields (optional) for a PUSCH-less SCell, 
+	-- which indicates how many bits in the field are for SRS request (0 or 1/2). 
+	-- Note that for Type A, there is a common SRS request field for all SCells in the set, but each SCell has its 
+	-- own TPC command bits. See TS 38.212. Network configures this field with the same value for all PUSCH-less SCells.
+	-- (see 38.212, 38.213, section 7.3.1, 11.3)
+	fieldTypeFormat2-3						INTEGER (0..1)																OPTIONAL, 	-- Cond Setup
+	-- A list of paris of [cc-SetIndex; cc-IndexInOneCC-Set] (see 38.212, 38.213, section 7.3.1, 11.3)
+	-- FFS: Improve description. What is a "CC"? Where is a CC-Set defined? ...
+	srs-CC-SetIndexlist						SEQUENCE (SIZE(1..4)) OF SRS-CC-SetIndex 									OPTIONAL	-- Cond Setup
+}
+
+SRS-CC-SetIndex ::=						SEQUENCE {
+	-- Indicates the CC set index for Type A associated (see 38.212, 38.213, section 7.3.1, 11.3)
+	cc-SetIndex								INTEGER (0..3)															OPTIONAL, 	-- Cond Setup
+	-- Indicates the CC index in one CC set for Type A (see 38.212, 38.213, section 7.3.1, 11.3)
+	cc-IndexInOneCC-Set						INTEGER (0..7)															OPTIONAL		-- Cond Setup
+}
+
+-- TAG-SRS-CARRIERSWITCHING-STOP
+-- TAG-SSB-INDEX-START
+
+SSB-Index ::=								INTEGER (0..63)
+
+-- TAG-SSB-INDEX-STOP
+-- TAG-SUBCARRIER-SPACING-START
+
+-- The subcarrier spacing supported in NR. Restrictions applicable for certain frequencies, channels or signals are clarified 
+-- in the fields that use this IE.
+SubcarrierSpacing ::= 					ENUMERATED {kHz15, kHz30, kHz60, kHz120, kHz240, spare3, spare2, spare1}
+
+
+-- TAG-SUBCARRIER-SPACING-STOP
+-- TAG-TCI-STATE-START
+
+TCI-State ::= 				SEQUENCE {
+	tci-StateId					TCI-StateId,
+	qcl-Type1					QCL-Info,
+	qcl-Type2					QCL-Info																					OPTIONAL,	-- Need R
+	nrofPTRS-Ports				ENUMERATED {n1, n2}																			OPTIONAL,	-- Need R
+	...
+}
+
+QCL-Info ::=				SEQUENCE {
+
+	-- The carrier which the RS is located in. If the field is absent, it applies to the serving cell in which the TCI-State is configured
+	cell						ServCellIndex																				OPTIONAL,	-- Need R
+
+	-- The DL BWP which the RS is located in. 
+	bwp-Id						BWP-Id			OPTIONAL, -- Cond CSI-RS-Indicated
+	-- Cond NZP-CSI-RS-Indicated: mandatory if csi-rs or csi-RS-for-tracking is included, absent otherwise
+	referenceSignal				CHOICE {
+		csi-rs						NZP-CSI-RS-ResourceId,
+		ssb							SSB-Index,
+		-- A set of CSI-RS resources for tracking
+		csi-RS-for-tracking			NZP-CSI-RS-ResourceSetId
+	},
+	qcl-Type					ENUMERATED {typeA, typeB, typeC, typeD},
+	...
+}
+
+-- TAG-TCI-STATE-STOP
+-- TAG-TCI-STATEID-START
+
+TCI-StateId ::=				INTEGER (0..maxNrofTCI-States-1)
+
+-- TAG-TCI-STATEID-STOP
+-- TAG-TDD-UL-DL-CONFIG-START
+
+TDD-UL-DL-ConfigCommon ::=			SEQUENCE {
+	-- Reference SCS used to determine the time domain boundaries in the UL-DL pattern which must be common across all subcarrier specific
+	-- virtual carriers, i.e., independent of the actual subcarrier spacing using for data transmission. 
+	-- Only the values 15 or 30 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are applicable.
+	-- Corresponds to L1 parameter 'reference-SCS' (see 38.211, section FFS_Section)
+	referenceSubcarrierSpacing			SubcarrierSpacing																	OPTIONAL,
+	-- Periodicity of the DL-UL pattern. Corresponds to L1 parameter 'DL-UL-transmission-periodicity' (see 38.211, section FFS_Section)
+	dl-UL-TransmissionPeriodicity		ENUMERATED {ms0p5, ms0p625, ms1, ms1p25, ms2, ms2p5, ms5, ms10}						OPTIONAL,
+
+	-- Number of consecutive full DL slots at the beginning of each DL-UL pattern. 
+	-- Corresponds to L1 parameter 'number-of-DL-slots' (see 38.211, Table 4.3.2-1)
+	nrofDownlinkSlots					INTEGER (0..maxNrofSlots)																	OPTIONAL,
+
+	-- Number of consecutive DL symbols in the beginning of the slot following the last full DL slot (as derived from nrofDownlinkSlots). 
+	-- If the field is absent or released, there is no partial-downlink slot.
+	-- Corresponds to L1 parameter 'number-of-DL-symbols-common' (see 38.211, section FFS_Section).
+	nrofDownlinkSymbols					INTEGER (0..maxNrofSymbols-1)															OPTIONAL,	-- Need R
+	
+	-- Number of consecutive full UL slots at the end of each DL-UL pattern. 
+	-- Corresponds to L1 parameter 'number-of-UL-slots' (see 38.211, Table 4.3.2-1)
+	nrofUplinkSlots						INTEGER (0..maxNrofSlots)																	OPTIONAL,
+	
+	-- Number of consecutive UL symbols in the end of the slot preceding the first full UL slot (as derived from nrofUplinkSlots).
+	-- If the field is absent or released, there is no partial-uplink slot.
+	-- Corresponds to L1 parameter 'number-of-UL-symbols-common' (see 38.211, section FFS_Section)
+	nrofUplinkSymbols					INTEGER (0..maxNrofSymbols-1)															OPTIONAL	-- Need R
+}
+
+TDD-UL-DL-ConfigDedicated ::=		SEQUENCE {
+	-- The slotSpecificConfiguration allows overriding UL/DL allocations provided in tdd-UL-DL-configurationCommon. 
+	-- FFS_ASN1: Consider making this an AddMod/Release list
+	-- FFS_ASN1: Replace absolute numbers by variables... once RAN1 confirms. 
+	-- FFS_CHECK: This list will grow very large if used for many slots.
+	slotSpecificConfigurationsToAddModList		SEQUENCE (SIZE (1..maxNrofSlots)) OF TDD-UL-DL-SlotConfig							OPTIONAL, -- Need N
+	slotSpecificConfigurationsToreleaseList		SEQUENCE (SIZE (1..maxNrofSlots)) OF TDD-UL-DL-SlotIndex						OPTIONAL -- Need N
+}
+
+TDD-UL-DL-SlotConfig ::=			SEQUENCE {
+	-- Identifies a slot within a dl-UL-TransmissionPeriodicity (given in tdd-UL-DL-configurationCommon)
+	slotIndex							TDD-UL-DL-SlotIndex,
+		
+	-- The direction (downlink or uplink) for the symbols in this slot. "allDownlink" indicates that all symbols in this slot are used
+	-- for downlink; "allUplink" indicates that all symbols in this slot are used for uplink; "explicit" indicates explicitly how many symbols 
+	-- in the beginning and end of this slot are allocated to downlink and uplink, respectively.
+	symbols								CHOICE {
+		allDownlink							NULL,
+		allUplink							NULL,
+		explicit							SEQUENCE {
+			-- Number of consecutive DL symbols in the beginning of the slot identified by slotIndex.
+			-- If the field is absent the UE assumes that there are no leading DL symbols.
+			-- Corresponds to L1 parameter 'number-of-DL-symbols-dedicated' (see 38.211, section FFS_Section)
+			nrofDownlinkSymbols					INTEGER (1..maxNrofSymbols-1)												OPTIONAL,	-- Need S
+			
+			-- Number of consecutive UL symbols in the end of the slot identified by slotIndex.
+			-- If the field is absent the UE assumes that there are no trailing UL symbols.
+			-- Corresponds to L1 parameter 'number-of-UL-symbols-dedicated' (see 38.211, section FFS_Section)
+			nrofUplinkSymbols					INTEGER (1..maxNrofSymbols-1)												OPTIONAL	-- Need S
+		}
+	}
+}
+
+TDD-UL-DL-SlotIndex ::=				INTEGER (0..maxNrofSlots-1)
+
+-- TAG-TDD-UL-DL-CONFIG-STOP
+
+TimeToTrigger ::=					ENUMERATED {
+										ms0, ms40, ms64, ms80, ms100, ms128, ms160, ms256,
+										ms320, ms480, ms512, ms640, ms1024, ms1280, ms2560,
+										ms5120}
+
+-- TAG-ZP-CSI-RS-RESOURCE-START
+
+ZP-CSI-RS-Resource ::=						SEQUENCE {
+	-- ZP CSI-RS resource configuration ID
+	-- Corresponds to L1 parameter 'ZP-CSI-RS-ResourceConfigId' (see 38.214, section 5.1.4.2)
+	zp-CSI-RS-ResourceId						ZP-CSI-RS-ResourceId,
+	-- OFDM symbol and subcarrier occupancy of the ZP-CSI-RS resource within a slot
+	resourceMapping								CSI-RS-ResourceMapping,
+	-- Periodicity and slot offset for periodic/semi-persistent ZP-CSI-RS
+	-- Corresponds to L1 parameter 'ZP-CSI-RS-timeConfig' (see 38.214, section 5.1.4.2)
+	periodicityAndOffset						CSI-ResourcePeriodicityAndOffset							OPTIONAL, --Cond PeriodicOrSemiPersistent
+
+	...
+}
+
+ZP-CSI-RS-ResourceId ::=							INTEGER (0..maxNrofZP-CSI-RS-Resources-1)
+
+-- TAG-ZP-CSI-RS-RESOURCE-STOP
+-- TAG-ZP-CSI-RS-RESOURCESET-START
+
+ZP-CSI-RS-ResourceSet ::= 						SEQUENCE {
+	zp-CSI-RS-ResourceSetId							ZP-CSI-RS-ResourceSetId,
+	-- The list of ZP-CSI-RS-ResourceId identifying the ZP-CSI-RS-Resource elements belonging to this set. 
+	zp-CSI-RS-ResourceIdList							SEQUENCE (SIZE(1..maxNrofZP-CSI-RS-ResourcesPerSet)) OF ZP-CSI-RS-ResourceId,
+	-- Time domain behavior of ZP-CSI-RS resource configuration. 
+	-- Corresponds to L1 parameter 'ZP-CSI-RS-ResourceConfigType' (see 38.214, section 5.1.4.2)
+	resourceType									ENUMERATED {aperiodic, semiPersistent, periodic},
+	...
+}
+
+-- TAG-ZP-CSI-RS-RESOURCESET-STOP
+-- TAG-ZP-CSI-RS-RESOURCESETID-START
+
+ZP-CSI-RS-ResourceSetId ::= 					INTEGER (0..maxNrofZP-CSI-RS-ResourceSets-1)
+
+-- TAG-ZP-CSI-RS-RESOURCESETID-STOP
+-- TAG-BANDCOMBINATIONLIST-START
+
+BandCombinationList ::=	SEQUENCE (SIZE (1..maxBandComb)) OF BandCombination
+
+BandCombination ::= SEQUENCE {
+	bandAndDL-ParametersList			BandAndDL-ParametersList,
+	bandCombinationsUL					BIT STRING (SIZE (1.. maxBandComb)),
+	bandCombinationParametersList		SEQUENCE (SIZE (1..maxBandComb)) OF BandCombinationParameters 	OPTIONAL
+}
+
+BandAndDL-ParametersList ::= SEQUENCE (SIZE (1..maxSimultaneousBands)) OF BandAndDL-Parameters
+
+BandAndDL-Parameters ::= CHOICE {
+	bandAndDL-ParametersEUTRA	BandAndDL-ParametersEUTRA,
+	bandAndDL-ParametersNR		BandAndDL-ParametersNR
+}
+BandCombinationParameters ::= SEQUENCE {
+	ca-ParametersNR					CA-ParametersNR			OPTIONAL,
+	mrdc-Parameters					MRDC-Parameters			OPTIONAL
+}
+
+CA-ParametersNR ::=	SEQUENCE {
+	multipleTimingAdvances		ENUMERATED {supported}				OPTIONAL,
+-- R4 2-5: Simultaneous reception and transmission for inter band CA (TDD-TDD or TDD-FDD)
+	simultaneousRxTxInterBandCA			ENUMERATED {supported}		OPTIONAL,
+-- BCS related to R4 2-1 and Updated CA BW class in R4-1803374
+	supportedBandwidthCombinationSet	BIT STRING (SIZE (1..32))	OPTIONAL
+}
+
+MRDC-Parameters ::=	SEQUENCE {
+	singleUL-Transmission		ENUMERATED {supported}		OPTIONAL,
+-- R4 1-10: Support of EN-DC with LTE-NR coexistence in UL sharing from UE perspective
+	ul-SharingEUTRA-NR					ENUMERATED {supported}		OPTIONAL,
+-- R4 1-11: Switching time between LTE UL and NR UL for EN-DC with LTE-NR coexistence in UL sharing from UE perspective
+	ul-SwitchingTimeEUTRA-NR			ENUMERATED {type1, type2}	OPTIONAL,
+-- R4 2-4: Simultaneous reception and transmission for inter-band EN-DC (TDD-TDD or TDD-FDD)
+	simultaneousRxTxInterBandENDC		ENUMERATED {supported}		OPTIONAL,
+-- R4 2-6: Asynchronous FDD-FDD intra-band EN-DC
+	asyncIntraBandENDC					ENUMERATED {supported}		OPTIONAL,
+	basebandProcesingCombinationMRDC 	BasebandProcessingCombinationMRDC
+}
+
+BandAndDL-ParametersEUTRA ::= SEQUENCE {
+	bandEUTRA					FreqBandIndicatorEUTRA,
+	ca-BandwidthClassDL-EUTRA	CA-BandwidthClassEUTRA		OPTIONAL,
+	intraBandContiguousCC-InfoDL-EUTRA-List		SEQUENCE (SIZE (1.. maxNrofServingCellsEUTRA)) OF IntraBandContiguousCC-InfoDL-EUTRA		OPTIONAL
+}
+
+BandAndDL-ParametersNR ::= SEQUENCE {
+	bandNR						FreqBandIndicatorNR,
+	ca-BandwidthClassDL			CA-BandwidthClassNR			OPTIONAL,
+-- R4 2-3: Non-contiguous intra-band CA frequency separation class for FR2 as in the RAN4 LS R4-1803363
+	intraBandFreqSeparationDL	FreqSeparationClass					OPTIONAL,
+	intraBandContiguousCC-InfoDL-List		SEQUENCE (SIZE (1.. maxNrofServingCells)) OF IntraBandContiguousCC-InfoDL		OPTIONAL
+}
+
+IntraBandContiguousCC-InfoDL ::=	SEQUENCE {
+-- Related to RAN4 LS R2-1804078
+	maxNumberMIMO-LayersPDSCH			MIMO-LayersDL					OPTIONAL
+}
+
+IntraBandContiguousCC-InfoDL-EUTRA ::=	SEQUENCE {
+-- Related to RAN4 LS R2-1804078
+	mimo-CapabilityDL					ENUMERATED {twoLayers, fourLayers, eightLayers}					OPTIONAL
+}
+
+-- TAG-BANDCOMBINATIONLIST-STOP
+-- TAG-BANDCOMBINATIONPARAMETERSULLIST-START
+
+BandCombinationParametersUL-List ::= SEQUENCE (SIZE (1..maxBandComb)) OF BandCombinationParametersUL
+
+BandCombinationParametersUL ::= SEQUENCE (SIZE (1.. maxSimultaneousBands)) OF BandParametersUL
+
+BandParametersUL ::= CHOICE {
+	bandParametersUL-EUTRA		BandParametersUL-EUTRA,
+	bandParametersUL-NR			BandParametersUL-NR
+}
+
+BandParametersUL-EUTRA ::= SEQUENCE {
+	ca-BandwidthClassUL-EUTRA	CA-BandwidthClassEUTRA		OPTIONAL,
+	intraBandContiguousCC-InfoUL-EUTRA-List		SEQUENCE (SIZE (1.. maxNrofServingCellsEUTRA)) OF IntraBandContiguousCC-InfoUL-EUTRA		OPTIONAL
+}
+
+BandParametersUL-NR ::= SEQUENCE {
+	ca-BandwidthClassUL			CA-BandwidthClassNR 				OPTIONAL,
+-- R4 2-3: Non-contiguous intra-band CA frequency separation class for FR2 as in the RAN4 LS R4-1803363
+	intraBandFreqSeparationUL	FreqSeparationClass					OPTIONAL,
+	intraBandContiguousCC-InfoUL-List		SEQUENCE (SIZE (1.. maxNrofServingCells)) OF IntraBandContiguousCC-InfoUL			OPTIONAL
+}
+
+IntraBandContiguousCC-InfoUL ::=	SEQUENCE {
+-- Related to RAN4 LS R2-1804078
+	maxNumberMIMO-LayersCB-PUSCH		MIMO-LayersUL					OPTIONAL,
+	maxNumberMIMO-LayersNonCB-PUSCH		MIMO-LayersUL					OPTIONAL
+}
+
+IntraBandContiguousCC-InfoUL-EUTRA ::=	SEQUENCE {
+-- Related to RAN4 LS R2-1804078
+	mimo-CapabilityUL						ENUMERATED {twoLayers, fourLayers}					OPTIONAL
+}
+
+-- TAG-BANDCOMBINATIONPARAMETERSULLIST-STOP
+-- TAG-BASEBANDCOMBINATIONPARAMETERSULLIST-START
+
+BasebandCombinationParametersUL-List ::= SEQUENCE (SIZE (1..maxBasebandProcComb)) OF BasebandCombinationParametersUL
+
+BasebandCombinationParametersUL ::= SEQUENCE (SIZE (1..maxSimultaneousBands)) OF BasebandParametersPerBandUL
+
+BasebandParametersPerBandUL ::= SEQUENCE {
+	ca-BandwidthClassUL				CA-BandwidthClassNR,
+	freqRange						ENUMERATED {fr1, fr2},
+	basebandParametersPerCC-UL		SEQUENCE (SIZE (1.. maxNrofServingCells)) OF BasebandParametersPerCC-UL
+}
+
+BasebandParametersPerCC-UL ::= SEQUENCE {
+-- R4 2-2: Simultaneous reception or transmission with same or  different numerologies in CA
+-- It is expressed by the combination of SCS whether simultaneous RxTx is supported or not.
+	supportedSubcarrierSpacingUL				SubcarrierSpacing,
+-- Accoding to the RAN4 LS R4-1803563, maximum Bandwidth supported per CC is added in BPC
+-- FFS how to work together with BCS and max BW for each CC to be defined for each CA band combination in the RAN4 spec.
+	supportedBandwidthUL		CHOICE {
+		fr1							ENUMERATED {mhz5, mhz10, mhz15, mhz20, mhz25, mhz30, mhz40, mhz50, mhz60, mhz80, mhz100},
+		fr2							ENUMERATED {mhz50, mhz100, mhz200, mhz400}
+	},
+	-- R2-1800012. To be confirmed by RAN1
+	scalingFactor0dot75				ENUMERATED {supported}		OPTIONAL,
+-- R1 2-14: Codebook based PUSCH MIMO transmission. Absence of this field implies that CB-based PUSCH is not supported.
+	maxNumberMIMO-LayersCB-PUSCH		MIMO-LayersUL					OPTIONAL,
+-- R1 2-15: Non-codebook based PUSCH MIMO transmission. Absence of this field implies that Non-CB-based PUSCH is not supported.
+	maxNumberMIMO-LayersNonCB-PUSCH		MIMO-LayersUL					OPTIONAL,
+-- Accoding to the RAN4 LS R4-1803563, modulation order is added per CC granularity in BPC
+-- FFS whether all of modulation order specified in the spec need to be signalled.
+-- FFS how to address the requirements agreed by RAN4, e.g. mandaotry w/o capabiltiy for 64QAM. mandaotry with capabiltiy for DL 256QAM in FR1.
+	supportedModulationOrderUL					ModulationOrder					OPTIONAL,
+-- R1 2-53: SRS resources
+	supportedSRS-Resources			SRS-Resources								OPTIONAL,
+-- R1 2-55: SRS Tx switch
+	srs-TxSwitch					SRS-TxSwitch								OPTIONAL,
+-- R1 2-57: Support low latency CSI feedback
+	lowLatencyCSI-Feedback				ENUMERATED {supported}					OPTIONAL,
+-- R1 5-12 & 5-12a: Up to 2/7 PUSCHs per slot for different TBs
+	pusch-DifferentTB-PerSlot		SEQUENCE {
+		scs-15kHz						ENUMERATED {upto2, upto7}					OPTIONAL,
+		scs-30kHz						ENUMERATED {upto2, upto7}					OPTIONAL,
+		scs-60kHz						ENUMERATED {upto2, upto7}					OPTIONAL,
+		scs-120kHz						ENUMERATED {upto2, upto7}					OPTIONAL
+	}																			OPTIONAL,
+-- R1 6-7: Two PUCCH group
+	twoPUCCH-Group					ENUMERATED {supported}						OPTIONAL,
+-- R1 6-8: Different numerology across PUCCH groups
+	diffNumerologyAcrossPUCCH-Group	ENUMERATED {supported}						OPTIONAL,
+-- R1 6-9: Different numerologies across carriers within the same PUCCH group
+	diffNumerologyWithinPUCCH-Group	ENUMERATED {supported}						OPTIONAL,
+-- R1 6-10: Cross carrier scheduling
+	crossCarrierScheduling			ENUMERATED {supported}						OPTIONAL,
+-- R1 6-11: Number of supported TAGs
+	supportedNumberTAG				ENUMERATED {n2, n3, n4}						OPTIONAL,
+-- R1 6-18: Supplemental uplink with dynamic switch
+	dynamicSwitchSUL				ENUMERATED {supported}						OPTIONAL,
+-- R1 6-19: Simultaneous transmission of SRS on an SUL/non-SUL carrier and PUSCH/PUCCH/SRS/PRACH on the other UL carrier in the same cell
+-- Details on the channel/signal combination are to be described in TS 38.306
+	simultaneousTxSUL-NonSUL		ENUMERATED {supported}						OPTIONAL,
+-- R1 6-22: UL search space sharing for CA
+	searchSpaceSharingCA-UL			ENUMERATED {supported}						OPTIONAL
+}
+
+-- TAG-BASEBANDCOMBINATIONPARAMETERSULLIST-STOP
+-- TAG-BASEBANDPROCESSINGCOMBINATIONMRDC-START
+
+BasebandProcessingCombinationMRDC ::= SEQUENCE (SIZE (1..maxBasebandProcComb)) OF BasebandProcessingCombinationLink
+
+BasebandProcessingCombinationLink ::= SEQUENCE {
+	basebandProcessingCombinationIndexMN		BasebandProcessingCombinationIndex, 
+	basebandProcessingCombinationLinkedIndexSN	SEQUENCE (SIZE (1..maxBasebandProcComb)) OF BasebandProcessingCombinationIndex
+}
+
+BasebandProcessingCombinationIndex ::= INTEGER (1..maxBasebandProcComb)
+
+-- TAG-BASEBANDPROCESSINGCOMBINATIONMRDC-STOP
+-- TAG-CA-BANDWIDTHCLASSNR-START
+
+-- Updated based on R4-1803374
+CA-BandwidthClassNR ::= ENUMERATED {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, ...}
+
+-- TAG-CA-BANDWIDTHCLASSNR-STOP
+-- TAG-CA-BANDWIDTHCLASSEUTRA-START
+
+CA-BandwidthClassEUTRA ::=	ENUMERATED {a, b, c, d, e, f, ...}
+
+-- TAG-CA-BANDWIDTHCLASSEUTRA-STOP
+-- TAG-FREQ-BAND-INDICATOR-EUTRA-START
+
+FreqBandIndicatorEUTRA ::=	INTEGER (1..maxBandsEUTRA)
+
+-- TAG-FREQ-BAND-INDICATOR-EUTRA-STOP
+-- TAG-FREQBANDLIST-START
+
+FreqBandList ::=	SEQUENCE (SIZE (1..maxBandsMRDC)) OF FreqBandInformation
+
+FreqBandInformation ::= CHOICE {
+	bandEUTRA				FreqBandIndicatorEUTRA,
+	bandNR					FreqBandIndicatorNR
+}
+
+-- TAG-FREQBANDLIST-STOP
+-- TAG-FREQSEPARATIONCLASS-START
+
+FreqSeparationClass ::=	ENUMERATED {c1, c2, c3, ...}
+
+-- TAG-FREQSEPARATIONCLASS-STOP
+-- TAG-MIMO-LAYERS-START
+
+MIMO-LayersDL ::=	ENUMERATED {twoLayers, fourLayers, eightLayers}
+
+MIMO-LayersUL ::=	ENUMERATED {oneLayer, twoLayers, fourLayers}
+
+-- TAG-MIMO-LAYERS-STOP
+-- TAG-MODULATION-ORDER-START
+
+ModulationOrder ::=	ENUMERATED {bpsk-halfpi, bpsk, qpsk, qam16, qam64, qam256}
+
+-- TAG-MODULATION-ORDER-STOP
+-- TAG-RAT-TYPE-START
+
+RAT-Type ::= ENUMERATED {nr, eutra-nr, spare2, spare1, ...}
+
+-- TAG-RAT-TYPE-STOP
+-- TAG-SUPPORTEDBASEBANDPROCESSINGCOMBINATION-START
+
+SupportedBasebandProcessingCombination ::= SEQUENCE (SIZE (1..maxBasebandProcComb)) OF BasebandProcessingCombination
+
+BasebandProcessingCombination ::= SEQUENCE {
+	basebandParametersDL			SEQUENCE (SIZE (1..maxSimultaneousBands)) OF BasebandParametersPerBandDL,
+	basebandParametersUL				BIT STRING (SIZE (1..maxBasebandProcComb))}
+
+BasebandParametersPerBandDL ::= SEQUENCE {
+	ca-BandwidthClassDL			CA-BandwidthClassNR,
+	freqRange					ENUMERATED {fr1, fr2},
+	basebandParametersPerCC-DL		SEQUENCE (SIZE (1.. maxNrofServingCells)) OF BasebandParametersPerCC-DL
+}
+
+BasebandParametersPerCC-DL ::= SEQUENCE {
+-- R4 2-2: Simultaneous reception or transmission with same or  different numerologies in CA
+-- It is expressed by the combination of SCS whether simultaneous RxTx is supported or not.
+	supportedSubcarrierSpacingDL				SubcarrierSpacing,
+-- Accoding to the RAN4 LS R4-1803563, maximum Bandwidth supported per CC is added in BPC
+-- FFS how to work together with BCS and max BW for each CC to be defined for each CA band combination in the RAN4 spec.
+	supportedBandwidthDL		CHOICE {
+		fr1							ENUMERATED {mhz5, mhz10, mhz15, mhz20, mhz25, mhz30, mhz40, mhz50, mhz60, mhz80, mhz100},
+		fr2							ENUMERATED {mhz50, mhz100, mhz200, mhz400}
+	},
+-- R2-1800012. To be confirmed by RAN1
+	scalingFactor0dot75			ENUMERATED {supported}		OPTIONAL,
+-- R1 2-2: PDSCH beam switching
+	timeDurationForQCL					SEQUENCE {
+		scs-60kHz							ENUMERATED {s7, s14, s28}				OPTIONAL,
+		sch-120kHz							ENUMERATED {s14, s28}					OPTIONAL
+	}																			OPTIONAL,
+-- R1 1-10: Support of SCell without SS/PBCH block
+	scellWithoutSSB					ENUMERATED {supported}						OPTIONAL,
+-- R1 1-11: Support of CSI-RS RRM measurement for SCell without SS/PBCH block
+	csi-RS-MeasSCellWithoutSSB		ENUMERATED {supported}						OPTIONAL,
+-- R1 2-3: PDSCH MIMO layers. Absence of this field implies support of one layer.
+	maxNumberMIMO-LayersPDSCH			MIMO-LayersDL							OPTIONAL,
+-- Accoding to the RAN4 LS R4-1803563, modulation order is added per CC granularity in BPC
+-- FFS whether all of modulation order specified in the spec need to be signalled.
+-- FFS how to address the requirements agreed by RAN4, e.g. mandaotry w/o capabiltiy for 64QAM. mandaotry with capabiltiy for DL 256QAM in FR1.
+	supportedModulationOrderDL					ModulationOrder					OPTIONAL,
+-- R1 2-15a: Association between CSI-RS and SRS
+	srs-AssocCSI-RS					ENUMERATED {supported}						OPTIONAL,
+-- R1 3-1a: For type 1 CSS with dedicated RRC configuration and for type 3 CSS, UE specific SS, CORESET resource allocation of 6RB bit-map and duration 3 OFDM symbols for FR2
+	type1-3-CSS						ENUMERATED {supported}						OPTIONAL,
+-- R1 3-5 & 3-5a: For type 1 with dedicated RRC configuration, type 3, and UE-SS,, monitoring occasion can be any OFDM symbol(s) of a slot for Case 2 (with a DCI gap)
+	pdcchMonitoringAnyOccasions		ENUMERATED {withoutDCI-gap, withDCI-gap}	OPTIONAL,
+-- R1 5-1a: UE specific RRC configure UL/DL assignment
+	ue-SpecificUL-DL-Assignment		ENUMERATED {supported}						OPTIONAL,
+-- R1 5-11 & 5-11a: Up to 2/7 unicast PDSCHs per slot for different TBs
+	pdsch-DifferentTB-PerSlot		SEQUENCE {
+		scs-15kHz						ENUMERATED {upto2, upto7}					OPTIONAL,
+		scs-30kHz						ENUMERATED {upto2, upto7}					OPTIONAL,
+		scs-60kHz						ENUMERATED {upto2, upto7}					OPTIONAL,
+		scs-120kHz						ENUMERATED {upto2, upto7}					OPTIONAL
+	}																			OPTIONAL,
+-- R1 6-10: Cross carrier scheduling
+	crossCarrierScheduling			ENUMERATED {supported}						OPTIONAL,
+-- R1 6-21: DL search space sharing for CA
+	searchSpaceSharingCA-DL			ENUMERATED {supported}						OPTIONAL
+}
+
+-- TAG-SUPPORTEDBASEBANDPROCESSINGCOMBINATION-STOP
+-- TAG-UE-CAPABILITY-RAT-CONTAINER-LIST-START
+
+UE-CapabilityRAT-ContainerList ::=SEQUENCE (SIZE (0.. maxRAT-CapabilityContainers)) OF UE-CapabilityRAT-Container
+
+UE-CapabilityRAT-Container ::= SEQUENCE {
+	rat-Type							RAT-Type,
+	ue-CapabilityRAT-Container			OCTET STRING
+}
+
+-- TAG-UE-CAPABILITY-RAT-CONTAINER-LIST-STOP
+-- TAG-UE-MRDC-CAPABILITY-START
+
+UE-MRDC-Capability ::=	SEQUENCE {
+	measParametersMRDC					MeasParametersMRDC					OPTIONAL,
+	rf-ParametersMRDC					RF-ParametersMRDC,
+	phy-ParametersMRDC					Phy-ParametersMRDC					OPTIONAL,
+	generalParametersMRDC				GeneralParametersMRDC-XDD-Diff		OPTIONAL,
+	fdd-Add-UE-MRDC-Capabilities		UE-MRDC-CapabilityAddXDD-Mode		OPTIONAL,
+	tdd-Add-UE-MRDC-Capabilities		UE-MRDC-CapabilityAddXDD-Mode		OPTIONAL,
+	fr1-Add-UE-MRDC-Capabilities		UE-MRDC-CapabilityAddFRX-Mode		OPTIONAL,
+	fr2-Add-UE-MRDC-Capabilities		UE-MRDC-CapabilityAddFRX-Mode		OPTIONAL,
+	lateNonCriticalExtension			OCTET STRING						OPTIONAL,
+	nonCriticalExtension				SEQUENCE {}							OPTIONAL
+}
+
+UE-MRDC-CapabilityAddXDD-Mode ::=	SEQUENCE {
+	phy-ParametersMRDC-XDD-Diff		Phy-ParametersMRDC-XDD-Diff		OPTIONAL,
+	measParametersMRDC-XDD-Diff		MeasParametersMRDC-XDD-Diff		OPTIONAL,
+	generalParametersMRDC-XDD-Diff		GeneralParametersMRDC-XDD-Diff		OPTIONAL
+}
+
+UE-MRDC-CapabilityAddFRX-Mode ::=	SEQUENCE {
+	phy-ParametersMRDC-FRX-Diff		Phy-ParametersMRDC-FRX-Diff		OPTIONAL,
+	measParametersMRDC-FRX-Diff		MeasParametersMRDC-FRX-Diff
+}
+
+RF-ParametersMRDC ::= SEQUENCE {
+	supportedBandCombination	BandCombinationList,
+	bandCombinationParametersUL-List	BandCombinationParametersUL-List
+}
+
+Phy-ParametersMRDC ::= SEQUENCE {
+	phy-ParametersMRDC-XDD-Diff		Phy-ParametersMRDC-XDD-Diff		OPTIONAL,
+	phy-ParametersMRDC-FRX-Diff		Phy-ParametersMRDC-FRX-Diff		OPTIONAL
+}
+
+Phy-ParametersMRDC-XDD-Diff ::=	SEQUENCE {
+-- R1 8-1: Dynamic power sharing for LTE-NR DC
+	dynamicPowerSharing					ENUMERATED {supported}				OPTIONAL,
+-- R1 6-13 & 8-2: Case 1 Single Tx UL LTE-NR DC
+	tdm-Pattern							ENUMERATED {supported}				OPTIONAL
+}
+Phy-ParametersMRDC-FRX-Diff ::=	SEQUENCE {
+-- R1 8-1: Dynamic power sharing for LTE-NR DC
+	dynamicPowerSharing					ENUMERATED {supported}				OPTIONAL,
+-- R1 6-13 & 8-2: Case 1 Single Tx UL LTE-NR DC
+	tdm-Pattern							ENUMERATED {supported}				OPTIONAL
+}
+
+MeasParametersMRDC ::= SEQUENCE {
+	measParametersMRDC-Common		MeasParametersMRDC-Common,
+	measParametersMRDC-XDD-Diff		MeasParametersMRDC-XDD-Diff				OPTIONAL,
+	measParametersMRDC-FRX-Diff		MeasParametersMRDC-FRX-Diff
+}
+
+MeasParametersMRDC-Common ::=	SEQUENCE {
+-- R4 3-1: Independent measurement gap configurations for FR1 and FR2
+	independentGapConfig			ENUMERATED {supported}	OPTIONAL 
+}
+
+MeasParametersMRDC-XDD-Diff ::=	SEQUENCE {
+	sftd-MeasPSCell							ENUMERATED {supported}		OPTIONAL,
+	sftd-MeasNR-Cell						ENUMERATED {supported}		OPTIONAL
+}
+
+MeasParametersMRDC-FRX-Diff ::=	SEQUENCE {
+-- R4 3-2: Simultaneous reception of data and SS block with different numerologies when UE conducts the serving cell measurement or intra-frequency measurement
+	simultaneousRxDataSSB-DiffNumerology	ENUMERATED {supported}		OPTIONAL
+}
+
+GeneralParametersMRDC-XDD-Diff ::= SEQUENCE {
+	splitSRB-WithOneUL-Path				ENUMERATED {supported}		OPTIONAL,
+	splitDRB-withUL-Both-MCG-SCG		ENUMERATED {supported}		OPTIONAL,
+	srb3									ENUMERATED {supported}		OPTIONAL
+}
+
+-- TAG-UE-MRDC-CAPABILITY-STOP
+-- TAG-UE-NR-CAPABILITY-START
+
+UE-NR-Capability ::= SEQUENCE {
+	pdcp-Parameters					PDCP-Parameters, 
+	rlc-Parameters					RLC-Parameters						OPTIONAL,						
+	mac-Parameters					MAC-Parameters						OPTIONAL,						 
+	phy-Parameters					Phy-Parameters,
+	rf-Parameters					RF-Parameters,
+	measParameters					MeasParameters						OPTIONAL,
+	fdd-Add-UE-NR-Capabilities		UE-NR-CapabilityAddXDD-Mode			OPTIONAL,
+	tdd-Add-UE-NR-Capabilities		UE-NR-CapabilityAddXDD-Mode			OPTIONAL,
+	fr1-Add-UE-NR-Capabilities		UE-NR-CapabilityAddFRX-Mode			OPTIONAL,
+	fr2-Add-UE-NR-Capabilities		UE-NR-CapabilityAddFRX-Mode			OPTIONAL,
+	lateNonCriticalExtension		OCTET STRING						OPTIONAL,
+	nonCriticalExtension			SEQUENCE {}							OPTIONAL
+}
+
+UE-NR-CapabilityAddXDD-Mode ::=	SEQUENCE {
+	phy-ParametersXDD-Diff			Phy-ParametersXDD-Diff			OPTIONAL,
+	mac-ParametersXDD-Diff			MAC-ParametersXDD-Diff			OPTIONAL,
+	measParametersXDD-Diff			MeasParametersXDD-Diff			OPTIONAL
+}
+
+UE-NR-CapabilityAddFRX-Mode ::=	SEQUENCE {
+	phy-ParametersFRX-Diff			Phy-ParametersFRX-Diff			OPTIONAL,
+	measParametersFRX-Diff			MeasParametersFRX-Diff			OPTIONAL
+}
+
+Phy-Parameters ::=	SEQUENCE {
+	phy-ParametersCommon			Phy-ParametersCommon				OPTIONAL,
+	phy-ParametersXDD-Diff			Phy-ParametersXDD-Diff				OPTIONAL,
+	phy-ParametersFRX-Diff			Phy-ParametersFRX-Diff				OPTIONAL,
+	phy-ParametersFR1				Phy-ParametersFR1					OPTIONAL,
+	phy-ParametersFR2				Phy-ParametersFR2					OPTIONAL,
+	supportedBasebandProcessingCombination		SupportedBasebandProcessingCombination,
+	basebandCombinationParametersUL-List		BasebandCombinationParametersUL-List
+}
+
+Phy-ParametersCommon ::=	SEQUENCE {
+-- R1 1-9: CSI-RS based CFRA for HO
+	csi-RS-CFRA-ForHO					ENUMERATED {supported}						OPTIONAL,
+-- R1 2-11: Downlink dynamic PRB bundling (DL)
+	dynamicPRB-BundlingDL				ENUMERATED {supported}						OPTIONAL,
+-- R1 2-32a: Semi-persistent CSI report on PUCCH
+	sp-CSI-ReportPUCCH					ENUMERATED {supported}						OPTIONAL,
+-- R1 2-32b: Semi-persistent CSI report on PUSCH
+	sp-CSI-ReportPUSCH					ENUMERATED {supported}						OPTIONAL,
+-- R1 2-34: NZP-CSI-RS  based interference measurement
+	nzp-CSI-RS-IntefMgmt				ENUMERATED {supported}						OPTIONAL,
+-- R1 2-42: Support Type II SP-CSI feedback on long PUCCH
+	type2-SP-CSI-Feedback-LongPUCCH		ENUMERATED {supported}						OPTIONAL,
+-- R1 3-3: More than one CORESET per BWP (in addition to CORESET #0)
+	multipleCORESET						ENUMERATED {supported}						OPTIONAL,
+-- R1 3-6: Dynamic SFI monitoring and dynamic UL/DL determination
+	dynamicSFI							ENUMERATED {supported}						OPTIONAL,
+-- R1 3-7: Precoder-granularity of CORESET size
+	precoderGranularityCORESET			ENUMERATED {supported}						OPTIONAL,
+-- R1 4-10: Dynamic HARQ-ACK codebook
+	dynamicHARQ-ACK-Codebook			ENUMERATED {supported}						OPTIONAL,
+-- R1 4-11: Semi-static HARQ-ACK codebook
+	semiStaticHARQ-ACK-Codebook			ENUMERATED {supported}						OPTIONAL,
+-- R1 4-12: HARQ-ACK spatial bundling for PUCCH or PUSCH per PUCCH group
+	spatialBundlingHARQ-ACK				ENUMERATED {supported}						OPTIONAL,
+-- R1 4-21: Dynamic beta-offset configuration and indication for HARQ-ACK and/or CSI
+	dynamicBetaOffsetInd-HARQ-ACK-CSI	ENUMERATED {supported}						OPTIONAL,
+-- R1 4-23: Repetitions for PUCCH format 1, 3,and 4 over multiple slots with K = 1, 2, 4, 8
+	pucch-Repetition-F1-3-4				ENUMERATED {supported}						OPTIONAL,
+-- R1 5-2: RA type 0 for PUSCH
+	ra-Type0-PUSCH						ENUMERATED {supported}						OPTIONAL,
+-- R1 5-3: Dynamic switching between RA type 0 and RA type 1 for PDSCH
+	dynamicSwitchRA-Type0-1-PDSCH		ENUMERATED {supported}						OPTIONAL,
+-- R1 5-4: Dynamic switching between RA type 0 andRA type 1 for PUSCH
+	dynamicSwitchRA-Type0-1-PUSCH		ENUMERATED {supported}						OPTIONAL,
+-- R1 5-6: PDSCH mapping type A with less than 7 OFDM symbols
+	pdsch-MappingTypeA					ENUMERATED {supported}						OPTIONAL,
+-- R1 5-6a: PDSCH mapping type B
+	pdsch-MappingTypeB					ENUMERATED {supported}						OPTIONAL,
+-- R1 5-7: Interleaving for VRB-to-PRB mapping for PDSCH
+	interleavingVRB-ToPRB-PDSCH			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-8: Interleaving for VRB-to-PRB mapping for PUSCH
+	interleavingVRB-ToPRB-PUSCH			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-10: Inter-slot frequency hopping for PUSCH
+	interSlotFreqHopping-PUSCH			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-13: Type 1 configured PUSCH repetitions within a slot
+	type1-PUSCH-RepetitionOneSlot		ENUMERATED {supported}						OPTIONAL,
+-- R1 5-14: Type 1 configured PUSCH repetitions over multiple slots
+	type1-PUSCH-RepetitionMultiSlots	ENUMERATED {supported}						OPTIONAL,
+-- R1 5-15: Type 2 configured PUSCH repetitions within a slot
+	type2-PUSCH-RepetitionOneSlot		ENUMERATED {supported}						OPTIONAL,
+-- R1 5-16: Type 2 configured PUSCH repetitions over multiple slots
+	type2-PUSCH-RepetitionMultiSlots	ENUMERATED {supported}						OPTIONAL,
+-- R1 5-17: PUSCH repetitions over multiple slots
+	pusch-RepetitionMultiSlots			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-17a: PDSCH repetitions over multiple slots
+	pdsch-RepetitionMultiSlots			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-18: DL SPS
+	downlinkSPS							ENUMERATED {supported}						OPTIONAL,
+-- R1 5-19: Type 1 Configured UL grant
+	configuredUL-GrantType1				ENUMERATED {supported}						OPTIONAL,
+-- R1 5-20: Type 2 Configured UL grant
+	configuredUL-GrantType2				ENUMERATED {supported}						OPTIONAL,
+-- R1 5-21: Pre-emption indication for DL
+	pre-EmptIndication-DL				ENUMERATED {supported}						OPTIONAL,
+-- R1 5-22 & 5-25: CBG-based re-transmission for DL/UL using CBGTI
+	cbg-TransIndication					BIT STRING (SIZE (2))						OPTIONAL,
+-- R1 5-23: CBGFI for CBG-based re-transmission for DL
+	cbg-FlushIndication-DL				ENUMERATED {supported}						OPTIONAL,
+-- R1 5-24: Dynamic HARQ-ACK codebook using sub-codebooks for CBG-based re-transmission for DL
+	dynamicHARQ-ACK-CodeB-CBG-Retx-DL	ENUMERATED {supported}						OPTIONAL,
+-- R1 5-26: Semi-static rate-matching resource set configuration for DL
+	rateMatchingResrcSetSemi-Static		ENUMERATED {supported}						OPTIONAL,
+-- R1 5-27: Dynamic rate-matching resource set configuration for DL
+	rateMatchingResrcSetDynamic			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-28: Rate-matching around LTE CRS
+	rateMatchingLTE-CRS					ENUMERATED {supported}						OPTIONAL,
+-- R4 1-8: BWP switching delay
+	bwp-SwitchingDelay					ENUMERATED {type1, type2}					OPTIONAL
+}
+
+Phy-ParametersXDD-Diff ::=	SEQUENCE {
+-- R1 4-2: 2 PUCCH of format 0 or 2 in consecutive symbols
+	twoPUCCH-F0-2-ConsecSymbols			ENUMERATED {supported}						OPTIONAL,
+-- R1 8-7: UL power control with 2 PUSCH closed loops
+	twoDifferentTPC-Loop-PUSCH			ENUMERATED {supported}						OPTIONAL,
+-- R1 8-8: UL power control with 2 PUCCH closed loops
+	twoDifferentTPC-Loop-PUCCH			ENUMERATED {supported}						OPTIONAL
+}
+
+Phy-ParametersFRX-Diff ::=	SEQUENCE {
+-- R1 2-6 & 2-16b: Support 1+2 DMRS (DL/UL)
+	oneFL-DMRS-TwoAdditionalDMRS		BIT STRING (SIZE (2))						OPTIONAL,
+-- R1 2-7 & 2-18: Supported 2 symbols front-loaded DMRS(DL/UL)
+	twoFL-DMRS							BIT STRING (SIZE (2))						OPTIONAL,
+-- R1 2-8 & 2-18a: Supported 2 symbols front-loaded +2 symbols additional DMRS(DL/UL)
+	twoFL-DMRS-TwoAdditionalDMRS		BIT STRING (SIZE (2))						OPTIONAL,
+-- R1 2-9 & 2-19: Support 1+3 DMRS (DL/UL)
+	oneFL-DMRS-ThreeAdditionalDMRS		BIT STRING (SIZE (2))						OPTIONAL,
+-- R1 2-10: Support DMRS type (DL)
+	supportedDMRS-TypeDL				ENUMERATED {type1, type2}					OPTIONAL,
+-- R1 2-17: Support DMRS type (UL)
+	supportedDMRS-TypeUL				ENUMERATED {type1, type2}					OPTIONAL,
+-- R1 2-37: Support Semi-open loop CSI
+	semiOpenLoopCSI						ENUMERATED {supported}						OPTIONAL,
+-- R1 2-38: CSI report without PMI
+	csi-ReportWithoutPMI				ENUMERATED {supported}						OPTIONAL,
+-- R1 2-39: CSI report with CRI
+	csi-ReportWithCRI					ENUMERATED {supported}						OPTIONAL,
+-- R1 2-39a: CSI report without CQI
+	csi-ReportWithoutCQI				ENUMERATED {supported}						OPTIONAL,
+-- R1 2-44 & 2-47: 1 port of DL/UL PTRS
+	onePortsPTRS						BIT STRING (SIZE (2))						OPTIONAL,
+-- R1 4-2: 2 PUCCH of format 0 or 2 in consecutive symbols
+	twoPUCCH-F0-2-ConsecSymbols			ENUMERATED {supported}						OPTIONAL,
+-- R1 4-3: PUCCH format 2 over 1 – 2 OFDM symbols once per slot with FH
+	pucch-F2-WithFH						ENUMERATED {supported}						OPTIONAL,
+-- R1 4-4: PUCCH format 3 over 4 – 14 OFDM symbols once per slot with FH
+	pucch-F3-WithFH						ENUMERATED {supported}						OPTIONAL,
+-- R1 4-5: PUCCH format 4 over 4 – 14 OFDM symbols once per slot with FH
+	pucch-F4-WithFH						ENUMERATED {supported}						OPTIONAL,
+-- R1 4-6: Non-frequency hopping for PUCCH formats 0 and 2
+	freqHoppingPUCCH-F0-2				ENUMERATED {notSupported}					OPTIONAL,
+-- R1 4-7: Non-frequency hopping for PUCCH format 1, 3, and 4
+	freqHoppingPUCCH-F1-3-4				ENUMERATED {notSupported}					OPTIONAL,
+-- R1 4-19: SR/HARQ-ACK/CSI multiplexing once per slot using a PUCCH (or piggybacked on a PUSCH)
+	mux-SR-HARQ-ACK-CSI-PUCCH			ENUMERATED {supported}						OPTIONAL,
+-- R1 4-20: UCI code-block segmentation 
+	uci-CodeBlockSegmentation			ENUMERATED {supported}						OPTIONAL,
+-- R1 4-22: 1 long PUCCH format and 1 short PUCCH format in the same slot
+	onePUCCH-LongAndShortFormat			ENUMERATED {supported}						OPTIONAL,
+-- R1 4-22a: 2 PUCCH transmissions in the same slot which are not covered by 4-22 and 4-2
+	twoPUCCH-AnyOthersInSlot			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-9: Intra-slot frequency-hopping for PUSCH except for PUSCH scheduled by Type 1 before RRC connection
+	intraSlotFreqHopping-PUSCH			ENUMERATED {supported}						OPTIONAL,
+-- R1 5-29: LBRM for PUSCH
+	pusch-LBRM							ENUMERATED {supported}						OPTIONAL,
+-- R1 6-5a: PDCCH blind detection capability for CA
+	pdcch-BlindDetectionCA				ENUMERATED {supported}						OPTIONAL,
+-- R1 8-3: TPC-PUSCH-RNTI
+	tpc-PUSCH-RNTI						ENUMERATED {supported}						OPTIONAL,
+-- R1 8-4: TPC-PUCCH-RNTI
+	tpc-PUCCH-RNTI						ENUMERATED {supported}						OPTIONAL,
+-- R1 8-5: TPC-SRS-RNTI
+	tpc-SRS-RNTI						ENUMERATED {supported}						OPTIONAL,
+-- R1 8-6: Absolute TPC command mode
+	absoluteTPC-Command					ENUMERATED {supported}						OPTIONAL,
+-- R1 8-7: UL power control with 2 PUSCH closed loops
+	twoDifferentTPC-Loop-PUSCH			ENUMERATED {supported}						OPTIONAL,
+-- R1 8-8: UL power control with 2 PUCCH closed loops
+	twoDifferentTPC-Loop-PUCCH			ENUMERATED {supported}						OPTIONAL,
+-- R4 1-6: pi/2-BPSK for PUSCH
+	pusch-HalfPi-BPSK					ENUMERATED {supported}						OPTIONAL,
+-- R4 1-7: pi/2-BPSK for PUCCH format 3/4
+	pucch-F3-4-HalfPi-BPSK				ENUMERATED {supported}						OPTIONAL,
+-- R4 1-9: 1-symbol GP in unpaired spectrum
+	oneSymbolGP-TDD						ENUMERATED {supported}						OPTIONAL,
+-- R4 2-7: Almost contiguous UL CP-OFDM
+	almostContiguousCP-OFDM-UL			ENUMERATED {supported}						OPTIONAL
+}
+
+Phy-ParametersFR1 ::=	SEQUENCE {
+-- R1 3-2: Unicast PDCCH monitoring following Case 1-2
+	pdcchMonitoringSingleOccasion		ENUMERATED {supported}						OPTIONAL,
+-- R4 1-1: 60kHz of subcarrier spacing for FR1
+	scs-60kHz							ENUMERATED {supported}						OPTIONAL,
+-- R4 1-4: 256QAM for PDSCH in FR1
+	pdsch-256QAM-FR1					ENUMERATED {supported}						OPTIONAL
+}
+
+Phy-ParametersFR2 ::=	SEQUENCE {
+-- R4 2-8: PA calibration gap
+	calibrationGapPA					ENUMERATED {supported}						OPTIONAL
+}
+
+RF-Parameters ::= SEQUENCE {
+	supportedBandListNR					SupportedBandListNR,
+	supportedBandCombination			BandCombinationList,
+	bandCombinationParametersUL-List	BandCombinationParametersUL-List
+}
+
+SupportedBandListNR ::=	SEQUENCE (SIZE (1..maxBands)) OF BandNR
+
+BandNR ::=	SEQUENCE {
+	bandNR							FreqBandIndicatorNR,
+-- Modified MPR behaviour as in RAN4 LS R2-1804077, which is needed for NSA as well as SA
+	modifiedMPR-Behaviour			BIT STRING (SIZE (8))						OPTIONAL,
+-- R4 2-1: Maximum channel bandwidth supported in each band for DL and UL separately and for each SCS that UE supports within a single CC
+-- RAN4 agreed that 400 MHz is optional for FR2. The other values defined for FR1/fR2 in TS 38.101 are mandatory w/o capability bit.
+	maxChannelBW-PerCC				ENUMERATED {mhz400}							OPTIONAL,
+	mimo-ParametersPerBand			MIMO-ParametersPerBand						OPTIONAL,
+-- R1 0-10: Extended CP
+	extendedCP						ENUMERATED {supported}						OPTIONAL,
+-- R1 0-13: Phase coherence across non-contiguous UL symbols in slot in the transmission of one channel
+	phaseCoherenceUL				ENUMERATED {supported}						OPTIONAL,
+-- R1 1-10: Support of SCell without SS/PBCH block
+	scellWithoutSSB					ENUMERATED {supported}						OPTIONAL,
+-- R1 1-11: Support of CSI-RS RRM measurement for SCell without SS/PBCH block
+	csi-RS-MeasSCellWithoutSSB		ENUMERATED {supported}						OPTIONAL,
+-- R1 2-15a: Association between CSI-RS and SRS
+	srs-AssocCSI-RS					ENUMERATED {supported}						OPTIONAL,
+-- R1 3-1a: For type 1 CSS with dedicated RRC configuration and for type 3 CSS, UE specific SS, CORESET resource allocation of 6RB bit-map and duration 3 OFDM symbols for FR2
+	type1-3-CSS						ENUMERATED {supported}						OPTIONAL,
+-- R1 3-4: More than one TCI state configurations per CORESET
+	multipleTCI						ENUMERATED {supported}						OPTIONAL,
+-- R1 3-5 & 3-5a: For type 1 with dedicated RRC configuration, type 3, and UE-SS,, monitoring occasion can be any OFDM symbol(s) of a slot for Case 2 (with a DCI gap)
+	pdcchMonitoringAnyOccasions		ENUMERATED {withoutDCI-gap, withDCI-gap}	OPTIONAL,
+-- R1 5-1a: UE specific RRC configure UL/DL assignment
+	ue-SpecificUL-DL-Assignment		ENUMERATED {supported}						OPTIONAL,
+-- R1 5-11 & 5-11a: Up to 2/7 unicast PDSCHs per slot for different TBs
+	pdsch-DifferentTB-PerSlot		SEQUENCE {
+		scs-15kHz						ENUMERATED {upto2, upto7}				OPTIONAL,
+		scs-30kHz						ENUMERATED {upto2, upto7}				OPTIONAL,
+		scs-60kHz						ENUMERATED {upto2, upto7}				OPTIONAL,
+		scs-120kHz						ENUMERATED {upto2, upto7}				OPTIONAL
+	}																			OPTIONAL,
+-- R1 5-12 & 5-12a: Up to 2/7 PUSCHs per slot for different TBs
+	pusch-DifferentTB-PerSlot		SEQUENCE {
+		scs-15kHz						ENUMERATED {upto2, upto7}				OPTIONAL,
+		scs-30kHz						ENUMERATED {upto2, upto7}				OPTIONAL,
+		scs-60kHz						ENUMERATED {upto2, upto7}				OPTIONAL,
+		scs-120kHz						ENUMERATED {upto2, upto7}				OPTIONAL
+	}																			OPTIONAL,
+-- R1 6-2 & 6-3: Type A/B BWP adaptation (up to 2/4 BWPs) with same numerology
+	bwp-SameNumerology					ENUMERATED {upto2, upto4}				OPTIONAL,
+-- R1 6-4: BWP adaptation (up to 4 BWPs) with different numerologies
+	bwp-DiffNumerology					ENUMERATED {upto4}						OPTIONAL,
+-- R1 6-7: Two PUCCH group
+	twoPUCCH-Group					ENUMERATED {supported}						OPTIONAL,
+-- R1 6-8: Different numerology across PUCCH groups
+	diffNumerologyAcrossPUCCH-Group	ENUMERATED {supported}						OPTIONAL,
+-- R1 6-9: Different numerologies across carriers within the same PUCCH group
+	diffNumerologyWithinPUCCH-Group	ENUMERATED {supported}						OPTIONAL,
+-- R1 6-10: Cross carrier scheduling
+	crossCarrierScheduling			ENUMERATED {supported}						OPTIONAL,
+-- R1 6-11: Number of supported TAGs
+	supportedNumberTAG				ENUMERATED {n2, n3, n4}						OPTIONAL,
+-- R1 6-19: Simultaneous transmission of SRS on an SUL/non-SUL carrier and PUSCH/PUCCH/SRS/PRACH on the other UL carrier in the same cell
+-- Details on the channel/signal combination are to be described in TS 38.306
+	simultaneousTxSUL-NonSUL		ENUMERATED {supported}						OPTIONAL,
+-- R1 6-21: DL search space sharing for CA
+	searchSpaceSharingCA-DL			ENUMERATED {supported}						OPTIONAL,
+-- R1 6-22: UL search space sharing for CA
+	searchSpaceSharingCA-UL			ENUMERATED {supported}						OPTIONAL,
+-- R4 1-4: 256QAM for PDSCH in FR2
+	pdsch-256QAM-FR2				ENUMERATED {supported}						OPTIONAL,
+-- R4 1-5: 256QAM for PUSCH
+	pusch-256QAM					ENUMERATED {supported}						OPTIONAL
+}
+
+MIMO-ParametersPerBand ::= SEQUENCE {
+-- R1 2-2: PDSCH beam switching
+	timeDurationForQCL					SEQUENCE {
+		scs-60kHz							ENUMERATED {s7, s14, s28}									OPTIONAL,
+		sch-120kHz							ENUMERATED {s14, s28}										OPTIONAL
+	}																									OPTIONAL,
+-- R1 2-3: PDSCH MIMO layers. Absence of this field implies support of one layer.
+	maxNumberMIMO-LayersPDSCH			MIMO-LayersDL													OPTIONAL,
+-- R1 2-14: Codebook based PUSCH MIMO transmission. Absence of this field implies that CB-based PUSCH is not supported.
+	maxNumberMIMO-LayersCB-PUSCH		MIMO-LayersUL													OPTIONAL,
+-- R1 2-15: Non-codebook based PUSCH MIMO transmission. Absence of this field implies that Non-CB-based PUSCH is not supported.
+	maxNumberMIMO-LayersNonCB-PUSCH		MIMO-LayersUL													OPTIONAL,
+-- R1 2-4: TCI states for PDSCH
+	maxNumberConfiguredTCIstates		ENUMERATED {n4, n8, n16, n32, n64}								OPTIONAL,
+	maxNumberActiveTCI-PerCC			ENUMERATED {n1, n2, n4, n8}										OPTIONAL,
+-- R1 2-13: PUSCH transmission coherence
+	pusch-TransCoherence				ENUMERATED {nonCoherent, partialNonCoherent, fullCoherent}	OPTIONAL,
+-- R1 2-20: Beam correspondence
+	beamCorrespondence					ENUMERATED {supported}											OPTIONAL,
+-- R1 2-21: Periodic beam report on PUCCH
+	periodicBeamReport					ENUMERATED {supported}											OPTIONAL,
+-- R1 2-22: Aperiodic beam report on PUSCH
+	aperiodicBeamReport					ENUMERATED {supported}											OPTIONAL,
+-- R1 2-23: Semi-persistent beam report on PUCCH
+	sp-BeamReportPUCCH					ENUMERATED {supported}											OPTIONAL,
+-- R1 2-23a: Semi-persistent beam report on PUSCH
+	sp-BeamReportPUSCH					ENUMERATED {supported}											OPTIONAL,
+-- R1 2-24: SSB/CSI-RS for beam management
+	beamManagementSSB-CSI-RS			BeamManagementSSB-CSI-RS										OPTIONAL,
+-- R1 2-26: Receiving beam selection using CSI-RS resource repetition "ON"
+	maxNumberRxBeam						INTEGER (2..8)													OPTIONAL,
+-- R1 2-27: Beam switching (including SSB and CSI-RS)
+	maxNumberRxTxBeamSwitchDL			SEQUENCE {
+		scs-15kHz							ENUMERATED {n4, n7, n14}									OPTIONAL,
+		scs-30kHz							ENUMERATED {n4, n7, n14}									OPTIONAL,
+		scs-60kHz							ENUMERATED {n4, n7, n14}									OPTIONAL,
+		scs-120kHz							ENUMERATED {n4, n7, n14}									OPTIONAL,
+		scs-240kHz							ENUMERATED {n4, n7, n14}									OPTIONAL
+	}																									OPTIONAL,
+-- R1 2-29: Non-group based beam reporting
+	maxNumberNonGroupBeamReporting		ENUMERATED {n1, n2, n4}											OPTIONAL,
+-- R1 2-29a: Group based beam reporting
+	groupBeamReporting					ENUMERATED {supported}											OPTIONAL,
+-- R1 2-30: UL beam management
+	uplinkBeamManagement				SEQUENCE {
+		maxNumberSRS-ResourcePerSet			ENUMERATED {n8, n16, n32},
+		maxNumberSRS-ResourceSet			INTEGER (1..8)
+	}																									OPTIONAL,
+-- R1 2-31: Beam failure recovery
+	maxNumberCSI-RS-BFR					INTEGER (1..64)													OPTIONAL,
+	maxNumberSSB-BFR					INTEGER (1..64)													OPTIONAL,
+	maxNumberCSI-RS-SSB-BFR				INTEGER (1..256)												OPTIONAL,
+-- R1 2-45 & 2-48: 2 ports of DL/UL PTRS
+	twoPortsPTRS						BIT STRING (SIZE (2))											OPTIONAL,
+-- R1 2-53: SRS resources
+	supportedSRS-Resources			SRS-Resources														OPTIONAL,
+-- R1 2-55: SRS Tx switch
+	srs-TxSwitch					SRS-TxSwitch														OPTIONAL,
+-- R1 2-54a: Simultaneous SRS Tx
+	maxNumberSimultaneousSRS-PerCC		INTEGER (1..4)													OPTIONAL,
+-- R1 2-57: Support low latency CSI feedback
+	lowLatencyCSI-Feedback				ENUMERATED {supported}											OPTIONAL
+}
+
+-- R1 2-24: SSB/CSI-RS for beam management
+BeamManagementSSB-CSI-RS ::=	SEQUENCE {
+	maxNumberSSB-CSI-RS-ResourceOneTx	ENUMERATED {n8, n16, n32, n64},
+	maxNumberSSB-CSI-RS-ResourceTwoTx	ENUMERATED {n0, n4, n8, n16, n32, n64},
+	supportedCSI-RS-Density				ENUMERATED {one, three, oneAndThree}
+}
+
+-- R1 2-53: SRS resources
+SRS-Resources ::=	SEQUENCE {
+	maxNumberAperiodicSRS-PerBWP					ENUMERATED {n1, n2, n4, n8, n16},
+	maxNumberAperiodicSRS-PerBWP-PerSlot			INTEGER (1..6),
+	maxNumberPeriodicSRS-PerBWP						ENUMERATED {n1, n2, n4, n8, n16},
+	maxNumberPeriodicSRS-PerBWP-PerSlot				INTEGER (1..6),
+	maxNumberSemiPersitentSRS-PerBWP				ENUMERATED {n0, n1, n2, n4, n8, n16},
+	maxNumberSP-SRS-PerBWP-PerSlot					INTEGER (0..6),
+	maxNumberSRS-Ports-PerResource					ENUMERATED {n1, n2, n4}
+}
+-- R1 2-55: SRS Tx switch
+SRS-TxSwitch ::=	SEQUENCE {
+	supportedSRS-TxPortSwitch			ENUMERATED {t1r2, t1r4, t2r4, t1r4-t2r4},
+	txSwitchImpactToRx					ENUMERATED {true}								OPTIONAL
+}
+
+PDCP-Parameters ::= SEQUENCE {
+	supportedROHC-Profiles	SEQUENCE {
+		profile0x0000		BOOLEAN, 
+		profile0x0001		BOOLEAN, 
+		profile0x0002		BOOLEAN,
+		profile0x0003		BOOLEAN, 
+		profile0x0004		BOOLEAN, 
+		profile0x0006		BOOLEAN, 
+		profile0x0101		BOOLEAN, 
+		profile0x0102		BOOLEAN, 
+		profile0x0103		BOOLEAN, 
+		profile0x0104		BOOLEAN
+	}, 
+	maxNumberROHC-ContextSessions	ENUMERATED {cs2, cs4, cs8, cs12, cs16, cs24, cs32, cs48, cs64, cs128, cs256, cs512, cs1024, cs16384, spare2, spare1},	
+	uplinkOnlyROHC-Profiles			ENUMERATED {supported}	OPTIONAL, 
+	continueROHC-Context			ENUMERATED {supported}	OPTIONAL,
+	outOfOrderDelivery				ENUMERATED {supported}	OPTIONAL, 
+	shortSN							ENUMERATED {supported} 	OPTIONAL
+}
+
+RLC-Parameters ::= SEQUENCE {
+	am-WithShortSN					ENUMERATED {supported}	OPTIONAL,
+		um-WithShortSN					ENUMERATED {supported}	OPTIONAL, 
+		um-WIthLongSN					ENUMERATED {supported}	OPTIONAL
+}
+
+MAC-Parameters ::= SEQUENCE {
+	mac-ParametersCommon			MAC-ParametersCommon	OPTIONAL,
+	mac-ParametersXDD-Diff			MAC-ParametersXDD-Diff	OPTIONAL
+}
+
+MAC-ParametersCommon ::=	SEQUENCE {
+	lcp-Restriction					ENUMERATED {supported}	OPTIONAL,
+-- R1 4-24: PUCCH-spatialrelationinfo indication by a MAC CE per PUCCH resource
+	pucch-SpatialRelInfoMAC-CE		ENUMERATED {supported}	OPTIONAL
+}
+
+MAC-ParametersXDD-Diff ::=	SEQUENCE {
+	skipUplinkTxDynamic				ENUMERATED {supported}	OPTIONAL,
+	logicalChannelSR-DelayTimer		ENUMERATED {supported}	OPTIONAL, 
+	longDRX-Cycle					ENUMERATED {supported}	OPTIONAL, 
+	shortDRX-Cycle					ENUMERATED {supported}	OPTIONAL, 
+	multipleSR-Configurations		ENUMERATED {supported}	OPTIONAL, 
+	-- If supported UE supports 8 SR configurations, otherwise 1 SR config is supported. 
+	-- Confirmation is needed whether to align the number to what the configuration signalling can support.
+	multipleConfiguredGrantConfigurations	ENUMERATED {supported}	OPTIONAL 
+	-- If supported UE supports 16 configured grant configurations, otherwise 1 ConfiguredGrant config is supported.
+	-- Confirmation is needed whether to align the number to what the configuration signalling can support, and to consider whether the 16 refers
+	-- to the configurations or the active ones only (as they are within the BWP).
+}
+
+MeasParameters ::= SEQUENCE {
+	measParametersXDD-Diff			MeasParametersXDD-Diff		OPTIONAL,
+	measParametersFRX-Diff			MeasParametersFRX-Diff		OPTIONAL
+}
+
+MeasParametersXDD-Diff ::=	SEQUENCE {
+	intraAndInterF-MeasAndReport	ENUMERATED {supported}	OPTIONAL,
+	eventA-MeasAndReport			ENUMERATED {supported}	OPTIONAL 
+	-- Confirmation is needed on the need of capability/IOT signaling in LTE for support of the additional measurement gap configurations.
+}
+
+MeasParametersFRX-Diff ::=	SEQUENCE {
+-- R1 1-3: SSB based SINR measurement
+	ss-SINR-Meas						ENUMERATED {supported}		OPTIONAL,
+-- R1 1-5: CSI-RS based RRM measurement with associated SS-block
+	csi-RSRP-AndRSRQ-MeasWithSSB		ENUMERATED {supported}		OPTIONAL,
+-- R1 1-5a: CSI-RS based RRM measurement without associated SS-block
+	csi-RSRP-AndRSRQ-MeasWithoutSSB		ENUMERATED {supported}		OPTIONAL,
+-- R1 1-6: CSI-RS based SINR measurement
+	csi-SINR-Meas						ENUMERATED {supported}		OPTIONAL,
+-- R1 1-7: CSI-RS based RLM
+	csi-RS-RLM							ENUMERATED {supported}		OPTIONAL
+}
+
+-- TAG-UE-NR-CAPABILITY-STOP
+-- TAG-RRC-TRANSACTIONIDENTIFIER-START
+
+RRC-TransactionIdentifier ::=		INTEGER (0..3)
+
+-- TAG-RRC-TRANSACTIONIDENTIFIER-STOP
+-- TAG-MULTIPLICITY-AND-TYPE-CONSTRAINT-DEFINITIONS-START
+
+maxBandComb								INTEGER ::=	65536	-- Maximum number of DL band combinations
+maxBasebandProcComb						INTEGER ::=	65536	-- Maximum number of baseband processing combinations
+maxNrofServingCells						INTEGER ::=	32		-- Max number of serving cells (SpCell + SCells) per cell group
+maxNrofServingCells-1					INTEGER ::= 31		-- Max number of serving cells (SpCell + SCells) per cell group minus 1
+maxNrofAggregatedCellsPerCellGroup		INTEGER ::= 16
+maxNrofSCells							INTEGER ::=	31		-- Max number of secondary serving cells per cell group
+maxNrofCellMeas							INTEGER ::=	32		-- Maximum number of entries in each of the cell lists in a measurement object
+maxNrofSS-BlocksToAverage				INTEGER ::= 16		-- Max number for the (max) number of SS blocks to average to determine cell
+															-- measurement
+maxNrofCSI-RS-ResourcesToAverage			INTEGER ::= 16		-- Max number for the (max) number of CSI-RS to average to determine cell
+															-- measurement
+maxNrofDL-Allocations 					INTEGER ::= 16		-- Maximum number of PDSCH time domain resource allocations
+
+maxNrofSR-ConfigPerCellGroup				INTEGER ::= 8		-- Maximum number of SR configurations per cell group
+
+maxLCG-ID								INTEGER ::= 7		-- Maximum value of LCG ID
+maxLC-ID								INTEGER ::= 32		-- Maximum value of Logical Channel ID
+maxNrofTAGs								INTEGER ::=	4		-- Maximum number of Timing Advance Groups
+maxNrofTAGs-1							INTEGER ::=	3		-- Maximum number of Timing Advance Groups minus 1
+
+maxNrofBWPs								INTEGER ::= 4		-- Maximum number of BWPs per serving cell
+maxNrofSymbols-1						INTEGER ::= 13		-- Maximum index identifying a symbol within a slot (14 symbols, indexed from 0..13)
+maxNrofSlots							INTEGER ::= 320		-- Maximum number of slots in a 10 ms period
+maxNrofSlots-1							INTEGER ::= 319		-- Maximum number of slots in a 10 ms period minus 1
+
+maxNrofPhysicalResourceBlocks			INTEGER ::= 275		-- Maximum number of PRBs
+maxNrofPhysicalResourceBlocks-1			INTEGER ::= 274		-- Maximum number of PRBs
+maxNrofControlResourceSets 				INTEGER ::= 12 		-- Max number of CoReSets configurable on a serving cell
+maxNrofControlResourceSets-1			INTEGER ::= 11  	-- Max number of CoReSets configurable on a serving cell minus 1
+maxCoReSetDuration						INTEGER ::= 3		-- Max number of OFDM symbols in a control resource set
+maxNrofSearchSpaces						INTEGER ::= 40		-- Max number of Search Spaces
+maxNrofSearchSpaces-1					INTEGER ::= 39		-- Max number of Search Spaces minus 1
+maxSFI-DCI-PayloadSize					INTEGER ::= 128		-- Max number payload of a DCI scrambled with SFI-RNTI
+maxSFI-DCI-PayloadSize-1				INTEGER ::= 127		-- Max number payload of a DCI scrambled with SFI-RNTI minus 1
+maxINT-DCI-PayloadSize					INTEGER ::= 126		-- Max number payload of a DCI scrambled with INT-RNTI
+maxINT-DCI-PayloadSize-1				INTEGER ::= 125		-- Max number payload of a DCI scrambled with INT-RNTI minus 1
+maxNrofRateMatchPatterns				INTEGER ::= 4		-- Max number of rate matching patterns that may be configured
+maxNrofRateMatchPatterns-1				INTEGER ::= 3		-- Max number of rate matching patterns that may be configured minus 1
+
+maxNrofCSI-ReportConfigurations			INTEGER ::= 48 		-- Maximum number of report configurations
+maxNrofCSI-ReportConfigurations-1		INTEGER ::= 47		-- Maximum number of report configurations minus 1
+
+maxNrofCSI-ResourceConfigurations		INTEGER ::= 112		-- Maximum number of resource configurations
+maxNrofCSI-ResourceConfigurations-1		INTEGER ::= 111		-- Maximum number of resource configurations minus 1
+
+maxNrofAP-CSI-RS-ResourcesPerSet		INTEGER ::= 16
+maxNrOfCSI-AperiodicTriggers			INTEGER ::= 128		-- Maximum number of triggers for aperiodic CSI reporting
+maxNrofReportConfigPerAperiodicTrigger	INTEGER ::= 16		-- Maximum number of report configurations per trigger state for aperiodic reporting
+
+maxNrofNZP-CSI-RS-Resources				INTEGER ::= 192		-- Maximum number of Non-Zero-Power (NZP) CSI-RS resources
+maxNrofNZP-CSI-RS-Resources-1			INTEGER ::= 191		-- Maximum number of Non-Zero-Power (NZP) CSI-RS resources minus 1
+maxNrofNZP-CSI-RS-ResourcesPerSet		INTEGER ::= 64		-- Maximum number of NZP CSI-RS resources per resource set
+maxNrofNZP-CSI-RS-ResourceSetsPerConfig	INTEGER ::= 16		-- Maximum number of resource sets per resource configuration
+
+maxNrofZP-CSI-RS-Resources				INTEGER ::= 32		-- Maximum number of Zero-Power (NZP) CSI-RS resources
+maxNrofZP-CSI-RS-Resources-1			INTEGER ::= 31		-- Maximum number of Zero-Power (NZP) CSI-RS resources minus 1
+maxNrofZP-CSI-RS-ResourceSets-1			INTEGER ::= 16
+maxNrofZP-CSI-RS-ResourcesPerSet		INTEGER ::= 16
+maxNrofZP-CSI-RS-Sets					INTEGER ::= 16
+
+maxNrofCSI-IM-Resources					INTEGER ::= 32		-- Maximum number of CSI-IM resources. See CSI-IM-ResourceMax in 38.214.
+maxNrofCSI-IM-Resources-1				INTEGER ::= 31		-- Maximum number of CSI-IM resources minus 1. See CSI-IM-ResourceMax in 38.214.
+maxNrofCSI-IM-ResourcesPerSet			INTEGER ::= 8		-- Maximum number of CSI-IM resources per set. See CSI-IM-ResourcePerSetMax in 38.214
+maxNrofCSI-IM-ResourceSetsPerConfig 	INTEGER ::= 16		-- Maximum number of CSI IM resource sets per resource configuration
+
+maxNrofSSB-Resources-1					INTEGER ::= 63		-- Maximum number of SSB resources in a resource set minus 1
+maxNrofCSI-SSB-ResourcePerSet 			INTEGER ::= 64
+maxNrofCSI-SSB-ResourceSetsPerConfig 	INTEGER ::= 1		-- Maximum number of CSI SSB resource sets per resource configuration
+
+maxNrofFailureDetectionResources		INTEGER ::= 10		-- Maximum number of failure detection resources	
+
+maxNrofObjectId							INTEGER ::= 64		-- Maximum number of measurement objects
+maxNrofPCI-Ranges						INTEGER ::= 8		-- Maximum number of PCI ranges
+maxNrofCSI-RS-ResourcesRRM				INTEGER ::= 96		-- Maximum number of CSI-RS resources for an RRM measurement object
+maxNrofCSI-RS-ResourcesRRM-1			INTEGER ::= 95		-- Maximum number of CSI-RS resources for an RRM measurement object minus 1
+maxNrofMeasId							INTEGER ::= 64		-- Maximum number of configured measurements
+maxNrofQuantityConfig					INTEGER	::= 2		-- Maximum number of quantity configurations
+maxNrofCSI-RS-CellsRRM 					INTEGER ::= 96 		-- Maximum number of FFS
+
+maxNrofSRS-ResourceSets					INTEGER ::= 16		-- Maximum number of SRS resource sets in a BWP.
+maxNrofSRS-ResourceSets-1				INTEGER ::= 15		-- Maximum number of SRS resource sets in a BWP minus 1.
+maxNrofSRS-Resources					INTEGER ::= 64		-- Maximum number of SRS resources in an SRS resource set.
+maxNrofSRS-Resources-1					INTEGER ::= 63		-- Maximum number of SRS resources in an SRS resource set minus 1.
+maxNrofSRS-TriggerStates-1 				INTEGER ::= 3		-- Maximum number of SRS trigger states minus 1, i.e., the largest code point.
+maxRAT-CapabilityContainers				INTEGER ::= 8		-- Maximum number of interworking RAT containers (incl NR and MRDC)
+maxSimultaneousBands					INTEGER ::= 32		-- Maximum number of simultaneously aggregated bands
+
+
+maxNrofSlotFormatCombinationsPerCell	INTEGER ::= 16		-- Maximum number of
+maxNrofSlotFormatCombinationsPerSet		INTEGER ::= 4096	-- Maximum number of Slot Format Combinations in a SF-Set.
+maxNrofSlotFormatCombinationsPerSet-1	INTEGER ::= 4095	-- Maximum number of Slot Format Combinations in a SF-Set minus 1.
+maxNrofPUCCH-Resources					INTEGER ::= 128
+maxNrofPUCCH-Resources-1				INTEGER ::= 127
+maxNrofPUCCH-ResourceSets				INTEGER ::= 4		-- Maximum number of PUCCH Resource Sets
+maxNrofPUCCH-ResourceSets-1				INTEGER ::= 3		-- Maximum number of PUCCH Resource Sets minus 1.
+maxNrofPUCCH-ResourcesPerSet			INTEGER ::= 32		-- Maximum number of PUCCH Resources per PUCCH-ResourceSet
+maxNrofPUCCH-ResourcesPerSet-1			INTEGER ::= 31		-- Maximum number of PUCCH Resources per PUCCH-ResourceSet minus 1.
+maxNrofPUCCH-P0-PerSet					INTEGER ::= 8		-- Maximum number of P0-pucch present in a p0-pucch set
+maxNrofPUCCH-PathlossReferenceRSs		INTEGER ::= 4		-- Maximum number of RSs used as pathloss reference for PUCCH power control. 
+maxNrofPUCCH-PathlossReferenceRSs-1		INTEGER ::= 3		-- Maximum number of RSs used as pathloss reference for PUCCH power control minus 1.
+
+maxNrofP0-PUSCH-AlphaSets				INTEGER ::= 30		-- Maximum number of P0-pusch-alpha-sets (see 38,213, section 7.1)
+maxNrofP0-PUSCH-AlphaSets-1				INTEGER ::= 29		-- Maximum number of P0-pusch-alpha-sets minus 1 (see 38,213, section 7.1)
+maxNrofPUSCH-PathlossReferenceRSs		INTEGER ::= 4		-- Maximum number of RSs used as pathloss reference for PUSCH power control. 
+maxNrofPUSCH-PathlossReferenceRSs-1		INTEGER ::= 3		-- Maximum number of RSs used as pathloss reference for PUSCH power control minus 1.
+
+maxBands 								INTEGER ::= 1024		-- Maximum number of supported bands in UE capability.
+maxBandsMRDC							INTEGER	::= 1280
+maxBandsEUTRA							INTEGER ::=	256
+maxCellPrep		 						INTEGER ::= 32
+maxCellReport		 					INTEGER ::= 8
+maxDRB		 							INTEGER ::= 29			-- Maximum number of DRBs (that can be added in DRB-ToAddModLIst).
+maxFreq		 							INTEGER ::= 8			-- Max number of non-serving frequencies in MeasResultSCG-Failure.
+maxNrofCSI-RS	 						INTEGER ::= 64
+maxNrofCandidateBeams 					INTEGER ::= 16			-- Max number of PRACH-ResourceDedicatedBFR that in BFR config.
+maxNrofPCIsPerSMTC 						INTEGER ::= 64			-- Maximun number of PCIs per SMTC.
+maxNrofQFIs 							INTEGER ::= 64
+maxNrofSR-Resources		 				INTEGER ::= 8			-- Maximum number of SR resources per BWP in a cell.
+maxNrofSlotFormatsPerCombination 		INTEGER ::= 256
+maxNrofSpatialRelationInfos 			INTEGER ::= 8
+maxNrofSRS-ResourcesPerSet 				INTEGER ::= 16
+maxNrofIndexesToReport 					INTEGER ::= 32
+maxNrofSSBs 							INTEGER ::= 64 			-- Maximum number of SSB resources in a resource set.
+maxNrofSSBs-1							INTEGER ::= 63			-- Maximum number of SSB resources in a resource set minus 1.
+
+maxNrofTCI-StatesPDCCH 					INTEGER ::= 64
+maxNrofTCI-States						INTEGER ::= 64			-- Maximum number of TCI states.
+maxNrofTCI-States-1						INTEGER ::= 63			-- Maximum number of TCI states minus 1.
+maxNrofUL-Allocations 					INTEGER ::= 16			-- Maximum number of PUSCH time domain resource allocations.
+maxQFI 									INTEGER ::= 63
+maxRA-CSIRS-Resources 					INTEGER ::= 96
+maxRA-OccasionsPerCSIRS					INTEGER ::= 64			-- Maximum number of RA occasions for one CSI-RS
+maxRA-Occasions-1						INTEGER ::=	511			-- Maximum number of RA occasions in the system
+maxRA-SSB-Resources 					INTEGER ::= 64
+maxSCSs									INTEGER ::= 5
+maxSecondaryCellGroups 					INTEGER ::= 3
+maxNrofServingCellsEUTRA				INTEGER ::= 32
+maxMBSFN-Allocations					INTEGER ::= 8
+maxNrofMultiBands						INTEGER ::= 8
+maxCellSFTD    	                    	INTEGER ::= 3  			-- Maximum number of cells for SFTD reporting
+maxReportConfigId                 	 	INTEGER ::= 64
+
+maxNrofSRI-PUSCH-Mappings				INTEGER ::= 16
+maxNrofSRI-PUSCH-Mappings-1				INTEGER ::= 15
+
+-- Editor’s Note: Targeted for completion in June 2018. Not used in EN-DC drop.
+CellIdentity ::=						ENUMERATED {ffsTypeAndValue}
+ShortMAC-I ::=							ENUMERATED {ffsTypeAndValue}
+
+-- TAG-MULTIPLICITY-AND-TYPE-CONSTRAINT-DEFINITIONS-STOP
+
+END
+
diff --git a/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-UE-Variables.asn b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-UE-Variables.asn
new file mode 100644
index 0000000000000000000000000000000000000000..3eeec31891fd642cffb55a28fd5987f81b2daee7
--- /dev/null
+++ b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/NR-UE-Variables.asn
@@ -0,0 +1,46 @@
+NR-UE-Variables DEFINITIONS AUTOMATIC TAGS ::=
+ 
+BEGIN
+
+-- TAG-VAR-MEAS-CONFIG-START
+
+VarMeasConfig ::=					SEQUENCE {
+	-- Measurement identities
+	measIdList							MeasIdToAddModList					OPTIONAL,
+	-- Measurement objects
+	measObjectList						MeasObjectToAddModList				OPTIONAL,
+	-- Reporting configurations
+	reportConfigList					ReportConfigToAddModList			OPTIONAL,
+	-- Other parameters
+	quantityConfig						QuantityConfig						OPTIONAL,
+	
+	s-MeasureConfig							CHOICE {
+		ssb-RSRP								RSRP-Range,						
+		csi-RSRP								RSRP-Range						
+	} 																		OPTIONAL
+
+}
+
+-- TAG-VAR-MEAS-CONFIG-STOP
+-- TAG-VAR-MEAS-REPORT-START
+
+VarMeasReportList ::=				SEQUENCE (SIZE (1..maxNrofMeasId)) OF VarMeasReport
+
+VarMeasReport ::=					SEQUENCE {
+	-- List of measurement that have been triggered
+	measId								MeasId,
+	cellsTriggeredList					CellsTriggeredList				OPTIONAL,
+	numberOfReportsSent					INTEGER
+}
+
+CellsTriggeredList ::=				SEQUENCE (SIZE (1..maxNrofCellMeas)) OF CHOICE {
+	physCellId							PhysCellId,
+--	Not needed for EN-DC.
+	physCellIdEUTRA						ENUMERATED {ffsTypeAndValue}
+	}
+
+
+-- TAG-VAR-MEAS-REPORT-STOP
+
+END
+
diff --git a/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spce.pl b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spce.pl
new file mode 100755
index 0000000000000000000000000000000000000000..18f6792a8c870819ba1ceac1641866d6376b0eec
--- /dev/null
+++ b/openair2/RRC/NR/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spce.pl
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+# This script extracts the ASN1 definition from and TS 38.331 and generates 3 output files that can be processed by asn2wrs
+# First download the specification from 3gpp.org as a word document and open it
+# Then in "view" menu, select normal or web layout (needed to removed page header and footers)
+# Finally save the document as a text file
+# Call the script: "perl extract_asn1_from_spec.pl 38331-xxx.txt"
+# It should generate: NR-RRC-Definitions.asn, NR-UE-Variables.asn and NR-InterNodeDefinitions
+use warnings;
+$input_file = $ARGV[0];
+$NR_def_output_file = "NR-RRC-Definitions.asn";
+$NR_var_output_file = "NR-UE-Variables.asn";
+$NR_internode_output_file = "NR-InterNodeDefinitions.asn";
+
+
+sub extract_asn1;
+
+open(INPUT_FILE, "< $input_file") or die "Can not open file $input_file";
+
+while (<INPUT_FILE>) {
+
+  # Process the NR-RRC-Definitions section
+  if( m/NR-RRC-Definitions DEFINITIONS AUTOMATIC TAGS ::=/){
+    open(OUTPUT_FILE, "> $NR_def_output_file") or die "Can not open file $def_output_file";
+    syswrite OUTPUT_FILE,"$_ \n";
+    syswrite OUTPUT_FILE,"BEGIN\n\n";
+
+    # Get all the text delimited by -- ASN1START and -- ASN1STOP
+    extract_asn1();
+
+    syswrite OUTPUT_FILE,"END\n\n";
+    close(OUTPUT_FILE);
+  }
+
+  # Process the NR-UE-Variables section
+  if( m/NR-UE-Variables DEFINITIONS AUTOMATIC TAGS ::=/){
+    open(OUTPUT_FILE, "> $NR_var_output_file") or die "Can not open file $def_output_file";
+    syswrite OUTPUT_FILE,"$_ \n";
+    syswrite OUTPUT_FILE,"BEGIN\n\n";
+
+    # Get all the text delimited by -- ASN1START and -- ASN1STOP
+    extract_asn1();
+
+    syswrite OUTPUT_FILE,"END\n\n";
+    close(OUTPUT_FILE);
+  }
+  # Process the NR-InterNodeDefinitions section
+  if( m/NR-InterNodeDefinitions DEFINITIONS AUTOMATIC TAGS ::=/){
+    open(OUTPUT_FILE, "> $NR_internode_output_file") or die "Can not open file $def_output_file";
+    syswrite OUTPUT_FILE,"$_ \n";
+    syswrite OUTPUT_FILE,"BEGIN\n\n";
+
+    # Get all the text delimited by -- ASN1START and -- ASN1STOP
+    extract_asn1();
+
+    syswrite OUTPUT_FILE,"END\n\n";
+    close(OUTPUT_FILE);
+  }
+
+}
+
+close(INPUT_FILE);
+
+# This subroutine copies the text delimited by -- ASN1START and -- ASN1STOP in INPUT_FILE
+# and copies it into OUTPUT_FILE.
+# It stops when it meets the keyword "END"
+sub extract_asn1 {
+  my $line = <INPUT_FILE>;
+  my $is_asn1 = 0;
+
+  while(($line ne "END\n") && ($line ne "END\r\n")){
+    if ($line =~ m/-- ASN1STOP/) {
+      $is_asn1 = 0;
+    }
+    if ($is_asn1 == 1){
+      syswrite OUTPUT_FILE,"$line";
+    }
+    if ($line =~ m/-- ASN1START/) {
+      $is_asn1 = 1;
+    }
+    $line = <INPUT_FILE>;
+  }
+}
diff --git a/openair2/RRC/NR/defs_NR.h b/openair2/RRC/NR/defs_NR.h
new file mode 100644
index 0000000000000000000000000000000000000000..b1a37590be5fbc5f14167d204334f5ce2c2e0cd8
--- /dev/null
+++ b/openair2/RRC/NR/defs_NR.h
@@ -0,0 +1,573 @@
+/* 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/LITE/defs_NR.h
+* \brief NR RRC struct definitions and function prototypes
+* \author Navid Nikaein, Raymond Knopp 
+* \date 2010 - 2014, 2018
+* \version 1.0
+* \company Eurecom
+* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr
+*/
+
+#ifndef __OPENAIR_RRC_DEFS_NR_H__
+#define __OPENAIR_RRC_DEFS_NR_H__
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "collection/tree.h"
+#include "rrc_types_NR.h"
+#include "COMMON/platform_constants.h"
+#include "COMMON/platform_types.h"
+
+//#include "COMMON/mac_rrc_primitives.h"
+#if defined(NR_Rel15)
+#include "NR_SIB1.h"
+//#include "SystemInformation.h"
+//#include "RRCConnectionReconfiguration.h"
+#include "NR_RRCReconfigurationComplete.h"
+#include "NR_RRCReconfiguration.h"
+//#include "RRCConnectionReconfigurationComplete.h"
+//#include "RRCConnectionSetup.h"
+//#include "RRCConnectionSetupComplete.h"
+//#include "RRCConnectionRequest.h"
+//#include "RRCConnectionReestablishmentRequest.h"
+//#include "BCCH-DL-SCH-Message.h"
+#include "NR_BCCH-BCH-Message.h"
+//#include "MCCH-Message.h"
+//#include "MBSFNAreaConfiguration-r9.h"
+//#include "SCellToAddMod-r10.h"
+//#include "AS-Config.h"
+//#include "AS-Context.h"
+#include "NR_UE-NR-Capability.h"
+#include "NR_MeasResults.h"
+#include "NR_ServingCellConfigCommon.h"
+#endif
+//-------------------
+
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+#endif
+
+/* TODO: be sure this include is correct.
+ * It solves a problem of compilation of the RRH GW,
+ * issue #186.
+ */
+#if !defined(ENABLE_ITTI)
+# include "as_message.h"
+#endif
+
+#if defined(ENABLE_USE_MME)
+# include "commonDef.h"
+#endif
+
+#if ENABLE_RAL
+# include "collection/hashtable/obj_hashtable.h"
+#endif
+
+
+
+/*I will change the name of the structure for compile purposes--> hope not to undo this process*/
+
+typedef unsigned int uid_NR_t;
+#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NR (((NUMBER_OF_NR_UE_MAX/8)/sizeof(unsigned int)) + 1)
+
+typedef struct uid_linear_allocator_NR_s {
+  unsigned int   bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NR];
+} uid_allocator_NR_t;
+    
+
+#define PROTOCOL_NRRRC_CTXT_UE_FMT                PROTOCOL_CTXT_FMT
+#define PROTOCOL_NRRRC_CTXT_UE_ARGS(CTXT_Pp)      PROTOCOL_CTXT_ARGS(CTXT_Pp)
+
+#define PROTOCOL_NRRRC_CTXT_FMT                   PROTOCOL_CTXT_FMT
+#define PROTOCOL_NRRRC_CTXT_ARGS(CTXT_Pp)         PROTOCOL_CTXT_ARGS(CTXT_Pp)
+
+
+#define UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!!
+#define UE_INDEX_INVALID  ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! used to be -1
+
+typedef enum {
+  NR_RRC_OK=0,
+  NR_RRC_ConnSetup_failed,
+  NR_RRC_PHY_RESYNCH,
+  NR_RRC_Handover_failed,
+  NR_RRC_HO_STARTED
+} NR_RRC_status_t;
+
+typedef enum UE_STATE_NR_e {
+  NR_RRC_INACTIVE=0,
+  NR_RRC_IDLE,
+  NR_RRC_SI_RECEIVED,
+  NR_RRC_CONNECTED,
+  NR_RRC_RECONFIGURED,
+  NR_RRC_HO_EXECUTION
+} NR_UE_STATE_t;
+
+typedef enum HO_STATE_NR_e {
+  NR_HO_IDLE=0,
+  NR_HO_MEASURMENT,
+  NR_HO_PREPARE,
+  NR_HO_CMD, // initiated by the src eNB
+  NR_HO_COMPLETE // initiated by the target eNB
+} NR_HO_STATE_t;
+
+//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG
+#define RRM_FREE(p)       if ( (p) != NULL) { free(p) ; p=NULL ; }
+#define RRM_MALLOC(t,n)   (t *) malloc16( sizeof(t) * n )
+#define RRM_CALLOC(t,n)   (t *) malloc16( sizeof(t) * n)
+#define RRM_CALLOC2(t,s)  (t *) malloc16( s )
+
+#define MAX_MEAS_OBJ                                  6
+#define MAX_MEAS_CONFIG                               6
+#define MAX_MEAS_ID                                   6
+
+#define PAYLOAD_SIZE_MAX                              1024
+#define RRC_BUF_SIZE                                  255
+#define UNDEF_SECURITY_MODE                           0xff
+#define NO_SECURITY_MODE                              0x20
+
+/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
+#define RRC_TRANSACTION_IDENTIFIER_NUMBER             3
+
+typedef struct {
+  unsigned short                                      transport_block_size;      /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */
+  unsigned short                                      max_transport_blocks;      /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */
+  unsigned long                                       Guaranteed_bit_rate;       /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/
+  unsigned long                                       Max_bit_rate;              /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/
+  uint8_t                                             Delay_class;               /*!< \brief Delay class offered by MAC layer scheduling*/
+  uint8_t                                             Target_bler;               /*!< \brief Target Average Transport Block Error rate*/
+  uint8_t                                             Lchan_t;                   /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/
+} __attribute__ ((__packed__))  LCHAN_DESC_NR;
+
+typedef struct UE_RRC_INFO_NR_s {
+  NR_UE_STATE_t                                       State;
+  uint8_t                                             SIB1systemInfoValueTag;
+  uint32_t                                            SIStatus;
+  uint32_t                                            SIcnt;
+#if defined(Rel10) || defined(Rel14)
+  uint8_t                                             MCCHStatus[8];             // MAX_MBSFN_AREA
+#endif
+  uint8_t                                             SIwindowsize;              //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40
+  uint8_t                                             handoverTarget;
+  //HO_STATE_t ho_state;
+  uint16_t                                            SIperiod;                  //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
+  unsigned short                                      UE_index;
+  uint32_t                                            T300_active;
+  uint32_t                                            T300_cnt;
+  uint32_t                                            T304_active;
+  uint32_t                                            T304_cnt;
+  uint32_t                                            T310_active;
+  uint32_t                                            T310_cnt;
+  uint32_t                                            N310_cnt;
+  uint32_t                                            N311_cnt;
+  rnti_t                                              rnti;
+} __attribute__ ((__packed__)) UE_RRC_INFO_NR;
+
+typedef struct UE_S_TMSI_NR_s {
+  boolean_t                                           presence;
+  mme_code_t                                          mme_code;
+  m_tmsi_t                                            m_tmsi;
+} __attribute__ ((__packed__)) UE_S_TMSI_NR;
+
+
+typedef enum e_rab_satus_NR_e {
+  E_RAB_STATUS_NEW_NR,
+  E_RAB_STATUS_DONE_NR,           // from the eNB perspective
+  E_RAB_STATUS_ESTABLISHED_NR,    // get the reconfigurationcomplete form UE
+  E_RAB_STATUS_FAILED_NR,
+} e_rab_status_NR_t;
+
+typedef struct e_rab_param_NR_s {
+  e_rab_t param;
+  uint8_t status;
+  uint8_t xid; // transaction_id
+} __attribute__ ((__packed__)) e_rab_param_NR_t;
+
+
+typedef struct HANDOVER_INFO_NR_s {
+  uint8_t                                             ho_prepare;
+  uint8_t                                             ho_complete;
+  uint8_t                                             modid_s;            //module_idP of serving cell
+  uint8_t                                             modid_t;            //module_idP of target cell
+  uint8_t                                             ueid_s;             //UE index in serving cell
+  uint8_t                                             ueid_t;             //UE index in target cell
+
+  // NR not define at this moment
+  //AS_Config_t                                       as_config;          /* these two parameters are taken from 36.331 section 10.2.2: HandoverPreparationInformation-r8-IEs */
+  //AS_Context_t                                      as_context;         /* They are mandatory for HO */
+
+  uint8_t                                             buf[RRC_BUF_SIZE];  /* ASN.1 encoded handoverCommandMessage */
+  int                                                 size;               /* size of above message in bytes */
+} HANDOVER_INFO_NR;
+
+
+#define RRC_HEADER_SIZE_MAX 64
+#define RRC_BUFFER_SIZE_MAX 1024
+
+typedef struct {
+  char                                                Payload[RRC_BUFFER_SIZE_MAX];
+  char                                                Header[RRC_HEADER_SIZE_MAX];
+  char                                                payload_size;
+} RRC_BUFFER_NR;
+
+#define RRC_BUFFER_SIZE_NR                            sizeof(RRC_BUFFER_NR)
+
+
+typedef struct RB_INFO_NR_s {
+  uint16_t                                            Rb_id;  //=Lchan_id
+  LCHAN_DESC Lchan_desc[2]; 
+  //MAC_MEAS_REQ_ENTRY *Meas_entry; //may not needed for NB-IoT
+} RB_INFO_NR;
+
+typedef struct SRB_INFO_NR_s {
+  uint16_t                                            Srb_id;         //=Lchan_id
+  RRC_BUFFER                                          Rx_buffer;
+  RRC_BUFFER                                          Tx_buffer;
+  LCHAN_DESC                                          Lchan_desc[2];
+  unsigned int                                        Trans_id;
+  uint8_t                                             Active;
+} SRB_INFO_NR;
+
+
+typedef struct RB_INFO_TABLE_ENTRY_NR_s {
+  RB_INFO_NR                                          Rb_info;
+  uint8_t                                             Active;
+  uint32_t                                            Next_check_frame;
+  uint8_t                                             Status;
+} RB_INFO_TABLE_ENTRY_NR;
+
+typedef struct SRB_INFO_TABLE_ENTRY_NR_s {
+  SRB_INFO_NR                                         Srb_info;
+  uint8_t                                             Active;
+  uint8_t                                             Status;
+  uint32_t                                            Next_check_frame;
+} SRB_INFO_TABLE_ENTRY_NR;
+
+typedef struct MEAS_REPORT_LIST_NR_s {
+  MeasId_t                                            measId;
+  //CellsTriggeredList  cellsTriggeredList;//OPTIONAL
+  uint32_t                                            numberOfReportsSent;
+} MEAS_REPORT_LIST_NR;
+
+typedef struct HANDOVER_INFO_UE_NR_s {
+  PhysCellId_t                                        targetCellId;
+  uint8_t                                             measFlag;
+} HANDOVER_INFO_UE_NR;
+
+//NB-IoT eNB_RRC_UE_NB_IoT_s--(used as a context in eNB --> ue_context in rrc_eNB_ue_context)------
+typedef struct gNB_RRC_UE_s {
+
+  uint8_t                                             primaryCC_id;
+  
+  //SCellToAddMod_t                               sCell_config[2];
+
+  SRB_ToAddModList_t*                                 SRB_configList;//for SRB1 and SRB1bis
+  SRB_ToAddModList_t*                                 SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER];
+  DRB_ToAddModList_t*                                 DRB_configList; //for all the DRBs
+  DRB_ToAddModList_t*                                 DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; //for the configured DRBs of a xid
+  uint8_t                                             DRB_active[8];//in LTE was 8 
+
+  // NR not define at this moment
+  //struct PhysicalConfigDedicated*                   physicalConfigDedicated_NR;
+  
+  struct SPS_Config*                                  sps_Config;
+  MeasObjectToAddMod_t*                               MeasObj[MAX_MEAS_OBJ];
+  struct ReportConfigToAddMod*                        ReportConfig[MAX_MEAS_CONFIG];
+  struct QuantityConfig*                              QuantityConfig;
+  struct MeasIdToAddMod*                              MeasId[MAX_MEAS_ID];
+
+  // NR not define at this moment
+  //MAC_MainConfig_t*                                 mac_MainConfig_NR;
+
+  MeasGapConfig_t*                                    measGapConfig;
+
+  SRB_INFO_NR                                         SI;
+  SRB_INFO_NR                                         Srb0;
+  SRB_INFO_TABLE_ENTRY_NR                             Srb1;
+  SRB_INFO_TABLE_ENTRY_NR                             Srb2;
+
+  MeasConfig_t*                                       measConfig;
+  HANDOVER_INFO_NR*                                   handover_info;
+
+
+#if defined(ENABLE_SECURITY)
+  /* KeNB as derived from KASME received from EPC */
+  uint8_t                                             kenb[32];
+#endif
+
+  /* Used integrity/ciphering algorithms */
+  //Specs. TS 38.331 V15.1.0 pag 432 Change position of chipering enumerative w.r.t previous version
+  e_NR_CipheringAlgorithm                                ciphering_algorithm; 
+  e_NR_IntegrityProtAlgorithm                           integrity_algorithm;
+
+  uint8_t                                             Status;
+  rnti_t                                              rnti;
+  uint64_t                                            random_ue_identity;
+
+
+
+  /* Information from UE RRC ConnectionRequest */
+  UE_S_TMSI_NR                                        Initialue_identity_s_TMSI;
+  
+  /* NR not define at this moment
+  EstablishmentCause_t                             establishment_cause_NR; //different set for NB-IoT
+  */
+  /* NR not define at this moment*/
+  /* Information from UE RRC ConnectionReestablishmentRequest  */
+  //ReestablishmentCause_t                           reestablishment_cause_NR; //different set for NB_IoT
+
+  /* UE id for initial connection to S1AP */
+  uint16_t                                            ue_initial_id;
+
+  /* Information from S1AP initial_context_setup_req */
+  uint32_t                                            eNB_ue_s1ap_id :24;
+
+  security_capabilities_t                             security_capabilities;
+
+  /* Total number of e_rab already setup in the list */ //NAS list?
+  uint8_t                                             setup_e_rabs;
+  /* Number of e_rab to be setup in the list */ //NAS list?
+  uint8_t                                             nb_of_e_rabs;
+  /* list of e_rab to be setup by RRC layers */
+  e_rab_param_NR_t                                    e_rab[NB_RB_MAX_NB_IOT];//[S1AP_MAX_E_RAB];
+
+  // LG: For GTPV1 TUNNELS
+  uint32_t                                            enb_gtp_teid[S1AP_MAX_E_RAB];
+  transport_layer_addr_t                              enb_gtp_addrs[S1AP_MAX_E_RAB];
+  rb_id_t                                             enb_gtp_ebi[S1AP_MAX_E_RAB];
+
+ //Which timers are referring to?
+  uint32_t                                            ul_failure_timer;
+  uint32_t                                            ue_release_timer;
+  //threshold of the release timer--> set in RRCConnectionRelease
+  uint32_t                                            ue_release_timer_thres;
+} gNB_RRC_UE_t;
+//--------------------------------------------------------------------------------
+
+typedef uid_NR_t ue_uid_t;
+
+
+//generally variable called: ue_context_pP
+typedef struct rrc_gNB_ue_context_s {
+
+  /* Tree related data */
+  RB_ENTRY(rrc_gNB_ue_context_s)         entries;
+
+  /* Uniquely identifies the UE between MME and eNB within the eNB.
+   * This id is encoded on 24bits.
+   */
+  rnti_t                                    ue_id_rnti;
+
+  // another key for protocol layers but should not be used as a key for RB tree
+  ue_uid_t                                  local_uid;
+
+  /* UE id for initial connection to S1AP */
+  struct gNB_RRC_UE_s                       ue_context; //context of ue in the e-nB
+
+} rrc_gNB_ue_context_t;
+
+
+//called "carrier"--> data from PHY layer
+typedef struct {
+
+  // buffer that contains the encoded messages
+  uint8_t							                      *MIB;
+  uint8_t							                      sizeof_MIB;
+
+  uint8_t                                   *SIB1;
+  uint8_t                                   sizeof_SIB1;
+
+  //implicit parameters needed
+  int                                       Ncp; //cyclic prefix for DL
+  int								                        Ncp_UL; //cyclic prefix for UL
+  int                                       p_gNB; //number of tx antenna port
+  int								                        p_rx_gNB; //number of receiving antenna ports
+  uint32_t                                  dl_CarrierFreq; //detected by the UE
+  uint32_t                                  ul_CarrierFreq; //detected by the UE
+  uint16_t                                  physCellId; 
+  
+  //are the only static one (memory has been already allocated)
+  BCCH_BCH_Message_t                        mib;
+  
+  NR_SIB1_t     		                            *sib1;
+  NR_ServingCellConfigCommon_t                 *servingcellconfigcommon;
+
+
+  SRB_INFO_NR                               SI;
+  SRB_INFO_NR                               Srb0;
+
+} rrc_gNB_carrier_data_t;
+//---------------------------------------------------
+
+
+
+//---NR---(completely change)---------------------
+typedef struct gNB_RRC_INST_s {
+
+  eth_params_t                                        eth_params_s;
+  rrc_gNB_carrier_data_t                              carrier[MAX_NUM_CCs];
+  uid_allocator_NR_t                                  uid_allocator; // for rrc_ue_head
+  RB_HEAD(rrc_ue_tree_NR_s, rrc_gNB_ue_context_s)     rrc_ue_head; // ue_context tree key search by rnti
+  
+  uint8_t                                             HO_flag;
+  uint8_t                                             Nb_ue;
+
+  hash_table_t                                        *initial_id2_s1ap_ids; // key is    content is rrc_ue_s1ap_ids_t
+  hash_table_t                                        *s1ap_id2_s1ap_ids   ; // key is    content is rrc_ue_s1ap_ids_t
+
+  //RRC configuration
+#if defined(ENABLE_ITTI)
+  gNB_RrcConfigurationReq                             configuration;//rrc_messages_types.h
+#endif
+
+  // other PLMN parameters
+  /// Mobile country code
+  int mcc;
+  /// Mobile network code
+  int mnc;
+  /// number of mnc digits
+  int mnc_digit_length;
+
+  // other RAN parameters
+  int srb1_timer_poll_retransmit;
+  int srb1_poll_pdu;
+  int srb1_poll_byte;
+  int srb1_max_retx_threshold;
+  int srb1_timer_reordering;
+  int srb1_timer_status_prohibit;
+  int srs_enable[MAX_NUM_CCs];
+
+} gNB_RRC_INST;
+
+//#define RRC_HEADER_SIZE_MAX_NR 64
+#define MAX_UE_CAPABILITY_SIZE_NR 255
+
+//not needed for the moment
+typedef struct OAI_UECapability_NR_s {
+ uint8_t sdu[MAX_UE_CAPABILITY_SIZE_NR];
+ uint8_t sdu_size;
+////NR------
+  NR_UE_NR_Capability_t  UE_Capability_NR; //replace the UE_EUTRA_Capability of LTE
+} OAI_UECapability_NR_t;
+
+
+typedef struct UE_RRC_INST_NR_s {
+  Rrc_State_NR_t     RrcState;
+  Rrc_Sub_State_NR_t RrcSubState;
+# if defined(ENABLE_USE_MME)
+  plmn_t          plmnID;
+  Byte_t          rat;
+  as_nas_info_t   initialNasMsg;
+# endif
+  OAI_UECapability_NR_t *UECap;
+  uint8_t *UECapability;
+  uint8_t UECapability_size;
+
+  UE_RRC_INFO_NR              Info[NB_SIG_CNX_UE];
+  
+  SRB_INFO_NR                 Srb0[NB_SIG_CNX_UE];
+  SRB_INFO_TABLE_ENTRY_NR     Srb1[NB_CNX_UE];
+  SRB_INFO_TABLE_ENTRY_NR     Srb2[NB_CNX_UE];
+  HANDOVER_INFO_UE_NR         HandoverInfoUe;
+  /*
+  uint8_t *SIB1[NB_CNX_UE];
+  uint8_t sizeof_SIB1[NB_CNX_UE];
+  uint8_t *SI[NB_CNX_UE];
+  uint8_t sizeof_SI[NB_CNX_UE];
+  uint8_t SIB1Status[NB_CNX_UE];
+  uint8_t SIStatus[NB_CNX_UE];
+  SIB1_t *sib1[NB_CNX_UE];
+  SystemInformation_t *si[NB_CNX_UE]; //!< Temporary storage for an SI message. Decoding happens in decode_SI().
+  
+  SystemInformationBlockType2_t *sib2[NB_CNX_UE];
+  SystemInformationBlockType3_t *sib3[NB_CNX_UE];
+  SystemInformationBlockType4_t *sib4[NB_CNX_UE];
+  SystemInformationBlockType5_t *sib5[NB_CNX_UE];
+  SystemInformationBlockType6_t *sib6[NB_CNX_UE];
+  SystemInformationBlockType7_t *sib7[NB_CNX_UE];
+  SystemInformationBlockType8_t *sib8[NB_CNX_UE];
+  SystemInformationBlockType9_t *sib9[NB_CNX_UE];
+  SystemInformationBlockType10_t *sib10[NB_CNX_UE];
+  SystemInformationBlockType11_t *sib11[NB_CNX_UE];
+
+#if defined(Rel10) || defined(Rel14)
+  uint8_t                           MBMS_flag;
+  uint8_t *MCCH_MESSAGE[NB_CNX_UE];
+  uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE];
+  uint8_t MCCH_MESSAGEStatus[NB_CNX_UE];
+  MBSFNAreaConfiguration_r9_t       *mcch_message[NB_CNX_UE];
+  SystemInformationBlockType12_r9_t *sib12[NB_CNX_UE];
+  SystemInformationBlockType13_r9_t *sib13[NB_CNX_UE];
+#endif
+#ifdef CBA
+  uint8_t                         num_active_cba_groups;
+  uint16_t                        cba_rnti[NUM_MAX_CBA_GROUP];
+#endif
+  uint8_t                         num_srb;
+  struct SRB_ToAddMod             *SRB1_config[NB_CNX_UE];
+  struct SRB_ToAddMod             *SRB2_config[NB_CNX_UE];
+  struct DRB_ToAddMod             *DRB_config[NB_CNX_UE][8];
+  rb_id_t                         *defaultDRB; // remember the ID of the default DRB
+  MeasObjectToAddMod_t            *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ];
+  struct ReportConfigToAddMod     *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG];
+  */
+  struct QuantityConfig           *QuantityConfig[NB_CNX_UE];
+  /*
+  struct MeasIdToAddMod           *MeasId[NB_CNX_UE][MAX_MEAS_ID];
+  MEAS_REPORT_LIST      *measReportList[NB_CNX_UE][MAX_MEAS_ID];
+  uint32_t           measTimer[NB_CNX_UE][MAX_MEAS_ID][6]; // 6 neighboring cells
+  RSRP_Range_t                    s_measure;
+  struct MeasConfig__speedStatePars *speedStatePars;
+  struct PhysicalConfigDedicated  *physicalConfigDedicated[NB_CNX_UE];
+  struct SPS_Config               *sps_Config[NB_CNX_UE];
+  MAC_MainConfig_t                *mac_MainConfig[NB_CNX_UE];
+  MeasGapConfig_t                 *measGapConfig[NB_CNX_UE];
+  double                          filter_coeff_rsrp; // [7] ???
+  double                          filter_coeff_rsrq; // [7] ???
+  float                           rsrp_db[7];
+  float                           rsrq_db[7];
+  float                           rsrp_db_filtered[7];
+  float                           rsrq_db_filtered[7];
+#if ENABLE_RAL
+  obj_hash_table_t               *ral_meas_thresholds;
+  ral_transaction_id_t            scan_transaction_id;
+#endif
+#if defined(ENABLE_SECURITY)
+  // KeNB as computed from parameters within USIM card //
+  uint8_t kenb[32];
+#endif
+
+  // Used integrity/ciphering algorithms //
+  CipheringAlgorithm_r12_t                          ciphering_algorithm;
+  e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
+  */
+}UE_RRC_INST_NR;
+
+
+
+
+#include "proto_NR.h" //should be put here otherwise compilation error
+
+#endif
+/** @} */
diff --git a/openair2/RRC/NR/extern_NR.h b/openair2/RRC/NR/extern_NR.h
new file mode 100644
index 0000000000000000000000000000000000000000..b45dbd11e9557db9667b6c2ea24f1906eb67f774
--- /dev/null
+++ b/openair2/RRC/NR/extern_NR.h
@@ -0,0 +1,87 @@
+/*
+ * 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 vars.h
+* \brief rrc external vars
+* \author Navid Nikaein and Raymond Knopp
+* \date 2011
+* \version 1.0
+* \company Eurecom
+* \email: navid.nikaein@eurecom.fr
+*/
+
+#ifndef __OPENAIR_RRC_EXTERN_H__
+#define __OPENAIR_RRC_EXTERN_H__
+#include "defs.h"
+#include "COMMON/mac_rrc_primitives.h"
+#include "LAYER2/MAC/defs.h"
+#include "LAYER2/MAC/extern.h"
+#include "LAYER2/RLC/rlc.h"
+
+extern UE_RRC_INST *UE_rrc_inst;
+
+#include "LAYER2/MAC/extern.h"
+
+extern uint8_t DRB2LCHAN[8];
+
+extern LogicalChannelConfig_t SRB1_logicalChannelConfig_defaultValue;
+extern LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue;
+
+
+#ifndef PHY_EMUL
+#ifndef PHYSIM
+//#define NB_INST 1
+#else
+extern unsigned char NB_INST;
+#endif
+extern unsigned char NB_eNB_INST;
+extern unsigned char NB_UE_INST;
+extern unsigned short NODE_ID[1];
+extern void* bigphys_malloc(int);
+#endif
+
+
+//CONSTANTS
+extern rlc_info_t Rlc_info_um,Rlc_info_am_config;
+//uint8_t RACH_TIME_ALLOC;
+extern uint16_t RACH_FREQ_ALLOC;
+//uint8_t NB_RACH;
+extern LCHAN_DESC BCCH_LCHAN_DESC,CCCH_LCHAN_DESC,DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC;
+extern MAC_MEAS_T BCCH_MEAS_TRIGGER,CCCH_MEAS_TRIGGER,DCCH_MEAS_TRIGGER,DTCH_MEAS_TRIGGER;
+extern MAC_AVG_T BCCH_MEAS_AVG,CCCH_MEAS_AVG,DCCH_MEAS_AVG, DTCH_MEAS_AVG;
+
+extern uint16_t T300[8];
+extern uint16_t T310[8];
+extern uint16_t N310[8];
+extern uint16_t N311[8];
+extern uint32_t T304[8];
+extern uint32_t timeToTrigger_ms[16];
+extern float RSRP_meas_mapping[98];
+extern float RSRQ_meas_mapping[35];
+
+extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+extern pthread_mutex_t ue_pf_po_mutex;
+
+extern uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2];
+
+#endif
+
+
diff --git a/openair2/RRC/NR/proto_NR.h b/openair2/RRC/NR/proto_NR.h
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
new file mode 100644
index 0000000000000000000000000000000000000000..4bc43a7d10df9dea5c0f26b9eea9e346fceeb3cd
--- /dev/null
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -0,0 +1,457 @@
+/*
+ * 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_gNB.c
+ * \brief rrc procedures for gNB
+ * \author Navid Nikaein and  Raymond Knopp , WEI-TAI CHEN
+ * \date 2011 - 2014 , 2018
+ * \version 1.0
+ * \company Eurecom
+ * \email: navid.nikaein@eurecom.fr and raymond.knopp@eurecom.fr
+ */
+#define RRC_GNB
+#define RRC_GNB_C
+
+#include "defs_NR.h"
+#include "extern.h"
+#include "assertions.h"
+#include "common/ran_context.h"
+#include "asn1_conversions.h"
+
+#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
+#include "LAYER2/RLC/rlc.h"
+#include "LAYER2/MAC/proto.h"
+#include "UTIL/LOG/log.h"
+#include "COMMON/mac_rrc_primitives.h"
+#include "RRC/NR/asn1_msg.h"
+
+///ASN.1 header files
+//#include "RRCConnectionRequest.h"
+//#include "RRCConnectionReestablishmentRequest.h"
+//#include "ReestablishmentCause.h"
+#include "BCCH-BCH-Message.h"
+//#include "UL-CCCH-Message.h"
+//#include "DL-CCCH-Message.h"
+#include "UL-DCCH-Message.h"
+#include "DL-DCCH-Message.h"
+//#include "TDD-Config.h"
+//#include "HandoverCommand.h"
+#include "MeasResults.h"
+
+#include "pdcp.h"
+#include "rlc.h"
+#include "SIMULATION/ETH_TRANSPORT/extern.h"
+#include "rrc_eNB_UE_context.h"
+#include "platform_types.h"
+#include "msc.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+#include "T.h"
+
+
+#include "RRC/NAS/nas_config.h"
+#include "RRC/NAS/rb_config.h"
+#include "OCG.h"
+#include "OCG_extern.h"
+
+#if defined(ENABLE_SECURITY)
+#   include "UTIL/OSA/osa_defs.h"
+#endif
+
+#if defined(ENABLE_USE_MME)
+#   include "rrc_eNB_S1AP.h"
+#   include "rrc_eNB_GTPV1U.h"
+#   if defined(ENABLE_ITTI)
+#   else
+#      include "../../S1AP/s1ap_eNB.h"
+#   endif
+#endif
+
+#include "gtpv1u_eNB_task.h"
+
+#if defined(ENABLE_ITTI)
+#   include "intertask_interface.h"
+#endif
+             
+#if ENABLE_RAL
+#   include "rrc_eNB_ral.h"
+#endif
+
+#include "SIMULATION/TOOLS/defs.h" // for taus
+
+//#define XER_PRINT
+
+extern RAN_CONTEXT_t RC;
+
+#ifdef PHY_EMUL
+extern EMULATION_VARS              *Emul_vars;
+#endif
+//extern eNB_MAC_INST                *eNB_mac_inst;
+//extern UE_MAC_INST                 *UE_mac_inst;
+#ifdef BIGPHYSAREA
+extern void*                        bigphys_malloc(int);
+#endif
+
+extern uint16_t                     two_tier_hexagonal_cellIds[7];
+
+mui_t                               rrc_gNB_mui = 0;
+
+///---------------------------------------------------------------------------------------------------------------///
+///---------------------------------------------------------------------------------------------------------------///
+
+void
+openair_nrrrc_on(
+  const protocol_ctxt_t* const ctxt_pP
+)
+//-----------------------------------------------------------------------------
+{
+  int            CC_id;
+
+    LOG_I(NR_RRC, PROTOCOL_RRC_CTXT_FMT" gNB:OPENAIR NR RRC IN....\n",
+          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+    for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+      rrc_config_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1);
+      RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1;
+      rrc_config_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1);
+      RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1;
+    }
+}
+
+///---------------------------------------------------------------------------------------------------------------///
+///---------------------------------------------------------------------------------------------------------------///
+
+static void
+init_NR_SI(
+  const protocol_ctxt_t* const ctxt_pP,
+  const int              CC_id
+#if defined(ENABLE_ITTI)
+  ,
+  gNB_RrcConfigurationReq * configuration
+#endif
+)
+//-----------------------------------------------------------------------------
+{
+  int                                 i;
+
+  LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__);
+
+  // copy basic parameters
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].physCellId      = configuration->Nid_cell[CC_id];
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB           = configuration->nb_antenna_ports[CC_id];
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Ncp             = configuration->prefix_type[CC_id];
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq  = configuration->downlink_frequency[CC_id];
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq  = configuration->downlink_frequency[CC_id]+ configuration->uplink_frequency_offset[CC_id];
+  
+  ///MIB
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_MIB      = 0;
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].MIB             = (uint8_t*) malloc16(4);
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_MIB      = do_MIB_NR(&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id],0,
+                                                                            #ifdef ENABLE_ITTI
+                                                                            configuration->MIB_ssb_SubcarrierOffset[CC_id],
+                                                                            configuration->pdcch_ConfigSIB1[CC_id],
+                                                                            configuration->MIB_subCarrierSpacingCommon[CC_id],
+                                                                            configuration->MIB_dmrs_TypeA_Position[CC_id]
+                                                                            #else
+                                                                            0,0,15,2
+                                                                            #endif
+                                                                            );
+
+  ///SIB1
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1     = 0;
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SIB1            = (uint8_t*) malloc16(32);
+  AssertFatal(RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SIB1! 
+              = NULL,PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for NR SIB1 allocated\n",PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+  
+  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1     = do_SIB1_NR(&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id],
+                                                                             ctxt_pP->module_id,
+                                                                             CC_id
+                                                                             #if defined(ENABLE_ITTI)
+                                                                             ,configuration
+                                                                             #endif
+                                                                             );
+  
+  AssertFatal(RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 != 255,"FATAL, RC.nrrrc[enb_mod_idP].carrier[CC_id].sizeof_SIB1 == 255");
+
+  do_SERVINGCELLCONFIGCOMMON(ctxt_pP->module_id,
+                             CC_id
+                             #if defined(ENABLE_ITTI)
+                             ,configuration
+                             #endif
+                             );
+
+  
+  
+  rrc_mac_config_req_gNB(ctxt_pP->module_id, CC_id,
+                         RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].physCellId,
+			 RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_gNB,
+			 RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Ncp,
+			 RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator,
+			 RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq,
+			 0, // rnti
+			 (BCCH_BCH_Message_t *)&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].mib,
+			 (ServingCellConfigCommon_t *)&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id]servingcellconfigcommon
+			 );
+}
+
+
+char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigurationReq* configuration){
+  protocol_ctxt_t      ctxt;
+  int                  CC_id;
+
+  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, gnb_mod_idP, GNB_FLAG_YES, NOT_A_RNTI, 0, 0,gnb_mod_idP);
+  LOG_I(NR_RRC,PROTOCOL_NRRRC_CTXT_FMT" Init...\n",PROTOCOL_NRRRC_CTXT_ARGS(&ctxt));
+
+  #if OCP_FRAMEWORK
+    while ( RC.nrrrc[gnb_mod_idP] == NULL ) {
+      LOG_E(NR_RRC, "RC.nrrrc not yet initialized, waiting 1 second\n");
+      sleep(1);
+    }
+  #endif 
+    AssertFatal(RC.nrrrc[gnb_mod_idP] != NULL, "RC.nrrrc not initialized!");
+    AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow");
+  #ifdef ENABLE_ITTI
+    AssertFatal(configuration!=NULL,"configuration input is null\n");
+  #endif
+
+  RC.nrrrc[ctxt.module_id]->Nb_ue = 0;
+
+  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+    RC.nrrrc[ctxt.module_id]->carrier[CC_id].Srb0.Active = 0;
+  }
+
+  uid_linear_allocator_init(&nrrrc.nrrrc[ctxt.module_id]->uid_allocator);
+  RB_INIT(&RC.nrrrc[ctxt.module_id]->rrc_ue_head);
+
+  RC.nrrrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
+  RC.nrrrc[ctxt.module_id]->s1ap_id2_s1ap_ids    = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
+
+  memcpy(&RC.nrrrc[ctxt.module_id]->configuration,configuration,sizeof(gNB_RrcConfigurationReq));
+
+  /// System Information INIT
+
+  LOG_I(NR_RRC, PROTOCOL_NRRRC_CTXT_FMT" Checking release \n",PROTOCOL_NRRRC_CTXT_ARGS(&ctxt));
+
+  #ifdef CBA
+
+  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+    for (j = 0; j < NUM_MAX_CBA_GROUP; j++) {
+      RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[j] = CBA_OFFSET + j;
+    }
+
+    if (RC.nrrrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups > NUM_MAX_CBA_GROUP) {
+      RC.nrrrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups = NUM_MAX_CBA_GROUP;
+    }
+
+    LOG_D(NR_RRC,
+          PROTOCOL_NRRRC_CTXT_FMT" Initialization of 4 cba_RNTI values (%x %x %x %x) num active groups %d\n",
+          PROTOCOL_NRRRC_CTXT_ARGS(&ctxt),
+          gnb_mod_idP, RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[0],
+          RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[1],
+          RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[2],
+          RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[3],
+          RC.nrrrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups);
+  }
+
+  #endif
+
+  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+    init_NR_SI(&ctxt,
+              CC_id
+              #if defined(ENABLE_ITTI)
+              ,configuration
+              #endif
+              );
+    for (int ue_id = 0; ue_id < NUMBER_OF_UE_MAX; ue_id++){
+        RC.nrrrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0;
+        RC.nrrrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t*) malloc16(256);
+    }
+
+  }//END for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++)
+
+  //rrc_init_NR_global_param();
+
+  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+    openair_rrc_top_init_gNB(RC.nrrrc[ctxt.module_id]->carrier[CC_id].MBMS_flag,0);
+  }
+
+  openair_nrrrc_on(&ctxt);
+
+  return 0;  
+
+}//END openair_rrc_gNB_configuration
+
+
+///---------------------------------------------------------------------------------------------------------------///
+///---------------------------------------------------------------------------------------------------------------///
+#if defined(ENABLE_ITTI)
+
+void* rrc_gnb_task(void* args_p){
+  MessageDef                         *msg_p;
+  const char                         *msg_name_p;
+  instance_t                         instance;
+  int                                result;
+  SRB_INFO                           *srb_info_p;
+  int                                CC_id;
+  protocol_ctxt_t                    ctxt;
+
+  itti_mark_task_ready(TASK_RRC_GNB);
+  LOG_I(NR_RRC,"Entering main loop of NR_RRC message task\n");
+
+  while (1) {
+  // Wait for a message
+    itti_receive_msg(TASK_RRC_GNB, &msg_p);
+
+    msg_name_p = ITTI_MSG_NAME(msg_p);
+    instance = ITTI_MSG_INSTANCE(msg_p);
+    LOG_I(RRC,"Received message %s\n",msg_name_p);
+
+    switch (ITTI_MSG_ID(msg_p)) {
+    case TERMINATE_MESSAGE:
+      LOG_W(RRC, " *** Exiting NR_RRC thread\n");
+      itti_exit_task();
+      break;
+
+    case MESSAGE_TEST:
+      LOG_I(RRC, "[gNB %d] Received %s\n", instance, msg_name_p);
+      break;
+
+      /* Messages from MAC */
+
+	    
+      /* Messages from PDCP */
+
+
+#if defined(ENABLE_USE_MME)
+
+      /* Messages from S1AP */
+    case S1AP_DOWNLINK_NAS:
+      rrc_eNB_process_S1AP_DOWNLINK_NAS(msg_p, msg_name_p, instance, &rrc_eNB_mui);
+      break;
+
+    case S1AP_INITIAL_CONTEXT_SETUP_REQ:
+      rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p, msg_name_p, instance);
+      break;
+
+    case S1AP_UE_CTXT_MODIFICATION_REQ:
+      rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(msg_p, msg_name_p, instance);
+      break;
+
+    case S1AP_PAGING_IND:
+      LOG_D(RRC, "[eNB %d] Received Paging message from S1AP: %s\n", instance, msg_name_p);
+      rrc_eNB_process_PAGING_IND(msg_p, msg_name_p, instance);
+      break;
+  
+    case S1AP_E_RAB_SETUP_REQ: 
+      rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(msg_p, msg_name_p, instance);
+      LOG_D(RRC, "[eNB %d] Received the message %s\n", instance, msg_name_p);
+      break;
+
+    case S1AP_E_RAB_MODIFY_REQ:
+      rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(msg_p, msg_name_p, instance);
+      break;
+
+    case S1AP_E_RAB_RELEASE_COMMAND:
+      rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(msg_p, msg_name_p, instance);
+      break;
+    
+    case S1AP_UE_CONTEXT_RELEASE_REQ:
+      rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name_p, instance);
+      break;
+
+    case S1AP_UE_CONTEXT_RELEASE_COMMAND:
+      rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p, msg_name_p, instance);
+      break;
+
+    case GTPV1U_ENB_DELETE_TUNNEL_RESP:
+      /* Nothing to do. Apparently everything is done in S1AP processing */
+      //LOG_I(RRC, "[eNB %d] Received message %s, not processed because procedure not synched\n",
+      //instance, msg_name_p);
+      if (rrc_eNB_get_ue_context(RC.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)
+          && rrc_eNB_get_ue_context(RC.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc > 0) {
+        rrc_eNB_get_ue_context(RC.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc =
+        rrc_eNB_get_ue_context(RC.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_thres_rrc;
+      }
+      break;
+
+#endif
+
+    /* Messages from gNB app */
+    case NRRRC_CONFIGURATION_REQ:
+      LOG_I(NR_RRC, "[gNB %d] Received %s : %p\n", instance, msg_name_p,&NRRRC_CONFIGURATION_REQ(msg_p));
+      openair_rrc_gNB_configuration(GNB_INSTANCE_TO_MODULE_ID(instance), &NRRRC_CONFIGURATION_REQ(msg_p));
+      break;
+
+    default:
+      LOG_E(NR_RRC, "[gNB %d] Received unexpected message %s\n", instance, msg_name_p);
+      break;
+    }
+
+    result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
+    AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+    msg_p = NULL;
+  }
+}
+
+#endif //END #if defined(ENABLE_ITTI)
+
+/*------------------------------------------------------------------------------*/
+void
+openair_rrc_top_init_gNB(int eMBMS_active,uint8_t HO_active)
+//-----------------------------------------------------------------------------
+{
+
+  module_id_t         module_id;
+  int                 CC_id;
+
+  /* for no gcc warnings */
+  (void)CC_id;
+
+  LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_gNB_INST=%d\n", RC.nb_nr_inst);
+
+  if (RC.nb_nr_inst > 0) {
+    LOG_I(RRC,"[gNB] handover active state is %d \n", HO_active);
+
+    for (module_id=0; module_id<NB_gNB_INST; module_id++) {
+      RC.nrrrc[module_id]->HO_flag   = (uint8_t)HO_active;
+    }
+
+  #if defined(Rel10) || defined(Rel14)
+    LOG_I(RRC,"[gNB] eMBMS active state is %d \n", eMBMS_active);
+
+    for (module_id=0; module_id<NB_gNB_INST; module_id++) {
+      for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+        RC.nrrrc[module_id]->carrier[CC_id].MBMS_flag = (uint8_t)eMBMS_active;
+      }
+    }
+
+  #endif
+  #ifdef CBA
+
+    for (module_id=0; module_id<RC.nb_nr_inst; module_id++) {
+      for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+        RC.nrrrc[module_id]->carrier[CC_id].num_active_cba_groups = cba_group_active;
+      }
+    }
+
+  #endif
+
+  }//END if (RC.nb_nr_inst > 0)
+
+}
\ No newline at end of file
diff --git a/openair2/RRC/NR/rrc_types_NR.h b/openair2/RRC/NR/rrc_types_NR.h
new file mode 100644
index 0000000000000000000000000000000000000000..7b6c895ecd9aec9822dc11f9b504d7c400028dbf
--- /dev/null
+++ b/openair2/RRC/NR/rrc_types_NR.h
@@ -0,0 +1,64 @@
+/*
+ * 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_types.h
+* \brief rrc types and subtypes
+* \author Navid Nikaein and Raymond Knopp
+* \date 2011 - 2014, 2018
+* \version 1.0
+* \company Eurecom
+* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr
+*/
+
+#ifndef RRC_TYPES_NR_H_
+#define RRC_TYPES_NR_H_
+
+typedef enum Rrc_State_NR_e {
+  RRC_STATE_INACTIVE_NR=0,
+  RRC_STATE_IDLE_NR,
+  RRC_STATE_CONNECTED_NR,
+
+  RRC_STATE_FIRST_NR = RRC_STATE_INACTIVE_NR,
+  RRC_STATE_LAST_NR = RRC_STATE_CONNECTED_NR,
+} Rrc_State_NR_t;
+
+typedef enum Rrc_Sub_State_NR_e {
+  RRC_SUB_STATE_INACTIVE_NR=0,
+
+  RRC_SUB_STATE_IDLE_SEARCHING_NR,
+  RRC_SUB_STATE_IDLE_RECEIVING_SIB_NR,
+  RRC_SUB_STATE_IDLE_SIB_COMPLETE_NR,
+  RRC_SUB_STATE_IDLE_CONNECTING_NR,
+  RRC_SUB_STATE_IDLE_NR,
+
+  RRC_SUB_STATE_CONNECTED_NR,
+
+  RRC_SUB_STATE_INACTIVE_FIRST_NR = RRC_SUB_STATE_INACTIVE_NR,
+  RRC_SUB_STATE_INACTIVE_LAST_NR = RRC_SUB_STATE_INACTIVE_NR,
+
+  RRC_SUB_STATE_IDLE_FIRST_NR = RRC_SUB_STATE_IDLE_SEARCHING_NR,
+  RRC_SUB_STATE_IDLE_LAST_NR = RRC_SUB_STATE_IDLE_NR,
+
+  RRC_SUB_STATE_CONNECTED_FIRST_NR = RRC_SUB_STATE_CONNECTED_NR,
+  RRC_SUB_STATE_CONNECTED_LAST_NR = RRC_SUB_STATE_CONNECTED_NR,
+} Rrc_Sub_State_NR_t;
+
+#endif /* RRC_TYPES_H_ */
diff --git a/openair2/RRC/NR_UE/defs.h b/openair2/RRC/NR_UE/defs.h
new file mode 100644
index 0000000000000000000000000000000000000000..37db3a9f02eb4f1ac622787614bac4bad821381d
--- /dev/null
+++ b/openair2/RRC/NR_UE/defs.h
@@ -0,0 +1,160 @@
+/*
+ * 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/LITE/defs.h
+* \brief RRC struct definitions and function prototypes
+* \author Navid Nikaein and Raymond Knopp
+* \date 2010 - 2014
+* \version 1.0
+* \company Eurecom
+* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr
+*/
+
+#ifndef __OPENAIR_NR_RRC_DEFS_H__
+#define __OPENAIR_NR_RRC_DEFS_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "collection/tree.h"
+#include "rrc_types.h"
+#include "PHY/defs.h"
+#include "LAYER2/RLC/rlc.h"
+
+#include "COMMON/platform_constants.h"
+#include "COMMON/platform_types.h"
+
+#include "LAYER2/MAC/defs.h"
+
+#include "SystemInformationBlockType1.h"
+#include "SystemInformation.h"
+#include "RRCConnectionReconfiguration.h"
+#include "RRCConnectionReconfigurationComplete.h"
+#include "RRCConnectionSetup.h"
+#include "RRCConnectionSetupComplete.h"
+#include "RRCConnectionRequest.h"
+#include "RRCConnectionReestablishmentRequest.h"
+#include "BCCH-DL-SCH-Message.h"
+#include "BCCH-BCH-Message.h"
+#if defined(Rel10) || defined(Rel14)
+#include "MCCH-Message.h"
+#include "MBSFNAreaConfiguration-r9.h"
+#include "SCellToAddMod-r10.h"
+#endif
+#include "AS-Config.h"
+#include "AS-Context.h"
+#include "UE-EUTRA-Capability.h"
+#include "MeasResults.h"
+
+/* for ImsiMobileIdentity_t */
+#include "MobileIdentity.h"
+
+
+typedef struct NR_UE_RRC_INST_s {
+  nr_rrc_state_t     rrc_state;
+  nr_rrc_sub_state_t rrc_sub_state;
+#if 0
+  OAI_UECapability_t *UECap;
+  uint8_t *UECapability;
+  uint8_t UECapability_size;
+  UE_RRC_INFO Info[NB_SIG_CNX_UE];
+  SRB_INFO Srb0[NB_SIG_CNX_UE];
+  SRB_INFO_TABLE_ENTRY Srb1[NB_CNX_UE];
+  SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE];
+  HANDOVER_INFO_UE HandoverInfoUe;
+  uint8_t *SIB1[NB_CNX_UE];
+  uint8_t sizeof_SIB1[NB_CNX_UE];
+  uint8_t *SI[NB_CNX_UE];
+  uint8_t sizeof_SI[NB_CNX_UE];
+  uint8_t SIB1Status[NB_CNX_UE];
+  uint8_t SIStatus[NB_CNX_UE];
+  SystemInformationBlockType1_t *sib1[NB_CNX_UE];
+  SystemInformation_t *si[NB_CNX_UE]; //!< Temporary storage for an SI message. Decoding happens in decode_SI().
+  SystemInformationBlockType2_t *sib2[NB_CNX_UE];
+  SystemInformationBlockType3_t *sib3[NB_CNX_UE];
+  SystemInformationBlockType4_t *sib4[NB_CNX_UE];
+  SystemInformationBlockType5_t *sib5[NB_CNX_UE];
+  SystemInformationBlockType6_t *sib6[NB_CNX_UE];
+  SystemInformationBlockType7_t *sib7[NB_CNX_UE];
+  SystemInformationBlockType8_t *sib8[NB_CNX_UE];
+  SystemInformationBlockType9_t *sib9[NB_CNX_UE];
+  SystemInformationBlockType10_t *sib10[NB_CNX_UE];
+  SystemInformationBlockType11_t *sib11[NB_CNX_UE];
+
+#if defined(Rel10) || defined(Rel14)
+  uint8_t                           MBMS_flag;
+  uint8_t *MCCH_MESSAGE[NB_CNX_UE];
+  uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE];
+  uint8_t MCCH_MESSAGEStatus[NB_CNX_UE];
+  MBSFNAreaConfiguration_r9_t       *mcch_message[NB_CNX_UE];
+  SystemInformationBlockType12_r9_t *sib12[NB_CNX_UE];
+  SystemInformationBlockType13_r9_t *sib13[NB_CNX_UE];
+#endif
+#ifdef CBA
+  uint8_t                         num_active_cba_groups;
+  uint16_t                        cba_rnti[NUM_MAX_CBA_GROUP];
+#endif
+  uint8_t                         num_srb;
+  struct SRB_ToAddMod             *SRB1_config[NB_CNX_UE];
+  struct SRB_ToAddMod             *SRB2_config[NB_CNX_UE];
+  struct DRB_ToAddMod             *DRB_config[NB_CNX_UE][8];
+  rb_id_t                         *defaultDRB; // remember the ID of the default DRB
+  MeasObjectToAddMod_t            *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ];
+  struct ReportConfigToAddMod     *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG];
+  struct QuantityConfig           *QuantityConfig[NB_CNX_UE];
+  struct MeasIdToAddMod           *MeasId[NB_CNX_UE][MAX_MEAS_ID];
+  MEAS_REPORT_LIST      *measReportList[NB_CNX_UE][MAX_MEAS_ID];
+  uint32_t           measTimer[NB_CNX_UE][MAX_MEAS_ID][6]; // 6 neighboring cells
+  RSRP_Range_t                    s_measure;
+  struct MeasConfig__speedStatePars *speedStatePars;
+  struct PhysicalConfigDedicated  *physicalConfigDedicated[NB_CNX_UE];
+  struct SPS_Config               *sps_Config[NB_CNX_UE];
+  MAC_MainConfig_t                *mac_MainConfig[NB_CNX_UE];
+  MeasGapConfig_t                 *measGapConfig[NB_CNX_UE];
+  double                          filter_coeff_rsrp; // [7] ???
+  double                          filter_coeff_rsrq; // [7] ???
+  float                           rsrp_db[7];
+  float                           rsrq_db[7];
+  float                           rsrp_db_filtered[7];
+  float                           rsrq_db_filtered[7];
+#if defined(ENABLE_SECURITY)
+  /* KeNB as computed from parameters within USIM card */
+  uint8_t kenb[32];
+  uint8_t nh[32];
+  int8_t  nh_ncc;
+#endif
+
+  /* Used integrity/ciphering algorithms */
+  CipheringAlgorithm_r12_t                          ciphering_algorithm;
+  e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
+#endif
+
+	MeasConfig_t 		*meas_config;
+	CellGroupConfig_t 	*cell_group_config;
+	RadioBearerConfig_t *radio_bearer_config;
+    
+} NR_UE_RRC_INST_t;
+
+#include "proto.h"
+
+#endif
+/** @} */
diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c
new file mode 100644
index 0000000000000000000000000000000000000000..814e68717eaead22004f309b162fd8ae9a63fdd3
--- /dev/null
+++ b/openair2/RRC/NR_UE/main_ue.c
@@ -0,0 +1,19 @@
+
+
+#include "defs.h"
+#include "proto.h"
+#include "extern.h"
+#include "assertions.h"
+
+
+
+
+
+int nr_l3_init_ue(void){
+    LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n");
+
+    openair_rrc_top_init_ue_nr(); 
+
+    return 1;
+
+}
diff --git a/openair2/RRC/NR_UE/proto.h b/openair2/RRC/NR_UE/proto.h
new file mode 100644
index 0000000000000000000000000000000000000000..6e876297f6622785e2c650aa14cfd8eb9a8de772
--- /dev/null
+++ b/openair2/RRC/NR_UE/proto.h
@@ -0,0 +1,79 @@
+/*
+ * 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 proto.h
+ * \brief RRC functions prototypes for eNB and UE
+ * \author Navid Nikaein and Raymond Knopp
+ * \date 2010 - 2014
+ * \email navid.nikaein@eurecom.fr
+ * \version 1.0
+ 
+ */
+/** \addtogroup _rrc
+ *  @{
+ */
+
+#include "defs.h"
+
+//
+//  main_rrc.c
+//
+/**\brief Layer 3 initialization*/
+int nr_l3_init_ue(void);
+
+//
+//  UE_rrc.c
+//
+
+/**\brief Initial the top level RRC structure instance*/
+uint8_t openair_rrc_top_init_ue_nr(void);
+
+/**\brief Decode DCCH from gNB, sent from lower layer through SRB3
+   \param buffer encoded DCCH bytes stream message
+   \param size length of buffer*/
+int8_t nr_rrc_ue_decode_dcch(const uint8_t *buffer, const uint32_t size);
+
+/**\brief Decode RRC Connection Reconfiguration, sent from E-UTRA RRC Connection Reconfiguration v1510 carring EN-DC config
+   \param buffer encoded NR-RRC-Connection-Reconfiguration/Secondary-Cell-Group-Config message.
+   \param size length of buffer*/
+//TODO check to use which one
+int8_t nr_rrc_ue_decode_rrcReconfiguration(const uint8_t *buffer, const uint32_t size);
+int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const uint8_t *buffer, const uint32_t size);
+
+
+/**\brief Process NR RRC connection reconfiguration via SRB3
+   \param rrcReconfiguration decoded rrc connection reconfiguration*/
+int8_t nr_rrc_ue_process_rrcReconfiguration(RRCReconfiguration_t *rrcReconfiguration);
+
+/**\prief Process measurement config from NR RRC connection reconfiguration message
+   \param meas_config measurement configuration*/
+int8_t nr_rrc_ue_process_meas_config(MeasConfig_t *meas_config);
+
+/**\prief Process secondary cell group config from NR RRC connection reconfiguration message or EN-DC primitives
+   \param cell_group_config secondary cell group configuration*/
+//TODO check EN-DC function call flow.
+int8_t nr_rrc_ue_process_scg_config(CellGroupConfig_t *cell_group_config);
+
+/**\prief Process radio bearer config from NR RRC connection reconfiguration message
+   \param radio_bearer_config radio bearer configuration*/
+int8_t nr_rrc_ue_process_radio_bearer_config(RadioBearerConfig_t *radio_bearer_config);
+
+/** @}*/
diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
new file mode 100644
index 0000000000000000000000000000000000000000..6e5bb3227c610bfada250d3e9ceae55f24182e2c
--- /dev/null
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -0,0 +1,276 @@
+/*
+ * 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_UE.c
+ * \brief rrc procedures for 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
+ */
+
+#define RRC_UE
+#define RRC_UE_C
+
+
+//  header files for RRC message for NR might be change to add prefix in from of the file name.
+#include "assertions.h"
+#include "hashtable.h"
+#include "asn1_conversions.h"
+#include "defs.h"
+#include "PHY/TOOLS/dB_routines.h"
+#include "extern.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 "UTIL/LOG/vcd_signal_dumper.h"
+#ifndef CELLULAR
+#include "RRC/LITE/MESSAGES/asn1_msg.h"
+#endif
+#include "RRCConnectionRequest.h"
+#include "RRCConnectionReconfiguration.h"
+#include "UL-CCCH-Message.h"
+#include "DL-CCCH-Message.h"
+#include "UL-DCCH-Message.h"
+#include "DL-DCCH-Message.h"
+#include "BCCH-DL-SCH-Message.h"
+#include "PCCH-Message.h"
+#if defined(Rel10) || defined(Rel14)
+#include "MCCH-Message.h"
+#endif
+#include "MeasConfig.h"
+#include "MeasGapConfig.h"
+#include "MeasObjectEUTRA.h"
+#include "TDD-Config.h"
+#include "UECapabilityEnquiry.h"
+#include "UE-CapabilityRequest.h"
+#include "RRC/NAS/nas_config.h"
+#include "RRC/NAS/rb_config.h"
+#if ENABLE_RAL
+#include "rrc_UE_ral.h"
+#endif
+
+#if defined(ENABLE_SECURITY)
+# include "UTIL/OSA/osa_defs.h"
+#endif
+
+
+#if defined(ENABLE_ITTI)
+#include "intertask_interface.h"
+#endif
+
+
+
+// from NR SRB3
+uint8_t nr_rrc_ue_decode_dcch(
+    const uint8_t *buffer,
+    const uint32_t size
+){
+    //  uper_decode by nr R15 rrc_connection_reconfiguration
+    
+    NR_RRC_DL_DCCH_Message_t *nr_dl_dcch_msg = (NR_RRC_DL_DCCH_Message_t *)0;
+
+    uper_decode(NULL,
+                &asn_DEF_NR_RRC_DL_DCCH_Message,    //might be added prefix later
+                (void**)&nr_dl_dcch_msg,
+                (uint8_t *)buffer,
+                size, 0, 0); 
+
+    if(nr_dl_dcch_msg != NULL){
+        switch(nr_dl_dcch_msg->message.present){            
+            case DL_DCCH_MessageType_PR_c1:
+
+                switch(nr_dl_dcch_msg->message.choice.c1.present){
+                    case DL_DCCH_MessageType__c1_PR_rrcReconfiguration:
+                        nr_rrc_ue_process_rrcReconfiguration(&nr_dl_dcch_msg->message.choice.c1.choice.rrcReconfiguration);
+                        break;
+
+                    case DL_DCCH_MessageType__c1_PR_NOTHING:
+                    case DL_DCCH_MessageType__c1_PR_spare15:
+                    case DL_DCCH_MessageType__c1_PR_spare14:
+                    case DL_DCCH_MessageType__c1_PR_spare13:
+                    case DL_DCCH_MessageType__c1_PR_spare12:
+                    case DL_DCCH_MessageType__c1_PR_spare11:
+                    case DL_DCCH_MessageType__c1_PR_spare10:
+                    case DL_DCCH_MessageType__c1_PR_spare9:
+                    case DL_DCCH_MessageType__c1_PR_spare8:
+                    case DL_DCCH_MessageType__c1_PR_spare7:
+                    case DL_DCCH_MessageType__c1_PR_spare6:
+                    case DL_DCCH_MessageType__c1_PR_spare5:
+                    case DL_DCCH_MessageType__c1_PR_spare4:
+                    case DL_DCCH_MessageType__c1_PR_spare3:
+                    case DL_DCCH_MessageType__c1_PR_spare2:
+                    case DL_DCCH_MessageType__c1_PR_spare1:
+                    default:
+                        //  not support or unuse
+                        break;
+                }   
+                break;
+            case DL_DCCH_MessageType_PR_NOTHING:
+            case DL_DCCH_MessageType_PR_messageClassExtension:
+            default:
+                //  not support or unuse
+                break;
+        }
+        
+        //  release memory allocation
+        free(nr_dl_dcch_msg);
+    }else{
+        //  log..
+    }
+
+    return 0;
+
+}
+
+// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
+uint8_t nr_rrc_ue_decode_secondary_cellgroup_config(
+    const uint8_t *buffer,
+    const uint32_t size
+){
+    CellGroupConfig_t *cellGroupConfig = (CellGroupConfig_t *)0;
+
+    uper_decode(NULL,
+                &asn_DEF_CellGroupConfig,   //might be added prefix later
+                (void **)&cellGroupConfig,
+                (uint8_t *)buffer,
+                size, 0, 0); 
+
+    if(NR_UE_rrc_inst->cell_group_config == (CellGroupConfig_t *)0){
+        NR_UE_rrc_inst->cell_group_config = cellGroupConfig;
+        nr_rrc_ue_process_scg_config(cellGroupConfig);
+    }else{
+        nr_rrc_ue_process_scg_config(cellGroupConfig);
+        asn_DEF_CellGroupConfig.free_struct(asn_DEF_CellGroupConfig, cellGroupConfig, 0);
+    }
+
+    nr_rrc_mac_config_req_ue(); 
+}
+
+
+// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (decoded)
+// RRCReconfiguration
+uint8_t nr_rrc_ue_process_rrcReconfiguration(RRCReconfiguration_t *rrcReconfiguration){
+
+    switch(rrcReconfiguration.criticalExtensions.present){
+        case RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration:
+            if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->radioBearerConfig != (RadioBearerConfig_t *)0){
+                if(NR_UE_rrc_inst->radio_bearer_config == (RadioBearerConfig_t *)0){
+                    NR_UE_rrc_inst->radio_bearer_config = rrcReconfiguration->radioBearerConfig;                
+                }else{
+                    nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->radioBearerConfig);
+                }
+            }
+
+            if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->secondaryCellGroup != (OCTET_STRING_t *)0){
+                CellGroupConfig_t *cellGroupConfig = (CellGroupConfig_t *)0;
+                uper_decode(NULL,
+                            &asn_DEF_CellGroupConfig,   //might be added prefix later
+                            (void **)&cellGroupConfig,
+                            (uint8_t *)rrcReconfiguration->secondaryCellGroup->buffer,
+                            rrcReconfiguration->secondaryCellGroup.size, 0, 0); 
+
+                if(NR_UE_rrc_inst->cell_group_config == (CellGroupConfig_t *)0){
+                    //  first time receive the configuration, just use the memory allocated from uper_decoder. TODO this is not good implementation, need to maintain RRC_INST own structure every time.
+                    NR_UE_rrc_inst->cell_group_config = cellGroupConfig;
+                    nr_rrc_ue_process_scg_config(cellGroupConfig);
+                }else{
+                    //  after first time, update it and free the memory after.
+                    nr_rrc_ue_process_scg_config(cellGroupConfig);
+                    asn_DEF_CellGroupConfig.free_struct(asn_DEF_CellGroupConfig, cellGroupConfig, 0);
+                }
+                
+            }
+
+            if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->measConfig != (MeasConfig *)0){
+                if(NR_UE_rrc_inst->meas_config == (MeasConfig_t *)0){
+                    NR_UE_rrc_inst->meas_config = rrcReconfiguration->measConfig;
+                }else{
+                    //  if some element need to be updated
+                    nr_rrc_ue_process_meas_config(rrcReconfiguration->measConfig);
+                }
+               
+            }
+
+            if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->lateNonCriticalExtension != (OCTET_STRING_t *)0){
+                //  unuse now
+            }
+
+            if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->nonCriticalExtension != (RRCReconfiguration_IEs__nonCriticalExtension *)0){
+                // unuse now
+            }
+            break;
+        case RRCReconfiguration__criticalExtensions_PR_NOTHING:
+        case RRCReconfiguration__criticalExtensions_PR_criticalExtensionsFuture:
+        default:
+            break;
+    }
+    nr_rrc_mac_config_req_ue(); 
+}
+
+uint8_t nr_rrc_ue_process_meas_config(MeasConfig_t *meas_config){
+
+}
+
+uint8_t nr_rrc_ue_process_scg_config(CellGroupConfig_t *cell_group_config){
+
+}
+uint8_t nr_rrc_ue_process_radio_bearer_config(RadioBearerConfig_t *radio_bearer_config){
+
+}
+
+
+uint8_t openair_rrc_top_init_ue_nr(void){
+
+    if(NB_NR_UE_INST > 0){
+        NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)malloc(NB_NR_UE_INST * sizeof(NR_UE_RRC_INST_t));
+        memset(NR_UE_rrc_inst, 0, NB_NR_UE_INST * sizeof(NR_UE_RRC_INST_t));
+
+        // fill UE-NR-Capability @ UE-CapabilityRAT-Container here.
+
+
+    }else{
+        NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)0;
+    }
+}
+
+
+uint8_t nr_ue_process_rlc_bearer_list(CellGroupConfig_t *cell_group_config){
+
+};
+
+uint8_t nr_ue_process_secondary_cell_list(CellGroupConfig_t *cell_group_config){
+
+};
+
+uint8_t nr_ue_process_mac_cell_group_config(MAC_CellGroupConfig_t *mac_cell_group_config){
+
+};
+
+uint8_t nr_ue_process_physical_cell_group_config(PhysicalCellGroupConfig_t *phy_cell_group_config){
+
+};
+
+uint8_t nr_ue_process_spcell_config(SpCellConfig_t *spcell_config){
+
+};
diff --git a/openair2/RRC/NR_UE/rrc_types.h b/openair2/RRC/NR_UE/rrc_types.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5540145b098234bccd42667a78c352e8d6e4ab7
--- /dev/null
+++ b/openair2/RRC/NR_UE/rrc_types.h
@@ -0,0 +1,71 @@
+/*
+ * 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_types.h
+* \brief rrc types and subtypes
+* \author Navid Nikaein and Raymond Knopp
+* \date 2011 - 2014
+* \version 1.0
+* \company Eurecom
+* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr
+*/
+
+#ifndef NR_RRC_TYPES_H_
+#define NR_RRC_TYPES_H_
+
+typedef enum nr_rrc_state_e {
+  //RRC_STATE_INACTIVE=0,
+  //RRC_STATE_IDLE,
+  //RRC_STATE_CONNECTED,
+
+  //RRC_STATE_FIRST = RRC_STATE_INACTIVE,
+  //RRC_STATE_LAST = RRC_STATE_CONNECTED,
+	RRC_STATE_IDLE 	= 0,
+	RRC_STATE_INACTIVE,
+	RRC_STATE_CONNECTED,
+
+	RRC_STATE_FIRST = RRC_STATE_IDLE,
+	RRC_STATE_LAST	= RRC_STATE_CONNECTED
+
+} nr_rrc_state_t;
+
+typedef enum nr_rrc_sub_state_e {
+  //RRC_SUB_STATE_INACTIVE=0,
+
+  //RRC_SUB_STATE_IDLE_SEARCHING,
+  //RRC_SUB_STATE_IDLE_RECEIVING_SIB,
+  //RRC_SUB_STATE_IDLE_SIB_COMPLETE,
+  //RRC_SUB_STATE_IDLE_CONNECTING,
+  //RRC_SUB_STATE_IDLE,
+
+  //RRC_SUB_STATE_CONNECTED,
+
+  //RRC_SUB_STATE_INACTIVE_FIRST = RRC_SUB_STATE_INACTIVE,
+  //RRC_SUB_STATE_INACTIVE_LAST = RRC_SUB_STATE_INACTIVE,
+
+  //RRC_SUB_STATE_IDLE_FIRST = RRC_SUB_STATE_IDLE_SEARCHING,
+  //RRC_SUB_STATE_IDLE_LAST = RRC_SUB_STATE_IDLE,
+
+  //RRC_SUB_STATE_CONNECTED_FIRST = RRC_SUB_STATE_CONNECTED,
+  //RRC_SUB_STATE_CONNECTED_LAST = RRC_SUB_STATE_CONNECTED,
+} nr_rrc_sub_state_t;
+
+#endif /* RRC_TYPES_H_ */
diff --git a/openair2/RRC/NR_UE/vars.h b/openair2/RRC/NR_UE/vars.h
new file mode 100644
index 0000000000000000000000000000000000000000..f21b49e9164be36344043ff658c3430a65626daa
--- /dev/null
+++ b/openair2/RRC/NR_UE/vars.h
@@ -0,0 +1,41 @@
+/*
+ * 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 vars.hles
+* \brief rrc variables
+* \author Raymond Knopp and Navid Nikaein
+* \date 2013
+* \version 1.0
+* \company Eurecom
+* \email: navid.nikaein@eurecom.fr
+*/
+
+
+#ifndef __OPENAIR_NR_RRC_VARS_H__
+#define __OPENAIR_NR_RRC_VARS_H__
+
+#include "defs.h"
+#include "LAYER2/RLC/rlc.h"
+#include "COMMON/mac_rrc_primitives.h"
+#include "LAYER2/MAC/defs.h"
+
+NR_UE_RRC_INST_t *NR_UE_rrc_inst;
+#endif
diff --git a/openair2/X2AP/MESSAGES/ASN1/R14.5/x2ap-14.5.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R14.5/x2ap-14.5.0.asn1
new file mode 100755
index 0000000000000000000000000000000000000000..acde008ffbfa556b37ee7488fbbe3592acac2e27
--- /dev/null
+++ b/openair2/X2AP/MESSAGES/ASN1/R14.5/x2ap-14.5.0.asn1
@@ -0,0 +1,5065 @@
+-- **************************************************************
+--
+-- Elementary Procedure definitions
+--
+-- **************************************************************
+
+X2AP-PDU-Descriptions {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) x2ap (2) version1 (1) x2ap-PDU-Descriptions (0) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- IE parameter types from other modules.
+--
+-- **************************************************************
+
+IMPORTS
+	Criticality,
+	ProcedureCode
+
+FROM X2AP-CommonDataTypes
+
+	CellActivationRequest,
+	CellActivationResponse,
+	CellActivationFailure,
+	ENBConfigurationUpdate,
+	ENBConfigurationUpdateAcknowledge,
+	ENBConfigurationUpdateFailure,
+	ErrorIndication,
+	HandoverCancel,
+	HandoverReport,
+	HandoverPreparationFailure,
+	HandoverRequest,
+	HandoverRequestAcknowledge,
+	LoadInformation,
+	PrivateMessage,
+	ResetRequest,
+	ResetResponse,
+	ResourceStatusFailure,
+	ResourceStatusRequest,
+	ResourceStatusResponse,
+	ResourceStatusUpdate, 
+	RLFIndication,
+	SNStatusTransfer,
+	UEContextRelease,
+	X2SetupFailure,
+	X2SetupRequest,
+	X2SetupResponse,
+	MobilityChangeRequest,
+	MobilityChangeAcknowledge,
+	MobilityChangeFailure,
+	X2Release,
+	X2APMessageTransfer,
+	SeNBAdditionRequest,
+	SeNBAdditionRequestAcknowledge,
+	SeNBAdditionRequestReject,
+	SeNBReconfigurationComplete,
+	SeNBModificationRequest,
+	SeNBModificationRequestAcknowledge,
+	SeNBModificationRequestReject,
+	SeNBModificationRequired,
+	SeNBModificationConfirm,
+	SeNBModificationRefuse,
+	SeNBReleaseRequest,
+	SeNBReleaseRequired,
+	SeNBReleaseConfirm,
+	SeNBCounterCheckRequest,
+	X2RemovalFailure,
+	X2RemovalRequest,
+	X2RemovalResponse,
+	RetrieveUEContextRequest,
+	RetrieveUEContextResponse,
+	RetrieveUEContextFailure
+
+FROM X2AP-PDU-Contents
+
+	id-cellActivation,
+	id-eNBConfigurationUpdate,
+	id-errorIndication,
+	id-handoverCancel, 
+	id-handoverReport,
+	id-handoverPreparation,
+	
+	id-loadIndication,
+	id-privateMessage,
+	id-reset,
+	
+	id-resourceStatusReporting,
+	id-resourceStatusReportingInitiation, 
+	id-rLFIndication,
+	id-snStatusTransfer,
+	id-uEContextRelease,
+	id-x2Setup,
+	id-mobilitySettingsChange,
+	id-x2Release,
+	id-x2APMessageTransfer,
+	id-seNBAdditionPreparation,
+	id-seNBReconfigurationCompletion,
+	id-meNBinitiatedSeNBModificationPreparation,
+	id-seNBinitiatedSeNBModification,
+	id-meNBinitiatedSeNBRelease,
+	id-seNBinitiatedSeNBRelease,
+	id-seNBCounterCheck,
+	id-x2Removal,
+	id-retrieveUEContext
+
+FROM X2AP-Constants;
+
+-- **************************************************************
+--
+-- Interface Elementary Procedure Class
+--
+-- **************************************************************
+
+X2AP-ELEMENTARY-PROCEDURE ::= CLASS {
+	&InitiatingMessage				,
+	&SuccessfulOutcome				OPTIONAL,
+	&UnsuccessfulOutcome				OPTIONAL,
+	&procedureCode			ProcedureCode 	UNIQUE,
+	&criticality			Criticality 	DEFAULT ignore
+}
+WITH SYNTAX {
+	INITIATING MESSAGE		&InitiatingMessage
+	[SUCCESSFUL OUTCOME		&SuccessfulOutcome]
+	[UNSUCCESSFUL OUTCOME		&UnsuccessfulOutcome]
+	PROCEDURE CODE			&procedureCode
+	[CRITICALITY			&criticality]
+}
+
+-- **************************************************************
+--
+-- Interface PDU Definition
+--
+-- **************************************************************
+
+X2AP-PDU ::= CHOICE {
+	initiatingMessage	InitiatingMessage,
+	successfulOutcome	SuccessfulOutcome,
+	unsuccessfulOutcome	UnsuccessfulOutcome,
+	...
+}
+
+InitiatingMessage ::= SEQUENCE {
+	procedureCode	X2AP-ELEMENTARY-PROCEDURE.&procedureCode		({X2AP-ELEMENTARY-PROCEDURES}),
+	criticality		X2AP-ELEMENTARY-PROCEDURE.&criticality			({X2AP-ELEMENTARY-PROCEDURES}{@procedureCode}),
+	value			X2AP-ELEMENTARY-PROCEDURE.&InitiatingMessage	({X2AP-ELEMENTARY-PROCEDURES}{@procedureCode})
+}
+
+SuccessfulOutcome ::= SEQUENCE {
+	procedureCode	X2AP-ELEMENTARY-PROCEDURE.&procedureCode		({X2AP-ELEMENTARY-PROCEDURES}),
+	criticality		X2AP-ELEMENTARY-PROCEDURE.&criticality			({X2AP-ELEMENTARY-PROCEDURES}{@procedureCode}),
+	value			X2AP-ELEMENTARY-PROCEDURE.&SuccessfulOutcome	({X2AP-ELEMENTARY-PROCEDURES}{@procedureCode})
+}
+
+UnsuccessfulOutcome ::= SEQUENCE {
+	procedureCode	X2AP-ELEMENTARY-PROCEDURE.&procedureCode		({X2AP-ELEMENTARY-PROCEDURES}),
+	criticality		X2AP-ELEMENTARY-PROCEDURE.&criticality			({X2AP-ELEMENTARY-PROCEDURES}{@procedureCode}),
+	value			X2AP-ELEMENTARY-PROCEDURE.&UnsuccessfulOutcome	({X2AP-ELEMENTARY-PROCEDURES}{@procedureCode})
+}
+
+-- **************************************************************
+--
+-- Interface Elementary Procedure List
+--
+-- **************************************************************
+
+X2AP-ELEMENTARY-PROCEDURES X2AP-ELEMENTARY-PROCEDURE ::= {
+	X2AP-ELEMENTARY-PROCEDURES-CLASS-1			|
+	X2AP-ELEMENTARY-PROCEDURES-CLASS-2			,
+	...
+}
+
+X2AP-ELEMENTARY-PROCEDURES-CLASS-1 X2AP-ELEMENTARY-PROCEDURE ::= {
+	handoverPreparation										|
+	reset													|
+	x2Setup													|
+	resourceStatusReportingInitiation						|
+	eNBConfigurationUpdate									|
+	mobilitySettingsChange									|
+	cellActivation											|
+	seNBAdditionPreparation									|
+	meNBinitiatedSeNBModificationPreparation				|
+	seNBinitiatedSeNBModification							|
+	seNBinitiatedSeNBRelease								|
+	x2Removal												|
+	retrieveUEContext,
+	...
+}
+
+X2AP-ELEMENTARY-PROCEDURES-CLASS-2 X2AP-ELEMENTARY-PROCEDURE ::= {
+	snStatusTransfer						|
+	uEContextRelease						|
+	handoverCancel							|
+	errorIndication							|
+	resourceStatusReporting					|
+	loadIndication							|
+	privateMessage							|
+	rLFIndication							|
+	handoverReport							|
+	x2Release								|
+	x2APMessageTransfer						|
+	seNBReconfigurationCompletion			|
+	meNBinitiatedSeNBRelease				|
+	seNBCounterCheck,
+	...
+
+}
+
+-- **************************************************************
+--
+-- Interface Elementary Procedures
+--
+-- **************************************************************
+
+handoverPreparation X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		HandoverRequest
+	SUCCESSFUL OUTCOME		HandoverRequestAcknowledge
+	UNSUCCESSFUL OUTCOME	HandoverPreparationFailure
+	PROCEDURE CODE			id-handoverPreparation
+	CRITICALITY				reject
+}
+
+snStatusTransfer X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SNStatusTransfer
+	PROCEDURE CODE			id-snStatusTransfer
+	CRITICALITY				ignore
+}
+
+uEContextRelease X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEContextRelease
+	PROCEDURE CODE			id-uEContextRelease
+	CRITICALITY				ignore
+}
+
+
+handoverCancel X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		HandoverCancel
+	PROCEDURE CODE			id-handoverCancel
+	CRITICALITY				ignore
+}
+
+handoverReport X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		HandoverReport
+	PROCEDURE CODE			id-handoverReport
+	CRITICALITY				ignore
+}
+
+errorIndication X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ErrorIndication
+	PROCEDURE CODE			id-errorIndication
+	CRITICALITY				ignore
+}
+
+reset	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ResetRequest
+	SUCCESSFUL OUTCOME		ResetResponse
+	PROCEDURE CODE			id-reset
+	CRITICALITY				reject
+}
+
+x2Setup	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		X2SetupRequest
+	SUCCESSFUL OUTCOME		X2SetupResponse
+	UNSUCCESSFUL OUTCOME	X2SetupFailure
+	PROCEDURE CODE			id-x2Setup
+	CRITICALITY				reject
+}
+
+
+loadIndication X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		LoadInformation
+	PROCEDURE CODE			id-loadIndication
+	CRITICALITY				ignore
+}
+
+eNBConfigurationUpdate		X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ENBConfigurationUpdate
+	SUCCESSFUL OUTCOME		ENBConfigurationUpdateAcknowledge
+	UNSUCCESSFUL OUTCOME	ENBConfigurationUpdateFailure
+	PROCEDURE CODE			id-eNBConfigurationUpdate
+	CRITICALITY				reject
+}
+
+resourceStatusReportingInitiation	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE				ResourceStatusRequest
+	SUCCESSFUL OUTCOME				ResourceStatusResponse
+	UNSUCCESSFUL OUTCOME			ResourceStatusFailure
+	PROCEDURE CODE					id-resourceStatusReportingInitiation
+	CRITICALITY						reject
+}
+
+resourceStatusReporting X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ResourceStatusUpdate
+	PROCEDURE CODE			id-resourceStatusReporting
+	CRITICALITY				ignore
+}
+
+rLFIndication X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		RLFIndication
+	PROCEDURE CODE			id-rLFIndication
+	CRITICALITY				ignore
+}
+
+privateMessage			X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		PrivateMessage
+	PROCEDURE CODE			id-privateMessage
+	CRITICALITY				ignore
+}
+
+mobilitySettingsChange	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		MobilityChangeRequest
+	SUCCESSFUL OUTCOME		MobilityChangeAcknowledge
+	UNSUCCESSFUL OUTCOME	MobilityChangeFailure
+	PROCEDURE CODE			id-mobilitySettingsChange
+	CRITICALITY				reject
+}
+
+cellActivation	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		CellActivationRequest
+	SUCCESSFUL OUTCOME		CellActivationResponse
+	UNSUCCESSFUL OUTCOME	CellActivationFailure
+	PROCEDURE CODE			id-cellActivation
+	CRITICALITY				reject
+}
+
+x2Release X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		X2Release
+	PROCEDURE CODE			id-x2Release
+	CRITICALITY				reject
+}
+
+x2APMessageTransfer X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		X2APMessageTransfer
+	PROCEDURE CODE			id-x2APMessageTransfer
+	CRITICALITY				reject
+}
+
+seNBAdditionPreparation	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SeNBAdditionRequest
+	SUCCESSFUL OUTCOME		SeNBAdditionRequestAcknowledge
+	UNSUCCESSFUL OUTCOME	SeNBAdditionRequestReject
+	PROCEDURE CODE			id-seNBAdditionPreparation
+	CRITICALITY				reject
+}
+
+seNBReconfigurationCompletion	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SeNBReconfigurationComplete
+	PROCEDURE CODE			id-seNBReconfigurationCompletion
+	CRITICALITY				ignore
+}
+
+meNBinitiatedSeNBModificationPreparation	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SeNBModificationRequest
+	SUCCESSFUL OUTCOME		SeNBModificationRequestAcknowledge
+	UNSUCCESSFUL OUTCOME	SeNBModificationRequestReject
+	PROCEDURE CODE			id-meNBinitiatedSeNBModificationPreparation
+	CRITICALITY				reject
+}
+
+seNBinitiatedSeNBModification	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SeNBModificationRequired
+	SUCCESSFUL OUTCOME		SeNBModificationConfirm
+	UNSUCCESSFUL OUTCOME	SeNBModificationRefuse
+	PROCEDURE CODE			id-seNBinitiatedSeNBModification
+	CRITICALITY				reject
+}
+
+meNBinitiatedSeNBRelease	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SeNBReleaseRequest
+	PROCEDURE CODE			id-meNBinitiatedSeNBRelease
+	CRITICALITY				ignore
+}
+
+seNBinitiatedSeNBRelease	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SeNBReleaseRequired
+	SUCCESSFUL OUTCOME		SeNBReleaseConfirm
+	PROCEDURE CODE			id-seNBinitiatedSeNBRelease
+	CRITICALITY				reject
+}
+
+seNBCounterCheck	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		SeNBCounterCheckRequest
+	PROCEDURE CODE			id-seNBCounterCheck
+	CRITICALITY				reject
+}
+
+x2Removal	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		X2RemovalRequest
+	SUCCESSFUL OUTCOME		X2RemovalResponse
+	UNSUCCESSFUL OUTCOME	X2RemovalFailure
+	PROCEDURE CODE			id-x2Removal
+	CRITICALITY				reject
+}
+
+retrieveUEContext	X2AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		RetrieveUEContextRequest
+	SUCCESSFUL OUTCOME		RetrieveUEContextResponse
+	UNSUCCESSFUL OUTCOME	RetrieveUEContextFailure
+	PROCEDURE CODE			id-retrieveUEContext
+	CRITICALITY				reject
+}
+
+END
+
+
+-- **************************************************************
+--
+-- PDU definitions for X2AP.
+--
+-- **************************************************************
+
+X2AP-PDU-Contents {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) x2ap (2) version1 (1) x2ap-PDU-Contents (1) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- IE parameter types from other modules.
+--
+-- **************************************************************
+
+IMPORTS
+	ABSInformation,
+	ABS-Status,
+	AS-SecurityInformation,
+	BearerType,
+	Cause,
+	CompositeAvailableCapacityGroup,
+	Correlation-ID,
+	COUNTvalue,
+	CellReportingIndicator,
+	CriticalityDiagnostics,
+	CRNTI,
+	CSGMembershipStatus,
+	CSG-Id,
+	DeactivationIndication,
+	DL-Forwarding,
+	DynamicDLTransmissionInformation,
+	ECGI,
+	E-RAB-ID,
+	E-RAB-Level-QoS-Parameters,
+	E-RAB-List,
+	EUTRANTraceID,
+	GlobalENB-ID,
+	GTPtunnelEndpoint,
+	GUGroupIDList,
+	GUMMEI,
+	HandoverReportType,
+	HandoverRestrictionList,
+	Masked-IMEISV,
+	InvokeIndication,
+	LocationReportingInformation,
+	MDT-Configuration,
+	ManagementBasedMDTallowed,
+	MDTPLMNList,
+	Neighbour-Information,
+	PCI,
+	PDCP-SN,
+	PLMN-Identity,
+	ReceiveStatusofULPDCPSDUs,
+	Registration-Request,
+	RelativeNarrowbandTxPower,
+	RadioResourceStatus,
+	RRCConnReestabIndicator,
+	RRCConnSetupIndicator,
+	UE-RLF-Report-Container,
+	RRC-Context,
+	ServedCell-Information,
+	ServedCells,
+	ShortMAC-I,
+	SRVCCOperationPossible,
+	SubscriberProfileIDforRFP,
+	TargetCellInUTRAN,
+	TargeteNBtoSource-eNBTransparentContainer,
+	TimeToWait,
+	TraceActivation,
+	TraceDepth,
+	TransportLayerAddress,
+	UEAggregateMaximumBitRate,
+	UE-HistoryInformation,
+	UE-HistoryInformationFromTheUE,
+	UE-S1AP-ID,
+	UESecurityCapabilities,
+	UE-X2AP-ID,
+	UL-HighInterferenceIndicationInfo,
+	UL-InterferenceOverloadIndication,
+	HWLoadIndicator,
+	S1TNLLoadIndicator,
+	Measurement-ID,
+	ReportCharacteristics,
+	MobilityParametersInformation,
+	MobilityParametersModificationRange,
+	ReceiveStatusOfULPDCPSDUsExtended,
+	COUNTValueExtended,
+	SubframeAssignment,
+	ExtendedULInterferenceOverloadInfo,
+	ExpectedUEBehaviour,
+	SeNBSecurityKey,
+	MeNBtoSeNBContainer,
+	SeNBtoMeNBContainer,
+	SCGChangeIndication,
+	CoMPInformation,
+	ReportingPeriodicityRSRPMR,
+	RSRPMRList,
+	UE-RLF-Report-Container-for-extended-bands,
+	ProSeAuthorized,
+	CoverageModificationList,
+	ReportingPeriodicityCSIR,
+	CSIReportList,
+	ReceiveStatusOfULPDCPSDUsPDCP-SNlength18,
+	COUNTvaluePDCP-SNlength18,
+	LHN-ID,
+	UE-ContextKeptIndicator,
+	UE-X2AP-ID-Extension,
+	SIPTOBearerDeactivationIndication,
+	TunnelInformation,
+	V2XServicesAuthorized,
+	X2BenefitValue,
+	ResumeID,
+	EUTRANCellIdentifier,
+	MakeBeforeBreakIndicator,
+	WTID,
+	WT-UE-XwAP-ID,
+	UESidelinkAggregateMaximumBitRate
+
+FROM X2AP-IEs
+
+	PrivateIE-Container{},
+	ProtocolExtensionContainer{},
+	ProtocolIE-Container{},
+	ProtocolIE-ContainerList{},
+	ProtocolIE-ContainerPair{},
+	ProtocolIE-ContainerPairList{},
+	ProtocolIE-Single-Container{},
+	X2AP-PRIVATE-IES,
+	X2AP-PROTOCOL-EXTENSION,
+	X2AP-PROTOCOL-IES,
+	X2AP-PROTOCOL-IES-PAIR
+FROM X2AP-Containers
+
+	id-ABSInformation,
+	id-ActivatedCellList,
+	id-BearerType,
+	id-Cause,
+	id-CellInformation,
+	id-CellInformation-Item,
+	id-CellMeasurementResult,
+	id-CellMeasurementResult-Item,
+	id-CellToReport,
+	id-CellToReport-Item,
+	id-CompositeAvailableCapacityGroup,
+	id-CriticalityDiagnostics,
+	id-DeactivationIndication,
+	id-DynamicDLTransmissionInformation,
+	id-E-RABs-Admitted-Item,
+	id-E-RABs-Admitted-List,
+	id-E-RABs-NotAdmitted-List,
+	id-E-RABs-SubjectToStatusTransfer-List,
+	id-E-RABs-SubjectToStatusTransfer-Item,
+	id-E-RABs-ToBeSetup-Item,
+	id-GlobalENB-ID,
+	id-GUGroupIDList,
+	id-GUGroupIDToAddList,
+	id-GUGroupIDToDeleteList,
+	id-GUMMEI-ID,
+	id-Masked-IMEISV,
+	id-InvokeIndication,
+	id-New-eNB-UE-X2AP-ID,
+	id-Old-eNB-UE-X2AP-ID,
+	id-Registration-Request,
+	id-ReportingPeriodicity,
+	id-ServedCells,
+	id-ServedCellsToActivate,
+	id-ServedCellsToAdd,
+	id-ServedCellsToModify,
+	id-ServedCellsToDelete,
+	id-SRVCCOperationPossible,
+	id-TargetCell-ID,
+	id-TargeteNBtoSource-eNBTransparentContainer,
+	id-TimeToWait,
+	id-TraceActivation,
+	id-UE-ContextInformation,
+	id-UE-HistoryInformation,
+	id-UE-X2AP-ID,
+	id-Measurement-ID,
+	id-ReportCharacteristics,
+	id-ENB1-Measurement-ID,
+	id-ENB2-Measurement-ID,
+	id-ENB1-Cell-ID,
+	id-ENB2-Cell-ID,
+	id-ENB2-Proposed-Mobility-Parameters,
+	id-ENB1-Mobility-Parameters,
+	id-ENB2-Mobility-Parameters-Modification-Range,
+	id-FailureCellPCI,
+	id-Re-establishmentCellECGI,
+	id-FailureCellCRNTI,
+	id-ShortMAC-I,
+	id-SourceCellECGI,
+	id-FailureCellECGI,
+	id-HandoverReportType,
+	id-UE-RLF-Report-Container,
+	id-PartialSuccessIndicator,
+	id-MeasurementInitiationResult-List,
+	id-MeasurementInitiationResult-Item,
+	id-MeasurementFailureCause-Item,
+	id-CompleteFailureCauseInformation-List,
+	id-CompleteFailureCauseInformation-Item,
+	id-CSGMembershipStatus,
+	id-CSG-Id,
+	id-MDTConfiguration,
+	id-ManagementBasedMDTallowed,
+	id-ABS-Status,
+	id-RRCConnSetupIndicator,
+	id-RRCConnReestabIndicator,
+	id-TargetCellInUTRAN,
+	id-MobilityInformation,
+	id-SourceCellCRNTI,
+	id-ManagementBasedMDTPLMNList,
+	id-ReceiveStatusOfULPDCPSDUsExtended,
+	id-ULCOUNTValueExtended,
+	id-DLCOUNTValueExtended,
+	id-IntendedULDLConfiguration,
+	id-ExtendedULInterferenceOverloadInfo,
+	id-RNL-Header,
+	id-x2APMessage,
+	id-UE-HistoryInformationFromTheUE,
+	id-ExpectedUEBehaviour,
+	id-MeNB-UE-X2AP-ID,
+	id-SeNB-UE-X2AP-ID,
+	id-UE-SecurityCapabilities,
+	id-SeNBSecurityKey,
+	id-SeNBUEAggregateMaximumBitRate,
+	id-ServingPLMN,
+	id-E-RABs-ToBeAdded-List,
+	id-E-RABs-ToBeAdded-Item,
+	id-MeNBtoSeNBContainer,
+	id-E-RABs-Admitted-ToBeAdded-List,
+	id-E-RABs-Admitted-ToBeAdded-Item,
+	id-SeNBtoMeNBContainer,
+	id-ResponseInformationSeNBReconfComp,
+	id-UE-ContextInformationSeNBModReq,
+	id-E-RABs-ToBeAdded-ModReqItem,
+	id-E-RABs-ToBeModified-ModReqItem,
+	id-E-RABs-ToBeReleased-ModReqItem,
+	id-E-RABs-Admitted-ToBeAdded-ModAckList,
+	id-E-RABs-Admitted-ToBeModified-ModAckList,
+	id-E-RABs-Admitted-ToBeReleased-ModAckList,
+	id-E-RABs-Admitted-ToBeAdded-ModAckItem,
+	id-E-RABs-Admitted-ToBeModified-ModAckItem,
+	id-E-RABs-Admitted-ToBeReleased-ModAckItem,
+	id-SCGChangeIndication,
+	id-E-RABs-ToBeReleased-ModReqd,
+	id-E-RABs-ToBeReleased-ModReqdItem,
+	id-E-RABs-ToBeReleased-List-RelReq,
+	id-E-RABs-ToBeReleased-RelReqItem,
+	id-E-RABs-ToBeReleased-List-RelConf,
+	id-E-RABs-ToBeReleased-RelConfItem,
+	id-E-RABs-SubjectToCounterCheck-List,
+	id-E-RABs-SubjectToCounterCheckItem,
+	id-CoMPInformation,
+	id-ReportingPeriodicityRSRPMR,
+	id-RSRPMRList,
+	id-UE-RLF-Report-Container-for-extended-bands,
+	id-ProSeAuthorized,
+	id-CoverageModificationList,
+	id-ReportingPeriodicityCSIR,
+	id-CSIReportList,
+	id-ReceiveStatusOfULPDCPSDUsPDCP-SNlength18,
+	id-ULCOUNTValuePDCP-SNlength18,
+	id-DLCOUNTValuePDCP-SNlength18,
+	id-LHN-ID,
+	id-Correlation-ID,
+	id-SIPTO-Correlation-ID,
+	id-UE-ContextReferenceAtSeNB,
+	id-UE-ContextReferenceAtWT,
+	id-UE-ContextKeptIndicator,
+	id-WT-UE-ContextKeptIndicator,
+	id-New-eNB-UE-X2AP-ID-Extension,
+	id-Old-eNB-UE-X2AP-ID-Extension,
+	id-MeNB-UE-X2AP-ID-Extension,
+	id-SeNB-UE-X2AP-ID-Extension,
+	id-SIPTO-BearerDeactivationIndication,
+	id-Tunnel-Information-for-BBF,
+	id-SIPTO-L-GW-TransportLayerAddress,
+	id-GW-TransportLayerAddress,
+	id-X2RemovalThreshold,
+	id-CellReportingIndicator,
+	id-V2XServicesAuthorized,
+	id-resumeID,
+	id-UE-ContextInformationRetrieve,
+	id-E-RABs-ToBeSetupRetrieve-Item,
+	id-NewEUTRANCellIdentifier,
+	id-MakeBeforeBreakIndicator,
+	id-UESidelinkAggregateMaximumBitRate,
+	id-uL-GTPtunnelEndpoint,
+
+	maxCellineNB,
+	maxnoofBearers,
+	maxnoofPDCP-SN,
+	maxFailedMeasObjects,
+	maxnoofCellIDforMDT,
+	maxnoofTAforMDT
+FROM X2AP-Constants;
+
+-- **************************************************************
+--
+-- HANDOVER REQUEST
+--
+-- **************************************************************
+
+HandoverRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container	{{HandoverRequest-IEs}},
+	...
+}
+
+HandoverRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Old-eNB-UE-X2AP-ID				CRITICALITY reject	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause								PRESENCE mandatory}|
+	{ ID id-TargetCell-ID					CRITICALITY reject	TYPE ECGI								PRESENCE mandatory}|
+	{ ID id-GUMMEI-ID						CRITICALITY reject	TYPE GUMMEI								PRESENCE mandatory}|
+	{ ID id-UE-ContextInformation			CRITICALITY reject	TYPE UE-ContextInformation				PRESENCE mandatory}|
+	{ ID id-UE-HistoryInformation			CRITICALITY ignore	TYPE UE-HistoryInformation				PRESENCE mandatory}|
+	{ ID id-TraceActivation					CRITICALITY ignore	TYPE TraceActivation					PRESENCE optional}|
+	{ ID id-SRVCCOperationPossible			CRITICALITY ignore	TYPE SRVCCOperationPossible				PRESENCE optional}|
+	{ ID id-CSGMembershipStatus				CRITICALITY reject	TYPE CSGMembershipStatus				PRESENCE optional}|
+	{ ID id-MobilityInformation				CRITICALITY ignore	TYPE MobilityInformation				PRESENCE optional}|
+	{ ID id-Masked-IMEISV					CRITICALITY ignore	TYPE Masked-IMEISV						PRESENCE optional}|
+	{ ID id-UE-HistoryInformationFromTheUE	CRITICALITY ignore	TYPE UE-HistoryInformationFromTheUE	PRESENCE optional}|
+	{ ID id-ExpectedUEBehaviour				CRITICALITY ignore	TYPE ExpectedUEBehaviour				PRESENCE optional}|
+	{ ID id-ProSeAuthorized					CRITICALITY ignore	TYPE ProSeAuthorized					PRESENCE optional}|
+	{ ID id-UE-ContextReferenceAtSeNB		CRITICALITY ignore	TYPE UE-ContextReferenceAtSeNB			PRESENCE optional}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension	CRITICALITY reject	TYPE UE-X2AP-ID-Extension				PRESENCE optional}|
+	{ ID id-V2XServicesAuthorized			CRITICALITY ignore	TYPE V2XServicesAuthorized				PRESENCE optional}|
+	{ ID id-UE-ContextReferenceAtWT			CRITICALITY ignore	TYPE UE-ContextReferenceAtWT			PRESENCE optional},
+	...
+}
+
+UE-ContextInformation ::= SEQUENCE {
+	mME-UE-S1AP-ID						UE-S1AP-ID,
+	uESecurityCapabilities				UESecurityCapabilities,
+	aS-SecurityInformation				AS-SecurityInformation,
+	uEaggregateMaximumBitRate			UEAggregateMaximumBitRate,
+	subscriberProfileIDforRFP			SubscriberProfileIDforRFP		OPTIONAL,
+	e-RABs-ToBeSetup-List				E-RABs-ToBeSetup-List,
+	rRC-Context							RRC-Context,
+	handoverRestrictionList				HandoverRestrictionList		OPTIONAL,
+	locationReportingInformation		LocationReportingInformation	OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { {UE-ContextInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+UE-ContextInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+{ ID id-ManagementBasedMDTallowed	CRITICALITY ignore	EXTENSION ManagementBasedMDTallowed		PRESENCE optional }|
+{ ID id-ManagementBasedMDTPLMNList	CRITICALITY ignore	EXTENSION MDTPLMNList					PRESENCE optional }|
+{ ID id-UESidelinkAggregateMaximumBitRate	CRITICALITY ignore	EXTENSION UESidelinkAggregateMaximumBitRate		PRESENCE optional},
+	...
+}
+
+E-RABs-ToBeSetup-List ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeSetup-ItemIEs} }
+
+E-RABs-ToBeSetup-ItemIEs 	X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeSetup-Item	 CRITICALITY ignore 	TYPE E-RABs-ToBeSetup-Item 	PRESENCE mandatory },
+	...
+}
+
+E-RABs-ToBeSetup-Item ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters,
+	dL-Forwarding					DL-Forwarding													OPTIONAL,
+	uL-GTPtunnelEndpoint			GTPtunnelEndpoint,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeSetup-ItemExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeSetup-ItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-BearerType		CRITICALITY reject	EXTENSION BearerType		PRESENCE optional},
+	...
+}
+
+MobilityInformation ::= BIT STRING (SIZE(32))
+
+UE-ContextReferenceAtSeNB ::= SEQUENCE {
+	source-GlobalSeNB-ID		GlobalENB-ID,
+	seNB-UE-X2AP-ID				UE-X2AP-ID,
+	seNB-UE-X2AP-ID-Extension	UE-X2AP-ID-Extension,
+	iE-Extensions				ProtocolExtensionContainer { {UE-ContextReferenceAtSeNB-ItemExtIEs} } OPTIONAL,
+	...
+}
+
+UE-ContextReferenceAtSeNB-ItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UE-ContextReferenceAtWT ::= SEQUENCE {
+	wTID					WTID,
+	wT-UE-XwAP-ID			WT-UE-XwAP-ID,
+	iE-Extensions			ProtocolExtensionContainer { {UE-ContextReferenceAtWT-ItemExtIEs} } OPTIONAL,
+	...
+}
+
+UE-ContextReferenceAtWT-ItemExtIEs	X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- HANDOVER REQUEST ACKNOWLEDGE
+--
+-- **************************************************************
+
+HandoverRequestAcknowledge ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{HandoverRequestAcknowledge-IEs}},
+	...
+}
+
+HandoverRequestAcknowledge-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Old-eNB-UE-X2AP-ID							CRITICALITY ignore	TYPE UE-X2AP-ID		PRESENCE mandatory}|
+	{ ID id-New-eNB-UE-X2AP-ID							CRITICALITY ignore	TYPE UE-X2AP-ID		PRESENCE mandatory}|
+	{ ID id-E-RABs-Admitted-List						CRITICALITY ignore	TYPE E-RABs-Admitted-List	PRESENCE mandatory}|
+	{ ID id-E-RABs-NotAdmitted-List						CRITICALITY ignore	TYPE E-RAB-List		PRESENCE optional}|
+	{ ID id-TargeteNBtoSource-eNBTransparentContainer	CRITICALITY ignore	TYPE TargeteNBtoSource-eNBTransparentContainer	PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics						CRITICALITY ignore	TYPE CriticalityDiagnostics	PRESENCE optional}|
+	{ ID id-UE-ContextKeptIndicator						CRITICALITY ignore	TYPE UE-ContextKeptIndicator	PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension					CRITICALITY ignore	TYPE UE-X2AP-ID-Extension	PRESENCE optional}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension				CRITICALITY ignore	TYPE UE-X2AP-ID-Extension	PRESENCE optional}|
+	{ ID id-New-eNB-UE-X2AP-ID-Extension				CRITICALITY reject	TYPE UE-X2AP-ID-Extension	PRESENCE optional}|
+	{ ID id-WT-UE-ContextKeptIndicator					CRITICALITY ignore	TYPE UE-ContextKeptIndicator	PRESENCE optional},
+	...
+}
+
+E-RABs-Admitted-List 		::= SEQUENCE (SIZE (1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-Admitted-ItemIEs} }
+
+E-RABs-Admitted-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-Admitted-Item	CRITICALITY ignore	TYPE E-RABs-Admitted-Item 	PRESENCE mandatory	}
+}
+
+E-RABs-Admitted-Item ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	uL-GTP-TunnelEndpoint			GTPtunnelEndpoint	OPTIONAL,
+	dL-GTP-TunnelEndpoint			GTPtunnelEndpoint	OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-Admitted-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- HANDOVER PREPARATION FAILURE
+--
+-- **************************************************************
+
+HandoverPreparationFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{HandoverPreparationFailure-IEs}},
+	...
+}
+
+HandoverPreparationFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Old-eNB-UE-X2AP-ID				CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension	CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional},
+
+	...
+}
+
+-- **************************************************************
+--
+-- Handover Report
+--
+-- **************************************************************
+
+HandoverReport ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{HandoverReport-IEs}},
+	...
+}
+
+HandoverReport-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-HandoverReportType							CRITICALITY ignore	TYPE HandoverReportType									PRESENCE mandatory}|
+	{ ID id-Cause										CRITICALITY ignore	TYPE Cause													PRESENCE mandatory}|
+	{ ID id-SourceCellECGI								CRITICALITY ignore	TYPE ECGI													PRESENCE mandatory}|
+	{ ID id-FailureCellECGI								CRITICALITY ignore	TYPE ECGI													PRESENCE mandatory}|
+	{ ID id-Re-establishmentCellECGI					CRITICALITY ignore	TYPE ECGI													PRESENCE conditional} -- The IE shall be present if the Handover Report Type IE is set to “HO to Wrong Cell” -- |
+	{ ID id-TargetCellInUTRAN							CRITICALITY ignore	TYPE TargetCellInUTRAN									PRESENCE conditional} -- The IE shall be present if the Handover Report Type IE is set to "InterRAT ping-pong" --|
+	{ ID id-SourceCellCRNTI								CRITICALITY ignore	TYPE CRNTI													PRESENCE optional}|
+	{ ID id-MobilityInformation							CRITICALITY ignore	TYPE MobilityInformation									PRESENCE optional}|
+	{ ID id-UE-RLF-Report-Container						CRITICALITY ignore	TYPE UE-RLF-Report-Container							PRESENCE optional}|
+	{ ID id-UE-RLF-Report-Container-for-extended-bands	CRITICALITY ignore	TYPE UE-RLF-Report-Container-for-extended-bands	PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- SN Status Transfer
+--
+-- **************************************************************
+
+SNStatusTransfer ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SNStatusTransfer-IEs}},
+	...
+}
+
+SNStatusTransfer-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Old-eNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID										PRESENCE mandatory}|
+	{ ID id-New-eNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID										PRESENCE mandatory}|
+	{ ID id-E-RABs-SubjectToStatusTransfer-List		CRITICALITY ignore	TYPE E-RABs-SubjectToStatusTransfer-List		PRESENCE mandatory}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension							PRESENCE optional}|
+	{ ID id-New-eNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension							PRESENCE optional},
+	...
+}
+
+E-RABs-SubjectToStatusTransfer-List	::= SEQUENCE (SIZE (1..maxnoofBearers)) OF ProtocolIE-Single-Container { { E-RABs-SubjectToStatusTransfer-ItemIEs} }
+
+E-RABs-SubjectToStatusTransfer-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-SubjectToStatusTransfer-Item	CRITICALITY ignore	TYPE E-RABs-SubjectToStatusTransfer-Item 	PRESENCE mandatory	}
+}
+
+E-RABs-SubjectToStatusTransfer-Item ::= SEQUENCE {
+	e-RAB-ID								E-RAB-ID,
+	
+	receiveStatusofULPDCPSDUs				ReceiveStatusofULPDCPSDUs			OPTIONAL,
+	uL-COUNTvalue					COUNTvalue,
+	dL-COUNTvalue					COUNTvalue,
+	iE-Extensions							ProtocolExtensionContainer { {E-RABs-SubjectToStatusTransfer-ItemExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-SubjectToStatusTransfer-ItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-ReceiveStatusOfULPDCPSDUsExtended			CRITICALITY ignore	EXTENSION ReceiveStatusOfULPDCPSDUsExtended			PRESENCE optional}|
+	{ ID id-ULCOUNTValueExtended						CRITICALITY ignore	EXTENSION COUNTValueExtended								PRESENCE optional}|
+	{ ID id-DLCOUNTValueExtended						CRITICALITY ignore	EXTENSION COUNTValueExtended								PRESENCE optional}|
+	{ ID id-ReceiveStatusOfULPDCPSDUsPDCP-SNlength18	CRITICALITY ignore	EXTENSION ReceiveStatusOfULPDCPSDUsPDCP-SNlength18	PRESENCE optional}|
+	{ ID id-ULCOUNTValuePDCP-SNlength18					CRITICALITY ignore	EXTENSION COUNTvaluePDCP-SNlength18						PRESENCE optional}|
+	{ ID id-DLCOUNTValuePDCP-SNlength18					CRITICALITY ignore	EXTENSION COUNTvaluePDCP-SNlength18						PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- UE Context Release 
+--
+-- **************************************************************
+
+UEContextRelease ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{UEContextRelease-IEs}},
+	...
+}
+
+UEContextRelease-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Old-eNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-New-eNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension						PRESENCE optional}|
+	{ ID id-New-eNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension						PRESENCE optional}|
+	{ ID id-SIPTO-BearerDeactivationIndication	CRITICALITY ignore	TYPE SIPTOBearerDeactivationIndication		PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- HANDOVER CANCEL
+--
+-- **************************************************************
+
+HandoverCancel ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{HandoverCancel-IEs}},
+	...
+}
+
+HandoverCancel-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Old-eNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-New-eNB-UE-X2AP-ID					CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE optional}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension		PRESENCE optional}|
+	{ ID id-New-eNB-UE-X2AP-ID-Extension		CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- ERROR INDICATION
+--
+-- **************************************************************
+
+ErrorIndication ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ErrorIndication-IEs}},
+	...
+}
+
+ErrorIndication-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Old-eNB-UE-X2AP-ID					CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE optional}|
+	{ ID id-New-eNB-UE-X2AP-ID					CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE optional}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause						PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension		CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional}|
+	{ ID id-New-eNB-UE-X2AP-ID-Extension		CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- Reset Request
+--
+-- **************************************************************
+
+ResetRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ResetRequest-IEs}},
+	...
+}
+
+ResetRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Cause				CRITICALITY ignore	TYPE Cause				PRESENCE mandatory},
+	...
+}
+
+-- **************************************************************
+--
+-- Reset Response
+--
+-- **************************************************************
+
+ResetResponse ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ResetResponse-IEs}},
+	...
+}
+
+ResetResponse-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-CriticalityDiagnostics	CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional },
+	...
+}
+
+-- **************************************************************
+--
+-- X2 SETUP REQUEST
+--
+-- **************************************************************
+
+X2SetupRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2SetupRequest-IEs}},
+	...
+}
+
+X2SetupRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-GlobalENB-ID			CRITICALITY reject	TYPE GlobalENB-ID			PRESENCE mandatory}|
+	{ ID id-ServedCells				CRITICALITY reject	TYPE ServedCells			PRESENCE mandatory}|
+	{ ID id-GUGroupIDList			CRITICALITY reject	TYPE GUGroupIDList			PRESENCE optional}|
+	{ ID id-LHN-ID					CRITICALITY ignore	TYPE LHN-ID					PRESENCE optional},
+...
+}
+
+
+
+-- **************************************************************
+--
+-- X2 SETUP RESPONSE
+--
+-- **************************************************************
+
+X2SetupResponse ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2SetupResponse-IEs}},
+	...
+}
+
+X2SetupResponse-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-GlobalENB-ID				CRITICALITY reject	TYPE GlobalENB-ID			PRESENCE mandatory}|
+	{ ID id-ServedCells					CRITICALITY reject	TYPE ServedCells			PRESENCE mandatory}|
+	{ ID id-GUGroupIDList				CRITICALITY reject	TYPE GUGroupIDList			PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics	PRESENCE optional}|
+	{ ID id-LHN-ID						CRITICALITY ignore	TYPE LHN-ID					PRESENCE optional},
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- X2 SETUP FAILURE
+--
+-- **************************************************************
+
+X2SetupFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2SetupFailure-IEs}},
+	...
+}
+
+X2SetupFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Cause					CRITICALITY ignore		TYPE Cause								PRESENCE mandatory} |
+	{ ID id-TimeToWait				CRITICALITY ignore		TYPE TimeToWait							PRESENCE optional} |
+	{ ID id-CriticalityDiagnostics	CRITICALITY ignore		TYPE CriticalityDiagnostics				PRESENCE optional },
+
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- LOAD INFORMATION
+--
+-- **************************************************************
+
+LoadInformation ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{LoadInformation-IEs}},
+	...
+}
+
+LoadInformation-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-CellInformation				CRITICALITY ignore	TYPE CellInformation-List		PRESENCE mandatory} ,
+	...
+}
+
+CellInformation-List ::= SEQUENCE (SIZE (1..maxCellineNB)) OF ProtocolIE-Single-Container { {CellInformation-ItemIEs} }
+
+CellInformation-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-CellInformation-Item	CRITICALITY ignore	TYPE CellInformation-Item 	PRESENCE mandatory	}
+}
+
+CellInformation-Item ::= SEQUENCE {
+	cell-ID							ECGI,
+	ul-InterferenceOverloadIndication		UL-InterferenceOverloadIndication		OPTIONAL,
+	ul-HighInterferenceIndicationInfo		UL-HighInterferenceIndicationInfo		OPTIONAL,
+	relativeNarrowbandTxPower				RelativeNarrowbandTxPower				OPTIONAL,
+	iE-Extensions							ProtocolExtensionContainer { {CellInformation-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+CellInformation-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+{ ID id-ABSInformation						CRITICALITY ignore	EXTENSION ABSInformation							PRESENCE optional }|
+{ ID id-InvokeIndication					CRITICALITY ignore	EXTENSION InvokeIndication							PRESENCE optional }|
+{ ID id-IntendedULDLConfiguration			CRITICALITY ignore	EXTENSION SubframeAssignment						PRESENCE optional }|
+{ ID id-ExtendedULInterferenceOverloadInfo	CRITICALITY ignore	EXTENSION ExtendedULInterferenceOverloadInfo	PRESENCE optional }|
+{ ID id-CoMPInformation						CRITICALITY ignore	EXTENSION CoMPInformation							PRESENCE optional }|
+{ ID id-DynamicDLTransmissionInformation	CRITICALITY ignore	EXTENSION DynamicDLTransmissionInformation		PRESENCE optional },
+	...
+}
+
+-- **************************************************************
+--
+-- ENB CONFIGURATION UPDATE
+--
+-- **************************************************************
+
+ENBConfigurationUpdate ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ENBConfigurationUpdate-IEs}},
+	...
+}
+
+ENBConfigurationUpdate-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ServedCellsToAdd			CRITICALITY reject	TYPE ServedCells					PRESENCE optional}|
+	{ ID id-ServedCellsToModify			CRITICALITY reject	TYPE ServedCellsToModify			PRESENCE optional}|
+	{ ID id-ServedCellsToDelete			CRITICALITY reject	TYPE Old-ECGIs						PRESENCE optional}|
+	{ ID id-GUGroupIDToAddList			CRITICALITY reject	TYPE GUGroupIDList					PRESENCE optional}|
+	{ ID id-GUGroupIDToDeleteList		CRITICALITY reject	TYPE GUGroupIDList					PRESENCE optional}|
+	{ ID id-CoverageModificationList	CRITICALITY reject	TYPE CoverageModificationList		PRESENCE optional},
+	...
+}
+
+ServedCellsToModify::= SEQUENCE (SIZE (1..maxCellineNB)) OF ServedCellsToModify-Item
+ 
+ServedCellsToModify-Item::= SEQUENCE {
+	old-ecgi						ECGI,
+	servedCellInfo					ServedCell-Information,
+	neighbour-Info					Neighbour-Information			OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { { ServedCellsToModify-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+ServedCellsToModify-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+{ ID id-DeactivationIndication			CRITICALITY ignore	EXTENSION DeactivationIndication				PRESENCE optional },
+	...
+}
+
+
+Old-ECGIs::= SEQUENCE (SIZE (1..maxCellineNB)) OF ECGI
+
+-- **************************************************************
+--
+-- ENB CONFIGURATION UPDATE ACKNOWLEDGE
+--
+-- **************************************************************
+
+ENBConfigurationUpdateAcknowledge ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ENBConfigurationUpdateAcknowledge-IEs}},
+	...
+}
+
+ENBConfigurationUpdateAcknowledge-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional},
+...
+}
+
+-- **************************************************************
+--
+-- ENB CONFIGURATION UPDATE FAIURE
+--
+-- **************************************************************
+
+ENBConfigurationUpdateFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ENBConfigurationUpdateFailure-IEs}},
+	...
+}
+
+ENBConfigurationUpdateFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-TimeToWait					CRITICALITY ignore	TYPE TimeToWait					PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional},
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- Resource Status Request
+--
+-- **************************************************************
+
+ResourceStatusRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ResourceStatusRequest-IEs}},
+	...
+}
+
+ResourceStatusRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ENB1-Measurement-ID			CRITICALITY reject	TYPE Measurement-ID					PRESENCE mandatory}|
+	{ ID id-ENB2-Measurement-ID			CRITICALITY ignore	TYPE Measurement-ID					PRESENCE conditional}|-- The IE shall be present if the Registration Request IE is set to “Stop”, “Partial stop” or to “Add”--
+	{ ID id-Registration-Request		CRITICALITY reject	TYPE Registration-Request			PRESENCE mandatory}|
+	{ ID id-ReportCharacteristics		CRITICALITY reject	TYPE ReportCharacteristics			PRESENCE optional}|
+	{ ID id-CellToReport				CRITICALITY ignore	TYPE CellToReport-List				PRESENCE mandatory}|
+	{ ID id-ReportingPeriodicity		CRITICALITY ignore	TYPE ReportingPeriodicity			PRESENCE optional}|
+	{ ID id-PartialSuccessIndicator		CRITICALITY ignore	TYPE PartialSuccessIndicator		PRESENCE optional}|
+	{ ID id-ReportingPeriodicityRSRPMR	CRITICALITY ignore	TYPE ReportingPeriodicityRSRPMR		PRESENCE optional}|
+	{ ID id-ReportingPeriodicityCSIR	CRITICALITY ignore	TYPE ReportingPeriodicityCSIR		PRESENCE optional},
+	...
+}
+
+
+CellToReport-List 		::= SEQUENCE (SIZE (1..maxCellineNB)) OF ProtocolIE-Single-Container { {CellToReport-ItemIEs} }
+
+CellToReport-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-CellToReport-Item	CRITICALITY ignore	TYPE CellToReport-Item 	PRESENCE mandatory}
+}
+
+CellToReport-Item ::= SEQUENCE {
+	cell-ID									ECGI,
+	iE-Extensions							ProtocolExtensionContainer { {CellToReport-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+CellToReport-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+ReportingPeriodicity ::= ENUMERATED {
+	one-thousand-ms,
+	two-thousand-ms,
+	five-thousand-ms,
+	ten-thousand-ms,
+...
+}
+
+PartialSuccessIndicator ::= ENUMERATED {
+	partial-success-allowed,
+...
+}
+
+-- **************************************************************
+--
+-- Resource Status Response
+--
+-- **************************************************************
+
+ResourceStatusResponse ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ResourceStatusResponse-IEs}},
+	...
+}
+
+ResourceStatusResponse-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ENB1-Measurement-ID					CRITICALITY reject	TYPE Measurement-ID							PRESENCE mandatory}|
+	{ ID id-ENB2-Measurement-ID					CRITICALITY reject	TYPE Measurement-ID							PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics					PRESENCE optional}|
+	{ ID id-MeasurementInitiationResult-List	CRITICALITY ignore	TYPE MeasurementInitiationResult-List	PRESENCE optional},
+	...
+}
+
+
+MeasurementInitiationResult-List ::= SEQUENCE (SIZE (1..maxCellineNB)) OF ProtocolIE-Single-Container { { MeasurementInitiationResult-ItemIEs} }
+
+MeasurementInitiationResult-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeasurementInitiationResult-Item	CRITICALITY ignore	TYPE MeasurementInitiationResult-Item	PRESENCE mandatory}
+}
+
+MeasurementInitiationResult-Item ::= SEQUENCE {
+	cell-ID											ECGI,
+	measurementFailureCause-List					MeasurementFailureCause-List	OPTIONAL,
+	iE-Extensions									ProtocolExtensionContainer { { MeasurementInitiationResult-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+MeasurementInitiationResult-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+MeasurementFailureCause-List ::= SEQUENCE (SIZE (1..maxFailedMeasObjects)) OF ProtocolIE-Single-Container { { MeasurementFailureCause-ItemIEs} }
+
+MeasurementFailureCause-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeasurementFailureCause-Item	CRITICALITY ignore	TYPE MeasurementFailureCause-Item		PRESENCE mandatory}
+}
+
+MeasurementFailureCause-Item ::= SEQUENCE {
+	measurementFailedReportCharacteristics			ReportCharacteristics,
+	cause											Cause,
+	iE-Extensions									ProtocolExtensionContainer { { MeasurementFailureCause-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+MeasurementFailureCause-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- Resource Status Failure
+--
+-- **************************************************************
+
+ResourceStatusFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ResourceStatusFailure-IEs}},
+	...
+}
+
+ResourceStatusFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ENB1-Measurement-ID						CRITICALITY reject	TYPE Measurement-ID									PRESENCE mandatory}|
+	{ ID id-ENB2-Measurement-ID						CRITICALITY reject	TYPE Measurement-ID									PRESENCE mandatory}|
+	{ ID id-Cause									CRITICALITY ignore	TYPE Cause											PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics					CRITICALITY ignore	TYPE CriticalityDiagnostics						PRESENCE optional}|
+	{ ID id-CompleteFailureCauseInformation-List	CRITICALITY ignore	TYPE CompleteFailureCauseInformation-List	PRESENCE optional},
+	...
+}
+
+CompleteFailureCauseInformation-List ::= SEQUENCE (SIZE (1..maxCellineNB)) OF ProtocolIE-Single-Container { {CompleteFailureCauseInformation-ItemIEs} }
+
+CompleteFailureCauseInformation-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-CompleteFailureCauseInformation-Item	CRITICALITY ignore	TYPE CompleteFailureCauseInformation-Item	PRESENCE mandatory}
+}
+
+CompleteFailureCauseInformation-Item ::= SEQUENCE {
+	cell-ID											ECGI,
+	measurementFailureCause-List					MeasurementFailureCause-List,
+	iE-Extensions									ProtocolExtensionContainer { { CompleteFailureCauseInformation-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+CompleteFailureCauseInformation-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- Resource Status Update
+--
+-- **************************************************************
+
+ResourceStatusUpdate ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ResourceStatusUpdate-IEs}},
+	...
+}
+
+ResourceStatusUpdate-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ENB1-Measurement-ID		CRITICALITY reject	TYPE Measurement-ID					PRESENCE mandatory}|
+	{ ID id-ENB2-Measurement-ID		CRITICALITY reject	TYPE Measurement-ID					PRESENCE mandatory}|
+	{ ID id-CellMeasurementResult	CRITICALITY ignore	TYPE CellMeasurementResult-List		PRESENCE mandatory},
+	...
+}
+
+CellMeasurementResult-List ::= SEQUENCE (SIZE (1..maxCellineNB)) OF ProtocolIE-Single-Container { {CellMeasurementResult-ItemIEs} }
+
+CellMeasurementResult-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-CellMeasurementResult-Item	CRITICALITY ignore	TYPE CellMeasurementResult-Item	PRESENCE mandatory}
+}
+
+CellMeasurementResult-Item ::= SEQUENCE {
+	cell-ID						ECGI,
+	hWLoadIndicator				HWLoadIndicator		OPTIONAL,
+	s1TNLLoadIndicator			S1TNLLoadIndicator	OPTIONAL,
+	radioResourceStatus			RadioResourceStatus	OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { {CellMeasurementResult-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+CellMeasurementResult-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-CompositeAvailableCapacityGroup	CRITICALITY ignore	EXTENSION CompositeAvailableCapacityGroup		PRESENCE optional}|
+	{ ID id-ABS-Status						CRITICALITY ignore	EXTENSION ABS-Status								PRESENCE optional}|
+	{ ID id-RSRPMRList						CRITICALITY ignore	EXTENSION RSRPMRList								PRESENCE optional}|
+	{ ID id-CSIReportList					CRITICALITY ignore	EXTENSION CSIReportList								PRESENCE optional}|
+	{ ID id-CellReportingIndicator			CRITICALITY ignore	EXTENSION CellReportingIndicator					PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- PRIVATE MESSAGE
+--
+-- **************************************************************
+
+PrivateMessage ::= SEQUENCE {
+	privateIEs		PrivateIE-Container	{{PrivateMessage-IEs}},
+	...
+}
+
+PrivateMessage-IEs X2AP-PRIVATE-IES ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- MOBILITY CHANGE REQUEST
+--
+-- **************************************************************
+
+MobilityChangeRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{MobilityChangeRequest-IEs}},
+	...
+}
+
+MobilityChangeRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ENB1-Cell-ID						CRITICALITY reject	TYPE ECGI											PRESENCE mandatory}|
+	{ ID id-ENB2-Cell-ID						CRITICALITY reject	TYPE ECGI											PRESENCE mandatory}|
+	{ ID id-ENB1-Mobility-Parameters			CRITICALITY ignore	TYPE MobilityParametersInformation				PRESENCE optional}|
+	{ ID id-ENB2-Proposed-Mobility-Parameters	CRITICALITY reject	TYPE MobilityParametersInformation				PRESENCE mandatory}|
+	{ ID id-Cause								CRITICALITY reject	TYPE Cause											PRESENCE mandatory},
+	...
+}
+
+-- **************************************************************
+--
+-- MOBILITY CHANGE ACKNOWLEDGE
+--
+-- **************************************************************
+
+MobilityChangeAcknowledge ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{MobilityChangeAcknowledge-IEs}},
+	...
+}
+
+MobilityChangeAcknowledge-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ENB1-Cell-ID			CRITICALITY reject	TYPE ECGI							PRESENCE mandatory}|
+	{ ID id-ENB2-Cell-ID			CRITICALITY reject	TYPE ECGI							PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics	CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- MOBILITY CHANGE FAILURE
+--
+-- **************************************************************
+
+MobilityChangeFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{MobilityChangeFailure-IEs}},
+	...
+}
+
+MobilityChangeFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ENB1-Cell-ID									CRITICALITY ignore	TYPE ECGI												PRESENCE mandatory}|
+	{ ID id-ENB2-Cell-ID									CRITICALITY ignore	TYPE ECGI												PRESENCE mandatory}|
+	{ ID id-Cause											CRITICALITY ignore	TYPE Cause												PRESENCE mandatory}|
+	{ ID id-ENB2-Mobility-Parameters-Modification-Range		CRITICALITY ignore	TYPE MobilityParametersModificationRange		PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics							CRITICALITY ignore	TYPE CriticalityDiagnostics						PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- Radio Link Failure Indication
+--
+-- **************************************************************
+
+RLFIndication ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{RLFIndication-IEs}},
+	...
+}
+
+RLFIndication-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-FailureCellPCI								CRITICALITY ignore	TYPE PCI														PRESENCE mandatory}|
+	{ ID id-Re-establishmentCellECGI					CRITICALITY ignore	TYPE ECGI														PRESENCE mandatory}|
+	{ ID id-FailureCellCRNTI							CRITICALITY ignore	TYPE CRNTI														PRESENCE mandatory}|
+	{ ID id-ShortMAC-I									CRITICALITY ignore	TYPE ShortMAC-I													PRESENCE optional}|
+	{ ID id-UE-RLF-Report-Container						CRITICALITY ignore	TYPE UE-RLF-Report-Container								PRESENCE optional}|
+	{ ID id-RRCConnSetupIndicator						CRITICALITY reject	TYPE RRCConnSetupIndicator									PRESENCE optional}|
+	{ ID id-RRCConnReestabIndicator						CRITICALITY ignore	TYPE RRCConnReestabIndicator								PRESENCE optional}|
+	{ ID id-UE-RLF-Report-Container-for-extended-bands	CRITICALITY ignore	TYPE UE-RLF-Report-Container-for-extended-bands		PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- Cell Activation Request
+--
+-- **************************************************************
+
+CellActivationRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{CellActivationRequest-IEs}},
+	...
+}
+
+CellActivationRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ServedCellsToActivate 	CRITICALITY reject	TYPE ServedCellsToActivate		PRESENCE mandatory},
+	...
+}
+
+ServedCellsToActivate::= SEQUENCE (SIZE (1..maxCellineNB)) OF ServedCellsToActivate-Item
+ 
+ServedCellsToActivate-Item::= SEQUENCE {
+	ecgi						ECGI,
+	iE-Extensions					ProtocolExtensionContainer { { ServedCellsToActivate-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+ServedCellsToActivate-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- Cell Activation Response
+--
+-- **************************************************************
+
+CellActivationResponse ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{CellActivationResponse-IEs}},
+	...
+}
+
+CellActivationResponse-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-ActivatedCellList		CRITICALITY ignore	TYPE ActivatedCellList				PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics	CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional},
+	...
+}
+
+ActivatedCellList ::= SEQUENCE (SIZE (1..maxCellineNB)) OF ActivatedCellList-Item
+ 
+ActivatedCellList-Item::= SEQUENCE {
+	ecgi								ECGI,
+	iE-Extensions						ProtocolExtensionContainer { { ActivatedCellList-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+ActivatedCellList-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+--**************************************************************
+--
+-- CELL ACTIVATION FAILURE
+--
+-- **************************************************************
+
+CellActivationFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{CellActivationFailure-IEs}},
+	...
+}
+
+CellActivationFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory }|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional },
+	...
+}
+
+-- **************************************************************
+--
+-- X2 RELEASE
+--
+-- **************************************************************
+
+X2Release ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2Release-IEs}},
+	...
+}
+
+X2Release-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-GlobalENB-ID			CRITICALITY reject	TYPE GlobalENB-ID			PRESENCE mandatory},
+...
+}
+
+-- **************************************************************
+--
+-- X2AP Message Transfer 
+--
+-- **************************************************************
+
+X2APMessageTransfer ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2APMessageTransfer-IEs}},
+	...
+}
+
+X2APMessageTransfer-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-RNL-Header	CRITICALITY reject	TYPE RNL-Header				PRESENCE mandatory}|
+	{ ID id-x2APMessage	CRITICALITY reject	TYPE X2AP-Message			PRESENCE optional},
+	...
+}
+
+RNL-Header ::= SEQUENCE {
+	source-GlobalENB-ID	GlobalENB-ID,
+	target-GlobalENB-ID	GlobalENB-ID	OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { { RNL-Header-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+RNL-Header-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+X2AP-Message ::= OCTET STRING
+
+-- **************************************************************
+--
+-- SENB ADDITION REQUEST
+--
+-- **************************************************************
+
+SeNBAdditionRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBAdditionRequest-IEs}},
+	...
+}
+
+SeNBAdditionRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-UE-SecurityCapabilities			CRITICALITY reject	TYPE UESecurityCapabilities				PRESENCE conditional}|
+	-- This IE shall be present if the Bearer Option IE is set to the value “SCG bearer” --
+	{ ID id-SeNBSecurityKey					CRITICALITY reject	TYPE SeNBSecurityKey					PRESENCE conditional}|
+	-- This IE shall be present if the Bearer Option IE is set to the value “SCG bearer” --
+	{ ID id-SeNBUEAggregateMaximumBitRate	CRITICALITY reject	TYPE UEAggregateMaximumBitRate			PRESENCE mandatory}|
+	{ ID id-ServingPLMN						CRITICALITY ignore	TYPE PLMN-Identity						PRESENCE optional}|
+	{ ID id-E-RABs-ToBeAdded-List			CRITICALITY reject	TYPE E-RABs-ToBeAdded-List				PRESENCE mandatory}|
+	{ ID id-MeNBtoSeNBContainer				CRITICALITY reject	TYPE MeNBtoSeNBContainer				PRESENCE mandatory}|
+	{ ID id-CSGMembershipStatus				CRITICALITY reject	TYPE CSGMembershipStatus				PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID							PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension				PRESENCE optional}|
+	{ ID id-ExpectedUEBehaviour				CRITICALITY ignore	TYPE ExpectedUEBehaviour				PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension				PRESENCE optional},
+	...
+}
+
+E-RABs-ToBeAdded-List ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { { E-RABs-ToBeAdded-ItemIEs} }
+
+E-RABs-ToBeAdded-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeAdded-Item	CRITICALITY reject	TYPE E-RABs-ToBeAdded-Item		PRESENCE mandatory},
+	...
+}
+
+E-RABs-ToBeAdded-Item ::= CHOICE {
+	sCG-Bearer		E-RABs-ToBeAdded-Item-SCG-Bearer,
+	split-Bearer	E-RABs-ToBeAdded-Item-Split-Bearer,
+	...
+}
+
+E-RABs-ToBeAdded-Item-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters,
+	dL-Forwarding					DL-Forwarding																	OPTIONAL,
+	s1-UL-GTPtunnelEndpoint			GTPtunnelEndpoint,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeAdded-Item-SCG-BearerExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABs-ToBeAdded-Item-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-Correlation-ID				CRITICALITY ignore	EXTENSION Correlation-ID		PRESENCE optional}|
+	{ ID id-SIPTO-Correlation-ID		CRITICALITY ignore	EXTENSION Correlation-ID		PRESENCE optional},
+	...
+}
+
+E-RABs-ToBeAdded-Item-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters,
+	meNB-GTPtunnelEndpoint			GTPtunnelEndpoint,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeAdded-Item-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeAdded-Item-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB ADDITION REQUEST ACKNOWLEDGE
+--
+-- **************************************************************
+
+SeNBAdditionRequestAcknowledge ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBAdditionRequestAcknowledge-IEs}},
+	...
+}
+
+SeNBAdditionRequestAcknowledge-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-E-RABs-Admitted-ToBeAdded-List		CRITICALITY ignore	TYPE E-RABs-Admitted-ToBeAdded-List	PRESENCE mandatory}|
+	{ ID id-E-RABs-NotAdmitted-List				CRITICALITY ignore	TYPE E-RAB-List							PRESENCE optional}|
+	{ ID id-SeNBtoMeNBContainer					CRITICALITY reject	TYPE SeNBtoMeNBContainer				PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional}|
+	{ ID id-GW-TransportLayerAddress			CRITICALITY ignore	TYPE TransportLayerAddress				PRESENCE optional}|
+	{ ID id-SIPTO-L-GW-TransportLayerAddress	CRITICALITY ignore	TYPE TransportLayerAddress				PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension				PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension				PRESENCE optional}|
+	{ ID id-Tunnel-Information-for-BBF			CRITICALITY ignore	TYPE TunnelInformation					PRESENCE optional},
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-List ::= SEQUENCE (SIZE (1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-Admitted-ToBeAdded-ItemIEs} }
+
+E-RABs-Admitted-ToBeAdded-ItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-Admitted-ToBeAdded-Item	CRITICALITY ignore	TYPE E-RABs-Admitted-ToBeAdded-Item 		PRESENCE mandatory}
+}
+
+E-RABs-Admitted-ToBeAdded-Item ::= CHOICE {
+	sCG-Bearer		E-RABs-Admitted-ToBeAdded-Item-SCG-Bearer,
+	split-Bearer	E-RABs-Admitted-ToBeAdded-Item-Split-Bearer,
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-Item-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID								E-RAB-ID,
+	s1-DL-GTPtunnelEndpoint					GTPtunnelEndpoint,
+	dL-Forwarding-GTPtunnelEndpoint			GTPtunnelEndpoint																	OPTIONAL,
+	uL-Forwarding-GTPtunnelEndpoint			GTPtunnelEndpoint																	OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-Admitted-ToBeAdded-Item-SCG-BearerExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-Item-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-Item-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	seNB-GTPtunnelEndpoint			GTPtunnelEndpoint,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-Admitted-ToBeAdded-Item-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-Item-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB ADDITION REQUEST REJECT
+--
+-- **************************************************************
+
+SeNBAdditionRequestReject ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBAdditionRequestReject-IEs}},
+	...
+}
+
+SeNBAdditionRequestReject-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension		PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- SENB RECONFIGURATION COMPLETE
+--
+-- **************************************************************
+
+SeNBReconfigurationComplete ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBReconfigurationComplete-IEs}},
+	...
+}
+
+SeNBReconfigurationComplete-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID							CRITICALITY reject	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID							CRITICALITY reject	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-ResponseInformationSeNBReconfComp		CRITICALITY ignore	TYPE ResponseInformationSeNBReconfComp	PRESENCE mandatory}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension				CRITICALITY reject	TYPE UE-X2AP-ID-Extension						PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension				CRITICALITY reject	TYPE UE-X2AP-ID-Extension						PRESENCE optional},
+	...
+}
+
+ResponseInformationSeNBReconfComp ::= CHOICE {
+	success				ResponseInformationSeNBReconfComp-SuccessItem,
+	reject-by-MeNB		ResponseInformationSeNBReconfComp-RejectByMeNBItem,
+	...
+}
+
+ResponseInformationSeNBReconfComp-SuccessItem ::= SEQUENCE {
+	meNBtoSeNBContainer				MeNBtoSeNBContainer OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {ResponseInformationSeNBReconfComp-SuccessItemExtIEs} }	OPTIONAL,
+	...
+}
+
+ResponseInformationSeNBReconfComp-SuccessItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ResponseInformationSeNBReconfComp-RejectByMeNBItem ::= SEQUENCE {
+	cause							Cause,
+	meNBtoSeNBContainer				MeNBtoSeNBContainer																						OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { { ResponseInformationSeNBReconfComp-RejectByMeNBItemExtIEs} }	OPTIONAL,
+	...
+}
+
+ResponseInformationSeNBReconfComp-RejectByMeNBItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB MODIFICATION REQUEST
+--
+-- **************************************************************
+
+SeNBModificationRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ SeNBModificationRequest-IEs}},
+	...
+}
+
+SeNBModificationRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID								PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID								PRESENCE mandatory}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause									PRESENCE mandatory}|
+	{ ID id-SCGChangeIndication					CRITICALITY ignore	TYPE SCGChangeIndication					PRESENCE optional}|
+	{ ID id-ServingPLMN							CRITICALITY ignore	TYPE PLMN-Identity							PRESENCE optional}|
+	{ ID id-UE-ContextInformationSeNBModReq		CRITICALITY reject	TYPE UE-ContextInformationSeNBModReq	PRESENCE optional}|
+	{ ID id-MeNBtoSeNBContainer					CRITICALITY ignore	TYPE MeNBtoSeNBContainer					PRESENCE optional}|
+	{ ID id-CSGMembershipStatus					CRITICALITY reject	TYPE CSGMembershipStatus					PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension					PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension					PRESENCE optional},
+	...
+}
+
+UE-ContextInformationSeNBModReq ::= SEQUENCE {
+	uE-SecurityCapabilities			UESecurityCapabilities															OPTIONAL,
+	seNB-SecurityKey				SeNBSecurityKey 																OPTIONAL,
+	seNBUEAggregateMaximumBitRate	UEAggregateMaximumBitRate														OPTIONAL,
+	e-RABs-ToBeAdded				E-RABs-ToBeAdded-List-ModReq													OPTIONAL,
+	e-RABs-ToBeModified				E-RABs-ToBeModified-List-ModReq													OPTIONAL,
+	e-RABs-ToBeReleased				E-RABs-ToBeReleased-List-ModReq													OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { { UE-ContextInformationSeNBModReqExtIEs} }	OPTIONAL,
+	...
+}
+
+UE-ContextInformationSeNBModReqExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-ToBeAdded-List-ModReq ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeAdded-ModReqItemIEs} }
+
+E-RABs-ToBeAdded-ModReqItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeAdded-ModReqItem	CRITICALITY ignore	TYPE E-RABs-ToBeAdded-ModReqItem	PRESENCE mandatory},
+	...
+}
+
+E-RABs-ToBeAdded-ModReqItem ::= CHOICE {
+	sCG-Bearer		E-RABs-ToBeAdded-ModReqItem-SCG-Bearer,
+	split-Bearer	E-RABs-ToBeAdded-ModReqItem-Split-Bearer,
+	...
+}
+
+E-RABs-ToBeAdded-ModReqItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters,
+	dL-Forwarding					DL-Forwarding																	OPTIONAL,
+	s1-UL-GTPtunnelEndpoint			GTPtunnelEndpoint,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeAdded-ModReqItem-SCG-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeAdded-ModReqItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-Correlation-ID				CRITICALITY ignore	EXTENSION Correlation-ID		PRESENCE optional}|
+	{ ID id-SIPTO-Correlation-ID		CRITICALITY ignore	EXTENSION Correlation-ID		PRESENCE optional},
+	...
+}
+
+E-RABs-ToBeAdded-ModReqItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters,
+	meNB-GTPtunnelEndpoint			GTPtunnelEndpoint,
+	iE-Extensions			ProtocolExtensionContainer { {E-RABs-ToBeAdded-ModReqItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeAdded-ModReqItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-ToBeModified-List-ModReq ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeModified-ModReqItemIEs} }
+
+E-RABs-ToBeModified-ModReqItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeModified-ModReqItem	CRITICALITY ignore	TYPE E-RABs-ToBeModified-ModReqItem		PRESENCE mandatory},
+	...
+}
+
+
+E-RABs-ToBeModified-ModReqItem ::= CHOICE {
+	sCG-Bearer		E-RABs-ToBeModified-ModReqItem-SCG-Bearer,
+	split-Bearer	E-RABs-ToBeModified-ModReqItem-Split-Bearer,
+	...
+}
+
+E-RABs-ToBeModified-ModReqItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters														OPTIONAL,
+	s1-UL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeModified-ModReqItem-SCG-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeModified-ModReqItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-ToBeModified-ModReqItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters																OPTIONAL,
+	meNB-GTPtunnelEndpoint			GTPtunnelEndpoint																		OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeModified-ModReqItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeModified-ModReqItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-ToBeReleased-List-ModReq ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeReleased-ModReqItemIEs} }
+
+E-RABs-ToBeReleased-ModReqItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeReleased-ModReqItem	CRITICALITY ignore	TYPE E-RABs-ToBeReleased-ModReqItem		PRESENCE mandatory},
+	...
+}
+
+E-RABs-ToBeReleased-ModReqItem ::= CHOICE {
+	sCG-Bearer		E-RABs-ToBeReleased-ModReqItem-SCG-Bearer,
+	split-Bearer	E-RABs-ToBeReleased-ModReqItem-Split-Bearer,
+	...
+}
+
+E-RABs-ToBeReleased-ModReqItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	dL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	uL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeReleased-ModReqItem-SCG-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeReleased-ModReqItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-ToBeReleased-ModReqItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID, 
+	dL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeReleased-ModReqItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeReleased-ModReqItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB MODIFICATION REQUEST ACKNOWLEDGE
+--
+-- **************************************************************
+
+SeNBModificationRequestAcknowledge ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBModificationRequestAcknowledge-IEs}},
+	...
+}
+
+SeNBModificationRequestAcknowledge-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID								CRITICALITY ignore	TYPE UE-X2AP-ID											PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID								CRITICALITY ignore	TYPE UE-X2AP-ID											PRESENCE mandatory}|
+	{ ID id-E-RABs-Admitted-ToBeAdded-ModAckList		CRITICALITY ignore	TYPE E-RABs-Admitted-ToBeAdded-ModAckList		PRESENCE optional}|
+	{ ID id-E-RABs-Admitted-ToBeModified-ModAckList		CRITICALITY ignore	TYPE E-RABs-Admitted-ToBeModified-ModAckList	PRESENCE optional}|
+	{ ID id-E-RABs-Admitted-ToBeReleased-ModAckList		CRITICALITY ignore	TYPE E-RABs-Admitted-ToBeReleased-ModAckList	PRESENCE optional}|
+	{ ID id-E-RABs-NotAdmitted-List						CRITICALITY ignore	TYPE E-RAB-List											PRESENCE optional}|
+	{ ID id-SeNBtoMeNBContainer							CRITICALITY ignore	TYPE SeNBtoMeNBContainer								PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics						CRITICALITY ignore	TYPE CriticalityDiagnostics							PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension					CRITICALITY ignore	TYPE UE-X2AP-ID-Extension							PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension					CRITICALITY ignore	TYPE UE-X2AP-ID-Extension							PRESENCE optional},
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-ModAckList ::= SEQUENCE (SIZE (1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-Admitted-ToBeAdded-ModAckItemIEs} }
+
+E-RABs-Admitted-ToBeAdded-ModAckItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-Admitted-ToBeAdded-ModAckItem	CRITICALITY ignore	TYPE E-RABs-Admitted-ToBeAdded-ModAckItem		PRESENCE mandatory}
+}
+
+E-RABs-Admitted-ToBeAdded-ModAckItem ::= CHOICE {
+	sCG-Bearer		E-RABs-Admitted-ToBeAdded-ModAckItem-SCG-Bearer,
+	split-Bearer	E-RABs-Admitted-ToBeAdded-ModAckItem-Split-Bearer,
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-ModAckItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID								E-RAB-ID,
+	s1-DL-GTPtunnelEndpoint					GTPtunnelEndpoint,
+	dL-Forwarding-GTPtunnelEndpoint			GTPtunnelEndpoint																	OPTIONAL,
+	uL-Forwarding-GTPtunnelEndpoint			GTPtunnelEndpoint																	OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-Admitted-ToBeAdded-ModAckItem-SCG-BearerExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-ModAckItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-ModAckItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	seNB-GTPtunnelEndpoint			GTPtunnelEndpoint,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-Admitted-ToBeAdded-ModAckItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeAdded-ModAckItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+E-RABs-Admitted-ToBeModified-ModAckList ::= SEQUENCE (SIZE (1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-Admitted-ToBeModified-ModAckItemIEs} }
+
+E-RABs-Admitted-ToBeModified-ModAckItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-Admitted-ToBeModified-ModAckItem		CRITICALITY ignore	TYPE E-RABs-Admitted-ToBeModified-ModAckItem	PRESENCE mandatory}
+}
+
+E-RABs-Admitted-ToBeModified-ModAckItem ::= CHOICE {
+	sCG-Bearer		E-RABs-Admitted-ToBeModified-ModAckItem-SCG-Bearer,
+	split-Bearer	E-RABs-Admitted-ToBeModified-ModAckItem-Split-Bearer,
+	...
+}
+
+E-RABs-Admitted-ToBeModified-ModAckItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	s1-DL-GTPtunnelEndpoint			GTPtunnelEndpoint																	OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-Admitted-ToBeModified-ModAckItem-SCG-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeModified-ModAckItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-Admitted-ToBeModified-ModAckItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	seNB-GTPtunnelEndpoint			GTPtunnelEndpoint																			OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-Admitted-ToBeModified-ModAckItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeModified-ModAckItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-Admitted-ToBeReleased-ModAckList ::= SEQUENCE (SIZE (1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-Admitted-ToBeReleased-ModAckItemIEs} }
+
+E-RABs-Admitted-ToBeReleased-ModAckItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-Admitted-ToBeReleased-ModAckItem		CRITICALITY ignore	TYPE E-RABs-Admitted-ToReleased-ModAckItem		PRESENCE mandatory}
+}
+
+E-RABs-Admitted-ToReleased-ModAckItem ::= CHOICE {
+	sCG-Bearer		E-RABs-Admitted-ToBeReleased-ModAckItem-SCG-Bearer,
+	split-Bearer	E-RABs-Admitted-ToBeReleased-ModAckItem-Split-Bearer,
+	...
+}
+
+E-RABs-Admitted-ToBeReleased-ModAckItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	iE-Extensions				ProtocolExtensionContainer { {E-RABs-Admitted-ToBeReleased-ModAckItem-SCG-BearerExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeReleased-ModAckItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-Admitted-ToBeReleased-ModAckItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	iE-Extensions				ProtocolExtensionContainer { {E-RABs-Admitted-ToBeReleased-ModAckItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-Admitted-ToBeReleased-ModAckItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB MODIFICATION REQUEST REJECT
+--
+-- **************************************************************
+
+SeNBModificationRequestReject ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBModificationRequestReject-IEs}},
+	...
+}
+
+SeNBModificationRequestReject-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- SENB MODIFICATION REQUIRED
+--
+-- **************************************************************
+
+SeNBModificationRequired ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container		{{SeNBModificationRequired-IEs}},
+	...
+}
+
+SeNBModificationRequired-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause								PRESENCE mandatory}|
+	{ ID id-SCGChangeIndication					CRITICALITY ignore	TYPE SCGChangeIndication				PRESENCE optional}|
+	{ ID id-E-RABs-ToBeReleased-ModReqd			CRITICALITY ignore	TYPE E-RABs-ToBeReleased-ModReqd		PRESENCE optional}|
+	{ ID id-SeNBtoMeNBContainer					CRITICALITY ignore	TYPE SeNBtoMeNBContainer				PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension				PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension				PRESENCE optional},
+	...
+}
+
+
+E-RABs-ToBeReleased-ModReqd ::= SEQUENCE (SIZE (1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeReleased-ModReqdItemIEs} }
+
+E-RABs-ToBeReleased-ModReqdItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeReleased-ModReqdItem	 CRITICALITY ignore		TYPE E-RABs-ToBeReleased-ModReqdItem	PRESENCE mandatory },
+	...
+}
+
+E-RABs-ToBeReleased-ModReqdItem ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	cause							Cause,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeReleased-ModReqdItemExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeReleased-ModReqdItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB MODIFICATION CONFIRM
+--
+-- **************************************************************
+
+SeNBModificationConfirm ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBModificationConfirm-IEs}},
+	...
+}
+
+SeNBModificationConfirm-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID						PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID						PRESENCE mandatory}|
+	{ ID id-MeNBtoSeNBContainer					CRITICALITY ignore	TYPE MeNBtoSeNBContainer			PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension			PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension			PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- SENB MODIFICATION REFUSE
+--
+-- **************************************************************
+
+SeNBModificationRefuse ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container		{{SeNBModificationRefuse-IEs}},
+	...
+}
+
+SeNBModificationRefuse-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-MeNBtoSeNBContainer					CRITICALITY ignore	TYPE MeNBtoSeNBContainer		PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- SENB RELEASE REQUEST
+--
+-- **************************************************************
+
+SeNBReleaseRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container		{{SeNBReleaseRequest-IEs}},
+	...
+}
+
+SeNBReleaseRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY reject	TYPE UE-X2AP-ID									PRESENCE optional}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause										PRESENCE optional}|
+	{ ID id-E-RABs-ToBeReleased-List-RelReq		CRITICALITY ignore	TYPE E-RABs-ToBeReleased-List-RelReq		PRESENCE optional}|
+	{ ID id-UE-ContextKeptIndicator				CRITICALITY ignore	TYPE UE-ContextKeptIndicator					PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension						PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension						PRESENCE optional}|
+	{ ID id-MakeBeforeBreakIndicator			CRITICALITY ignore	TYPE MakeBeforeBreakIndicator				PRESENCE optional},
+	...
+}
+E-RABs-ToBeReleased-List-RelReq ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeReleased-RelReqItemIEs} }
+
+E-RABs-ToBeReleased-RelReqItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeReleased-RelReqItem		CRITICALITY ignore	TYPE E-RABs-ToBeReleased-RelReqItem		PRESENCE mandatory},
+	...
+}
+
+E-RABs-ToBeReleased-RelReqItem ::= CHOICE {
+	sCG-Bearer		E-RABs-ToBeReleased-RelReqItem-SCG-Bearer,
+	split-Bearer	E-RABs-ToBeReleased-RelReqItem-Split-Bearer,
+	...
+}
+
+E-RABs-ToBeReleased-RelReqItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	uL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	dL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeReleased-RelReqItem-SCG-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeReleased-RelReqItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-ToBeReleased-RelReqItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	dL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeReleased-RelReqItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeReleased-RelReqItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB RELEASE REQUIRED
+--
+-- **************************************************************
+
+SeNBReleaseRequired ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBReleaseRequired-IEs}},
+	...
+}
+
+SeNBReleaseRequired-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension		PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension		CRITICALITY reject	TYPE UE-X2AP-ID-Extension		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- SENB RELEASE CONFIRM
+--
+-- **************************************************************
+
+SeNBReleaseConfirm ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBReleaseConfirm-IEs}},
+	...
+}
+
+SeNBReleaseConfirm-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID							CRITICALITY ignore	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID							CRITICALITY ignore	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-E-RABs-ToBeReleased-List-RelConf		CRITICALITY ignore	TYPE E-RABs-ToBeReleased-List-RelConf		PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics					CRITICALITY ignore	TYPE CriticalityDiagnostics					PRESENCE optional}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension				CRITICALITY ignore	TYPE UE-X2AP-ID-Extension						PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension				CRITICALITY ignore	TYPE UE-X2AP-ID-Extension						PRESENCE optional},
+	...
+}
+E-RABs-ToBeReleased-List-RelConf ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeReleased-RelConfItemIEs} }
+
+E-RABs-ToBeReleased-RelConfItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeReleased-RelConfItem		CRITICALITY ignore		TYPE E-RABs-ToBeReleased-RelConfItem		PRESENCE mandatory},
+	...
+}
+
+E-RABs-ToBeReleased-RelConfItem ::= CHOICE {
+	sCG-Bearer		E-RABs-ToBeReleased-RelConfItem-SCG-Bearer,
+	split-Bearer	E-RABs-ToBeReleased-RelConfItem-Split-Bearer,
+	...
+}
+
+E-RABs-ToBeReleased-RelConfItem-SCG-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	uL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	dL-GTPtunnelEndpoint			GTPtunnelEndpoint																OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeReleased-RelConfItem-SCG-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeReleased-RelConfItem-SCG-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABs-ToBeReleased-RelConfItem-Split-Bearer ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	dL-GTPtunnelEndpoint			GTPtunnelEndpoint													OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeReleased-RelConfItem-Split-BearerExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeReleased-RelConfItem-Split-BearerExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- SENB COUNTER CHECK REQUEST
+--
+-- **************************************************************
+
+SeNBCounterCheckRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{SeNBCounterCheckRequest-IEs}},
+	...
+}
+
+SeNBCounterCheckRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-MeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID						CRITICALITY ignore	TYPE UE-X2AP-ID									PRESENCE mandatory}|
+	{ ID id-E-RABs-SubjectToCounterCheck-List	CRITICALITY ignore	TYPE E-RABs-SubjectToCounterCheck-List		PRESENCE mandatory}|
+	{ ID id-MeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension						PRESENCE optional}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY ignore	TYPE UE-X2AP-ID-Extension						PRESENCE optional},
+	...
+}
+E-RABs-SubjectToCounterCheck-List ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-SubjectToCounterCheckItemIEs} }
+
+E-RABs-SubjectToCounterCheckItemIEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-SubjectToCounterCheckItem	CRITICALITY ignore	TYPE E-RABs-SubjectToCounterCheckItem		PRESENCE mandatory},
+	...
+}
+
+E-RABs-SubjectToCounterCheckItem ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	uL-Count						INTEGER (0..4294967295),
+	dL-Count						INTEGER (0..4294967295),
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-SubjectToCounterCheckItemExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-SubjectToCounterCheckItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- X2 REMOVAL REQUEST
+--
+-- **************************************************************
+
+X2RemovalRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2RemovalRequest-IEs}},
+	...
+}
+
+X2RemovalRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-GlobalENB-ID				CRITICALITY reject	TYPE GlobalENB-ID			PRESENCE mandatory}|
+	{ ID id-X2RemovalThreshold			CRITICALITY reject	TYPE X2BenefitValue			PRESENCE optional},
+...
+}
+
+
+
+-- **************************************************************
+--
+-- X2 REMOVAL RESPONSE
+--
+-- **************************************************************
+
+X2RemovalResponse ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2RemovalResponse-IEs}},
+	...
+}
+
+X2RemovalResponse-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-GlobalENB-ID				CRITICALITY reject	TYPE GlobalENB-ID				PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional},
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- X2 REMOVAL FAILURE
+--
+-- **************************************************************
+
+X2RemovalFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{X2RemovalFailure-IEs}},
+	...
+}
+
+X2RemovalFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause							PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- RETRIEVE UE CONTEXT REQUEST
+--
+-- **************************************************************
+
+RetrieveUEContextRequest ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ RetrieveUEContextRequest-IEs}},
+	...
+}
+
+RetrieveUEContextRequest-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-New-eNB-UE-X2AP-ID					CRITICALITY reject	TYPE UE-X2AP-ID				PRESENCE mandatory}|
+	{ ID id-SeNB-UE-X2AP-ID-Extension			CRITICALITY reject	TYPE UE-X2AP-ID-Extension	PRESENCE optional}|
+	{ ID id-resumeID							CRITICALITY reject	TYPE ResumeID				PRESENCE mandatory}|
+	{ ID id-ShortMAC-I							CRITICALITY reject	TYPE ShortMAC-I				PRESENCE mandatory}|
+	{ ID id-NewEUTRANCellIdentifier				CRITICALITY reject	TYPE EUTRANCellIdentifier	PRESENCE mandatory},
+	...
+}
+
+-- **************************************************************
+--
+-- RETRIEVE UE CONTEXT RESPONSE
+--
+-- **************************************************************
+
+RetrieveUEContextResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container	{{ RetrieveUEContextResponse-IEs}},
+	...
+}
+
+RetrieveUEContextResponse-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-New-eNB-UE-X2AP-ID				CRITICALITY ignore	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-New-eNB-UE-X2AP-ID-Extension	CRITICALITY ignore	TYPE UE-X2AP-ID-Extension				PRESENCE optional}|
+	{ ID id-Old-eNB-UE-X2AP-ID				CRITICALITY ignore	TYPE UE-X2AP-ID							PRESENCE mandatory}|
+	{ ID id-Old-eNB-UE-X2AP-ID-Extension	CRITICALITY ignore	TYPE UE-X2AP-ID-Extension				PRESENCE optional}|
+	{ ID id-GUMMEI-ID						CRITICALITY reject	TYPE GUMMEI								PRESENCE mandatory}|
+	{ ID id-UE-ContextInformationRetrieve	CRITICALITY reject	TYPE UE-ContextInformationRetrieve	PRESENCE mandatory}|
+	{ ID id-TraceActivation					CRITICALITY ignore	TYPE TraceActivation					PRESENCE optional}|
+	{ ID id-SRVCCOperationPossible			CRITICALITY ignore	TYPE SRVCCOperationPossible				PRESENCE optional}|
+	{ ID id-Masked-IMEISV					CRITICALITY ignore	TYPE Masked-IMEISV						PRESENCE optional}|
+	{ ID id-ExpectedUEBehaviour				CRITICALITY ignore	TYPE ExpectedUEBehaviour				PRESENCE optional}|
+	{ ID id-ProSeAuthorized					CRITICALITY ignore	TYPE ProSeAuthorized					PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional}|
+	{ ID id-V2XServicesAuthorized			CRITICALITY ignore	TYPE V2XServicesAuthorized				PRESENCE optional},
+	...
+}
+
+UE-ContextInformationRetrieve ::= SEQUENCE {
+	mME-UE-S1AP-ID						UE-S1AP-ID,
+	uESecurityCapabilities				UESecurityCapabilities,
+	aS-SecurityInformation				AS-SecurityInformation,
+	uEaggregateMaximumBitRate			UEAggregateMaximumBitRate,
+	subscriberProfileIDforRFP			SubscriberProfileIDforRFP		OPTIONAL,
+	e-RABs-ToBeSetup-ListRetrieve		E-RABs-ToBeSetup-ListRetrieve,
+	rRC-Context							RRC-Context,
+	handoverRestrictionList				HandoverRestrictionList			OPTIONAL,
+	locationReportingInformation		LocationReportingInformation	OPTIONAL,
+	managBasedMDTallowed				ManagementBasedMDTallowed		OPTIONAL,
+	managBasedMDTPLMNList				MDTPLMNList						OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { {UE-ContextInformationRetrieve-ExtIEs} } OPTIONAL,
+	...
+}
+
+UE-ContextInformationRetrieve-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+{ ID id-UESidelinkAggregateMaximumBitRate	CRITICALITY ignore	EXTENSION UESidelinkAggregateMaximumBitRate		PRESENCE optional},
+	...
+}
+
+E-RABs-ToBeSetup-ListRetrieve ::= SEQUENCE (SIZE(1..maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RABs-ToBeSetupRetrieve-ItemIEs} }
+
+E-RABs-ToBeSetupRetrieve-ItemIEs	X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABs-ToBeSetupRetrieve-Item	CRITICALITY ignore	TYPE E-RABs-ToBeSetupRetrieve-Item	PRESENCE mandatory},
+	...
+}
+
+E-RABs-ToBeSetupRetrieve-Item ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		E-RAB-Level-QoS-Parameters,
+	bearerType						BearerType	OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABs-ToBeSetupRetrieve-ItemExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABs-ToBeSetupRetrieve-ItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-uL-GTPtunnelEndpoint		CRITICALITY reject	EXTENSION GTPtunnelEndpoint		PRESENCE mandatory},
+	...
+}
+
+-- **************************************************************
+--
+-- RETRIEVE UE CONTEXT FAILURE
+--
+-- **************************************************************
+
+RetrieveUEContextFailure ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container	{{ RetrieveUEContextFailure-IEs}},
+	...
+}
+
+RetrieveUEContextFailure-IEs X2AP-PROTOCOL-IES ::= {
+	{ ID id-New-eNB-UE-X2AP-ID				CRITICALITY ignore	TYPE UE-X2AP-ID					PRESENCE mandatory}|
+	{ ID id-New-eNB-UE-X2AP-ID-Extension	CRITICALITY ignore	TYPE UE-X2AP-ID-Extension		PRESENCE optional}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause						PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional},
+	...
+}
+
+END
+
+
+-- **************************************************************
+--
+-- Information Element Definitions
+--
+-- **************************************************************
+
+X2AP-IEs {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) x2ap (2) version1 (1) x2ap-IEs (2) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+IMPORTS
+	
+	id-E-RAB-Item,
+	id-Number-of-Antennaports,
+	id-MBSFN-Subframe-Info,
+	id-PRACH-Configuration,
+	id-CSG-Id,
+	id-MDTConfiguration,
+	id-SignallingBasedMDTPLMNList,
+	id-MultibandInfoList,
+	id-FreqBandIndicatorPriority,
+	id-NeighbourTAC,
+	id-Time-UE-StayedInCell-EnhancedGranularity,
+	id-MBMS-Service-Area-List,
+	id-HO-cause,
+	id-eARFCNExtension,
+	id-DL-EARFCNExtension,
+	id-UL-EARFCNExtension,
+	id-M3Configuration,
+	id-M4Configuration,
+	id-M5Configuration,
+	id-MDT-Location-Info,
+	id-AdditionalSpecialSubframe-Info,
+	id-UEID,
+	id-enhancedRNTP,
+	id-ProSeUEtoNetworkRelaying,
+	id-M6Configuration,
+	id-M7Configuration,
+	id-OffsetOfNbiotChannelNumberToDL-EARFCN,
+	id-OffsetOfNbiotChannelNumberToUL-EARFCN,
+	id-AdditionalSpecialSubframeExtension-Info,
+	id-BandwidthReducedSI,
+	id-DL-scheduling-PDCCH-CCE-usage,
+	id-UL-scheduling-PDCCH-CCE-usage,
+	maxnoofBearers,
+	maxCellineNB,
+	maxEARFCN,
+	maxEARFCNPlusOne,
+	newmaxEARFCN,
+	maxInterfaces,
+	
+	maxnoofBands,
+	maxnoofBPLMNs,
+	maxnoofCells,
+	maxnoofEPLMNs,
+	maxnoofEPLMNsPlusOne,
+	maxnoofForbLACs,
+	maxnoofForbTACs,
+	maxnoofNeighbours,
+	maxnoofPRBs,
+	maxNrOfErrors,
+	maxPools,
+	maxnoofMBSFN,
+	maxnoofTAforMDT,
+	maxnoofCellIDforMDT,
+	maxnoofMBMSServiceAreaIdentities,
+	maxnoofMDTPLMNs,
+	maxnoofCoMPHypothesisSet,
+	maxnoofCoMPCells,
+	maxUEReport,
+	maxCellReport,
+	maxnoofPA,
+	maxCSIProcess,
+	maxCSIReport,
+	maxSubband
+
+FROM X2AP-Constants
+
+	Criticality,
+	ProcedureCode,
+	ProtocolIE-ID,
+	TriggeringMessage
+FROM X2AP-CommonDataTypes
+
+	ProtocolExtensionContainer{},
+	ProtocolIE-Single-Container{},
+	
+	X2AP-PROTOCOL-EXTENSION,
+	X2AP-PROTOCOL-IES
+FROM X2AP-Containers;
+
+-- A
+
+ABSInformation ::= CHOICE {
+	fdd					ABSInformationFDD,
+	tdd					ABSInformationTDD,
+	abs-inactive		NULL,
+	...
+}
+
+ABSInformationFDD ::= SEQUENCE {
+	abs-pattern-info					BIT STRING (SIZE(40)),
+	numberOfCellSpecificAntennaPorts	ENUMERATED {one, two, four, ...},
+	measurement-subset					BIT STRING (SIZE(40)),
+	iE-Extensions						ProtocolExtensionContainer { { ABSInformationFDD-ExtIEs} } OPTIONAL,
+	...
+}
+
+ABSInformationFDD-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ABSInformationTDD ::= SEQUENCE {
+	abs-pattern-info					BIT STRING (SIZE(1..70, ...)),
+	numberOfCellSpecificAntennaPorts	ENUMERATED {one, two, four, ...},
+	measurement-subset					BIT STRING (SIZE(1..70, ...)),
+	iE-Extensions						ProtocolExtensionContainer { { ABSInformationTDD-ExtIEs} } OPTIONAL,
+	...
+}
+
+ABSInformationTDD-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ABS-Status ::= SEQUENCE {
+	dL-ABS-status								DL-ABS-status,
+	usableABSInformation						UsableABSInformation,
+	iE-Extensions								ProtocolExtensionContainer { {ABS-Status-ExtIEs} } OPTIONAL,
+	...
+}
+
+ABS-Status-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AdditionalSpecialSubframe-Info ::=		SEQUENCE {
+	additionalspecialSubframePatterns		AdditionalSpecialSubframePatterns,
+	cyclicPrefixDL							CyclicPrefixDL,
+	cyclicPrefixUL							CyclicPrefixUL,
+	iE-Extensions							ProtocolExtensionContainer { { AdditionalSpecialSubframe-Info-ExtIEs} } OPTIONAL,
+	...
+}
+
+AdditionalSpecialSubframe-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AdditionalSpecialSubframePatterns ::= ENUMERATED {
+	ssp0,
+	ssp1,
+	ssp2,
+	ssp3,
+	ssp4,
+	ssp5,
+	ssp6,
+	ssp7,
+	ssp8,
+	ssp9,
+	...
+}
+
+AdditionalSpecialSubframeExtension-Info ::=		SEQUENCE {
+	additionalspecialSubframePatternsExtension	AdditionalSpecialSubframePatternsExtension,
+	cyclicPrefixDL								CyclicPrefixDL,
+	cyclicPrefixUL								CyclicPrefixUL,
+	iE-Extensions								ProtocolExtensionContainer { { AdditionalSpecialSubframeExtension-Info-ExtIEs} } OPTIONAL,
+	...
+}
+
+AdditionalSpecialSubframeExtension-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AdditionalSpecialSubframePatternsExtension ::= ENUMERATED {
+	ssp10,
+	...
+}
+
+AllocationAndRetentionPriority ::= SEQUENCE {
+	priorityLevel				PriorityLevel,
+	pre-emptionCapability		Pre-emptionCapability,
+	pre-emptionVulnerability	Pre-emptionVulnerability,
+	iE-Extensions				ProtocolExtensionContainer { {AllocationAndRetentionPriority-ExtIEs} } OPTIONAL,
+	...
+}
+
+AllocationAndRetentionPriority-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AreaScopeOfMDT ::= CHOICE {	
+	cellBased					CellBasedMDT,
+	tABased						TABasedMDT,
+	pLMNWide					NULL,
+	...,
+	tAIBased					TAIBasedMDT
+}
+
+AS-SecurityInformation ::= SEQUENCE {
+	key-eNodeB-star		Key-eNodeB-Star,
+	nextHopChainingCount			NextHopChainingCount,
+	iE-Extensions						ProtocolExtensionContainer { { AS-SecurityInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+AS-SecurityInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- B
+
+BandwidthReducedSI::= ENUMERATED {
+	scheduled,
+	...
+}
+
+BearerType ::= ENUMERATED {
+	non-IP,
+	...
+}
+
+BenefitMetric ::= INTEGER (-101..100, ...)
+
+BitRate ::= INTEGER (0..10000000000)
+BroadcastPLMNs-Item ::= SEQUENCE (SIZE(1..maxnoofBPLMNs)) OF PLMN-Identity
+
+
+-- C
+
+CapacityValue ::= INTEGER (0..100)
+
+Cause ::= CHOICE {
+	radioNetwork		CauseRadioNetwork,
+	transport			CauseTransport,
+	protocol			CauseProtocol,
+	misc				CauseMisc,
+	...
+}
+
+CauseMisc ::= ENUMERATED {
+	control-processing-overload,
+	hardware-failure,
+	om-intervention,
+	not-enough-user-plane-processing-resources,
+	unspecified,
+	...
+}
+
+CauseProtocol ::= ENUMERATED {
+	transfer-syntax-error,
+	abstract-syntax-error-reject,
+	abstract-syntax-error-ignore-and-notify,
+	message-not-compatible-with-receiver-state,
+	semantic-error,
+	unspecified,
+	abstract-syntax-error-falsely-constructed-message,
+	...
+}
+
+CauseRadioNetwork ::= ENUMERATED {
+	handover-desirable-for-radio-reasons,
+	time-critical-handover,
+	resource-optimisation-handover,
+	reduce-load-in-serving-cell,
+	partial-handover,
+	unknown-new-eNB-UE-X2AP-ID, 
+	unknown-old-eNB-UE-X2AP-ID, 
+	unknown-pair-of-UE-X2AP-ID,
+	ho-target-not-allowed,
+	tx2relocoverall-expiry,
+	trelocprep-expiry,
+	cell-not-available,
+	no-radio-resources-available-in-target-cell,
+	invalid-MME-GroupID,
+	unknown-MME-Code,
+	encryption-and-or-integrity-protection-algorithms-not-supported,
+	reportCharacteristicsEmpty,
+	noReportPeriodicity,
+	existingMeasurementID,
+	unknown-eNB-Measurement-ID,
+	measurement-temporarily-not-available,
+	unspecified,
+	...,
+	load-balancing,
+	handover-optimisation,
+	value-out-of-allowed-range,
+	multiple-E-RAB-ID-instances,
+	switch-off-ongoing,
+	not-supported-QCI-value,
+	measurement-not-supported-for-the-object,
+	tDCoverall-expiry,
+	tDCprep-expiry,
+	action-desirable-for-radio-reasons,
+	reduce-load,
+	resource-optimisation,
+	time-critical-action,
+	target-not-allowed,
+	no-radio-resources-available,
+	invalid-QoS-combination,
+	encryption-algorithms-not-aupported,
+	procedure-cancelled,
+	rRM-purpose,
+	improve-user-bit-rate,
+	user-inactivity,
+	radio-connection-with-UE-lost,
+	failure-in-the-radio-interface-procedure,
+	bearer-option-not-supported
+
+}
+
+CauseTransport ::= ENUMERATED {
+	transport-resource-unavailable,
+	unspecified,
+	...
+}
+
+CellBasedMDT::= SEQUENCE {
+	cellIdListforMDT	CellIdListforMDT,
+	iE-Extensions		ProtocolExtensionContainer { {CellBasedMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+CellBasedMDT-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CellCapacityClassValue ::= INTEGER (1..100, ...)
+
+CellDeploymentStatusIndicator ::= ENUMERATED {pre-change-notification, ...}
+
+CellIdListforMDT ::= SEQUENCE (SIZE(1..maxnoofCellIDforMDT)) OF ECGI
+
+CellReplacingInfo ::= SEQUENCE {
+	replacingCellsList				ReplacingCellsList,
+	iE-Extensions					ProtocolExtensionContainer { { CellReplacingInfo-ExtIEs}}	OPTIONAL,
+	...
+}
+
+CellReplacingInfo-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CellReportingIndicator ::= ENUMERATED {stop-request, ... }
+
+Cell-Size ::= ENUMERATED {verysmall, small, medium, large, ... }
+
+
+CellType ::= SEQUENCE {
+	cell-Size						Cell-Size,
+	iE-Extensions					ProtocolExtensionContainer { { CellType-ExtIEs}}	OPTIONAL,
+	...
+}
+
+CellType-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CoMPHypothesisSet ::= SEQUENCE (SIZE(1..maxnoofCoMPCells)) OF CoMPHypothesisSetItem
+
+CoMPHypothesisSetItem ::= SEQUENCE {
+	coMPCellID						ECGI,
+	coMPHypothesis					BIT STRING (SIZE(6..4400, ...)),
+	iE-Extensions					ProtocolExtensionContainer { { CoMPHypothesisSetItem-ExtIEs} } OPTIONAL,
+	...
+}
+
+CoMPHypothesisSetItem-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CoMPInformation ::= SEQUENCE {
+	coMPInformationItem						CoMPInformationItem,
+	coMPInformationStartTime				CoMPInformationStartTime,
+	iE-Extensions							ProtocolExtensionContainer { { CoMPInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+CoMPInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CoMPInformationItem ::= SEQUENCE (SIZE(1..maxnoofCoMPHypothesisSet)) OF
+	SEQUENCE {
+		coMPHypothesisSet					CoMPHypothesisSet,
+		benefitMetric						BenefitMetric,
+		iE-Extensions						ProtocolExtensionContainer { { CoMPInformationItem-ExtIEs} } OPTIONAL,
+		...
+	}
+
+CoMPInformationItem-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CoMPInformationStartTime ::= SEQUENCE (SIZE(0..1)) OF
+	SEQUENCE {
+		startSFN							INTEGER (0..1023, ...),
+		startSubframeNumber					INTEGER (0..9, ...), 
+		iE-Extensions						ProtocolExtensionContainer { { CoMPInformationStartTime-ExtIEs} } OPTIONAL,
+		...
+	}
+
+CoMPInformationStartTime-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CompositeAvailableCapacity ::= SEQUENCE {
+	cellCapacityClassValue							CellCapacityClassValue				OPTIONAL,
+	capacityValue									CapacityValue,
+	iE-Extensions									ProtocolExtensionContainer { { CompositeAvailableCapacity-ExtIEs} } OPTIONAL,
+	...
+}
+
+CompositeAvailableCapacity-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CompositeAvailableCapacityGroup	::= SEQUENCE {
+	dL-CompositeAvailableCapacity					CompositeAvailableCapacity,
+	uL-CompositeAvailableCapacity					CompositeAvailableCapacity,
+	iE-Extensions									ProtocolExtensionContainer { { CompositeAvailableCapacityGroup-ExtIEs} } OPTIONAL,
+	...
+}
+
+CompositeAvailableCapacityGroup-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Correlation-ID ::= OCTET STRING (SIZE (4))
+
+COUNTvalue ::= SEQUENCE {
+	pDCP-SN					PDCP-SN,
+	hFN						HFN,
+	iE-Extensions			ProtocolExtensionContainer { { COUNTvalue-ExtIEs} } OPTIONAL,
+	...
+}
+
+COUNTvalue-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+COUNTValueExtended ::= SEQUENCE {
+	pDCP-SNExtended			PDCP-SNExtended,
+	hFNModified				HFNModified,
+	iE-Extensions			ProtocolExtensionContainer { { COUNTValueExtended-ExtIEs} } OPTIONAL,
+	...
+}
+
+COUNTValueExtended-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+COUNTvaluePDCP-SNlength18 ::= SEQUENCE {
+	pDCP-SNlength18			PDCP-SNlength18,
+	hFNforPDCP-SNlength18	HFNforPDCP-SNlength18,
+	iE-Extensions			ProtocolExtensionContainer { { COUNTvaluePDCP-SNlength18-ExtIEs} } OPTIONAL,
+	...
+}
+
+COUNTvaluePDCP-SNlength18-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CoverageModificationList ::= SEQUENCE (SIZE (1..maxCellineNB)) OF CoverageModification-Item
+
+CoverageModification-Item ::= SEQUENCE {
+	eCGI							ECGI,
+	coverageState					INTEGER (0..15, ...),
+	cellDeploymentStatusIndicator	CellDeploymentStatusIndicator			OPTIONAL,
+	cellReplacingInfo				CellReplacingInfo						OPTIONAL,
+-- Included in case the Cell Deployment Status Indicator IE is present
+	...
+}
+
+CriticalityDiagnostics ::= SEQUENCE {
+	procedureCode					ProcedureCode					OPTIONAL,
+	triggeringMessage				TriggeringMessage				OPTIONAL,
+	procedureCriticality			Criticality						OPTIONAL,
+	iEsCriticalityDiagnostics		CriticalityDiagnostics-IE-List	OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {CriticalityDiagnostics-ExtIEs} }	OPTIONAL,
+	...
+}
+
+
+CriticalityDiagnostics-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF
+	SEQUENCE {
+		iECriticality			Criticality,
+		iE-ID					ProtocolIE-ID,
+		typeOfError				TypeOfError,
+		iE-Extensions			ProtocolExtensionContainer { {CriticalityDiagnostics-IE-List-ExtIEs} } OPTIONAL,
+		...
+}
+
+CriticalityDiagnostics-IE-List-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CRNTI ::= BIT STRING (SIZE (16))
+
+CSGMembershipStatus ::= ENUMERATED { 
+	member,
+	not-member
+}
+
+CSG-Id ::= BIT STRING (SIZE (27))
+
+CSIReportList ::= SEQUENCE (SIZE(1..maxUEReport)) OF
+	SEQUENCE {
+		uEID							UEID,
+		cSIReportPerCSIProcess			CSIReportPerCSIProcess, 
+		iE-Extensions					ProtocolExtensionContainer { { CSIReportList-ExtIEs} } OPTIONAL,
+		...
+	}
+
+CSIReportList-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CSIReportPerCSIProcess ::= SEQUENCE (SIZE(1.. maxCSIProcess)) OF
+	SEQUENCE {
+		cSIProcessConfigurationIndex	INTEGER (1..7, ...),
+		cSIReportPerCSIProcessItem		CSIReportPerCSIProcessItem, 
+		iE-Extensions					ProtocolExtensionContainer { { CSIReportPerCSIProcess-ExtIEs} } OPTIONAL,
+		...
+	}
+
+CSIReportPerCSIProcess-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CSIReportPerCSIProcessItem ::= SEQUENCE (SIZE(1.. maxCSIReport)) OF
+	SEQUENCE {
+		rI								INTEGER (1..8, ...),
+		widebandCQI						WidebandCQI, 
+		subbandSize						SubbandSize,
+		subbandCQIList					SubbandCQIList	OPTIONAL,
+		iE-Extensions					ProtocolExtensionContainer { { CSIReportPerCSIProcessItem-ExtIEs} } OPTIONAL,
+		...
+	}
+
+CSIReportPerCSIProcessItem-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CyclicPrefixDL ::= ENUMERATED { 
+	normal,
+	extended,
+	...
+}
+
+CyclicPrefixUL ::= ENUMERATED { 
+	normal,
+	extended,
+	...
+}
+
+
+-- D
+
+DeactivationIndication::= ENUMERATED { 
+	deactivated,
+	...
+}
+
+DL-ABS-status::= INTEGER (0..100)
+
+DL-Forwarding ::= ENUMERATED {
+	dL-forwardingProposed,
+	...
+}
+
+DL-GBR-PRB-usage::= INTEGER (0..100)
+
+DL-non-GBR-PRB-usage::= INTEGER (0..100)
+
+DL-scheduling-PDCCH-CCE-usage::= INTEGER (0..100)
+
+DL-Total-PRB-usage::= INTEGER (0..100)
+
+DynamicDLTransmissionInformation ::= CHOICE {
+	naics-active			DynamicNAICSInformation,
+	naics-inactive			NULL,
+	...
+}
+
+DynamicNAICSInformation ::= SEQUENCE {
+	transmissionModes					BIT STRING (SIZE(8))												OPTIONAL,
+	pB-information						INTEGER(0..3)														OPTIONAL,
+	pA-list								SEQUENCE (SIZE(0..maxnoofPA)) OF PA-Values,
+	iE-Extensions						ProtocolExtensionContainer { {DynamicNAICSInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+DynamicNAICSInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- E
+
+EARFCN ::= INTEGER (0..maxEARFCN)
+
+EARFCNExtension ::= INTEGER(maxEARFCNPlusOne..newmaxEARFCN, ...)
+
+ECGI ::= SEQUENCE {
+	pLMN-Identity				PLMN-Identity,
+	eUTRANcellIdentifier		EUTRANCellIdentifier,
+	iE-Extensions				ProtocolExtensionContainer { {ECGI-ExtIEs} } OPTIONAL,
+	...
+}
+
+ECGI-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+EnhancedRNTP ::= SEQUENCE {
+	enhancedRNTPBitmap			BIT STRING (SIZE(12..8800, ...)),
+	rNTP-High-Power-Threshold	RNTP-Threshold,
+	enhancedRNTPStartTime		EnhancedRNTPStartTime  OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { { EnhancedRNTP-ExtIEs} } OPTIONAL,
+	...
+}
+
+EnhancedRNTP-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+EnhancedRNTPStartTime ::= SEQUENCE {
+		startSFN				INTEGER (0..1023, ...),
+		startSubframeNumber		INTEGER (0..9, ...), 
+		iE-Extensions			ProtocolExtensionContainer { { EnhancedRNTPStartTime-ExtIEs} } OPTIONAL,
+		...
+	}
+
+EnhancedRNTPStartTime-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ENB-ID ::= CHOICE {
+	macro-eNB-ID	BIT STRING (SIZE (20)),
+	home-eNB-ID		BIT STRING (SIZE (28)),
+	... ,
+	short-Macro-eNB-ID		BIT STRING (SIZE(18)),
+	long-Macro-eNB-ID		BIT STRING (SIZE(21))
+}
+
+EncryptionAlgorithms ::= BIT STRING (SIZE (16, ...))
+
+EPLMNs ::= SEQUENCE (SIZE(1..maxnoofEPLMNs)) OF PLMN-Identity
+
+E-RAB-ID ::= INTEGER (0..15, ...)
+
+E-RAB-Level-QoS-Parameters ::= SEQUENCE {
+	qCI								QCI,
+	allocationAndRetentionPriority	AllocationAndRetentionPriority,
+	gbrQosInformation				GBR-QosInformation													OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { { E-RAB-Level-QoS-Parameters-ExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RAB-Level-QoS-Parameters-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RAB-List ::= SEQUENCE (SIZE(1.. maxnoofBearers)) OF ProtocolIE-Single-Container { {E-RAB-ItemIEs} }
+
+E-RAB-ItemIEs 	X2AP-PROTOCOL-IES ::= {
+	{ ID id-E-RAB-Item	 CRITICALITY ignore 	TYPE E-RAB-Item 	PRESENCE mandatory },
+	...
+}
+
+E-RAB-Item ::= SEQUENCE {
+	e-RAB-ID				E-RAB-ID,
+	cause						Cause,
+	iE-Extensions				ProtocolExtensionContainer { {E-RAB-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+E-RAB-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+EUTRA-Mode-Info ::= CHOICE {
+	fDD		FDD-Info,
+	tDD		TDD-Info,
+	...
+}
+
+EUTRANCellIdentifier ::= BIT STRING (SIZE (28))
+
+EUTRANTraceID		::= OCTET STRING (SIZE (8))
+
+EventType ::= ENUMERATED{
+	change-of-serving-cell,
+	...
+}
+
+ExpectedUEBehaviour ::= SEQUENCE {
+	expectedActivity		ExpectedUEActivityBehaviour OPTIONAL,
+	expectedHOInterval		ExpectedHOInterval			OPTIONAL,
+	iE-Extensions			ProtocolExtensionContainer { { ExpectedUEBehaviour-ExtIEs} } OPTIONAL,
+	...
+}
+
+ExpectedUEBehaviour-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ExpectedUEActivityBehaviour ::= SEQUENCE {
+	expectedActivityPeriod					ExpectedActivityPeriod					OPTIONAL,
+	expectedIdlePeriod						ExpectedIdlePeriod						OPTIONAL,
+	sourceofUEActivityBehaviourInformation	SourceOfUEActivityBehaviourInformation	OPTIONAL,
+	iE-Extensions		ProtocolExtensionContainer { { ExpectedUEActivityBehaviour-ExtIEs} } OPTIONAL,
+	...
+}
+
+ExpectedUEActivityBehaviour-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ExpectedActivityPeriod ::= INTEGER (1..30|40|50|60|80|100|120|150|180|181,...)
+
+ExpectedIdlePeriod ::= INTEGER (1..30|40|50|60|80|100|120|150|180|181,...)
+
+ExpectedHOInterval ::= ENUMERATED {
+	sec15, sec30, sec60, sec90, sec120, sec180, long-time,
+	...
+}
+
+ExtendedULInterferenceOverloadInfo ::= SEQUENCE {
+	associatedSubframes							BIT STRING (SIZE (5)),
+	extended-ul-InterferenceOverloadIndication	UL-InterferenceOverloadIndication,
+	iE-Extensions								ProtocolExtensionContainer { { ExtendedULInterferenceOverloadInfo-ExtIEs} } OPTIONAL,
+	...
+}
+
+ExtendedULInterferenceOverloadInfo-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- F
+
+FDD-Info ::= SEQUENCE {
+	uL-EARFCN						EARFCN,
+	dL-EARFCN						EARFCN,
+	uL-Transmission-Bandwidth		Transmission-Bandwidth,
+	dL-Transmission-Bandwidth		Transmission-Bandwidth,
+	iE-Extensions				ProtocolExtensionContainer { {FDD-Info-ExtIEs} } OPTIONAL,
+	...
+}
+
+FDD-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-UL-EARFCNExtension		CRITICALITY reject	EXTENSION EARFCNExtension		PRESENCE optional}|
+	{ ID id-DL-EARFCNExtension		CRITICALITY reject	EXTENSION EARFCNExtension		PRESENCE optional}|
+	{ ID id-OffsetOfNbiotChannelNumberToDL-EARFCN	CRITICALITY reject	EXTENSION OffsetOfNbiotChannelNumberToEARFCN		PRESENCE optional}|
+	{ ID id-OffsetOfNbiotChannelNumberToUL-EARFCN	CRITICALITY reject	EXTENSION OffsetOfNbiotChannelNumberToEARFCN		PRESENCE optional},
+	...
+}
+
+ForbiddenInterRATs ::= ENUMERATED {
+	all,
+	geran,
+	utran,
+	cdma2000,
+	...,
+	geranandutran,
+	cdma2000andutran
+
+}
+
+ForbiddenTAs ::= SEQUENCE (SIZE(1.. maxnoofEPLMNsPlusOne)) OF ForbiddenTAs-Item
+
+ForbiddenTAs-Item ::= SEQUENCE {
+	pLMN-Identity		PLMN-Identity,
+	forbiddenTACs		ForbiddenTACs,
+	iE-Extensions		ProtocolExtensionContainer { {ForbiddenTAs-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+ForbiddenTAs-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ForbiddenTACs ::= SEQUENCE (SIZE(1..maxnoofForbTACs)) OF TAC
+
+ForbiddenLAs ::= SEQUENCE (SIZE(1..maxnoofEPLMNsPlusOne)) OF ForbiddenLAs-Item
+
+ForbiddenLAs-Item ::= SEQUENCE {	
+	pLMN-Identity		PLMN-Identity,
+	forbiddenLACs		ForbiddenLACs,
+	iE-Extensions		ProtocolExtensionContainer { {ForbiddenLAs-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+ForbiddenLAs-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ForbiddenLACs ::= SEQUENCE (SIZE(1..maxnoofForbLACs)) OF LAC
+
+Fourframes ::= BIT STRING (SIZE (24))
+
+FreqBandIndicator ::= INTEGER (1..256, ...) 
+
+FreqBandIndicatorPriority ::= ENUMERATED {
+	not-broadcasted,
+	broadcasted, 
+	...
+}
+
+-- G
+
+GBR-QosInformation ::= SEQUENCE {
+	e-RAB-MaximumBitrateDL			BitRate,
+	e-RAB-MaximumBitrateUL			BitRate,
+	e-RAB-GuaranteedBitrateDL		BitRate,
+	e-RAB-GuaranteedBitrateUL		BitRate,
+	iE-Extensions					ProtocolExtensionContainer { { GBR-QosInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+GBR-QosInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+GlobalENB-ID ::= SEQUENCE {
+	pLMN-Identity			PLMN-Identity,
+	eNB-ID					ENB-ID,
+	iE-Extensions			ProtocolExtensionContainer { {GlobalENB-ID-ExtIEs} } OPTIONAL,
+	...
+}
+
+GlobalENB-ID-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+GTPtunnelEndpoint ::= SEQUENCE {
+	transportLayerAddress			TransportLayerAddress,
+	gTP-TEID						GTP-TEI,
+	iE-Extensions					ProtocolExtensionContainer { {GTPtunnelEndpoint-ExtIEs} } OPTIONAL,
+	...
+}
+
+GTPtunnelEndpoint-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+GTP-TEI					::= OCTET STRING (SIZE (4))
+
+GUGroupIDList		::= SEQUENCE (SIZE (1..maxPools)) OF GU-Group-ID
+
+
+GU-Group-ID			::= SEQUENCE {
+	pLMN-Identity		PLMN-Identity,
+	mME-Group-ID		MME-Group-ID,
+	iE-Extensions		ProtocolExtensionContainer { {GU-Group-ID-ExtIEs} } OPTIONAL,
+	...
+}
+
+GU-Group-ID-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+GUMMEI			::= SEQUENCE {
+	
+	gU-Group-ID		GU-Group-ID,
+	mME-Code			MME-Code,
+	iE-Extensions					ProtocolExtensionContainer { {GUMMEI-ExtIEs} } OPTIONAL,
+	...
+}
+
+GUMMEI-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+
+-- H
+
+HandoverReportType ::= ENUMERATED {
+	hoTooEarly,
+	hoToWrongCell,
+	...,
+	interRATpingpong
+}
+
+HandoverRestrictionList ::= SEQUENCE {
+	servingPLMN					PLMN-Identity,
+	equivalentPLMNs				EPLMNs					OPTIONAL,
+	forbiddenTAs				ForbiddenTAs			OPTIONAL,
+	forbiddenLAs				ForbiddenLAs			OPTIONAL,
+	forbiddenInterRATs			ForbiddenInterRATs		OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { {HandoverRestrictionList-ExtIEs} }	OPTIONAL,
+	...
+}
+
+HandoverRestrictionList-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+HFN ::= INTEGER (0..1048575)
+
+HFNModified ::= INTEGER (0..131071)
+
+HFNforPDCP-SNlength18 ::= INTEGER (0..16383)
+
+HWLoadIndicator ::= SEQUENCE {
+	dLHWLoadIndicator			LoadIndicator,
+	uLHWLoadIndicator			LoadIndicator,
+	iE-Extensions				ProtocolExtensionContainer { { HWLoadIndicator-ExtIEs} } OPTIONAL,
+	...
+}
+
+HWLoadIndicator-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- I
+
+IntegrityProtectionAlgorithms ::= BIT STRING (SIZE (16, ...))
+
+InterfacesToTrace ::= BIT STRING (SIZE (8)) 
+
+InvokeIndication ::= ENUMERATED{
+	abs-information,
+	...,
+	naics-information-start,
+	naics-information-stop
+}
+
+-- J
+-- K
+
+Key-eNodeB-Star ::= BIT STRING (SIZE(256))
+
+-- L
+
+LAC					::= OCTET STRING (SIZE (2)) --(EXCEPT ('0000'H|'FFFE'H))
+
+LastVisitedCell-Item ::= CHOICE {
+	e-UTRAN-Cell					LastVisitedEUTRANCellInformation,
+	uTRAN-Cell						LastVisitedUTRANCellInformation,
+	gERAN-Cell						LastVisitedGERANCellInformation,
+	...
+}
+
+LastVisitedEUTRANCellInformation ::= SEQUENCE {
+	global-Cell-ID					ECGI,
+	cellType						CellType,
+	time-UE-StayedInCell			Time-UE-StayedInCell,
+	iE-Extensions					ProtocolExtensionContainer { { LastVisitedEUTRANCellInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+LastVisitedEUTRANCellInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+-- Extension for Rel-11 to support enhanced granularity for time UE stayed in cell --
+	{ ID id-Time-UE-StayedInCell-EnhancedGranularity	CRITICALITY ignore	EXTENSION Time-UE-StayedInCell-EnhancedGranularity	PRESENCE optional}|
+	{ ID id-HO-cause									CRITICALITY ignore	EXTENSION Cause							PRESENCE optional},
+	...
+}
+
+LastVisitedGERANCellInformation ::= CHOICE {
+	undefined						NULL,
+	...
+}
+
+LastVisitedUTRANCellInformation	::= OCTET STRING
+
+LHN-ID ::=  OCTET STRING(SIZE (32..256))
+
+Links-to-log ::= ENUMERATED {uplink, downlink, both-uplink-and-downlink, ...}
+
+LoadIndicator ::= ENUMERATED {
+	lowLoad,
+	mediumLoad, 
+	highLoad,
+	overLoad,
+	...
+}
+
+LocationReportingInformation ::= SEQUENCE {
+	eventType		EventType,
+	reportArea		ReportArea,
+	iE-Extensions		ProtocolExtensionContainer { {LocationReportingInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+LocationReportingInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::={
+	...
+}
+
+-- M
+
+M1PeriodicReporting ::= SEQUENCE { 
+	reportInterval				ReportIntervalMDT,
+	reportAmount				ReportAmountMDT,
+	iE-Extensions				ProtocolExtensionContainer { { M1PeriodicReporting-ExtIEs} } OPTIONAL,
+	...
+}
+
+M1PeriodicReporting-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M1ReportingTrigger::= ENUMERATED{
+	periodic,
+	a2eventtriggered,
+	...,
+	a2eventtriggered-periodic
+}
+
+M1ThresholdEventA2 ::= SEQUENCE { 
+	measurementThreshold		MeasurementThresholdA2,
+	iE-Extensions				ProtocolExtensionContainer { { M1ThresholdEventA2-ExtIEs} } OPTIONAL,
+	...
+}
+
+M1ThresholdEventA2-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M3Configuration ::= SEQUENCE {
+	m3period			M3period,
+	iE-Extensions		ProtocolExtensionContainer { { M3Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M3Configuration-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M3period ::= ENUMERATED {ms100, ms1000, ms10000, ... } 
+
+M4Configuration ::= SEQUENCE {
+	m4period			M4period,
+	m4-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M4Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M4Configuration-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M4period ::= ENUMERATED {ms1024, ms2048, ms5120, ms10240, min1, ... } 
+
+
+M5Configuration ::= SEQUENCE {
+	m5period			M5period,
+	m5-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M5Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M5Configuration-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M5period ::= ENUMERATED {ms1024, ms2048, ms5120, ms10240, min1, ... }
+
+M6Configuration ::= SEQUENCE {
+	m6report-interval	M6report-interval,
+	m6delay-threshold	M6delay-threshold	OPTIONAL,
+-- This IE shall be present if the M6 Links to log IE is set to “uplink” or to “both-uplink-and-downlink” --
+	m6-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M6Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M6Configuration-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M6report-interval ::= ENUMERATED { ms1024, ms2048, ms5120, ms10240, ... } 
+
+M6delay-threshold ::= ENUMERATED { ms30, ms40, ms50, ms60, ms70, ms80, ms90, ms100, ms150, ms300, ms500, ms750, ... }
+
+M7Configuration ::= SEQUENCE {
+	m7period			M7period,
+	m7-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M7Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M7Configuration-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M7period ::= INTEGER(1..60, ...)
+
+MakeBeforeBreakIndicator::= ENUMERATED {true, ...}
+
+ManagementBasedMDTallowed ::= ENUMERATED {allowed, ...}
+
+Masked-IMEISV ::= BIT STRING (SIZE (64))
+
+MDT-Activation		::= ENUMERATED { 
+	immediate-MDT-only,
+	immediate-MDT-and-Trace,
+	...
+}
+
+MDT-Configuration ::= SEQUENCE {
+	mdt-Activation				MDT-Activation,
+	areaScopeOfMDT				AreaScopeOfMDT,
+	measurementsToActivate		MeasurementsToActivate,
+	m1reportingTrigger			M1ReportingTrigger,
+	m1thresholdeventA2			M1ThresholdEventA2			OPTIONAL,
+-- Included in case of event-triggered, or event-triggered periodic reporting for measurement M1
+	m1periodicReporting			M1PeriodicReporting			OPTIONAL,
+-- Included in case of periodic, or event-triggered periodic reporting for measurement M1
+	iE-Extensions				ProtocolExtensionContainer { { MDT-Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+MDT-Configuration-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ID id-M3Configuration				CRITICALITY ignore	EXTENSION M3Configuration		PRESENCE conditional}|
+	{ID id-M4Configuration				CRITICALITY ignore	EXTENSION M4Configuration		PRESENCE conditional}|
+	{ID id-M5Configuration				CRITICALITY ignore	EXTENSION M5Configuration		PRESENCE conditional}|
+	{ID id-MDT-Location-Info			CRITICALITY ignore	EXTENSION MDT-Location-Info		PRESENCE optional}|
+	{ID id-SignallingBasedMDTPLMNList	CRITICALITY ignore	EXTENSION MDTPLMNList			PRESENCE optional}|
+	{ID id-M6Configuration				CRITICALITY ignore	EXTENSION M6Configuration		PRESENCE conditional}|
+	{ID id-M7Configuration				CRITICALITY ignore	EXTENSION M7Configuration		PRESENCE conditional},
+	...
+}
+
+MDTPLMNList ::= SEQUENCE (SIZE(1..maxnoofMDTPLMNs)) OF PLMN-Identity
+
+MDT-Location-Info ::= BIT STRING (SIZE (8))
+
+Measurement-ID	::= INTEGER (1..4095, ...) 
+
+MeasurementsToActivate::= BIT STRING (SIZE (8))
+
+MeasurementThresholdA2 ::= CHOICE { 
+	threshold-RSRP				Threshold-RSRP,
+	threshold-RSRQ				Threshold-RSRQ,
+	...
+}
+
+MeNBtoSeNBContainer  ::= OCTET STRING
+
+MME-Group-ID	::= OCTET STRING (SIZE (2))
+
+MME-Code		::= OCTET STRING (SIZE (1))
+
+MBMS-Service-Area-Identity-List ::= SEQUENCE (SIZE(1.. maxnoofMBMSServiceAreaIdentities)) OF MBMS-Service-Area-Identity
+
+MBMS-Service-Area-Identity ::= OCTET STRING (SIZE (2))
+
+MBSFN-Subframe-Infolist::= SEQUENCE (SIZE(1.. maxnoofMBSFN)) OF MBSFN-Subframe-Info
+
+MBSFN-Subframe-Info	::= SEQUENCE {
+	radioframeAllocationPeriod		RadioframeAllocationPeriod,
+	radioframeAllocationOffset		RadioframeAllocationOffset,
+	subframeAllocation				SubframeAllocation,
+	iE-Extensions			ProtocolExtensionContainer { { MBSFN-Subframe-Info-ExtIEs } } 	OPTIONAL,
+	...
+}
+
+MBSFN-Subframe-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+MobilityParametersModificationRange ::= SEQUENCE {
+	handoverTriggerChangeLowerLimit		INTEGER (-20..20),
+	handoverTriggerChangeUpperLimit		INTEGER (-20..20),
+	...
+}
+
+MobilityParametersInformation ::= SEQUENCE {
+	handoverTriggerChange			INTEGER (-20..20),
+	...
+}
+
+MultibandInfoList ::= SEQUENCE (SIZE(1..maxnoofBands)) OF BandInfo 
+
+
+BandInfo	::= SEQUENCE {
+	freqBandIndicator		FreqBandIndicator,
+	iE-Extensions			ProtocolExtensionContainer { { BandInfo-ExtIEs } } 	OPTIONAL,
+	...
+}
+
+BandInfo-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- N
+
+Neighbour-Information ::= SEQUENCE (SIZE (0..maxnoofNeighbours)) OF SEQUENCE {
+	eCGI						ECGI,
+	pCI					 		PCI,
+	eARFCN						EARFCN,
+	iE-Extensions		 ProtocolExtensionContainer { {Neighbour-Information-ExtIEs} } OPTIONAL,
+	...
+}
+
+Neighbour-Information-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-NeighbourTAC		CRITICALITY ignore	EXTENSION TAC				PRESENCE optional}|
+	{ ID id-eARFCNExtension		CRITICALITY reject	EXTENSION EARFCNExtension	PRESENCE optional},
+	...
+}
+
+NextHopChainingCount ::= INTEGER (0..7)
+
+Number-of-Antennaports ::= ENUMERATED {
+		an1,
+	 	an2,
+		an4,
+		...
+}
+
+-- O
+
+OffsetOfNbiotChannelNumberToEARFCN ::= ENUMERATED {
+		minusTen,
+		minusNine,
+		minusEight,
+		minusSeven,
+		minusSix,
+		minusFive,
+		minusFour,
+		minusThree,
+		minusTwo,
+		minusOne,
+		minusZeroDotFive,
+		zero,
+		one,
+		two,
+		three,
+		four,
+		five,
+		six,
+		seven,
+		eight,
+		nine,
+		...
+}
+
+Oneframe ::= BIT STRING (SIZE (6))
+
+-- P
+
+PA-Values ::= ENUMERATED {
+	dB-6,
+	dB-4dot77,
+	dB-3,
+	dB-1dot77,
+	dB0,
+	dB1,
+	dB2,
+	dB3,
+	...
+}
+
+PDCP-SN ::= INTEGER (0..4095)
+
+PDCP-SNExtended ::= INTEGER (0..32767)
+
+PDCP-SNlength18 ::= INTEGER (0..262143)
+
+PCI ::= INTEGER (0..503, ...)
+
+PLMN-Identity ::= OCTET STRING (SIZE(3))
+
+Port-Number ::= OCTET STRING (SIZE (2))
+
+PRACH-Configuration ::= SEQUENCE {
+	rootSequenceIndex						INTEGER (0..837),
+	zeroCorrelationIndex					INTEGER (0..15),
+	highSpeedFlag							BOOLEAN,
+	prach-FreqOffset						INTEGER (0..94),
+	prach-ConfigIndex						INTEGER (0..63)		OPTIONAL,  -- present for TDD --
+	iE-Extensions							ProtocolExtensionContainer { {PRACH-Configuration-ExtIEs} }	OPTIONAL,
+	...
+}
+
+PRACH-Configuration-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Pre-emptionCapability ::= ENUMERATED {
+	shall-not-trigger-pre-emption,
+	may-trigger-pre-emption
+}
+
+Pre-emptionVulnerability ::= ENUMERATED {
+	not-pre-emptable,
+	pre-emptable
+}
+
+PriorityLevel				::= INTEGER { spare (0), highest (1), lowest (14), no-priority (15) } (0..15)
+
+ProSeAuthorized ::= SEQUENCE {
+	proSeDirectDiscovery		ProSeDirectDiscovery			OPTIONAL,
+	proSeDirectCommunication	ProSeDirectCommunication		OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { {ProSeAuthorized-ExtIEs} }	OPTIONAL,
+	...
+}
+
+ProSeAuthorized-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-ProSeUEtoNetworkRelaying	CRITICALITY ignore	EXTENSION ProSeUEtoNetworkRelaying		PRESENCE optional},
+	...
+}
+
+ProSeDirectDiscovery ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+ProSeDirectCommunication ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+ProSeUEtoNetworkRelaying ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+-- Q
+
+QCI ::= INTEGER (0..255)
+
+-- R
+
+RadioframeAllocationOffset ::= INTEGER (0..7, ...)
+
+RadioframeAllocationPeriod ::= ENUMERATED{
+	n1,
+	n2,
+	n4,
+	n8,
+	n16,
+	n32,
+	...
+}
+
+
+RadioResourceStatus	::= SEQUENCE {
+	dL-GBR-PRB-usage							DL-GBR-PRB-usage,
+	uL-GBR-PRB-usage							UL-GBR-PRB-usage,
+	dL-non-GBR-PRB-usage						DL-non-GBR-PRB-usage,
+	uL-non-GBR-PRB-usage						UL-non-GBR-PRB-usage,
+	dL-Total-PRB-usage							DL-Total-PRB-usage,
+	uL-Total-PRB-usage							UL-Total-PRB-usage,
+	iE-Extensions								ProtocolExtensionContainer { {RadioResourceStatus-ExtIEs} } OPTIONAL,
+	...
+}
+
+RadioResourceStatus-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ID id-DL-scheduling-PDCCH-CCE-usage		CRITICALITY ignore	EXTENSION DL-scheduling-PDCCH-CCE-usage		PRESENCE optional}|
+
+	{ID id-UL-scheduling-PDCCH-CCE-usage		CRITICALITY ignore	EXTENSION UL-scheduling-PDCCH-CCE-usage		PRESENCE optional},
+	...
+}
+
+ReceiveStatusofULPDCPSDUs ::= BIT STRING (SIZE(4096))
+
+ReceiveStatusOfULPDCPSDUsExtended ::= BIT STRING (SIZE(1..16384))
+
+ReceiveStatusOfULPDCPSDUsPDCP-SNlength18 ::= BIT STRING (SIZE(1..131072))
+
+Registration-Request	::= ENUMERATED {
+	start,
+	stop,
+	...,
+	partial-stop,
+	add
+}
+ 
+RelativeNarrowbandTxPower ::= SEQUENCE {
+
+	rNTP-PerPRB							BIT STRING (SIZE(6..110, ...)),
+	rNTP-Threshold						RNTP-Threshold,
+	numberOfCellSpecificAntennaPorts	ENUMERATED {one, two, four, ...},
+	p-B									INTEGER (0..3,...),
+	pDCCH-InterferenceImpact			INTEGER (0..4,...),
+	iE-Extensions						ProtocolExtensionContainer { { RelativeNarrowbandTxPower-ExtIEs} } OPTIONAL,
+	...
+}
+
+RelativeNarrowbandTxPower-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-enhancedRNTP	CRITICALITY ignore	EXTENSION EnhancedRNTP		PRESENCE optional },
+	...
+}
+
+ReplacingCellsList ::= SEQUENCE (SIZE(0.. maxCellineNB)) OF ReplacingCellsList-Item
+
+ReplacingCellsList-Item ::= SEQUENCE {
+	eCGI			ECGI,
+	...
+}
+
+ReportAmountMDT ::= ENUMERATED{r1, r2, r4, r8, r16, r32, r64, rinfinity}
+
+ReportArea ::= ENUMERATED{
+	ecgi,
+	...
+}
+
+ReportCharacteristics	::= BIT STRING (SIZE (32))
+
+ReportingPeriodicityCSIR ::= ENUMERATED {
+	ms5,
+	ms10,
+	ms20,
+	ms40,
+	ms80,
+...
+}
+
+ReportingPeriodicityRSRPMR ::= ENUMERATED {
+	one-hundred-20-ms,
+	two-hundred-40-ms,
+	four-hundred-80-ms,
+	six-hundred-40-ms,
+...
+}
+
+ReportIntervalMDT ::= ENUMERATED {ms120, ms240, ms480, ms640, ms1024, ms2048, ms5120, ms10240, min1, min6, min12, min30, min60}
+
+ResumeID	::= CHOICE {
+	non-truncated	BIT STRING(SIZE(40)),
+	truncated		BIT STRING(SIZE(24)),
+	...
+}
+
+RNTP-Threshold ::= ENUMERATED {
+	minusInfinity,
+	minusEleven,
+	minusTen,
+	minusNine,
+	minusEight,
+	minusSeven,
+	minusSix,
+	minusFive,
+	minusFour,
+	minusThree,
+	minusTwo,
+	minusOne,
+	zero,
+	one,
+	two,
+	three,
+	...
+}
+
+RRC-Context ::= OCTET STRING
+
+RRCConnReestabIndicator ::= ENUMERATED {
+	reconfigurationFailure, handoverFailure, otherFailure, ...
+}
+-- The values correspond to the values of ReestablishmentCause reported from the UE in the RRCConnectionReestablishmentRequest, as defined in TS 36.331 [9]
+
+RRCConnSetupIndicator::= ENUMERATED {
+	rrcConnSetup,
+	...
+}
+
+RSRPMeasurementResult ::= SEQUENCE (SIZE(1..maxCellReport)) OF
+	SEQUENCE {
+		rSRPCellID						ECGI,
+		rSRPMeasured					INTEGER (0..97, ...), 
+		iE-Extensions					ProtocolExtensionContainer { { RSRPMeasurementResult-ExtIEs} } OPTIONAL,
+		...
+	}
+
+RSRPMeasurementResult-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RSRPMRList ::= SEQUENCE (SIZE(1..maxUEReport)) OF
+	SEQUENCE {
+		rSRPMeasurementResult			RSRPMeasurementResult, 
+		iE-Extensions					ProtocolExtensionContainer { { RSRPMRList-ExtIEs} } OPTIONAL,
+		...
+	}
+
+RSRPMRList-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-UEID	CRITICALITY ignore	EXTENSION UEID		PRESENCE optional},
+	...
+}
+
+-- S
+
+S1TNLLoadIndicator ::= SEQUENCE {
+	dLS1TNLLoadIndicator			LoadIndicator,
+	uLS1TNLLoadIndicator			LoadIndicator,
+	iE-Extensions					ProtocolExtensionContainer { { S1TNLLoadIndicator-ExtIEs} } OPTIONAL,
+	...
+}
+
+S1TNLLoadIndicator-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+SCGChangeIndication ::= ENUMERATED {pDCPCountWrapAround, pSCellChange, other, ...}
+
+SeNBSecurityKey ::= BIT STRING (SIZE(256))
+
+SeNBtoMeNBContainer ::= OCTET STRING
+
+
+ServedCells ::= SEQUENCE (SIZE (1.. maxCellineNB)) OF SEQUENCE {
+	servedCellInfo					ServedCell-Information,
+	neighbour-Info					Neighbour-Information			OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {ServedCell-ExtIEs} } OPTIONAL,
+	...
+}
+
+ServedCell-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ServedCell-Information ::= SEQUENCE {
+	pCI					PCI,
+	cellId				ECGI,
+	tAC					TAC,
+	broadcastPLMNs		BroadcastPLMNs-Item,
+	eUTRA-Mode-Info		EUTRA-Mode-Info,
+	iE-Extensions		ProtocolExtensionContainer { {ServedCell-Information-ExtIEs} } OPTIONAL,
+	...
+}
+
+ServedCell-Information-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-Number-of-Antennaports		CRITICALITY ignore	EXTENSION Number-of-Antennaports				PRESENCE optional}|
+	{ ID id-PRACH-Configuration			CRITICALITY ignore	EXTENSION PRACH-Configuration					PRESENCE optional}|
+	{ ID id-MBSFN-Subframe-Info			CRITICALITY ignore	EXTENSION MBSFN-Subframe-Infolist				PRESENCE optional}|
+	{ ID id-CSG-Id						CRITICALITY ignore	EXTENSION CSG-Id								PRESENCE optional}|
+	{ ID id-MBMS-Service-Area-List		CRITICALITY ignore	EXTENSION MBMS-Service-Area-Identity-List	PRESENCE optional}|
+	{ ID id-MultibandInfoList			CRITICALITY ignore	EXTENSION MultibandInfoList						PRESENCE optional}|
+	{ ID id-FreqBandIndicatorPriority	CRITICALITY ignore	EXTENSION FreqBandIndicatorPriority				PRESENCE optional}|
+	{ ID id-BandwidthReducedSI			CRITICALITY ignore	EXTENSION BandwidthReducedSI					PRESENCE optional},
+	...
+}
+
+SIPTOBearerDeactivationIndication ::= ENUMERATED {
+	true,
+	...
+}
+
+ShortMAC-I ::= BIT STRING (SIZE(16))
+
+SourceOfUEActivityBehaviourInformation ::= ENUMERATED {
+	subscription-information,
+	statistics,
+	...
+}
+
+SpecialSubframe-Info ::= SEQUENCE {
+	specialSubframePatterns		SpecialSubframePatterns,
+	cyclicPrefixDL				CyclicPrefixDL,
+	cyclicPrefixUL				CyclicPrefixUL,
+	iE-Extensions				ProtocolExtensionContainer { { SpecialSubframe-Info-ExtIEs} } OPTIONAL,
+	...
+}
+
+SpecialSubframe-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+SpecialSubframePatterns ::= ENUMERATED { 
+	ssp0,
+	ssp1, 
+	ssp2,
+	ssp3,
+	ssp4,
+	ssp5,
+	ssp6,
+	ssp7,
+	ssp8,
+	...
+}
+
+SubbandCQI ::= SEQUENCE {
+	subbandCQICodeword0			SubbandCQICodeword0,
+	subbandCQICodeword1			SubbandCQICodeword1		OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { { SubbandCQI-ExtIEs} } OPTIONAL,
+	...
+}
+
+SRVCCOperationPossible ::= ENUMERATED {
+	possible,
+	...
+}
+
+SubbandCQI-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+SubbandCQICodeword0 ::= CHOICE {
+	four-bitCQI						INTEGER (0..15, ...),
+	two-bitSubbandDifferentialCQI	INTEGER (0..3, ...),
+	two-bitDifferentialCQI			INTEGER (0..3, ...),
+	...
+}
+SubbandCQICodeword1 ::= CHOICE {
+	four-bitCQI							INTEGER (0..15, ...),
+	three-bitSpatialDifferentialCQI		INTEGER (0..7, ...),
+	two-bitSubbandDifferentialCQI		INTEGER (0..3, ...),
+	two-bitDifferentialCQI				INTEGER (0..3, ...),
+	...
+}
+
+SubbandCQIList ::= SEQUENCE (SIZE(1.. maxSubband)) OF SubbandCQIItem
+
+SubbandCQIItem ::= SEQUENCE {
+	subbandCQI			SubbandCQI,
+	subbandIndex		INTEGER (0..27,...),
+	iE-Extensions		ProtocolExtensionContainer { { SubbandCQIItem-ExtIEs} } OPTIONAL,
+	...
+}
+
+SubbandCQIItem-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+SubbandSize ::= ENUMERATED { 
+	size2,
+	size3,
+	size4,
+	size6,
+	size8,
+	...
+}
+
+SubscriberProfileIDforRFP ::= INTEGER (1..256) 
+
+SubframeAllocation ::= CHOICE {
+	oneframe						Oneframe,
+	fourframes						Fourframes,
+	...
+}
+
+SubframeAssignment ::= ENUMERATED { 
+	sa0,
+	sa1, 
+	sa2,
+	sa3,
+	sa4,
+	sa5,
+	sa6,
+	...
+}
+
+
+-- T
+
+TABasedMDT::= SEQUENCE {
+	tAListforMDT		TAListforMDT,
+	iE-Extensions		ProtocolExtensionContainer { {TABasedMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+TABasedMDT-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TAC ::= OCTET STRING (SIZE (2)) 
+
+TAIBasedMDT ::= SEQUENCE {
+	tAIListforMDT			TAIListforMDT,
+	iE-Extensions			ProtocolExtensionContainer { {TAIBasedMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+TAIBasedMDT-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TAIListforMDT ::= SEQUENCE (SIZE(1..maxnoofTAforMDT)) OF TAI-Item
+
+TAI-Item ::= SEQUENCE {
+	tAC					TAC,
+	pLMN-Identity		PLMN-Identity,
+	iE-Extensions		ProtocolExtensionContainer { { TAI-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+TAI-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TAListforMDT ::= SEQUENCE (SIZE(1..maxnoofTAforMDT)) OF TAC
+
+TargetCellInUTRAN ::= OCTET STRING -- This IE is to be encoded according to the UTRAN Cell ID in the Last Visited UTRAN Cell Information IE in TS 25.413 [24]
+
+TargeteNBtoSource-eNBTransparentContainer	::= OCTET STRING
+
+TDD-Info ::= SEQUENCE {
+	eARFCN							EARFCN,
+	transmission-Bandwidth			Transmission-Bandwidth,
+	subframeAssignment				SubframeAssignment,
+	specialSubframe-Info				SpecialSubframe-Info,
+	iE-Extensions				ProtocolExtensionContainer { {TDD-Info-ExtIEs} } OPTIONAL,
+	...
+}
+TDD-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-AdditionalSpecialSubframe-Info	CRITICALITY ignore	EXTENSION AdditionalSpecialSubframe-Info	PRESENCE optional}|
+	{ ID id-eARFCNExtension					CRITICALITY reject	EXTENSION EARFCNExtension						PRESENCE optional}|
+	{ ID id-AdditionalSpecialSubframeExtension-Info	CRITICALITY ignore	EXTENSION AdditionalSpecialSubframeExtension-Info	PRESENCE optional},
+	...
+}
+
+Threshold-RSRP ::= INTEGER(0..97)
+
+Threshold-RSRQ ::= INTEGER(0..34)
+
+TimeToWait ::= ENUMERATED {
+	v1s, 
+	v2s, 
+	v5s, 
+	v10s, 
+	v20s, 
+	v60s, 
+	...
+}
+
+Time-UE-StayedInCell ::= INTEGER (0..4095)
+
+Time-UE-StayedInCell-EnhancedGranularity ::= INTEGER (0..40950)
+
+TraceActivation ::= SEQUENCE {
+	eUTRANTraceID					EUTRANTraceID,
+	interfacesToTrace				InterfacesToTrace,
+     traceDepth						TraceDepth,
+     traceCollectionEntityIPAddress	TraceCollectionEntityIPAddress,
+	iE-Extensions					ProtocolExtensionContainer { {TraceActivation-ExtIEs} } OPTIONAL,
+	...
+}
+
+TraceActivation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-MDTConfiguration	CRITICALITY ignore	EXTENSION MDT-Configuration		PRESENCE optional},
+	...
+}
+
+TraceCollectionEntityIPAddress ::= BIT STRING (SIZE(1..160, ...))
+
+TraceDepth 		::= ENUMERATED { 
+	minimum,
+	medium,
+	maximum,
+	minimumWithoutVendorSpecificExtension,
+	mediumWithoutVendorSpecificExtension,
+	maximumWithoutVendorSpecificExtension,
+	...
+}
+
+Transmission-Bandwidth ::= ENUMERATED {
+		bw6,
+	 	bw15,
+		bw25,
+	 	bw50,
+		bw75,
+		bw100,
+		...,
+		bw1
+}
+
+TransportLayerAddress			::= BIT STRING (SIZE(1..160, ...))
+
+TunnelInformation ::= SEQUENCE {
+	transportLayerAddress	TransportLayerAddress,
+	uDP-Port-Number			Port-Number			OPTIONAL,
+	iE-Extensions			ProtocolExtensionContainer { {Tunnel-Information-ExtIEs} } OPTIONAL,
+	...
+}
+
+Tunnel-Information-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {	
+	...
+}
+
+TypeOfError ::= ENUMERATED {
+	not-understood,
+	missing,
+	...
+}
+
+
+-- U
+
+UEAggregateMaximumBitRate ::= SEQUENCE {
+	uEaggregateMaximumBitRateDownlink	BitRate,
+	uEaggregateMaximumBitRateUplink		BitRate,
+	iE-Extensions						ProtocolExtensionContainer { {UEAggregate-MaximumBitrate-ExtIEs} } OPTIONAL,
+	...
+}
+
+UEAggregate-MaximumBitrate-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UE-ContextKeptIndicator ::= ENUMERATED {
+	true,
+	...
+}
+
+UEID ::= BIT STRING (SIZE (16))
+
+UE-HistoryInformation ::= SEQUENCE (SIZE(1..maxnoofCells)) OF LastVisitedCell-Item
+
+UE-HistoryInformationFromTheUE ::= OCTET STRING
+-- This IE is a transparent container and shall be encoded as the VisitedCellInfoList field contained in the UEInformationResponse message as defined in TS 36.331 [9]
+
+UE-S1AP-ID ::= INTEGER (0.. 4294967295)
+
+UE-X2AP-ID ::= INTEGER (0..4095)
+
+UE-X2AP-ID-Extension ::= INTEGER (0..4095, ...)
+
+UE-RLF-Report-Container::= OCTET STRING
+-- This IE is a transparent container and shall be encoded as the RLF-Report-r9 field contained in the UEInformationResponse message as defined in TS 36.331 [9]
+
+UE-RLF-Report-Container-for-extended-bands ::= OCTET STRING
+-- This IE is a transparent container and shall be encoded as the RLF-Report-v9e0 field contained in the UEInformationResponse message as defined in TS 36.331 [9]
+
+UESecurityCapabilities ::= SEQUENCE {
+	encryptionAlgorithms				EncryptionAlgorithms,
+	integrityProtectionAlgorithms		IntegrityProtectionAlgorithms,
+	iE-Extensions						ProtocolExtensionContainer { { UESecurityCapabilities-ExtIEs} }		OPTIONAL,
+...
+}
+
+UESecurityCapabilities-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UESidelinkAggregateMaximumBitRate ::= SEQUENCE {
+	uESidelinkAggregateMaximumBitRate		BitRate,
+	iE-Extensions					ProtocolExtensionContainer { {UE-Sidelink-Aggregate-MaximumBitRate-ExtIEs} } OPTIONAL,
+	...
+}
+
+UE-Sidelink-Aggregate-MaximumBitRate-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UL-GBR-PRB-usage::= INTEGER (0..100)
+
+UL-HighInterferenceIndicationInfo ::= SEQUENCE (SIZE(1..maxCellineNB)) OF UL-HighInterferenceIndicationInfo-Item
+
+UL-HighInterferenceIndicationInfo-Item ::= SEQUENCE {
+	target-Cell-ID					ECGI,
+	ul-interferenceindication		UL-HighInterferenceIndication,
+	iE-Extensions					ProtocolExtensionContainer { { UL-HighInterferenceIndicationInfo-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+UL-HighInterferenceIndicationInfo-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UL-HighInterferenceIndication ::= BIT STRING (SIZE(1..110, ...))
+
+UL-InterferenceOverloadIndication ::= SEQUENCE (SIZE(1..maxnoofPRBs)) OF UL-InterferenceOverloadIndication-Item
+
+UL-InterferenceOverloadIndication-Item ::= ENUMERATED {
+	high-interference,
+	medium-interference,
+	low-interference,
+	...
+}
+
+UL-non-GBR-PRB-usage::= INTEGER (0..100)
+
+UL-scheduling-PDCCH-CCE-usage::= INTEGER (0..100)
+
+UL-Total-PRB-usage::= INTEGER (0..100)
+
+UsableABSInformation ::= CHOICE {
+	fdd					UsableABSInformationFDD,
+	tdd					UsableABSInformationTDD,
+	...
+}
+
+UsableABSInformationFDD ::= SEQUENCE {
+	usable-abs-pattern-info				BIT STRING (SIZE(40)),
+	iE-Extensions						ProtocolExtensionContainer { { UsableABSInformationFDD-ExtIEs} } OPTIONAL,
+	...
+}
+
+UsableABSInformationFDD-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UsableABSInformationTDD ::= SEQUENCE {
+	usaable-abs-pattern-info			BIT STRING (SIZE(1..70, ...)),
+	iE-Extensions						ProtocolExtensionContainer { { UsableABSInformationTDD-ExtIEs} } OPTIONAL,
+	...
+}
+
+UsableABSInformationTDD-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- V
+
+V2XServicesAuthorized ::= SEQUENCE {
+	vehicleUE			VehicleUE											OPTIONAL,
+pedestrianUE 		PedestrianUE										    OPTIONAL,
+	iE-Extensions		ProtocolExtensionContainer { {V2XServicesAuthorized-ExtIEs} }	OPTIONAL,
+	...
+}
+
+V2XServicesAuthorized-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+VehicleUE ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+PedestrianUE ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+-- W
+
+WidebandCQI ::= SEQUENCE {
+	widebandCQICodeword0		INTEGER (0..15, ...),
+	widebandCQICodeword1		WidebandCQICodeword1		OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { { WidebandCQI-ExtIEs} } OPTIONAL,
+	...
+}
+
+WidebandCQI-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+WidebandCQICodeword1::= CHOICE {
+	four-bitCQI								INTEGER (0..15, ...),
+	three-bitSpatialDifferentialCQI			INTEGER (0..7, ...),
+	...
+}
+
+WTID ::= CHOICE {
+	wTID-Type1			WTID-Type1,
+	wTID-Type2			WTID-Long-Type2,
+	...
+}
+
+WTID-Type1 ::= SEQUENCE {
+	pLMN-Identity					PLMN-Identity,
+	shortWTID						BIT STRING (SIZE(24)),
+	...
+}
+
+WTID-Long-Type2 ::= BIT STRING (SIZE(48))
+
+WT-UE-XwAP-ID ::= OCTET STRING (SIZE (3))
+
+-- X
+
+X2BenefitValue ::= INTEGER (1..8, ...)
+
+-- Y
+-- Z
+
+END
+
+
+-- **************************************************************
+--
+-- Common definitions
+--
+-- **************************************************************
+
+X2AP-CommonDataTypes {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) x2ap (2) version1 (1) x2ap-CommonDataTypes (3) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- Extension constants
+--
+-- **************************************************************
+
+maxPrivateIEs 									INTEGER ::= 65535
+maxProtocolExtensions 							INTEGER ::= 65535
+maxProtocolIEs									INTEGER ::= 65535
+
+-- **************************************************************
+--
+-- Common Data Types
+--
+-- **************************************************************
+
+Criticality		::= ENUMERATED { reject, ignore, notify }
+
+Presence		::= ENUMERATED { optional, conditional, mandatory }
+
+PrivateIE-ID	::= CHOICE {
+	local				INTEGER (0.. maxPrivateIEs),
+	global				OBJECT IDENTIFIER
+}
+
+ProcedureCode		::= INTEGER (0..255)
+
+
+ProtocolIE-ID		::= INTEGER (0..maxProtocolIEs)
+
+
+TriggeringMessage	::= ENUMERATED { initiating-message, successful-outcome, unsuccessful-outcome}
+
+END
+
+
+-- **************************************************************
+--
+-- Constant definitions
+--
+-- **************************************************************
+
+X2AP-Constants {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) x2ap (2) version1 (1) x2ap-Constants (4) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+IMPORTS
+	ProcedureCode,
+	ProtocolIE-ID
+FROM X2AP-CommonDataTypes;
+
+-- **************************************************************
+--
+-- Elementary Procedures
+--
+-- **************************************************************
+
+id-handoverPreparation											ProcedureCode ::= 0
+id-handoverCancel												ProcedureCode ::= 1
+id-loadIndication												ProcedureCode ::= 2
+id-errorIndication												ProcedureCode ::= 3
+id-snStatusTransfer												ProcedureCode ::= 4
+id-uEContextRelease												ProcedureCode ::= 5
+id-x2Setup														ProcedureCode ::= 6
+id-reset														ProcedureCode ::= 7
+id-eNBConfigurationUpdate										ProcedureCode ::= 8
+id-resourceStatusReportingInitiation							ProcedureCode ::= 9
+id-resourceStatusReporting										ProcedureCode ::= 10
+id-privateMessage												ProcedureCode ::= 11
+id-mobilitySettingsChange										ProcedureCode ::= 12
+id-rLFIndication												ProcedureCode ::= 13
+id-handoverReport												ProcedureCode ::= 14
+id-cellActivation												ProcedureCode ::= 15
+id-x2Release													ProcedureCode ::= 16
+id-x2APMessageTransfer											ProcedureCode ::= 17
+id-x2Removal													ProcedureCode ::= 18
+id-seNBAdditionPreparation										ProcedureCode ::= 19
+id-seNBReconfigurationCompletion								ProcedureCode ::= 20
+id-meNBinitiatedSeNBModificationPreparation						ProcedureCode ::= 21
+id-seNBinitiatedSeNBModification								ProcedureCode ::= 22
+id-meNBinitiatedSeNBRelease										ProcedureCode ::= 23
+id-seNBinitiatedSeNBRelease										ProcedureCode ::= 24
+id-seNBCounterCheck												ProcedureCode ::= 25
+id-retrieveUEContext											ProcedureCode ::= 26
+
+
+-- **************************************************************
+--
+-- Lists
+--
+-- **************************************************************
+
+maxEARFCN									INTEGER ::= 65535
+maxEARFCNPlusOne							INTEGER ::= 65536
+newmaxEARFCN								INTEGER ::= 262143
+maxInterfaces								INTEGER ::= 16
+maxCellineNB								INTEGER ::= 256
+maxnoofBands								INTEGER ::= 16
+maxnoofBearers								INTEGER ::= 256
+maxNrOfErrors								INTEGER ::= 256
+maxnoofPDCP-SN								INTEGER ::= 16
+maxnoofEPLMNs								INTEGER ::= 15
+maxnoofEPLMNsPlusOne						INTEGER ::= 16
+maxnoofForbLACs								INTEGER ::= 4096
+maxnoofForbTACs								INTEGER ::= 4096
+maxnoofBPLMNs								INTEGER ::= 6
+maxnoofNeighbours							INTEGER ::= 512
+maxnoofPRBs									INTEGER ::= 110
+maxPools									INTEGER ::= 16
+maxnoofCells								INTEGER ::= 16
+maxnoofMBSFN								INTEGER ::= 8
+maxFailedMeasObjects						INTEGER ::= 32
+maxnoofCellIDforMDT							INTEGER ::= 32
+maxnoofTAforMDT								INTEGER ::= 8
+maxnoofMBMSServiceAreaIdentities			INTEGER ::= 256
+maxnoofMDTPLMNs								INTEGER ::= 16
+maxnoofCoMPHypothesisSet					INTEGER ::= 256
+maxnoofCoMPCells							INTEGER ::= 32
+maxUEReport									INTEGER ::= 128
+maxCellReport								INTEGER ::= 9
+maxnoofPA									INTEGER ::= 3
+maxCSIProcess								INTEGER ::= 4
+maxCSIReport								INTEGER ::= 2
+maxSubband									INTEGER ::= 14
+
+-- **************************************************************
+--
+-- IEs
+--
+-- **************************************************************
+
+id-E-RABs-Admitted-Item														ProtocolIE-ID ::= 0
+id-E-RABs-Admitted-List														ProtocolIE-ID ::= 1
+id-E-RAB-Item																ProtocolIE-ID ::= 2
+id-E-RABs-NotAdmitted-List													ProtocolIE-ID ::= 3
+id-E-RABs-ToBeSetup-Item													ProtocolIE-ID ::= 4
+id-Cause																	ProtocolIE-ID ::= 5
+id-CellInformation															ProtocolIE-ID ::= 6
+id-CellInformation-Item														ProtocolIE-ID ::= 7
+id-New-eNB-UE-X2AP-ID														ProtocolIE-ID ::= 9
+id-Old-eNB-UE-X2AP-ID														ProtocolIE-ID ::= 10
+id-TargetCell-ID															ProtocolIE-ID ::= 11
+id-TargeteNBtoSource-eNBTransparentContainer								ProtocolIE-ID ::= 12
+id-TraceActivation															ProtocolIE-ID ::= 13
+id-UE-ContextInformation													ProtocolIE-ID ::= 14
+id-UE-HistoryInformation													ProtocolIE-ID ::= 15
+id-UE-X2AP-ID																ProtocolIE-ID ::= 16
+id-CriticalityDiagnostics													ProtocolIE-ID ::= 17
+id-E-RABs-SubjectToStatusTransfer-List										ProtocolIE-ID ::= 18
+id-E-RABs-SubjectToStatusTransfer-Item										ProtocolIE-ID ::= 19
+id-ServedCells																ProtocolIE-ID ::= 20
+id-GlobalENB-ID																ProtocolIE-ID ::= 21
+id-TimeToWait																ProtocolIE-ID ::= 22
+id-GUMMEI-ID																ProtocolIE-ID ::= 23
+id-GUGroupIDList															ProtocolIE-ID ::= 24
+id-ServedCellsToAdd															ProtocolIE-ID ::= 25
+id-ServedCellsToModify														ProtocolIE-ID ::= 26
+id-ServedCellsToDelete														ProtocolIE-ID ::= 27
+id-Registration-Request														ProtocolIE-ID ::= 28
+id-CellToReport																ProtocolIE-ID ::= 29
+id-ReportingPeriodicity														ProtocolIE-ID ::= 30
+id-CellToReport-Item														ProtocolIE-ID ::= 31
+id-CellMeasurementResult													ProtocolIE-ID ::= 32
+id-CellMeasurementResult-Item												ProtocolIE-ID ::= 33
+id-GUGroupIDToAddList														ProtocolIE-ID ::= 34
+id-GUGroupIDToDeleteList													ProtocolIE-ID ::= 35
+id-SRVCCOperationPossible													ProtocolIE-ID ::= 36
+id-Measurement-ID															ProtocolIE-ID ::= 37
+id-ReportCharacteristics													ProtocolIE-ID ::= 38
+id-ENB1-Measurement-ID														ProtocolIE-ID ::= 39
+id-ENB2-Measurement-ID														ProtocolIE-ID ::= 40
+id-Number-of-Antennaports													ProtocolIE-ID ::= 41
+id-CompositeAvailableCapacityGroup											ProtocolIE-ID ::= 42
+id-ENB1-Cell-ID																ProtocolIE-ID ::= 43
+id-ENB2-Cell-ID																ProtocolIE-ID ::= 44
+id-ENB2-Proposed-Mobility-Parameters										ProtocolIE-ID ::= 45
+id-ENB1-Mobility-Parameters													ProtocolIE-ID ::= 46
+id-ENB2-Mobility-Parameters-Modification-Range								ProtocolIE-ID ::= 47
+id-FailureCellPCI															ProtocolIE-ID ::= 48
+id-Re-establishmentCellECGI													ProtocolIE-ID ::= 49
+id-FailureCellCRNTI															ProtocolIE-ID ::= 50
+id-ShortMAC-I																ProtocolIE-ID ::= 51
+id-SourceCellECGI															ProtocolIE-ID ::= 52
+id-FailureCellECGI															ProtocolIE-ID ::= 53
+id-HandoverReportType														ProtocolIE-ID ::= 54
+id-PRACH-Configuration														ProtocolIE-ID ::= 55
+id-MBSFN-Subframe-Info														ProtocolIE-ID ::= 56
+id-ServedCellsToActivate													ProtocolIE-ID ::= 57
+id-ActivatedCellList														ProtocolIE-ID ::= 58
+id-DeactivationIndication													ProtocolIE-ID ::= 59
+id-UE-RLF-Report-Container													ProtocolIE-ID ::= 60
+id-ABSInformation															ProtocolIE-ID ::= 61
+id-InvokeIndication															ProtocolIE-ID ::= 62
+id-ABS-Status																ProtocolIE-ID ::= 63
+id-PartialSuccessIndicator													ProtocolIE-ID ::= 64
+id-MeasurementInitiationResult-List											ProtocolIE-ID ::= 65
+id-MeasurementInitiationResult-Item											ProtocolIE-ID ::= 66
+id-MeasurementFailureCause-Item												ProtocolIE-ID ::= 67
+id-CompleteFailureCauseInformation-List										ProtocolIE-ID ::= 68
+id-CompleteFailureCauseInformation-Item										ProtocolIE-ID ::= 69
+id-CSG-Id																	ProtocolIE-ID ::= 70
+id-CSGMembershipStatus														ProtocolIE-ID ::= 71
+id-MDTConfiguration															ProtocolIE-ID ::= 72
+id-ManagementBasedMDTallowed												ProtocolIE-ID ::= 74
+id-RRCConnSetupIndicator													ProtocolIE-ID ::= 75
+id-NeighbourTAC																ProtocolIE-ID ::= 76
+id-Time-UE-StayedInCell-EnhancedGranularity									ProtocolIE-ID ::= 77
+id-RRCConnReestabIndicator													ProtocolIE-ID ::= 78
+id-MBMS-Service-Area-List													ProtocolIE-ID ::= 79
+id-HO-cause																	ProtocolIE-ID ::= 80
+id-TargetCellInUTRAN														ProtocolIE-ID ::= 81
+id-MobilityInformation														ProtocolIE-ID ::= 82
+id-SourceCellCRNTI															ProtocolIE-ID ::= 83
+id-MultibandInfoList														ProtocolIE-ID ::= 84
+id-M3Configuration															ProtocolIE-ID ::= 85
+id-M4Configuration															ProtocolIE-ID ::= 86
+id-M5Configuration															ProtocolIE-ID ::= 87
+id-MDT-Location-Info														ProtocolIE-ID ::= 88
+id-ManagementBasedMDTPLMNList												ProtocolIE-ID ::= 89
+id-SignallingBasedMDTPLMNList												ProtocolIE-ID ::= 90
+id-ReceiveStatusOfULPDCPSDUsExtended										ProtocolIE-ID ::= 91
+id-ULCOUNTValueExtended														ProtocolIE-ID ::= 92
+id-DLCOUNTValueExtended														ProtocolIE-ID ::= 93
+id-eARFCNExtension															ProtocolIE-ID ::= 94
+id-UL-EARFCNExtension														ProtocolIE-ID ::= 95
+id-DL-EARFCNExtension														ProtocolIE-ID ::= 96
+id-AdditionalSpecialSubframe-Info											ProtocolIE-ID ::= 97
+id-Masked-IMEISV															ProtocolIE-ID ::= 98
+id-IntendedULDLConfiguration												ProtocolIE-ID ::= 99
+id-ExtendedULInterferenceOverloadInfo										ProtocolIE-ID ::= 100
+id-RNL-Header																ProtocolIE-ID ::= 101
+id-x2APMessage																ProtocolIE-ID ::= 102
+id-ProSeAuthorized															ProtocolIE-ID ::= 103
+id-ExpectedUEBehaviour														ProtocolIE-ID ::= 104
+id-UE-HistoryInformationFromTheUE											ProtocolIE-ID ::= 105
+id-DynamicDLTransmissionInformation											ProtocolIE-ID ::= 106
+id-UE-RLF-Report-Container-for-extended-bands								ProtocolIE-ID ::= 107
+id-CoMPInformation															ProtocolIE-ID ::= 108
+id-ReportingPeriodicityRSRPMR												ProtocolIE-ID ::= 109
+id-RSRPMRList																ProtocolIE-ID ::= 110
+id-MeNB-UE-X2AP-ID															ProtocolIE-ID ::= 111
+id-SeNB-UE-X2AP-ID															ProtocolIE-ID ::= 112
+id-UE-SecurityCapabilities													ProtocolIE-ID ::= 113
+id-SeNBSecurityKey															ProtocolIE-ID ::= 114
+id-SeNBUEAggregateMaximumBitRate											ProtocolIE-ID ::= 115
+id-ServingPLMN																ProtocolIE-ID ::= 116
+id-E-RABs-ToBeAdded-List													ProtocolIE-ID ::= 117
+id-E-RABs-ToBeAdded-Item													ProtocolIE-ID ::= 118
+id-MeNBtoSeNBContainer														ProtocolIE-ID ::= 119
+id-E-RABs-Admitted-ToBeAdded-List											ProtocolIE-ID ::= 120
+id-E-RABs-Admitted-ToBeAdded-Item											ProtocolIE-ID ::= 121
+id-SeNBtoMeNBContainer														ProtocolIE-ID ::= 122
+id-ResponseInformationSeNBReconfComp										ProtocolIE-ID ::= 123
+id-UE-ContextInformationSeNBModReq											ProtocolIE-ID ::= 124
+id-E-RABs-ToBeAdded-ModReqItem												ProtocolIE-ID ::= 125
+id-E-RABs-ToBeModified-ModReqItem											ProtocolIE-ID ::= 126
+id-E-RABs-ToBeReleased-ModReqItem											ProtocolIE-ID ::= 127
+id-E-RABs-Admitted-ToBeAdded-ModAckList										ProtocolIE-ID ::= 128
+id-E-RABs-Admitted-ToBeModified-ModAckList									ProtocolIE-ID ::= 129
+id-E-RABs-Admitted-ToBeReleased-ModAckList									ProtocolIE-ID ::= 130
+id-E-RABs-Admitted-ToBeAdded-ModAckItem										ProtocolIE-ID ::= 131
+id-E-RABs-Admitted-ToBeModified-ModAckItem									ProtocolIE-ID ::= 132
+id-E-RABs-Admitted-ToBeReleased-ModAckItem									ProtocolIE-ID ::= 133
+id-E-RABs-ToBeReleased-ModReqd												ProtocolIE-ID ::= 134
+id-E-RABs-ToBeReleased-ModReqdItem											ProtocolIE-ID ::= 135
+id-SCGChangeIndication														ProtocolIE-ID ::= 136
+id-E-RABs-ToBeReleased-List-RelReq											ProtocolIE-ID ::= 137
+id-E-RABs-ToBeReleased-RelReqItem											ProtocolIE-ID ::= 138
+id-E-RABs-ToBeReleased-List-RelConf											ProtocolIE-ID ::= 139
+id-E-RABs-ToBeReleased-RelConfItem											ProtocolIE-ID ::= 140
+id-E-RABs-SubjectToCounterCheck-List										ProtocolIE-ID ::= 141
+id-E-RABs-SubjectToCounterCheckItem											ProtocolIE-ID ::= 142
+id-CoverageModificationList													ProtocolIE-ID ::= 143
+id-ReportingPeriodicityCSIR													ProtocolIE-ID ::= 145
+id-CSIReportList															ProtocolIE-ID ::= 146
+id-UEID																		ProtocolIE-ID ::= 147
+id-enhancedRNTP																ProtocolIE-ID ::= 148
+id-ProSeUEtoNetworkRelaying													ProtocolIE-ID ::= 149
+id-ReceiveStatusOfULPDCPSDUsPDCP-SNlength18									ProtocolIE-ID ::= 150
+id-ULCOUNTValuePDCP-SNlength18												ProtocolIE-ID ::= 151
+id-DLCOUNTValuePDCP-SNlength18												ProtocolIE-ID ::= 152
+id-UE-ContextReferenceAtSeNB												ProtocolIE-ID ::= 153
+id-UE-ContextKeptIndicator													ProtocolIE-ID ::= 154
+id-New-eNB-UE-X2AP-ID-Extension												ProtocolIE-ID ::= 155
+id-Old-eNB-UE-X2AP-ID-Extension												ProtocolIE-ID ::= 156
+id-MeNB-UE-X2AP-ID-Extension												ProtocolIE-ID ::= 157
+id-SeNB-UE-X2AP-ID-Extension												ProtocolIE-ID ::= 158
+id-LHN-ID																	ProtocolIE-ID ::= 159
+id-FreqBandIndicatorPriority												ProtocolIE-ID ::= 160
+id-M6Configuration															ProtocolIE-ID ::= 161
+id-M7Configuration															ProtocolIE-ID ::= 162
+id-Tunnel-Information-for-BBF												ProtocolIE-ID ::= 163
+id-SIPTO-BearerDeactivationIndication										ProtocolIE-ID ::= 164
+id-GW-TransportLayerAddress													ProtocolIE-ID ::= 165
+id-Correlation-ID															ProtocolIE-ID ::= 166
+id-SIPTO-Correlation-ID														ProtocolIE-ID ::= 167
+id-SIPTO-L-GW-TransportLayerAddress											ProtocolIE-ID ::= 168
+id-X2RemovalThreshold														ProtocolIE-ID ::= 169
+id-CellReportingIndicator													ProtocolIE-ID ::= 170
+id-BearerType																ProtocolIE-ID ::= 171
+id-resumeID																	ProtocolIE-ID ::= 172
+id-UE-ContextInformationRetrieve											ProtocolIE-ID ::= 173
+id-E-RABs-ToBeSetupRetrieve-Item											ProtocolIE-ID ::= 174
+id-NewEUTRANCellIdentifier													ProtocolIE-ID ::= 175
+id-V2XServicesAuthorized													ProtocolIE-ID ::= 176
+id-OffsetOfNbiotChannelNumberToDL-EARFCN									ProtocolIE-ID ::= 177
+id-OffsetOfNbiotChannelNumberToUL-EARFCN									ProtocolIE-ID ::= 178
+id-AdditionalSpecialSubframeExtension-Info									ProtocolIE-ID ::= 179
+id-BandwidthReducedSI														ProtocolIE-ID ::= 180
+id-MakeBeforeBreakIndicator													ProtocolIE-ID ::= 181
+id-UE-ContextReferenceAtWT													ProtocolIE-ID ::= 182
+id-WT-UE-ContextKeptIndicator												ProtocolIE-ID ::= 183
+id-UESidelinkAggregateMaximumBitRate										ProtocolIE-ID ::= 184
+id-uL-GTPtunnelEndpoint														ProtocolIE-ID ::= 185
+id-DL-scheduling-PDCCH-CCE-usage											ProtocolIE-ID ::= 193
+id-UL-scheduling-PDCCH-CCE-usage											ProtocolIE-ID ::= 194
+
+END
+
+
+-- **************************************************************
+--
+-- Container definitions
+--
+-- **************************************************************
+
+X2AP-Containers {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) x2ap (2) version1 (1) x2ap-Containers (5) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- IE parameter types from other modules.
+--
+-- **************************************************************
+
+IMPORTS
+	maxPrivateIEs,
+	maxProtocolExtensions,
+	maxProtocolIEs,
+	Criticality,
+	Presence,
+	PrivateIE-ID,
+	ProtocolIE-ID	
+FROM X2AP-CommonDataTypes;
+
+-- **************************************************************
+--
+-- Class Definition for Protocol IEs
+--
+-- **************************************************************
+
+X2AP-PROTOCOL-IES ::= CLASS {
+	&id				ProtocolIE-ID 			UNIQUE,
+	&criticality	Criticality,
+	&Value,
+	&presence		Presence
+}
+WITH SYNTAX {
+	ID				&id
+	CRITICALITY		&criticality
+	TYPE			&Value
+	PRESENCE		&presence
+}
+
+-- **************************************************************
+--
+-- Class Definition for Protocol IEs
+--
+-- **************************************************************
+
+X2AP-PROTOCOL-IES-PAIR ::= CLASS {
+	&id						ProtocolIE-ID 		UNIQUE,
+	&firstCriticality		Criticality,
+	&FirstValue,
+	&secondCriticality		Criticality,
+	&SecondValue,
+	&presence				Presence
+}
+WITH SYNTAX {
+	ID						&id
+	FIRST CRITICALITY 		&firstCriticality
+	FIRST TYPE				&FirstValue
+	SECOND CRITICALITY 		&secondCriticality
+	SECOND TYPE				&SecondValue
+	PRESENCE				&presence
+}
+
+-- **************************************************************
+--
+-- Class Definition for Protocol Extensions
+--
+-- **************************************************************
+
+X2AP-PROTOCOL-EXTENSION ::= CLASS {
+	&id					ProtocolIE-ID 		UNIQUE,
+	&criticality		Criticality,
+	&Extension,
+	&presence			Presence
+}
+WITH SYNTAX {
+	ID					&id
+	CRITICALITY			&criticality
+	EXTENSION			&Extension
+	PRESENCE			&presence
+}
+
+-- **************************************************************
+--
+-- Class Definition for Private IEs
+--
+-- **************************************************************
+
+X2AP-PRIVATE-IES ::= CLASS {
+	&id					PrivateIE-ID,
+	&criticality		Criticality,
+	&Value,
+	&presence			Presence
+}
+WITH SYNTAX {
+	ID					&id
+	CRITICALITY			&criticality
+	TYPE				&Value
+	PRESENCE			&presence
+}
+
+-- **************************************************************
+--
+-- Container for Protocol IEs
+--
+-- **************************************************************
+
+ProtocolIE-Container {X2AP-PROTOCOL-IES : IEsSetParam} ::= 
+	SEQUENCE (SIZE (0..maxProtocolIEs)) OF
+	ProtocolIE-Field {{IEsSetParam}}
+
+ProtocolIE-Single-Container {X2AP-PROTOCOL-IES : IEsSetParam} ::= 
+	ProtocolIE-Field {{IEsSetParam}}
+
+ProtocolIE-Field {X2AP-PROTOCOL-IES : IEsSetParam} ::= SEQUENCE {
+	id				X2AP-PROTOCOL-IES.&id					({IEsSetParam}),
+	criticality		X2AP-PROTOCOL-IES.&criticality			({IEsSetParam}{@id}),
+	value			X2AP-PROTOCOL-IES.&Value				({IEsSetParam}{@id})
+}
+
+-- **************************************************************
+--
+-- Container for Protocol IE Pairs
+--
+-- **************************************************************
+
+ProtocolIE-ContainerPair {X2AP-PROTOCOL-IES-PAIR : IEsSetParam} ::= 
+	SEQUENCE (SIZE (0..maxProtocolIEs)) OF
+	ProtocolIE-FieldPair {{IEsSetParam}}
+
+ProtocolIE-FieldPair {X2AP-PROTOCOL-IES-PAIR : IEsSetParam} ::= SEQUENCE {
+	id					X2AP-PROTOCOL-IES-PAIR.&id					({IEsSetParam}),
+	firstCriticality	X2AP-PROTOCOL-IES-PAIR.&firstCriticality	({IEsSetParam}{@id}),
+	firstValue			X2AP-PROTOCOL-IES-PAIR.&FirstValue			({IEsSetParam}{@id}),
+	secondCriticality	X2AP-PROTOCOL-IES-PAIR.&secondCriticality	({IEsSetParam}{@id}),
+	secondValue			X2AP-PROTOCOL-IES-PAIR.&SecondValue			({IEsSetParam}{@id})
+}
+
+-- **************************************************************
+--
+-- Container Lists for Protocol IE Containers
+--
+-- **************************************************************
+
+ProtocolIE-ContainerList {INTEGER : lowerBound, INTEGER : upperBound, X2AP-PROTOCOL-IES : IEsSetParam} ::=
+	SEQUENCE (SIZE (lowerBound..upperBound)) OF
+	ProtocolIE-Container {{IEsSetParam}}
+
+ProtocolIE-ContainerPairList {INTEGER : lowerBound, INTEGER : upperBound, X2AP-PROTOCOL-IES-PAIR : IEsSetParam} ::=
+	SEQUENCE (SIZE (lowerBound..upperBound)) OF
+	ProtocolIE-ContainerPair {{IEsSetParam}}
+
+-- **************************************************************
+--
+-- Container for Protocol Extensions
+--
+-- **************************************************************
+
+ProtocolExtensionContainer {X2AP-PROTOCOL-EXTENSION : ExtensionSetParam} ::= 
+	SEQUENCE (SIZE (1..maxProtocolExtensions)) OF
+	ProtocolExtensionField {{ExtensionSetParam}}
+
+ProtocolExtensionField {X2AP-PROTOCOL-EXTENSION : ExtensionSetParam} ::= SEQUENCE {
+	id					X2AP-PROTOCOL-EXTENSION.&id				({ExtensionSetParam}),
+	criticality			X2AP-PROTOCOL-EXTENSION.&criticality	({ExtensionSetParam}{@id}),
+	extensionValue		X2AP-PROTOCOL-EXTENSION.&Extension		({ExtensionSetParam}{@id})
+}
+
+-- **************************************************************
+--
+-- Container for Private IEs
+--
+-- **************************************************************
+
+PrivateIE-Container {X2AP-PRIVATE-IES : IEsSetParam} ::= 
+	SEQUENCE (SIZE (1..maxPrivateIEs)) OF
+	PrivateIE-Field {{IEsSetParam}}
+
+PrivateIE-Field {X2AP-PRIVATE-IES : IEsSetParam} ::= SEQUENCE {
+	id				X2AP-PRIVATE-IES.&id			({IEsSetParam}),
+	criticality		X2AP-PRIVATE-IES.&criticality	({IEsSetParam}{@id}),
+	value			X2AP-PRIVATE-IES.&Value			({IEsSetParam}{@id})
+}
+
+END
+
diff --git a/openair2/X2AP/x2ap_common.c b/openair2/X2AP/x2ap_common.c
index d92f2c69bb31021f59bae16f4d73412a2bfa771a..762ba810c737b4d11d96e8d39a1075cb70a6a3e9 100644
--- a/openair2/X2AP/x2ap_common.c
+++ b/openair2/X2AP/x2ap_common.c
@@ -29,7 +29,7 @@
 #include <stdint.h>
 
 #include "x2ap_common.h"
-#include "X2AP-PDU.h"
+#include "X2AP_X2AP-PDU.h"
 
 int asn_debug = 0;
 int asn1_xer_print = 0;
@@ -55,29 +55,27 @@ inline void ASN_DEBUG(const char *fmt, ...)
 ssize_t x2ap_generate_initiating_message(
   uint8_t               **buffer,
   uint32_t               *length,
-  X2ap_ProcedureCode_t    procedureCode,
-  X2ap_Criticality_t      criticality,
+  X2AP_ProcedureCode_t    procedureCode,
+  X2AP_Criticality_t      criticality,
   asn_TYPE_descriptor_t  *td,
   void                   *sptr)
 {
-  X2AP_PDU_t pdu;
+  X2AP_X2AP_PDU_t pdu;
   ssize_t    encoded;
-
-  memset(&pdu, 0, sizeof(X2AP_PDU_t));
-
-  pdu.present = X2AP_PDU_PR_initiatingMessage;
+  memset(&pdu, 0, sizeof(X2AP_X2AP_PDU_t));
+  pdu.present = X2AP_X2AP_PDU_PR_initiatingMessage;
   pdu.choice.initiatingMessage.procedureCode = procedureCode;
   pdu.choice.initiatingMessage.criticality   = criticality;
   ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr);
 
   if (asn1_xer_print) {
-    xer_fprint(stdout, &asn_DEF_X2AP_PDU, (void *)&pdu);
+    xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)&pdu);
   }
 
   /* We can safely free list of IE from sptr */
   ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
 
-  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu,
+  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_X2AP_PDU, 0, &pdu,
                  (void **)buffer)) < 0) {
     return -1;
   }
@@ -89,107 +87,67 @@ ssize_t x2ap_generate_initiating_message(
 ssize_t x2ap_generate_successfull_outcome(
   uint8_t               **buffer,
   uint32_t               *length,
-  X2ap_ProcedureCode_t         procedureCode,
-  X2ap_Criticality_t           criticality,
+  X2AP_ProcedureCode_t         procedureCode,
+  X2AP_Criticality_t           criticality,
   asn_TYPE_descriptor_t  *td,
   void                   *sptr)
 {
-  X2AP_PDU_t pdu;
+  X2AP_X2AP_PDU_t pdu;
   ssize_t    encoded;
-
-  memset(&pdu, 0, sizeof(X2AP_PDU_t));
-
-  pdu.present = X2AP_PDU_PR_successfulOutcome;
+  memset(&pdu, 0, sizeof(X2AP_X2AP_PDU_t));
+  pdu.present = X2AP_X2AP_PDU_PR_successfulOutcome;
   pdu.choice.successfulOutcome.procedureCode = procedureCode;
   pdu.choice.successfulOutcome.criticality   = criticality;
   ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
 
   if (asn1_xer_print) {
-    xer_fprint(stdout, &asn_DEF_X2AP_PDU, (void *)&pdu);
+    xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)&pdu);
   }
 
   /* We can safely free list of IE from sptr */
   ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
 
-  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu,
+  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_X2AP_PDU, 0, &pdu,
                  (void **)buffer)) < 0) {
     return -1;
   }
 
   *length = encoded;
-
   return encoded;
 }
 
 ssize_t x2ap_generate_unsuccessfull_outcome(
   uint8_t               **buffer,
   uint32_t               *length,
-  X2ap_ProcedureCode_t         procedureCode,
-  X2ap_Criticality_t           criticality,
+  X2AP_ProcedureCode_t         procedureCode,
+  X2AP_Criticality_t           criticality,
   asn_TYPE_descriptor_t  *td,
   void                   *sptr)
 {
-  X2AP_PDU_t pdu;
+  X2AP_X2AP_PDU_t pdu;
   ssize_t    encoded;
-
-  memset(&pdu, 0, sizeof(X2AP_PDU_t));
-
-  pdu.present = X2AP_PDU_PR_unsuccessfulOutcome;
+  memset(&pdu, 0, sizeof(X2AP_X2AP_PDU_t));
+  pdu.present = X2AP_X2AP_PDU_PR_unsuccessfulOutcome;
   pdu.choice.successfulOutcome.procedureCode = procedureCode;
   pdu.choice.successfulOutcome.criticality   = criticality;
   ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
 
   if (asn1_xer_print) {
-    xer_fprint(stdout, &asn_DEF_X2AP_PDU, (void *)&pdu);
+    xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)&pdu);
   }
 
   /* We can safely free list of IE from sptr */
   ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
 
-  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu,
+  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_X2AP_PDU, 0, &pdu,
                  (void **)buffer)) < 0) {
     return -1;
   }
 
   *length = encoded;
-
   return encoded;
 }
 
-X2ap_IE_t *x2ap_new_ie(
-  X2ap_ProtocolIE_ID_t   id,
-  X2ap_Criticality_t     criticality,
-  asn_TYPE_descriptor_t *type,
-  void                  *sptr)
-{
-  X2ap_IE_t *buff;
-
-  if ((buff = malloc(sizeof(X2ap_IE_t))) == NULL) {
-    // Possible error on malloc
-    return NULL;
-  }
-
-  memset((void *)buff, 0, sizeof(X2ap_IE_t));
-
-  buff->id = id;
-  buff->criticality = criticality;
-
-  if (ANY_fromType_aper(&buff->value, type, sptr) < 0) {
-    fprintf(stderr, "Encoding of %s failed\n", type->name);
-    free(buff);
-    return NULL;
-  }
-
-  if (asn1_xer_print)
-    if (xer_fprint(stdout, &asn_DEF_X2ap_IE, buff) < 0) {
-      free(buff);
-      return NULL;
-    }
-
-  return buff;
-}
-
-void x2ap_handle_criticality(X2ap_Criticality_t criticality)
+void x2ap_handle_criticality(X2AP_Criticality_t criticality)
 {
-
 }
diff --git a/openair2/X2AP/x2ap_common.h b/openair2/X2AP/x2ap_common.h
index b7c93614768daa5b8f7235f802299fb198807da6..6843e2913fb7f0bcbcf20a500b7b202abd772892 100644
--- a/openair2/X2AP/x2ap_common.h
+++ b/openair2/X2AP/x2ap_common.h
@@ -23,247 +23,17 @@
 # include "config.h"
 #endif
 
-#include "X2ap-ABSInformationFDD.h"
-#include "X2ap-ABSInformation.h"
-#include "X2ap-ABSInformationTDD.h"
-#include "X2ap-ABS-Status.h"
-#include "X2ap-ActivatedCellList.h"
-#include "X2ap-AllocationAndRetentionPriority.h"
-#include "X2ap-AreaScopeOfMDT.h"
-#include "X2ap-AS-SecurityInformation.h"
-#include "X2ap-BandInfo.h"
-#include "X2ap-BitRate.h"
-#include "X2ap-BroadcastPLMNs-Item.h"
-
-#include "X2ap-CapacityValue.h"
-#include "X2ap-Cause.h"
-#include "X2ap-CauseMisc.h"
-#include "X2ap-CauseProtocol.h"
-#include "X2ap-CauseRadioNetwork.h"
-#include "X2ap-CauseTransport.h"
-#include "X2ap-CellActivationFailure.h"
-#include "X2ap-CellActivationRequest.h"
-#include "X2ap-CellActivationResponse.h"
-#include "X2ap-CellBasedMDT.h"
-#include "X2ap-CellCapacityClassValue.h"
-#include "X2ap-CellIdListforMDT.h"
-#include "X2ap-CellInformation-Item.h"
-#include "X2ap-CellInformation-List.h"
-#include "X2ap-Cell-Size.h"
-#include "X2ap-CellToReport-Item.h"
-#include "X2ap-CellToReport-List.h"
-#include "X2ap-CellType.h"
-#include "X2ap-CellMeasurementResult-Item.h" 
-#include "X2ap-CellMeasurementResult-List.h"
-#include "X2ap-CompleteFailureCauseInformation-Item.h"
-#include "X2ap-CompleteFailureCauseInformation-List.h"
-#include "X2ap-CompositeAvailableCapacityGroup.h"
-#include "X2ap-CompositeAvailableCapacity.h"
-#include "X2ap-COUNTvalue.h"
-#include "X2ap-CriticalityDiagnostics.h"
-#include "X2ap-CriticalityDiagnostics-IE-List.h"
-#include "X2ap-Criticality.h"
-#include "X2ap-CRNTI.h"
-#include "X2ap-CSG-Id.h"
-#include "X2ap-CSGMembershipStatus.h"
-#include "X2ap-CyclicPrefixDL.h"
-#include "X2ap-CyclicPrefixUL.h"
-#include "X2ap-DeactivationIndication.h"
-#include "X2ap-DL-ABS-status.h"
-#include "X2ap-DL-Forwarding.h"
-#include "X2ap-DL-GBR-PRB-usage.h"
-#include "X2ap-DL-non-GBR-PRB-usage.h"
-#include "X2ap-DL-Total-PRB-usage.h"
-#include "X2ap-EARFCN.h"
-#include "X2ap-ECGI.h"
-#include "X2ap-ENB-ID.h"
-#include "X2ap-ENBConfigurationUpdateFailure.h"
-#include "X2ap-ENBConfigurationUpdateAcknowledge.h"
-#include "X2ap-ENBConfigurationUpdate.h"
-#include "X2ap-EncryptionAlgorithms.h"
-#include "X2ap-EPLMNs.h"
-#include "X2ap-E-RAB-ID.h"
-#include "X2ap-E-RAB-Item.h"
-#include "X2ap-E-RABs-Admitted-List.h"
-#include "X2ap-E-RAB-Level-QoS-Parameters.h"
-#include "X2ap-E-RAB-List.h"
-#include "X2ap-E-RABs-SubjectToStatusTransfer-Item.h"
-#include "X2ap-E-RABs-Admitted-Item.h"
-#include "X2ap-E-RABs-SubjectToStatusTransfer-List.h"
-#include "X2ap-ErrorIndication.h"
-#include "X2ap-EUTRA-Mode-Info.h"
-#include "X2ap-EUTRANCellIdentifier.h"
-#include "X2ap-EUTRANTraceID.h"
-#include "X2ap-EventType.h"
-
-#include "X2ap-FDD-Info.h"
-#include "X2ap-ForbiddenInterRATs.h"
-#include "X2ap-ForbiddenLACs.h"
-#include "X2ap-ForbiddenLAs.h"
-#include "X2ap-ForbiddenLAs-Item.h"
-#include "X2ap-ForbiddenTACs.h"
-#include "X2ap-ForbiddenTAs.h"
-#include "X2ap-ForbiddenTAs-Item.h"
-#include "X2ap-Fourframes.h"
-#include "X2ap-FreqBandIndicator.h"
-#include "X2ap-GBR-QosInformation.h"
-#include "X2ap-GlobalENB-ID.h"
-#include "X2ap-GTP-TEI.h"
-#include "X2ap-GTPtunnelEndpoint.h"
-#include "X2ap-GU-Group-ID.h"
-#include "X2ap-GUGroupIDList.h"
-#include "X2ap-GUMMEI.h"
-#include "X2ap-HandoverCancel.h"
-#include "X2ap-HandoverReportType.h"
-#include "X2ap-HandoverRequest.h"
-#include "X2ap-HandoverReport.h"
-#include "X2ap-HandoverRestrictionList.h"
-#include "X2ap-HandoverPreparationFailure.h"
-#include "X2ap-HandoverRequestAcknowledge.h"
-
-#include "X2ap-HFN.h"
-#include "X2ap-HWLoadIndicator.h"
-#include "X2ap-IE-Extensions.h"
-#include "X2ap-IE.h"
-#include "X2ap-IntegrityProtectionAlgorithms.h"
-#include "X2ap-InterfacesToTrace.h"
-#include "X2ap-InvokeIndication.h"
-#include "X2ap-Key-eNodeB-Star.h"
-#include "X2ap-LAC.h"
-#include "X2ap-LastVisitedCell-Item.h"
-#include "X2ap-LastVisitedEUTRANCellInformation.h"
-#include "X2ap-LastVisitedGERANCellInformation.h"
-#include "X2ap-LastVisitedUTRANCellInformation.h"
-#include "X2ap-LoadIndicator.h"
-#include "X2ap-LoadInformation.h"
-#include "X2ap-LocationReportingInformation.h"
-#include "X2ap-ManagementBasedMDTallowed.h"
-#include "X2ap-MBMS-Service-Area-Identity.h"
-#include "X2ap-MBMS-Service-Area-Identity-List.h"
-#include "X2ap-MBSFN-Subframe-Info.h"
-#include "X2ap-MBSFN-Subframe-Infolist.h"
-#include "X2ap-MDT-Activation.h"
-#include "X2ap-MDT-Configuration.h"
-#include "X2ap-Measurement-ID.h"
-#include "X2ap-MeasurementsToActivate.h"
-#include "X2ap-MeasurementThresholdA2.h"
-#include "X2ap-MeasurementInitiationResult-Item.h"
-#include "X2ap-MeasurementInitiationResult-List.h"
-
-#include "X2ap-MeasurementFailureCause-Item.h"
-#include "X2ap-MME-Code.h"
-#include "X2ap-MME-Group-ID.h"
-#include "X2ap-MobilityChangeAcknowledge.h"
-#include "X2ap-MobilityChangeFailure.h"
-#include "X2ap-MobilityChangeRequest.h"
-#include "X2ap-MobilityParametersInformation.h"
-#include "X2ap-MobilityParametersModificationRange.h"
-#include "X2ap-MultibandInfoList.h"
-#include "X2ap-Neighbour-Information.h"
-#include "X2ap-NextHopChainingCount.h"
-#include "X2ap-Number-of-Antennaports.h"
-#include "X2ap-Oneframe.h"
-#include "X2ap-Old-ECGIs.h"
-#include "X2ap-PartialSuccessIndicator.h"
-#include "X2ap-PCI.h"
-#include "X2ap-PDCP-SN.h"
-#include "X2AP-PDU.h"
-#include "X2ap-PeriodicReportingMDT.h"
-#include "X2ap-PLMN-Identity.h"
-#include "X2ap-PRACH-Configuration.h"
-#include "X2ap-Pre-emptionCapability.h"
-#include "X2ap-Pre-emptionVulnerability.h"
-#include "X2ap-Presence.h"
-#include "X2ap-PriorityLevel.h"
-#include "X2ap-PrivateIE-ID.h"
-#include "X2ap-ProcedureCode.h"
-#include "X2ap-ProtocolIE-ID.h"
-#include "X2ap-QCI.h"
-#include "X2ap-RadioframeAllocationOffset.h"
-#include "X2ap-RadioframeAllocationPeriod.h"
-#include "X2ap-RadioResourceStatus.h"
-#include "X2ap-ReceiveStatusofULPDCPSDUs.h"
-#include "X2ap-Registration-Request.h"
-#include "X2ap-RelativeNarrowbandTxPower.h"
-#include "X2ap-ReportAmountMDT.h"
-#include "X2ap-ReportArea.h"
-#include "X2ap-ReportCharacteristics.h"
-#include "X2ap-ReportingTriggerMDT.h"
-#include "X2ap-ReportIntervalMDT.h"
-#include "X2ap-ReportingPeriodicity.h"
-#include "X2ap-ResourceStatusFailure.h"
-#include "X2ap-ResourceStatusResponse.h"
-#include "X2ap-ResourceStatusUpdate.h"
-
-#include "X2ap-RNTP-Threshold.h"
-#include "X2ap-RRCConnReestabIndicator.h"
-#include "X2ap-RRCConnSetupIndicator.h"
-#include "X2ap-RRC-Context.h"
-#include "X2ap-RLFIndication.h"
-#include "X2ap-ResourceStatusRequest.h"
-#include "X2ap-S1TNLLoadIndicator.h"
-//nclude "X2ap-ServedCellInformation.h"
-#include "X2ap-ServedCells.h"
-#include "X2ap-ServedCellsToModify.h"
-#include "X2ap-ServedCellsToActivate.h"
-#include "X2ap-ShortMAC-I.h"
-#include "X2ap-SpecialSubframe-Info.h"
-#include "X2ap-SpecialSubframePatterns.h"
-#include "X2ap-SRVCCOperationPossible.h"
-#include "X2ap-SubframeAllocation.h"
-#include "X2ap-SubframeAssignment.h"
-#include "X2ap-SubscriberProfileIDforRFP.h"
-#include "X2ap-SNStatusTransfer.h"
-
-#include "X2ap-TABasedMDT.h"
-#include "X2ap-TAC.h"
-#include "X2ap-TAListforMDT.h"
-#include "X2ap-TargetCellInUTRAN.h"
-#include "X2ap-TargeteNBtoSource-eNBTransparentContainer.h"
-#include "X2ap-TDD-Info.h"
-#include "X2ap-ThresholdEventA2.h"
-#include "X2ap-Threshold-RSRP.h"
-#include "X2ap-Threshold-RSRQ.h"
-#include "X2ap-TimeToWait.h"
-#include "X2ap-Time-UE-StayedInCell-EnhancedGranularity.h"
-#include "X2ap-Time-UE-StayedInCell.h"
-#include "X2ap-E-RABs-ToBeSetup-Item.h"
-#include "X2ap-TraceActivation.h"
-#include "X2ap-TraceCollectionEntityIPAddress.h"
-#include "X2ap-TraceDepth.h"
-#include "X2ap-Transmission-Bandwidth.h"
-#include "X2ap-TransportLayerAddress.h"
-#include "X2ap-TriggeringMessage.h"
-#include "X2ap-TypeOfError.h"
-#include "X2ap-UEAggregateMaximumBitRate.h"
-#include "X2ap-UE-ContextInformation.h"
-#include "X2ap-UE-HistoryInformation.h"
-#include "X2ap-UE-RLF-Report-Container.h"
-#include "X2ap-UE-S1AP-ID.h"
-#include "X2ap-UE-X2AP-ID.h"
-#include "X2ap-UEContextRelease.h"
-#include "X2ap-UESecurityCapabilities.h"
-#include "X2ap-UL-GBR-PRB-usage.h"
-#include "X2ap-UL-HighInterferenceIndication.h"
-#include "X2ap-UL-HighInterferenceIndicationInfo.h"
-#include "X2ap-UL-HighInterferenceIndicationInfo-Item.h"
-#include "X2ap-UL-InterferenceOverloadIndication.h"
-#include "X2ap-UL-InterferenceOverloadIndication-Item.h"
-#include "X2ap-UL-non-GBR-PRB-usage.h"
-#include "X2ap-UL-Total-PRB-usage.h"
-#include "X2ap-UsableABSInformationFDD.h"
-#include "X2ap-UsableABSInformation.h"
-#include "X2ap-UsableABSInformationTDD.h"
-
-#include "X2ap-ResetResponse.h"
-#include "X2ap-ResetRequest.h"
-#include "X2SetupFailure.h"
-#include "X2SetupRequest.h"
-#include "X2SetupResponse.h"
-
-#include "X2ap-Old-ECGIs.h"
-#include "X2ap-Criticality.h"
-#include "X2ap-ProcedureCode.h"
+#include "X2AP_ProtocolIE-Field.h"
+#include "X2AP_X2AP-PDU.h"
+#include "X2AP_InitiatingMessage.h"
+#include "X2AP_SuccessfulOutcome.h"
+#include "X2AP_UnsuccessfulOutcome.h"
+#include "X2AP_ProtocolIE-Field.h"
+#include "X2AP_ProtocolIE-FieldPair.h"
+#include "X2AP_ProtocolIE-ContainerPair.h"
+#include "X2AP_ProtocolExtensionField.h"
+#include "X2AP_ProtocolExtensionContainer.h"
+#include "X2AP_asn_constant.h"
 
 #ifndef X2AP_COMMON_H_
 #define X2AP_COMMON_H_
@@ -323,8 +93,8 @@ typedef int (*x2ap_message_decoded_callback)(
 ssize_t x2ap_generate_successfull_outcome(
   uint8_t               **buffer,
   uint32_t               *length,
-  X2ap_ProcedureCode_t         procedureCode,
-  X2ap_Criticality_t           criticality,
+  X2AP_ProcedureCode_t         procedureCode,
+  X2AP_Criticality_t           criticality,
   asn_TYPE_descriptor_t  *td,
   void                   *sptr);
 
@@ -340,8 +110,8 @@ ssize_t x2ap_generate_successfull_outcome(
 ssize_t x2ap_generate_initiating_message(
   uint8_t               **buffer,
   uint32_t               *length,
-  X2ap_ProcedureCode_t    procedureCode,
-  X2ap_Criticality_t      criticality,
+  X2AP_ProcedureCode_t    procedureCode,
+  X2AP_Criticality_t      criticality,
   asn_TYPE_descriptor_t  *td,
   void                   *sptr);
 
@@ -357,28 +127,15 @@ ssize_t x2ap_generate_initiating_message(
 ssize_t x2ap_generate_unsuccessfull_outcome(
   uint8_t               **buffer,
   uint32_t               *length,
-  X2ap_ProcedureCode_t         procedureCode,
-  X2ap_Criticality_t           criticality,
+  X2AP_ProcedureCode_t         procedureCode,
+  X2AP_Criticality_t           criticality,
   asn_TYPE_descriptor_t  *td,
   void                   *sptr);
 
-/** \brief Generate a new IE
- \param id Protocol ie id of the IE
- \param criticality Criticality of the IE
- \param type ASN1 type descriptor of the IE value
- \param sptr Structure to be encoded in the value field
- @returns a pointer to the newly created IE structure or NULL in case of failure
- **/
-X2ap_IE_t *x2ap_new_ie(
-  X2ap_ProtocolIE_ID_t   id,
-  X2ap_Criticality_t     criticality,
-  asn_TYPE_descriptor_t *type,
-  void                  *sptr);
-
 /** \brief Handle criticality
  \param criticality Criticality of the IE
  @returns void
  **/
-void x2ap_handle_criticality(X2ap_Criticality_t criticality);
+void x2ap_handle_criticality(X2AP_Criticality_t criticality);
 
 #endif /* X2AP_COMMON_H_ */
diff --git a/openair3/S1AP/MESSAGES/ASN1/R14.4/s1ap-14.4.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R14.4/s1ap-14.4.0.asn1
new file mode 100755
index 0000000000000000000000000000000000000000..83f486a1d4edc0f62639dda5c786e978f1e9f7fc
--- /dev/null
+++ b/openair3/S1AP/MESSAGES/ASN1/R14.4/s1ap-14.4.0.asn1
@@ -0,0 +1,6634 @@
+-- **************************************************************
+--
+-- Elementary Procedure definitions
+--
+-- **************************************************************
+
+S1AP-PDU-Descriptions  { 
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) s1ap (1) version1 (1) s1ap-PDU-Descriptions (0)}
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- IE parameter types from other modules.
+--
+-- **************************************************************
+
+IMPORTS
+	Criticality,
+	ProcedureCode
+FROM S1AP-CommonDataTypes
+
+	CellTrafficTrace,
+	DeactivateTrace,
+	DownlinkUEAssociatedLPPaTransport,
+	DownlinkNASTransport,
+	DownlinkNonUEAssociatedLPPaTransport,
+	DownlinkS1cdma2000tunnelling,
+	ENBDirectInformationTransfer,
+	ENBStatusTransfer,
+	ENBConfigurationUpdate,
+	ENBConfigurationUpdateAcknowledge,
+	ENBConfigurationUpdateFailure,
+	ErrorIndication,
+	HandoverCancel,
+	HandoverCancelAcknowledge,
+	HandoverCommand,
+	HandoverFailure,
+	HandoverNotify,
+	HandoverPreparationFailure,
+	HandoverRequest,
+	HandoverRequestAcknowledge,
+	HandoverRequired,
+	InitialContextSetupFailure,
+	InitialContextSetupRequest,
+	InitialContextSetupResponse,
+	InitialUEMessage,
+	KillRequest,
+	KillResponse,
+	LocationReportingControl,
+	LocationReportingFailureIndication,
+	LocationReport,
+	MMEConfigurationUpdate,
+	MMEConfigurationUpdateAcknowledge,
+	MMEConfigurationUpdateFailure,
+	MMEDirectInformationTransfer,
+	MMEStatusTransfer,
+	NASNonDeliveryIndication,
+	OverloadStart,
+	OverloadStop,
+	Paging,
+	PathSwitchRequest,
+	PathSwitchRequestAcknowledge,
+	PathSwitchRequestFailure,	
+	PrivateMessage,
+	Reset,
+	ResetAcknowledge,
+	S1SetupFailure,
+	S1SetupRequest,
+	S1SetupResponse,
+	E-RABModifyRequest,
+	E-RABModifyResponse,
+	E-RABModificationIndication,
+	E-RABModificationConfirm,
+	E-RABReleaseCommand,
+	E-RABReleaseResponse,
+	E-RABReleaseIndication,
+	E-RABSetupRequest,
+	E-RABSetupResponse,
+	TraceFailureIndication,
+	TraceStart,
+	UECapabilityInfoIndication,
+	UEContextModificationFailure,
+	UEContextModificationRequest,
+	UEContextModificationResponse,
+	UEContextReleaseCommand,
+	UEContextReleaseComplete,
+	UEContextReleaseRequest,
+	UERadioCapabilityMatchRequest,
+	UERadioCapabilityMatchResponse,
+	UplinkUEAssociatedLPPaTransport,
+	UplinkNASTransport,
+	UplinkNonUEAssociatedLPPaTransport,
+	UplinkS1cdma2000tunnelling,
+	WriteReplaceWarningRequest,
+	WriteReplaceWarningResponse,
+	ENBConfigurationTransfer,
+	MMEConfigurationTransfer,
+	PWSRestartIndication,
+	UEContextModificationIndication,
+	UEContextModificationConfirm,
+	RerouteNASRequest,
+	PWSFailureIndication,
+	UEContextSuspendRequest,
+	UEContextSuspendResponse,
+	UEContextResumeRequest,
+	UEContextResumeResponse,
+	UEContextResumeFailure,
+	ConnectionEstablishmentIndication,
+	NASDeliveryIndication,
+	RetrieveUEInformation,
+	UEInformationTransfer,
+	ENBCPRelocationIndication,
+	MMECPRelocationIndication
+
+
+FROM S1AP-PDU-Contents
+	
+	id-CellTrafficTrace,
+	id-DeactivateTrace,
+	id-downlinkUEAssociatedLPPaTransport,
+	id-downlinkNASTransport,
+	id-downlinkNonUEAssociatedLPPaTransport,
+	id-DownlinkS1cdma2000tunnelling,
+	id-eNBStatusTransfer,
+	id-ErrorIndication,
+	id-HandoverCancel,
+	id-HandoverNotification,
+	id-HandoverPreparation,
+	id-HandoverResourceAllocation,
+	id-InitialContextSetup,
+	id-initialUEMessage,
+	id-ENBConfigurationUpdate,
+	id-Kill,
+	id-LocationReportingControl,
+	id-LocationReportingFailureIndication,
+	id-LocationReport,
+	id-eNBDirectInformationTransfer,
+	id-MMEConfigurationUpdate,
+	id-MMEDirectInformationTransfer,
+	id-MMEStatusTransfer,
+	id-NASNonDeliveryIndication,
+	id-OverloadStart,
+	id-OverloadStop,
+	id-Paging,
+	id-PathSwitchRequest,
+	id-PrivateMessage,
+	id-Reset,
+	id-S1Setup,
+	id-E-RABModify,
+	id-E-RABModificationIndication,
+	id-E-RABRelease,
+	id-E-RABReleaseIndication,
+	id-E-RABSetup,
+	id-TraceFailureIndication,
+	id-TraceStart,
+	id-UECapabilityInfoIndication,
+	id-UEContextModification,
+	id-UEContextRelease,
+	id-UEContextReleaseRequest,
+	id-UERadioCapabilityMatch,
+	id-uplinkUEAssociatedLPPaTransport,
+	id-uplinkNASTransport,
+	id-uplinkNonUEAssociatedLPPaTransport,
+	id-UplinkS1cdma2000tunnelling,
+	id-WriteReplaceWarning,
+	id-eNBConfigurationTransfer,
+	id-MMEConfigurationTransfer,
+	id-PWSRestartIndication,
+	id-UEContextModificationIndication,
+	id-RerouteNASRequest,
+	id-PWSFailureIndication,
+	id-UEContextSuspend,
+	id-UEContextResume,
+	id-ConnectionEstablishmentIndication,
+	id-NASDeliveryIndication,
+	id-RetrieveUEInformation,
+	id-UEInformationTransfer,
+	id-eNBCPRelocationIndication,
+	id-MMECPRelocationIndication
+
+
+FROM S1AP-Constants;
+
+
+-- **************************************************************
+--
+-- Interface Elementary Procedure Class
+--
+-- **************************************************************
+
+S1AP-ELEMENTARY-PROCEDURE ::= CLASS {
+	&InitiatingMessage				,
+	&SuccessfulOutcome							OPTIONAL,
+	&UnsuccessfulOutcome						OPTIONAL,
+	&procedureCode				ProcedureCode 	UNIQUE,
+	&criticality				Criticality 	DEFAULT ignore
+}
+WITH SYNTAX {
+	INITIATING MESSAGE			&InitiatingMessage
+	[SUCCESSFUL OUTCOME			&SuccessfulOutcome]
+	[UNSUCCESSFUL OUTCOME		&UnsuccessfulOutcome]
+	PROCEDURE CODE				&procedureCode
+	[CRITICALITY				&criticality]
+}
+
+-- **************************************************************
+--
+-- Interface PDU Definition
+--
+-- **************************************************************
+
+S1AP-PDU ::= CHOICE {
+	initiatingMessage	InitiatingMessage,
+	successfulOutcome	SuccessfulOutcome,
+	unsuccessfulOutcome	UnsuccessfulOutcome,
+	...
+}
+
+InitiatingMessage ::= SEQUENCE {
+	procedureCode	S1AP-ELEMENTARY-PROCEDURE.&procedureCode		({S1AP-ELEMENTARY-PROCEDURES}),
+	criticality		S1AP-ELEMENTARY-PROCEDURE.&criticality			({S1AP-ELEMENTARY-PROCEDURES}{@procedureCode}),
+	value			S1AP-ELEMENTARY-PROCEDURE.&InitiatingMessage	({S1AP-ELEMENTARY-PROCEDURES}{@procedureCode})
+}
+
+SuccessfulOutcome ::= SEQUENCE {
+	procedureCode	S1AP-ELEMENTARY-PROCEDURE.&procedureCode		({S1AP-ELEMENTARY-PROCEDURES}),
+	criticality		S1AP-ELEMENTARY-PROCEDURE.&criticality			({S1AP-ELEMENTARY-PROCEDURES}{@procedureCode}),
+	value			S1AP-ELEMENTARY-PROCEDURE.&SuccessfulOutcome	({S1AP-ELEMENTARY-PROCEDURES}{@procedureCode})
+}
+
+UnsuccessfulOutcome ::= SEQUENCE {
+	procedureCode	S1AP-ELEMENTARY-PROCEDURE.&procedureCode		({S1AP-ELEMENTARY-PROCEDURES}),
+	criticality		S1AP-ELEMENTARY-PROCEDURE.&criticality			({S1AP-ELEMENTARY-PROCEDURES}{@procedureCode}),
+	value			S1AP-ELEMENTARY-PROCEDURE.&UnsuccessfulOutcome	({S1AP-ELEMENTARY-PROCEDURES}{@procedureCode})
+}
+
+-- **************************************************************
+--
+-- Interface Elementary Procedure List
+--
+-- **************************************************************
+
+S1AP-ELEMENTARY-PROCEDURES S1AP-ELEMENTARY-PROCEDURE ::= {
+	S1AP-ELEMENTARY-PROCEDURES-CLASS-1			|
+	S1AP-ELEMENTARY-PROCEDURES-CLASS-2,	
+	...
+}
+
+
+S1AP-ELEMENTARY-PROCEDURES-CLASS-1 S1AP-ELEMENTARY-PROCEDURE ::= {
+	handoverPreparation				|
+	handoverResourceAllocation		|
+	pathSwitchRequest 				|
+	e-RABSetup						|
+	e-RABModify						|
+	e-RABRelease					|
+	initialContextSetup				|
+	handoverCancel					|
+	kill							|
+	reset							|
+	s1Setup							|
+	uEContextModification			|
+	uEContextRelease				|
+	eNBConfigurationUpdate			|
+	mMEConfigurationUpdate			|
+	writeReplaceWarning				,
+	...,
+	uERadioCapabilityMatch						|
+	e-RABModificationIndication					|
+	uEContextModificationIndication				|
+	uEContextSuspend							|
+	uEContextResume
+}
+
+S1AP-ELEMENTARY-PROCEDURES-CLASS-2 S1AP-ELEMENTARY-PROCEDURE ::= {	
+	handoverNotification			|
+	e-RABReleaseIndication			|
+	paging 							|
+	downlinkNASTransport			|
+	initialUEMessage				|
+	uplinkNASTransport				|
+	errorIndication					|
+	nASNonDeliveryIndication		|
+	uEContextReleaseRequest			|
+	downlinkS1cdma2000tunnelling	|
+	uplinkS1cdma2000tunnelling		|
+	uECapabilityInfoIndication		|
+	eNBStatusTransfer				|
+	mMEStatusTransfer				|
+	deactivateTrace					|
+	traceStart						|
+	traceFailureIndication			|
+	cellTrafficTrace				|
+	locationReportingControl		|
+	locationReportingFailureIndication	|
+	locationReport					|
+	overloadStart					|
+	overloadStop					|
+	eNBDirectInformationTransfer	|
+	mMEDirectInformationTransfer	|
+	eNBConfigurationTransfer		|
+	mMEConfigurationTransfer		|
+	privateMessage					,
+	...,
+	downlinkUEAssociatedLPPaTransport	|
+	uplinkUEAssociatedLPPaTransport	|
+	downlinkNonUEAssociatedLPPaTransport	|
+	uplinkNonUEAssociatedLPPaTransport	|
+	pWSRestartIndication			|
+	rerouteNASRequest				|
+	pWSFailureIndication						|
+	connectionEstablishmentIndication	|
+	nASDeliveryIndication			|
+	retrieveUEInformation			|
+	uEInformationTransfer			|
+	eNBCPRelocationIndication					|
+	mMECPRelocationIndication
+}
+
+-- **************************************************************
+--
+-- Interface Elementary Procedures
+--
+-- **************************************************************
+
+handoverPreparation S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		HandoverRequired
+	SUCCESSFUL OUTCOME		HandoverCommand
+	UNSUCCESSFUL OUTCOME	HandoverPreparationFailure
+	PROCEDURE CODE			id-HandoverPreparation
+	CRITICALITY				reject
+}
+
+handoverResourceAllocation S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		HandoverRequest
+	SUCCESSFUL OUTCOME		HandoverRequestAcknowledge
+	UNSUCCESSFUL OUTCOME	HandoverFailure
+	PROCEDURE CODE			id-HandoverResourceAllocation
+	CRITICALITY				reject
+}
+
+handoverNotification S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		HandoverNotify
+	PROCEDURE CODE			id-HandoverNotification
+	CRITICALITY				ignore
+}
+
+pathSwitchRequest S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		PathSwitchRequest
+	SUCCESSFUL OUTCOME		PathSwitchRequestAcknowledge
+	UNSUCCESSFUL OUTCOME	PathSwitchRequestFailure
+	PROCEDURE CODE			id-PathSwitchRequest
+	CRITICALITY				reject
+}
+
+e-RABSetup S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		E-RABSetupRequest
+	SUCCESSFUL OUTCOME		E-RABSetupResponse
+	PROCEDURE CODE			id-E-RABSetup
+	CRITICALITY				reject
+}
+
+e-RABModify S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		E-RABModifyRequest
+	SUCCESSFUL OUTCOME		E-RABModifyResponse
+	PROCEDURE CODE			id-E-RABModify
+	CRITICALITY				reject
+}
+
+e-RABRelease S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		E-RABReleaseCommand
+	SUCCESSFUL OUTCOME		E-RABReleaseResponse
+	PROCEDURE CODE			id-E-RABRelease
+	CRITICALITY				reject
+}
+
+e-RABReleaseIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		E-RABReleaseIndication
+	PROCEDURE CODE			id-E-RABReleaseIndication
+	CRITICALITY				ignore
+}
+
+initialContextSetup S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		InitialContextSetupRequest
+	SUCCESSFUL OUTCOME		InitialContextSetupResponse
+	UNSUCCESSFUL OUTCOME 	InitialContextSetupFailure
+	PROCEDURE CODE			id-InitialContextSetup
+	CRITICALITY				reject
+}
+
+uEContextReleaseRequest S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEContextReleaseRequest
+	PROCEDURE CODE			id-UEContextReleaseRequest
+	CRITICALITY				ignore
+}
+
+paging S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		Paging
+	PROCEDURE CODE			id-Paging
+	CRITICALITY				ignore
+}
+
+downlinkNASTransport S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		DownlinkNASTransport
+	PROCEDURE CODE			id-downlinkNASTransport
+	CRITICALITY				ignore
+}
+
+initialUEMessage S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		InitialUEMessage
+	PROCEDURE CODE			id-initialUEMessage
+	CRITICALITY				ignore
+}
+
+uplinkNASTransport S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UplinkNASTransport
+	PROCEDURE CODE			id-uplinkNASTransport
+	CRITICALITY				ignore
+}
+nASNonDeliveryIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		NASNonDeliveryIndication
+	PROCEDURE CODE			id-NASNonDeliveryIndication
+	CRITICALITY				ignore
+}
+
+handoverCancel S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		HandoverCancel
+	SUCCESSFUL OUTCOME		HandoverCancelAcknowledge
+	PROCEDURE CODE			id-HandoverCancel
+	CRITICALITY				reject
+}
+
+reset S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		Reset
+	SUCCESSFUL OUTCOME		ResetAcknowledge
+	PROCEDURE CODE			id-Reset
+	CRITICALITY				reject
+}
+
+errorIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ErrorIndication
+	PROCEDURE CODE			id-ErrorIndication
+	CRITICALITY				ignore
+}
+
+s1Setup S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		S1SetupRequest
+	SUCCESSFUL OUTCOME		S1SetupResponse
+	UNSUCCESSFUL OUTCOME 	S1SetupFailure
+	PROCEDURE CODE			id-S1Setup
+	CRITICALITY				reject
+}
+
+eNBConfigurationUpdate S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ENBConfigurationUpdate
+	SUCCESSFUL OUTCOME		ENBConfigurationUpdateAcknowledge
+	UNSUCCESSFUL OUTCOME 	ENBConfigurationUpdateFailure
+	PROCEDURE CODE			id-ENBConfigurationUpdate
+	CRITICALITY				reject
+}
+
+mMEConfigurationUpdate S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		MMEConfigurationUpdate
+	SUCCESSFUL OUTCOME		MMEConfigurationUpdateAcknowledge
+	UNSUCCESSFUL OUTCOME 	MMEConfigurationUpdateFailure
+	PROCEDURE CODE			id-MMEConfigurationUpdate
+	CRITICALITY				reject
+}
+
+downlinkS1cdma2000tunnelling S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		DownlinkS1cdma2000tunnelling
+	PROCEDURE CODE			id-DownlinkS1cdma2000tunnelling
+	CRITICALITY				ignore
+}
+
+uplinkS1cdma2000tunnelling S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UplinkS1cdma2000tunnelling
+	PROCEDURE CODE			id-UplinkS1cdma2000tunnelling
+	CRITICALITY				ignore
+}
+
+uEContextModification S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEContextModificationRequest
+	SUCCESSFUL OUTCOME		UEContextModificationResponse
+	UNSUCCESSFUL OUTCOME 	UEContextModificationFailure
+	PROCEDURE CODE			id-UEContextModification
+	CRITICALITY				reject
+}
+
+uECapabilityInfoIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UECapabilityInfoIndication
+	PROCEDURE CODE			id-UECapabilityInfoIndication
+	CRITICALITY				ignore
+}
+
+uEContextRelease S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEContextReleaseCommand
+	SUCCESSFUL OUTCOME		UEContextReleaseComplete
+	PROCEDURE CODE			id-UEContextRelease
+	CRITICALITY				reject
+}
+
+eNBStatusTransfer S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ENBStatusTransfer
+	PROCEDURE CODE			id-eNBStatusTransfer
+	CRITICALITY				ignore
+}
+
+mMEStatusTransfer S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		MMEStatusTransfer
+	PROCEDURE CODE			id-MMEStatusTransfer
+	CRITICALITY				ignore
+}
+
+deactivateTrace S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		DeactivateTrace
+	PROCEDURE CODE			id-DeactivateTrace
+	CRITICALITY				ignore
+}
+
+traceStart S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		TraceStart
+	PROCEDURE CODE			id-TraceStart
+	CRITICALITY				ignore
+}
+
+traceFailureIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		TraceFailureIndication
+	PROCEDURE CODE			id-TraceFailureIndication
+	CRITICALITY				ignore
+}
+cellTrafficTrace S1AP-ELEMENTARY-PROCEDURE ::={
+     INITIATING MESSAGE		CellTrafficTrace
+     PROCEDURE CODE			id-CellTrafficTrace
+     CRITICALITY				ignore
+}
+
+locationReportingControl S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		LocationReportingControl
+	PROCEDURE CODE			id-LocationReportingControl
+	CRITICALITY				ignore
+}
+
+locationReportingFailureIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		LocationReportingFailureIndication
+	PROCEDURE CODE			id-LocationReportingFailureIndication
+	CRITICALITY				ignore
+}
+
+locationReport S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		LocationReport
+	PROCEDURE CODE			id-LocationReport
+	CRITICALITY				ignore
+}
+
+overloadStart S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		OverloadStart
+	PROCEDURE CODE			id-OverloadStart
+	CRITICALITY				ignore
+}
+
+overloadStop S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		OverloadStop
+	PROCEDURE CODE			id-OverloadStop
+	CRITICALITY				reject
+}
+
+writeReplaceWarning S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		WriteReplaceWarningRequest
+	SUCCESSFUL OUTCOME		WriteReplaceWarningResponse
+	PROCEDURE CODE			id-WriteReplaceWarning
+	CRITICALITY				reject
+}
+
+eNBDirectInformationTransfer S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ENBDirectInformationTransfer
+	PROCEDURE CODE			id-eNBDirectInformationTransfer
+	CRITICALITY				ignore
+}
+
+mMEDirectInformationTransfer S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		MMEDirectInformationTransfer
+	PROCEDURE CODE			id-MMEDirectInformationTransfer
+	CRITICALITY				ignore
+}
+
+eNBConfigurationTransfer S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ENBConfigurationTransfer
+	PROCEDURE CODE			id-eNBConfigurationTransfer
+	CRITICALITY				ignore
+}
+
+mMEConfigurationTransfer S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		MMEConfigurationTransfer
+	PROCEDURE CODE			id-MMEConfigurationTransfer
+	CRITICALITY				ignore
+}
+
+
+privateMessage S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		PrivateMessage
+	PROCEDURE CODE			id-PrivateMessage
+	CRITICALITY				ignore
+}
+
+pWSRestartIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		PWSRestartIndication
+	PROCEDURE CODE			id-PWSRestartIndication
+	CRITICALITY				ignore
+}
+
+kill S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		KillRequest
+	SUCCESSFUL OUTCOME		KillResponse
+	PROCEDURE CODE			id-Kill
+	CRITICALITY				reject
+}
+
+downlinkUEAssociatedLPPaTransport S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		DownlinkUEAssociatedLPPaTransport
+	PROCEDURE CODE			id-downlinkUEAssociatedLPPaTransport
+	CRITICALITY				ignore
+}
+
+uplinkUEAssociatedLPPaTransport S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UplinkUEAssociatedLPPaTransport
+	PROCEDURE CODE			id-uplinkUEAssociatedLPPaTransport
+	CRITICALITY				ignore
+}
+downlinkNonUEAssociatedLPPaTransport S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		DownlinkNonUEAssociatedLPPaTransport
+	PROCEDURE CODE			id-downlinkNonUEAssociatedLPPaTransport
+	CRITICALITY				ignore
+}
+
+uplinkNonUEAssociatedLPPaTransport S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UplinkNonUEAssociatedLPPaTransport
+	PROCEDURE CODE			id-uplinkNonUEAssociatedLPPaTransport
+	CRITICALITY				ignore
+}
+
+uERadioCapabilityMatch S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UERadioCapabilityMatchRequest
+	SUCCESSFUL OUTCOME		UERadioCapabilityMatchResponse
+	PROCEDURE CODE			id-UERadioCapabilityMatch
+	CRITICALITY				reject
+}
+
+e-RABModificationIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		E-RABModificationIndication
+	SUCCESSFUL OUTCOME		E-RABModificationConfirm
+	PROCEDURE CODE			id-E-RABModificationIndication
+	CRITICALITY				reject
+}
+
+uEContextModificationIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEContextModificationIndication
+	SUCCESSFUL OUTCOME		UEContextModificationConfirm
+	PROCEDURE CODE			id-UEContextModificationIndication
+	CRITICALITY				reject
+}
+
+rerouteNASRequest S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		RerouteNASRequest
+	PROCEDURE CODE			id-RerouteNASRequest
+	CRITICALITY				reject
+}
+
+pWSFailureIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		PWSFailureIndication
+	PROCEDURE CODE			id-PWSFailureIndication
+	CRITICALITY				ignore
+}
+
+uEContextSuspend S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEContextSuspendRequest
+	SUCCESSFUL OUTCOME		UEContextSuspendResponse
+	PROCEDURE CODE			id-UEContextSuspend
+	CRITICALITY				reject
+}
+
+uEContextResume S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEContextResumeRequest
+	SUCCESSFUL OUTCOME		UEContextResumeResponse
+	UNSUCCESSFUL OUTCOME 	UEContextResumeFailure
+	PROCEDURE CODE			id-UEContextResume
+	CRITICALITY				reject
+}
+
+connectionEstablishmentIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ConnectionEstablishmentIndication
+	PROCEDURE CODE			id-ConnectionEstablishmentIndication
+	CRITICALITY				reject
+}
+
+nASDeliveryIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		NASDeliveryIndication
+	PROCEDURE CODE			id-NASDeliveryIndication
+	CRITICALITY				ignore
+}
+
+retrieveUEInformation S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		RetrieveUEInformation
+	PROCEDURE CODE			id-RetrieveUEInformation
+	CRITICALITY				reject
+}
+
+uEInformationTransfer S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		UEInformationTransfer
+	PROCEDURE CODE			id-UEInformationTransfer
+	CRITICALITY				reject
+}
+
+eNBCPRelocationIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		ENBCPRelocationIndication
+	PROCEDURE CODE			id-eNBCPRelocationIndication
+	CRITICALITY				reject
+}
+
+mMECPRelocationIndication S1AP-ELEMENTARY-PROCEDURE ::= {
+	INITIATING MESSAGE		MMECPRelocationIndication
+	PROCEDURE CODE			id-MMECPRelocationIndication
+	CRITICALITY				reject
+}
+
+
+END
+
+
+
+-- **************************************************************
+--
+-- PDU definitions for S1AP.
+--
+-- **************************************************************
+
+S1AP-PDU-Contents { 
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) s1ap (1) version1 (1) s1ap-PDU-Contents (1) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- IE parameter types from other modules.
+--
+-- **************************************************************
+
+IMPORTS
+	
+	UEAggregateMaximumBitrate,
+	BearerType,
+	Cause,
+	CellAccessMode,
+	Cdma2000HORequiredIndication,
+	Cdma2000HOStatus,
+	Cdma2000OneXSRVCCInfo,
+	Cdma2000OneXRAND,
+	Cdma2000PDU,
+	Cdma2000RATType,
+	Cdma2000SectorID,
+	EUTRANRoundTripDelayEstimationInfo,
+	CNDomain,
+	ConcurrentWarningMessageIndicator,
+	CriticalityDiagnostics,
+	CSFallbackIndicator,
+	CSG-Id,
+	CSG-IdList, 
+	CSGMembershipStatus,
+	Data-Forwarding-Not-Possible,
+	Direct-Forwarding-Path-Availability,
+	Global-ENB-ID,
+	EUTRAN-CGI,
+	ENBname,
+	ENB-StatusTransfer-TransparentContainer,
+	ENB-UE-S1AP-ID,
+	ExtendedRepetitionPeriod,
+	GTP-TEID,
+	GUMMEI,
+	GUMMEIType,
+	HandoverRestrictionList,
+	HandoverType,
+	Masked-IMEISV,
+	LAI,
+	LPPa-PDU,
+	ManagementBasedMDTAllowed,
+	MDTPLMNList,
+	MMEname,
+	MMERelaySupportIndicator,
+	MME-UE-S1AP-ID,
+	MSClassmark2,
+	MSClassmark3,
+	NAS-PDU,
+	NASSecurityParametersfromE-UTRAN,
+	NASSecurityParameterstoE-UTRAN,
+	OverloadResponse,
+	PagingDRX,
+	PagingPriority,
+	PLMNidentity,
+	ProSeAuthorized,
+	RIMTransfer,
+	RelativeMMECapacity,
+	RequestType,
+	E-RAB-ID,
+	E-RABLevelQoSParameters,
+	E-RABList,
+	RelayNode-Indicator,
+	Routing-ID,
+	SecurityKey,
+	SecurityContext,
+	ServedGUMMEIs,
+	SONConfigurationTransfer,
+	Source-ToTarget-TransparentContainer,
+	SourceBSS-ToTargetBSS-TransparentContainer,
+	SourceeNB-ToTargeteNB-TransparentContainer,
+	SourceRNC-ToTargetRNC-TransparentContainer,
+	SubscriberProfileIDforRFP,
+	SRVCCOperationNotPossible,
+	SRVCCOperationPossible,
+	SRVCCHOIndication,
+	SupportedTAs,
+	TAI,
+	Target-ToSource-TransparentContainer,
+	TargetBSS-ToSourceBSS-TransparentContainer,	
+	TargeteNB-ToSourceeNB-TransparentContainer,
+	TargetID,
+	TargetRNC-ToSourceRNC-TransparentContainer,
+	TimeToWait,
+	TraceActivation,
+	TrafficLoadReductionIndication,
+	E-UTRAN-Trace-ID,
+	TransportLayerAddress,
+	UEIdentityIndexValue,
+	UEPagingID,
+	UERadioCapability,
+	UERadioCapabilityForPaging,
+	UE-RetentionInformation,
+	UE-S1AP-IDs,
+	UE-associatedLogicalS1-ConnectionItem,
+	UESecurityCapabilities,
+	S-TMSI,
+	MessageIdentifier,
+	SerialNumber,
+	WarningAreaList,
+	RepetitionPeriod,
+	NumberofBroadcastRequest,
+	WarningType,
+	WarningSecurityInfo,
+	DataCodingScheme,
+	WarningMessageContents,
+	BroadcastCompletedAreaList,
+	RRC-Establishment-Cause,
+	BroadcastCancelledAreaList,
+	PS-ServiceNotAvailable,
+	GUMMEIList,
+	Correlation-ID,
+	GWContextReleaseIndication,
+	PrivacyIndicator,
+	VoiceSupportMatchIndicator,
+	TunnelInformation,
+	KillAllWarningMessages,
+	TransportInformation,
+	LHN-ID,
+	UserLocationInformation,
+	AdditionalCSFallbackIndicator,
+	ECGIListForRestart,
+	TAIListForRestart,
+	EmergencyAreaIDListForRestart,
+	ExpectedUEBehaviour,
+	Paging-eDRXInformation,
+	Extended-UEIdentityIndexValue,
+	MME-Group-ID,
+	Additional-GUTI,
+	PWSfailedECGIList,
+	CellIdentifierAndCELevelForCECapableUEs,
+	AssistanceDataForPaging,
+	InformationOnRecommendedCellsAndENBsForPaging,
+	UE-Usage-Type,
+	UEUserPlaneCIoTSupportIndicator,
+	NB-IoT-DefaultPagingDRX,
+	NB-IoT-Paging-eDRXInformation,
+	CE-mode-B-SupportIndicator,
+	NB-IoT-UEIdentityIndexValue,
+	V2XServicesAuthorized,
+	DCN-ID,
+	ServedDCNs,
+	UESidelinkAggregateMaximumBitrate,
+	DLNASPDUDeliveryAckRequest,
+	Coverage-Level,
+	EnhancedCoverageRestricted,
+	DL-CP-SecurityInformation,
+	UL-CP-SecurityInformation
+
+
+
+FROM S1AP-IEs
+
+	PrivateIE-Container{},
+	ProtocolExtensionContainer{},
+	ProtocolIE-Container{},
+	ProtocolIE-ContainerList{},
+	ProtocolIE-ContainerPair{},
+	ProtocolIE-ContainerPairList{},
+	ProtocolIE-SingleContainer{},
+	S1AP-PRIVATE-IES,
+	S1AP-PROTOCOL-EXTENSION,
+	S1AP-PROTOCOL-IES,
+	S1AP-PROTOCOL-IES-PAIR
+FROM S1AP-Containers
+
+
+	id-AssistanceDataForPaging,
+	id-uEaggregateMaximumBitrate,
+	id-BearerType,
+	id-Cause,
+	id-CellAccessMode,
+	id-CellIdentifierAndCELevelForCECapableUEs,
+	id-cdma2000HORequiredIndication,
+	id-cdma2000HOStatus,
+	id-cdma2000OneXSRVCCInfo,
+	id-cdma2000OneXRAND,
+	id-cdma2000PDU,
+	id-cdma2000RATType,
+	id-cdma2000SectorID,
+	id-EUTRANRoundTripDelayEstimationInfo,
+	id-CNDomain,
+	id-ConcurrentWarningMessageIndicator,
+	id-CriticalityDiagnostics,
+	id-CSFallbackIndicator,
+	id-CSG-Id,
+	id-CSG-IdList,
+	id-CSGMembershipStatus,
+	id-Data-Forwarding-Not-Possible,
+	id-DefaultPagingDRX,
+	id-Direct-Forwarding-Path-Availability,
+	id-Global-ENB-ID,
+	id-EUTRAN-CGI,
+	id-eNBname,
+	id-eNB-StatusTransfer-TransparentContainer,
+	id-eNB-UE-S1AP-ID, 
+	id-GERANtoLTEHOInformationRes,
+	id-GUMMEI-ID,
+	id-GUMMEIType,
+	id-HandoverRestrictionList,
+	id-HandoverType,
+	id-Masked-IMEISV,
+	id-InformationOnRecommendedCellsAndENBsForPaging,
+	id-InitialContextSetup,
+	id-Inter-SystemInformationTransferTypeEDT,
+	id-Inter-SystemInformationTransferTypeMDT,
+	id-LPPa-PDU,
+	id-NAS-DownlinkCount,
+	id-ManagementBasedMDTAllowed,
+	id-ManagementBasedMDTPLMNList,
+	id-MMEname,
+	id-MME-UE-S1AP-ID,
+	id-MSClassmark2,
+	id-MSClassmark3,
+	id-NAS-PDU,
+	id-NASSecurityParametersfromE-UTRAN,
+	id-NASSecurityParameterstoE-UTRAN,
+	id-OverloadResponse,
+	id-pagingDRX,
+	id-PagingPriority,
+	id-RelativeMMECapacity,
+	id-RequestType,
+	id-Routing-ID,
+	id-E-RABAdmittedItem,
+	id-E-RABAdmittedList,
+	id-E-RABDataForwardingItem,
+	id-E-RABFailedToModifyList,
+	id-E-RABFailedToReleaseList,
+	id-E-RABFailedtoSetupItemHOReqAck,
+	id-E-RABFailedToSetupListBearerSURes,
+	id-E-RABFailedToSetupListCtxtSURes,
+	id-E-RABFailedToSetupListHOReqAck,
+	id-E-RABFailedToBeReleasedList,
+	id-E-RABFailedToResumeListResumeReq,
+	id-E-RABFailedToResumeItemResumeReq,
+	id-E-RABFailedToResumeListResumeRes,
+	id-E-RABFailedToResumeItemResumeRes,
+	id-E-RABModify,
+	id-E-RABModifyItemBearerModRes,
+	id-E-RABModifyListBearerModRes,
+	id-E-RABRelease,
+	id-E-RABReleaseItemBearerRelComp,
+	id-E-RABReleaseItemHOCmd,
+	id-E-RABReleaseListBearerRelComp,
+	id-E-RABReleaseIndication,
+	id-E-RABSetup,
+	id-E-RABSetupItemBearerSURes,
+	id-E-RABSetupItemCtxtSURes,
+	id-E-RABSetupListBearerSURes,
+	id-E-RABSetupListCtxtSURes,
+	id-E-RABSubjecttoDataForwardingList,
+	id-E-RABToBeModifiedItemBearerModReq,
+	id-E-RABToBeModifiedListBearerModReq,
+	id-E-RABToBeModifiedListBearerModInd,
+	id-E-RABToBeModifiedItemBearerModInd,
+	id-E-RABNotToBeModifiedListBearerModInd,
+	id-E-RABNotToBeModifiedItemBearerModInd,
+	id-E-RABModifyListBearerModConf,
+	id-E-RABModifyItemBearerModConf,
+	id-E-RABFailedToModifyListBearerModConf, 
+	id-E-RABToBeReleasedListBearerModConf,
+	id-E-RABToBeReleasedList,
+	id-E-RABReleasedList,
+	id-E-RABToBeSetupItemBearerSUReq,
+	id-E-RABToBeSetupItemCtxtSUReq,
+	id-E-RABToBeSetupItemHOReq,
+	id-E-RABToBeSetupListBearerSUReq,
+	id-E-RABToBeSetupListCtxtSUReq,
+	id-E-RABToBeSetupListHOReq,
+	id-E-RABToBeSwitchedDLItem,
+	id-E-RABToBeSwitchedDLList,
+	id-E-RABToBeSwitchedULList,
+	id-E-RABToBeSwitchedULItem,
+	id-E-RABtoReleaseListHOCmd,
+	id-ProSeAuthorized,
+	id-SecurityKey,
+	id-SecurityContext,
+	id-ServedGUMMEIs,
+	id-SONConfigurationTransferECT,
+	id-SONConfigurationTransferMCT,
+	id-Source-ToTarget-TransparentContainer,
+	id-Source-ToTarget-TransparentContainer-Secondary,
+	id-SourceMME-UE-S1AP-ID,
+	id-SRVCCOperationNotPossible,
+	id-SRVCCOperationPossible,
+	id-SRVCCHOIndication,
+	id-SubscriberProfileIDforRFP,
+	id-SupportedTAs,
+	id-S-TMSI,
+	id-TAI,
+	id-TAIItem,
+	id-TAIList,
+	id-Target-ToSource-TransparentContainer,
+	id-Target-ToSource-TransparentContainer-Secondary,
+	id-TargetID,
+	id-TimeToWait,
+	id-TraceActivation,
+	id-TrafficLoadReductionIndication,
+	id-E-UTRAN-Trace-ID,
+	id-UEIdentityIndexValue,
+	id-UEPagingID,
+	id-UERadioCapability,
+	id-UERadioCapabilityForPaging,
+	id-UTRANtoLTEHOInformationRes,
+	id-UE-associatedLogicalS1-ConnectionListResAck,
+	id-UE-associatedLogicalS1-ConnectionItem,
+	id-UE-RetentionInformation,
+	id-UESecurityCapabilities,
+	id-UE-S1AP-IDs,
+	id-V2XServicesAuthorized,
+	id-ResetType,
+	id-MessageIdentifier,
+	id-SerialNumber,
+	id-WarningAreaList,
+	id-RepetitionPeriod,
+	id-NumberofBroadcastRequest,
+	id-WarningType,
+	id-WarningSecurityInfo,
+	id-DataCodingScheme,
+	id-WarningMessageContents,
+	id-BroadcastCompletedAreaList,
+	id-BroadcastCancelledAreaList,
+	id-RRC-Establishment-Cause,
+	id-TraceCollectionEntityIPAddress,
+	maxnoofTAIs,
+	maxnoofErrors,
+	maxnoofE-RABs,
+	maxnoofIndividualS1ConnectionsToReset,
+	maxnoofEmergencyAreaID,
+	maxnoofCellID,
+	maxnoofTAIforWarning,
+	maxnoofCellinTAI,
+	maxnoofCellinEAI,
+	id-ExtendedRepetitionPeriod,
+	id-PS-ServiceNotAvailable,
+	id-RegisteredLAI,
+	id-GUMMEIList,
+	id-SourceMME-GUMMEI,
+	id-MME-UE-S1AP-ID-2,
+	id-GW-TransportLayerAddress,
+	id-RelayNode-Indicator,
+	id-Correlation-ID,
+	id-MMERelaySupportIndicator,
+	id-GWContextReleaseIndication,
+	id-PrivacyIndicator,
+	id-VoiceSupportMatchIndicator,
+	id-Tunnel-Information-for-BBF,
+	id-SIPTO-Correlation-ID,
+	id-SIPTO-L-GW-TransportLayerAddress,
+	id-KillAllWarningMessages,
+	id-TransportInformation,
+	id-LHN-ID,
+	id-UserLocationInformation,
+	id-AdditionalCSFallbackIndicator,
+	id-ECGIListForRestart,
+	id-TAIListForRestart,
+	id-EmergencyAreaIDListForRestart,
+	id-ExpectedUEBehaviour,
+	id-Paging-eDRXInformation,
+	id-extended-UEIdentityIndexValue,
+	id-CSGMembershipInfo,
+	id-MME-Group-ID,
+	id-Additional-GUTI,
+	id-S1-Message,
+	id-PWSfailedECGIList,
+	id-PWSFailureIndication,
+	id-UE-Usage-Type,
+	id-UEUserPlaneCIoTSupportIndicator,
+	id-NB-IoT-DefaultPagingDRX,
+	id-NB-IoT-Paging-eDRXInformation,
+	id-CE-mode-B-SupportIndicator,
+	id-NB-IoT-UEIdentityIndexValue,
+	id-RRC-Resume-Cause,
+	id-DCN-ID,
+	id-ServedDCNs,
+	id-UESidelinkAggregateMaximumBitrate,
+	id-DLNASPDUDeliveryAckRequest,
+	id-Coverage-Level,
+	id-EnhancedCoverageRestricted,
+	id-UE-Level-QoS-Parameters,
+	id-DL-CP-SecurityInformation,
+	id-UL-CP-SecurityInformation
+
+
+FROM S1AP-Constants;
+
+-- **************************************************************
+--
+-- Common Container Lists
+--
+-- **************************************************************
+
+E-RAB-IE-ContainerList			{ S1AP-PROTOCOL-IES      : IEsSetParam }	::= ProtocolIE-ContainerList     { 1, maxnoofE-RABs,   {IEsSetParam} }
+E-RAB-IE-ContainerPairList		{ S1AP-PROTOCOL-IES-PAIR : IEsSetParam }	::= ProtocolIE-ContainerPairList { 1, maxnoofE-RABs,   {IEsSetParam} }
+ProtocolError-IE-ContainerList	{ S1AP-PROTOCOL-IES      : IEsSetParam }	::= ProtocolIE-ContainerList     { 1, maxnoofE-RABs,   {IEsSetParam} }
+
+-- **************************************************************
+--
+-- HANDOVER PREPARATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Handover Required
+--
+-- **************************************************************
+
+HandoverRequired ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container		{ { HandoverRequiredIEs} },
+	...
+}
+
+HandoverRequiredIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID							CRITICALITY reject	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-HandoverType							CRITICALITY reject	TYPE HandoverType						PRESENCE mandatory}|
+	{ ID id-Cause									CRITICALITY ignore	TYPE Cause								PRESENCE mandatory}|
+	{ ID id-TargetID								CRITICALITY reject	TYPE TargetID							PRESENCE mandatory}|
+	{ ID id-Direct-Forwarding-Path-Availability		CRITICALITY ignore	TYPE Direct-Forwarding-Path-Availability		PRESENCE optional}|
+	{ ID id-SRVCCHOIndication						CRITICALITY reject	TYPE SRVCCHOIndication					PRESENCE optional}|
+	{ ID id-Source-ToTarget-TransparentContainer	CRITICALITY reject	TYPE Source-ToTarget-TransparentContainer	PRESENCE mandatory}|
+	{ ID id-Source-ToTarget-TransparentContainer-Secondary	CRITICALITY reject	TYPE Source-ToTarget-TransparentContainer	PRESENCE optional}|
+	{ ID id-MSClassmark2							CRITICALITY reject	TYPE MSClassmark2						PRESENCE conditional}|
+	{ ID id-MSClassmark3							CRITICALITY ignore	TYPE MSClassmark3						PRESENCE conditional}|
+	{ ID id-CSG-Id									CRITICALITY reject	TYPE CSG-Id								PRESENCE optional}|
+	{ ID id-CellAccessMode							CRITICALITY reject	TYPE CellAccessMode						PRESENCE optional}|
+	{ ID id-PS-ServiceNotAvailable					CRITICALITY ignore	TYPE PS-ServiceNotAvailable			PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- Handover Command
+--
+-- **************************************************************
+
+HandoverCommand ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container		{ { HandoverCommandIEs} },
+	...
+}
+
+HandoverCommandIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY reject	TYPE MME-UE-S1AP-ID							PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID							CRITICALITY reject	TYPE ENB-UE-S1AP-ID							PRESENCE mandatory}|
+	{ ID id-HandoverType							CRITICALITY reject	TYPE HandoverType							PRESENCE mandatory}|
+	{ ID id-NASSecurityParametersfromE-UTRAN		CRITICALITY reject	TYPE NASSecurityParametersfromE-UTRAN			PRESENCE conditional
+	-- This IE shall be present if HandoverType IE is set to value "LTEtoUTRAN" or "LTEtoGERAN" --}|
+	{ ID id-E-RABSubjecttoDataForwardingList		CRITICALITY ignore	TYPE E-RABSubjecttoDataForwardingList			PRESENCE optional}|
+	{ ID id-E-RABtoReleaseListHOCmd					CRITICALITY ignore	TYPE E-RABList								PRESENCE optional}|
+	{ ID id-Target-ToSource-TransparentContainer	CRITICALITY reject	TYPE Target-ToSource-TransparentContainer		PRESENCE mandatory}|
+	{ ID id-Target-ToSource-TransparentContainer-Secondary	CRITICALITY reject	TYPE Target-ToSource-TransparentContainer	PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics					CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional},
+	...
+}
+
+E-RABSubjecttoDataForwardingList ::= E-RAB-IE-ContainerList { {E-RABDataForwardingItemIEs} }
+
+E-RABDataForwardingItemIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABDataForwardingItem					CRITICALITY ignore	TYPE E-RABDataForwardingItem			PRESENCE mandatory	},
+	...
+}
+
+E-RABDataForwardingItem ::= SEQUENCE {
+	e-RAB-ID							E-RAB-ID,
+	dL-transportLayerAddress			TransportLayerAddress 													OPTIONAL,
+	dL-gTP-TEID							GTP-TEID 																OPTIONAL,
+	uL-TransportLayerAddress			TransportLayerAddress													OPTIONAL,
+	uL-GTP-TEID							GTP-TEID																OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { { E-RABDataForwardingItem-ExtIEs} }			OPTIONAL,
+	...
+}
+
+E-RABDataForwardingItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- Handover Preparation Failure
+--
+-- **************************************************************
+
+HandoverPreparationFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container		{ { HandoverPreparationFailureIEs} },
+	...
+}
+
+HandoverPreparationFailureIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- HANDOVER RESOURCE ALLOCATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Handover Request
+--
+-- **************************************************************
+
+HandoverRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container		{ {HandoverRequestIEs} },
+	...
+}
+
+HandoverRequestIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-HandoverType							CRITICALITY reject	TYPE HandoverType						PRESENCE mandatory}|
+	{ ID id-Cause									CRITICALITY ignore	TYPE Cause								PRESENCE mandatory}|
+	{ ID id-uEaggregateMaximumBitrate				CRITICALITY reject	TYPE UEAggregateMaximumBitrate			PRESENCE mandatory}|
+	{ ID id-E-RABToBeSetupListHOReq					CRITICALITY reject	TYPE E-RABToBeSetupListHOReq			PRESENCE mandatory}|
+	{ ID id-Source-ToTarget-TransparentContainer	CRITICALITY reject	TYPE Source-ToTarget-TransparentContainer	PRESENCE mandatory}|
+	{ ID id-UESecurityCapabilities					CRITICALITY reject	TYPE UESecurityCapabilities			PRESENCE mandatory}|
+	{ ID id-HandoverRestrictionList					CRITICALITY ignore	TYPE HandoverRestrictionList			PRESENCE optional}|
+	{ ID id-TraceActivation							CRITICALITY ignore	TYPE TraceActivation					PRESENCE optional}|
+	{ ID id-RequestType								CRITICALITY ignore	TYPE RequestType						PRESENCE optional}|
+	{ ID id-SRVCCOperationPossible					CRITICALITY ignore	TYPE SRVCCOperationPossible			PRESENCE optional}|
+	{ ID id-SecurityContext							CRITICALITY reject	TYPE SecurityContext					PRESENCE mandatory}|
+	{ ID id-NASSecurityParameterstoE-UTRAN			CRITICALITY reject	TYPE NASSecurityParameterstoE-UTRAN		PRESENCE conditional
+	-- This IE shall be present if the Handover Type IE is set to the value "UTRANtoLTE" or "GERANtoLTE" --				}|
+	{ ID id-CSG-Id									CRITICALITY reject	TYPE CSG-Id								PRESENCE optional}|
+	{ ID id-CSGMembershipStatus						CRITICALITY ignore	TYPE CSGMembershipStatus				PRESENCE optional}|
+	{ ID id-GUMMEI-ID								CRITICALITY ignore	TYPE GUMMEI								PRESENCE optional}|
+	{ ID id-MME-UE-S1AP-ID-2						CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE optional}|
+	{ ID id-ManagementBasedMDTAllowed				CRITICALITY ignore	TYPE ManagementBasedMDTAllowed			PRESENCE optional}|
+	{ ID id-ManagementBasedMDTPLMNList				CRITICALITY ignore	TYPE MDTPLMNList						PRESENCE optional}|
+	{ ID id-Masked-IMEISV							CRITICALITY ignore	TYPE Masked-IMEISV						PRESENCE optional}|
+	{ ID id-ExpectedUEBehaviour						CRITICALITY ignore	TYPE ExpectedUEBehaviour				PRESENCE optional}|
+	{ ID id-ProSeAuthorized							CRITICALITY ignore	TYPE ProSeAuthorized					PRESENCE optional}|
+	{ ID id-UEUserPlaneCIoTSupportIndicator			CRITICALITY ignore	TYPE UEUserPlaneCIoTSupportIndicator 		PRESENCE optional}|
+	{ ID id-V2XServicesAuthorized					CRITICALITY ignore	TYPE V2XServicesAuthorized			PRESENCE optional}|
+	{ ID id-UESidelinkAggregateMaximumBitrate		CRITICALITY ignore	TYPE UESidelinkAggregateMaximumBitrate		PRESENCE optional}|
+	{ ID id-EnhancedCoverageRestricted				CRITICALITY ignore	TYPE EnhancedCoverageRestricted			PRESENCE optional},
+	...
+}
+
+E-RABToBeSetupListHOReq 					::= E-RAB-IE-ContainerList { {E-RABToBeSetupItemHOReqIEs} }
+
+E-RABToBeSetupItemHOReqIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABToBeSetupItemHOReq				CRITICALITY reject	TYPE E-RABToBeSetupItemHOReq			PRESENCE mandatory	},
+	...
+}
+
+E-RABToBeSetupItemHOReq ::= SEQUENCE {
+	e-RAB-ID							E-RAB-ID,
+	transportLayerAddress				TransportLayerAddress,
+	gTP-TEID							GTP-TEID,
+	e-RABlevelQosParameters				E-RABLevelQoSParameters,
+	iE-Extensions						ProtocolExtensionContainer { {E-RABToBeSetupItemHOReq-ExtIEs} }		OPTIONAL,
+	...
+}
+
+E-RABToBeSetupItemHOReq-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-Data-Forwarding-Not-Possible		CRITICALITY ignore	EXTENSION Data-Forwarding-Not-Possible	PRESENCE optional}|
+	{ ID id-BearerType							CRITICALITY reject	EXTENSION BearerType					PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- Handover Request Acknowledge
+--
+-- **************************************************************
+
+HandoverRequestAcknowledge ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {HandoverRequestAcknowledgeIEs} },
+	...
+}
+
+HandoverRequestAcknowledgeIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID							CRITICALITY ignore	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-E-RABAdmittedList						CRITICALITY ignore	TYPE E-RABAdmittedList					PRESENCE mandatory}|
+	{ ID id-E-RABFailedToSetupListHOReqAck			CRITICALITY ignore	TYPE E-RABFailedtoSetupListHOReqAck		PRESENCE optional}|
+	{ ID id-Target-ToSource-TransparentContainer	CRITICALITY reject	TYPE Target-ToSource-TransparentContainer	PRESENCE mandatory}|
+	{ ID id-CSG-Id									CRITICALITY ignore	TYPE CSG-Id								PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics					CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional}|
+	{ ID id-CellAccessMode							CRITICALITY ignore	TYPE CellAccessMode						PRESENCE optional}|
+	{ ID id-CE-mode-B-SupportIndicator				CRITICALITY ignore	TYPE CE-mode-B-SupportIndicator			PRESENCE optional},
+	...
+}
+
+E-RABAdmittedList 					::= E-RAB-IE-ContainerList { {E-RABAdmittedItemIEs} }
+
+E-RABAdmittedItemIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABAdmittedItem			CRITICALITY ignore	TYPE E-RABAdmittedItem			PRESENCE mandatory	},
+	...
+}
+
+E-RABAdmittedItem ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	transportLayerAddress			TransportLayerAddress,
+	gTP-TEID						GTP-TEID,
+	dL-transportLayerAddress		TransportLayerAddress	OPTIONAL,
+	dL-gTP-TEID						GTP-TEID				OPTIONAL,
+	uL-TransportLayerAddress		TransportLayerAddress	OPTIONAL,
+	uL-GTP-TEID						GTP-TEID				OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABAdmittedItem-ExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABAdmittedItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABFailedtoSetupListHOReqAck 					::= E-RAB-IE-ContainerList { {E-RABFailedtoSetupItemHOReqAckIEs} }
+
+E-RABFailedtoSetupItemHOReqAckIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABFailedtoSetupItemHOReqAck			CRITICALITY ignore	TYPE E-RABFailedToSetupItemHOReqAck			PRESENCE mandatory	},
+	...
+}
+
+E-RABFailedToSetupItemHOReqAck ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	cause				Cause,
+	iE-Extensions					ProtocolExtensionContainer { { E-RABFailedToSetupItemHOReqAckExtIEs} }			OPTIONAL,
+	...
+}
+
+E-RABFailedToSetupItemHOReqAckExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- **************************************************************
+--
+-- Handover Failure
+--
+-- **************************************************************
+
+HandoverFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { HandoverFailureIEs} },
+	...
+}
+
+HandoverFailureIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- HANDOVER NOTIFICATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Handover Notify
+--
+-- **************************************************************
+
+HandoverNotify ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { HandoverNotifyIEs} },
+	...
+}
+
+HandoverNotifyIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID			PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID			PRESENCE mandatory}|
+	{ ID id-EUTRAN-CGI						CRITICALITY ignore	TYPE EUTRAN-CGI				PRESENCE mandatory}|
+	{ ID id-TAI								CRITICALITY ignore	TYPE TAI					PRESENCE mandatory}|
+-- Extension for Release 11 to support BBAI -- 
+	{ ID id-Tunnel-Information-for-BBF		CRITICALITY ignore	TYPE TunnelInformation		PRESENCE optional}|
+	{ ID id-LHN-ID							CRITICALITY ignore	TYPE LHN-ID					PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- PATH SWITCH REQUEST ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Path Switch Request
+--
+-- **************************************************************
+
+PathSwitchRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { PathSwitchRequestIEs} },
+	...
+}
+
+PathSwitchRequestIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-E-RABToBeSwitchedDLList			CRITICALITY reject	TYPE E-RABToBeSwitchedDLList	PRESENCE mandatory}|
+	{ ID id-SourceMME-UE-S1AP-ID			CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-EUTRAN-CGI						CRITICALITY ignore	TYPE EUTRAN-CGI					PRESENCE mandatory}|
+	{ ID id-TAI								CRITICALITY ignore	TYPE TAI						PRESENCE mandatory}|
+	{ ID id-UESecurityCapabilities			CRITICALITY ignore	TYPE UESecurityCapabilities		PRESENCE mandatory}|
+	{ ID id-CSG-Id							CRITICALITY ignore	TYPE CSG-Id						PRESENCE optional}|
+	{ ID id-CellAccessMode					CRITICALITY ignore	TYPE CellAccessMode				PRESENCE optional}|
+	{ ID id-SourceMME-GUMMEI				CRITICALITY ignore	TYPE GUMMEI						PRESENCE optional}|
+	{ ID id-CSGMembershipStatus				CRITICALITY ignore	TYPE CSGMembershipStatus		PRESENCE optional}|
+-- Extension for Release 11 to support BBAI -- 
+	{ ID id-Tunnel-Information-for-BBF		CRITICALITY ignore	TYPE TunnelInformation			PRESENCE optional}|
+	{ ID id-LHN-ID							CRITICALITY ignore	TYPE LHN-ID						PRESENCE optional}|
+	{ ID id-RRC-Resume-Cause				CRITICALITY ignore	TYPE RRC-Establishment-Cause	PRESENCE optional },
+	...
+}
+
+E-RABToBeSwitchedDLList					::= E-RAB-IE-ContainerList { {E-RABToBeSwitchedDLItemIEs} }
+
+E-RABToBeSwitchedDLItemIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABToBeSwitchedDLItem			CRITICALITY reject	TYPE E-RABToBeSwitchedDLItem			PRESENCE mandatory	},
+	...
+}
+
+E-RABToBeSwitchedDLItem ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	transportLayerAddress			TransportLayerAddress,
+	gTP-TEID						GTP-TEID,
+	iE-Extensions					ProtocolExtensionContainer { { E-RABToBeSwitchedDLItem-ExtIEs} }			OPTIONAL,
+	...
+}
+
+E-RABToBeSwitchedDLItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- Path Switch Request Acknowledge
+--
+-- **************************************************************
+
+PathSwitchRequestAcknowledge ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { PathSwitchRequestAcknowledgeIEs} },
+	...
+}
+
+PathSwitchRequestAcknowledgeIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY ignore	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-uEaggregateMaximumBitrate		CRITICALITY ignore	TYPE UEAggregateMaximumBitrate			PRESENCE optional}|
+	{ ID id-E-RABToBeSwitchedULList			CRITICALITY ignore	TYPE E-RABToBeSwitchedULList			PRESENCE optional}|
+	{ ID id-E-RABToBeReleasedList			CRITICALITY ignore	TYPE E-RABList							PRESENCE optional}|
+	{ ID id-SecurityContext					CRITICALITY reject	TYPE SecurityContext					PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional}|
+	{ ID id-MME-UE-S1AP-ID-2				CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE optional}|
+	{ ID id-CSGMembershipStatus				CRITICALITY ignore	TYPE CSGMembershipStatus				PRESENCE optional}|
+	{ ID id-ProSeAuthorized					CRITICALITY ignore	TYPE ProSeAuthorized					PRESENCE optional}|
+	{ ID id-UEUserPlaneCIoTSupportIndicator	CRITICALITY ignore	TYPE UEUserPlaneCIoTSupportIndicator	PRESENCE optional}|
+	{ ID id-V2XServicesAuthorized			CRITICALITY ignore	TYPE V2XServicesAuthorized				PRESENCE optional}|
+	{ ID id-UESidelinkAggregateMaximumBitrate		CRITICALITY ignore	TYPE UESidelinkAggregateMaximumBitrate	PRESENCE optional}|
+	{ ID id-EnhancedCoverageRestricted		CRITICALITY ignore	TYPE EnhancedCoverageRestricted			PRESENCE optional},
+	...
+}
+
+E-RABToBeSwitchedULList ::= E-RAB-IE-ContainerList { {E-RABToBeSwitchedULItemIEs} }
+
+E-RABToBeSwitchedULItemIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABToBeSwitchedULItem		CRITICALITY ignore	TYPE E-RABToBeSwitchedULItem		PRESENCE mandatory	},
+	...
+}
+
+E-RABToBeSwitchedULItem ::= SEQUENCE {
+	e-RAB-ID							E-RAB-ID,
+	transportLayerAddress				TransportLayerAddress,
+	gTP-TEID							GTP-TEID,
+	iE-Extensions						ProtocolExtensionContainer { { E-RABToBeSwitchedULItem-ExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABToBeSwitchedULItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- **************************************************************
+--
+-- Path Switch Request Failure
+--
+-- **************************************************************
+
+PathSwitchRequestFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { PathSwitchRequestFailureIEs} },
+	...
+}
+
+PathSwitchRequestFailureIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- HANDOVER CANCEL ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Handover Cancel
+--
+-- **************************************************************
+
+HandoverCancel ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { HandoverCancelIEs} },
+	...
+}
+
+HandoverCancelIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-Cause							CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- Handover Cancel Request Acknowledge
+--
+-- **************************************************************
+
+HandoverCancelAcknowledge ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { HandoverCancelAcknowledgeIEs} },
+	...
+}
+
+HandoverCancelAcknowledgeIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- E-RAB SETUP ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- E-RAB Setup Request
+--
+-- **************************************************************
+
+E-RABSetupRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {E-RABSetupRequestIEs} },
+	...
+}
+
+E-RABSetupRequestIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-uEaggregateMaximumBitrate		CRITICALITY reject	TYPE UEAggregateMaximumBitrate			PRESENCE optional	}|
+	{ ID id-E-RABToBeSetupListBearerSUReq	CRITICALITY reject	TYPE E-RABToBeSetupListBearerSUReq	PRESENCE mandatory	},
+	...
+}
+
+E-RABToBeSetupListBearerSUReq ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABToBeSetupItemBearerSUReqIEs} }
+
+E-RABToBeSetupItemBearerSUReqIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABToBeSetupItemBearerSUReq	 CRITICALITY reject 	TYPE E-RABToBeSetupItemBearerSUReq 	PRESENCE mandatory },
+	...
+}
+
+E-RABToBeSetupItemBearerSUReq ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RABlevelQoSParameters			E-RABLevelQoSParameters,
+	transportLayerAddress			TransportLayerAddress,
+	gTP-TEID						GTP-TEID,
+	nAS-PDU							NAS-PDU,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABToBeSetupItemBearerSUReqExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABToBeSetupItemBearerSUReqExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-Correlation-ID			CRITICALITY ignore	EXTENSION Correlation-ID		PRESENCE optional}|
+	{ ID id-SIPTO-Correlation-ID	CRITICALITY ignore	EXTENSION Correlation-ID		PRESENCE optional}|
+	{ ID id-BearerType				CRITICALITY reject	EXTENSION BearerType			PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- E-RAB Setup Response
+--
+-- **************************************************************
+
+E-RABSetupResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {E-RABSetupResponseIEs} },
+	...
+}
+
+E-RABSetupResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY ignore	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID							CRITICALITY ignore	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-E-RABSetupListBearerSURes				CRITICALITY ignore	TYPE E-RABSetupListBearerSURes	PRESENCE optional	}|
+	{ ID id-E-RABFailedToSetupListBearerSURes		CRITICALITY ignore	TYPE E-RABList					PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics					CRITICALITY ignore	TYPE CriticalityDiagnostics	PRESENCE optional	},
+	...
+}
+
+
+E-RABSetupListBearerSURes ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABSetupItemBearerSUResIEs} }
+
+E-RABSetupItemBearerSUResIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABSetupItemBearerSURes	 CRITICALITY ignore 	TYPE E-RABSetupItemBearerSURes 	PRESENCE mandatory },
+	...
+}
+
+E-RABSetupItemBearerSURes ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	transportLayerAddress		TransportLayerAddress,
+	gTP-TEID					GTP-TEID,
+	iE-Extensions				ProtocolExtensionContainer { {E-RABSetupItemBearerSUResExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABSetupItemBearerSUResExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- E-RAB MODIFY ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- E-RAB Modify Request
+--
+-- **************************************************************
+
+E-RABModifyRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {E-RABModifyRequestIEs} },
+	...
+}
+
+E-RABModifyRequestIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID						CRITICALITY reject	TYPE MME-UE-S1AP-ID							PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID						CRITICALITY reject	TYPE ENB-UE-S1AP-ID							PRESENCE mandatory	}|
+	{ ID id-uEaggregateMaximumBitrate			CRITICALITY reject	TYPE UEAggregateMaximumBitrate			PRESENCE optional	}|
+	{ ID id-E-RABToBeModifiedListBearerModReq	CRITICALITY reject	TYPE E-RABToBeModifiedListBearerModReq		PRESENCE mandatory	},
+	...
+}
+
+E-RABToBeModifiedListBearerModReq ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABToBeModifiedItemBearerModReqIEs} }
+
+E-RABToBeModifiedItemBearerModReqIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABToBeModifiedItemBearerModReq	 CRITICALITY reject 	TYPE E-RABToBeModifiedItemBearerModReq 	PRESENCE mandatory },
+	...
+}
+
+E-RABToBeModifiedItemBearerModReq ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RABLevelQoSParameters			E-RABLevelQoSParameters,
+	nAS-PDU							NAS-PDU,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABToBeModifyItemBearerModReqExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABToBeModifyItemBearerModReqExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-TransportInformation	CRITICALITY reject	EXTENSION TransportInformation		PRESENCE optional},
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- E-RAB Modify Response
+--
+-- **************************************************************
+
+E-RABModifyResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {E-RABModifyResponseIEs} },
+	...
+}
+
+E-RABModifyResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY ignore	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-E-RABModifyListBearerModRes		CRITICALITY ignore	TYPE E-RABModifyListBearerModRes		PRESENCE optional	}|
+	{ ID id-E-RABFailedToModifyList			CRITICALITY ignore	TYPE E-RABList							PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional	},
+	...
+}
+
+
+E-RABModifyListBearerModRes ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABModifyItemBearerModResIEs} }
+
+E-RABModifyItemBearerModResIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABModifyItemBearerModRes		CRITICALITY ignore	TYPE E-RABModifyItemBearerModRes		PRESENCE mandatory},
+	...
+}
+
+E-RABModifyItemBearerModRes ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	iE-Extensions				ProtocolExtensionContainer { {E-RABModifyItemBearerModResExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABModifyItemBearerModResExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+
+
+-- **************************************************************
+--
+-- E-RAB RELEASE ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- E-RAB Release Command
+--
+-- **************************************************************
+
+E-RABReleaseCommand ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container		{ {E-RABReleaseCommandIEs} },
+	...
+}
+
+E-RABReleaseCommandIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-uEaggregateMaximumBitrate		CRITICALITY reject	TYPE UEAggregateMaximumBitrate		PRESENCE optional	}|
+	{ ID id-E-RABToBeReleasedList			CRITICALITY ignore	TYPE E-RABList						PRESENCE mandatory	}|
+	{ ID id-NAS-PDU							CRITICALITY ignore	TYPE NAS-PDU						PRESENCE optional	},
+	...
+}
+
+
+-- **************************************************************
+--
+-- E-RAB Release Response
+--
+-- **************************************************************
+
+E-RABReleaseResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { E-RABReleaseResponseIEs } },
+	...
+}
+
+E-RABReleaseResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY ignore	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-E-RABReleaseListBearerRelComp	CRITICALITY ignore	TYPE E-RABReleaseListBearerRelComp	PRESENCE optional	}|
+	{ ID id-E-RABFailedToReleaseList		CRITICALITY ignore	TYPE E-RABList							PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional	}|
+-- Extension for Release 12 to support User Location Information -- 
+	{ ID id-UserLocationInformation			CRITICALITY ignore	TYPE UserLocationInformation			PRESENCE optional	},
+	...
+}
+
+
+E-RABReleaseListBearerRelComp ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABReleaseItemBearerRelCompIEs} }
+
+E-RABReleaseItemBearerRelCompIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABReleaseItemBearerRelComp	CRITICALITY ignore	TYPE E-RABReleaseItemBearerRelComp	PRESENCE mandatory },
+	...
+}
+
+E-RABReleaseItemBearerRelComp ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABReleaseItemBearerRelCompExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABReleaseItemBearerRelCompExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+
+-- **************************************************************
+--
+-- E-RAB RELEASE INDICATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- E-RAB Release Indication
+--
+-- **************************************************************
+
+E-RABReleaseIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {E-RABReleaseIndicationIEs} },
+	...
+}
+
+E-RABReleaseIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-E-RABReleasedList				CRITICALITY ignore	TYPE E-RABList						PRESENCE mandatory	}|
+-- Extension for Release 12 to support User Location Information -- 
+	{ ID id-UserLocationInformation			CRITICALITY ignore	TYPE UserLocationInformation		PRESENCE optional	},
+	...
+}
+-- **************************************************************
+--
+-- INITIAL CONTEXT SETUP ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Initial Context Setup Request
+--
+-- **************************************************************
+
+InitialContextSetupRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {InitialContextSetupRequestIEs} },
+	...
+}
+
+InitialContextSetupRequestIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-uEaggregateMaximumBitrate		CRITICALITY reject	TYPE UEAggregateMaximumBitrate			PRESENCE mandatory}|
+	{ ID id-E-RABToBeSetupListCtxtSUReq		CRITICALITY reject	TYPE E-RABToBeSetupListCtxtSUReq		PRESENCE mandatory}|
+	{ ID id-UESecurityCapabilities			CRITICALITY reject	TYPE UESecurityCapabilities				PRESENCE mandatory}|
+	{ ID id-SecurityKey						CRITICALITY reject	TYPE SecurityKey						PRESENCE mandatory}|
+	{ ID id-TraceActivation					CRITICALITY ignore	TYPE TraceActivation					PRESENCE optional}|
+	{ ID id-HandoverRestrictionList			CRITICALITY ignore	TYPE HandoverRestrictionList			PRESENCE optional}|
+	{ ID id-UERadioCapability				CRITICALITY ignore	TYPE UERadioCapability					PRESENCE optional}|
+	{ ID id-SubscriberProfileIDforRFP		CRITICALITY ignore	TYPE SubscriberProfileIDforRFP			PRESENCE optional}|
+	{ ID id-CSFallbackIndicator				CRITICALITY reject	TYPE CSFallbackIndicator				PRESENCE optional}|
+	{ ID id-SRVCCOperationPossible			CRITICALITY ignore	TYPE SRVCCOperationPossible				PRESENCE optional}|
+	{ ID id-CSGMembershipStatus				CRITICALITY ignore	TYPE CSGMembershipStatus				PRESENCE optional}|
+	{ ID id-RegisteredLAI					CRITICALITY ignore	TYPE LAI								PRESENCE optional}|
+	{ ID id-GUMMEI-ID						CRITICALITY ignore	TYPE GUMMEI								PRESENCE optional}|
+	{ ID id-MME-UE-S1AP-ID-2				CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE optional}|
+	{ ID id-ManagementBasedMDTAllowed		CRITICALITY ignore	TYPE ManagementBasedMDTAllowed			PRESENCE optional}|
+	{ ID id-ManagementBasedMDTPLMNList		CRITICALITY ignore	TYPE MDTPLMNList						PRESENCE optional}|
+	{ ID id-AdditionalCSFallbackIndicator	CRITICALITY ignore	TYPE AdditionalCSFallbackIndicator	PRESENCE conditional}|
+	{ ID id-Masked-IMEISV					CRITICALITY ignore	TYPE Masked-IMEISV						PRESENCE optional}|
+	{ ID id-ExpectedUEBehaviour				CRITICALITY ignore	TYPE ExpectedUEBehaviour				PRESENCE optional}|
+	{ ID id-ProSeAuthorized					CRITICALITY ignore	TYPE ProSeAuthorized					PRESENCE optional}|
+	{ ID id-UEUserPlaneCIoTSupportIndicator	CRITICALITY ignore	TYPE UEUserPlaneCIoTSupportIndicator	PRESENCE optional}|
+	{ ID id-V2XServicesAuthorized			CRITICALITY ignore	TYPE V2XServicesAuthorized				PRESENCE optional}|
+	{ ID id-UESidelinkAggregateMaximumBitrate		CRITICALITY ignore	TYPE UESidelinkAggregateMaximumBitrate	PRESENCE optional}|
+	{ ID id-EnhancedCoverageRestricted		CRITICALITY ignore	TYPE EnhancedCoverageRestricted			PRESENCE optional},
+	...
+}
+
+
+
+
+E-RABToBeSetupListCtxtSUReq ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABToBeSetupItemCtxtSUReqIEs} }
+
+E-RABToBeSetupItemCtxtSUReqIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABToBeSetupItemCtxtSUReq	CRITICALITY reject	TYPE E-RABToBeSetupItemCtxtSUReq		PRESENCE mandatory	},
+	...
+}
+
+E-RABToBeSetupItemCtxtSUReq ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	e-RABlevelQoSParameters			E-RABLevelQoSParameters,
+	transportLayerAddress			TransportLayerAddress,
+	gTP-TEID						GTP-TEID,
+	nAS-PDU							NAS-PDU		OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABToBeSetupItemCtxtSUReqExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABToBeSetupItemCtxtSUReqExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-Correlation-ID					CRITICALITY ignore	EXTENSION Correlation-ID			PRESENCE optional}|
+	{ ID id-SIPTO-Correlation-ID			CRITICALITY ignore	EXTENSION Correlation-ID			PRESENCE optional}|
+	{ ID id-BearerType						CRITICALITY reject	EXTENSION BearerType				PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- Initial Context Setup Response
+--
+-- **************************************************************
+
+InitialContextSetupResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {InitialContextSetupResponseIEs} },
+	...
+}
+
+InitialContextSetupResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID						CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID						CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-E-RABSetupListCtxtSURes				CRITICALITY ignore	TYPE E-RABSetupListCtxtSURes		PRESENCE mandatory	}|
+	{ ID id-E-RABFailedToSetupListCtxtSURes		CRITICALITY ignore	TYPE E-RABList						PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+
+E-RABSetupListCtxtSURes ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABSetupItemCtxtSUResIEs} }
+
+E-RABSetupItemCtxtSUResIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABSetupItemCtxtSURes		CRITICALITY ignore	TYPE E-RABSetupItemCtxtSURes	PRESENCE mandatory	},
+	...
+}
+
+E-RABSetupItemCtxtSURes ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	transportLayerAddress 			TransportLayerAddress,
+	gTP-TEID						GTP-TEID,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABSetupItemCtxtSUResExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABSetupItemCtxtSUResExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- **************************************************************
+--
+-- Initial Context Setup Failure
+--
+-- **************************************************************
+
+InitialContextSetupFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {InitialContextSetupFailureIEs} },
+	...
+}
+
+InitialContextSetupFailureIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- PAGING ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+
+-- **************************************************************
+--
+-- Paging
+--
+-- **************************************************************
+
+Paging ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{PagingIEs}},
+	...
+}
+
+PagingIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-UEIdentityIndexValue			CRITICALITY ignore	TYPE UEIdentityIndexValue				PRESENCE mandatory}|
+	{ ID id-UEPagingID						CRITICALITY ignore	TYPE UEPagingID							PRESENCE mandatory}|
+	{ ID id-pagingDRX						CRITICALITY ignore	TYPE PagingDRX							PRESENCE optional}|
+	{ ID id-CNDomain						CRITICALITY ignore	TYPE CNDomain							PRESENCE mandatory}|
+	{ ID id-TAIList							CRITICALITY ignore	TYPE TAIList							PRESENCE mandatory}|
+	{ ID id-CSG-IdList						CRITICALITY ignore	TYPE CSG-IdList							PRESENCE optional}|
+	{ ID id-PagingPriority					CRITICALITY ignore	TYPE PagingPriority						PRESENCE optional}|
+	{ ID id-UERadioCapabilityForPaging		CRITICALITY ignore	TYPE UERadioCapabilityForPaging			PRESENCE optional}|
+-- Extension for Release 13 to support Paging Optimisation and Coverage Enhancement paging –-
+	{ ID id-AssistanceDataForPaging			CRITICALITY ignore	TYPE AssistanceDataForPaging			PRESENCE optional}|
+	{ ID id-Paging-eDRXInformation			CRITICALITY ignore	TYPE Paging-eDRXInformation				PRESENCE optional}|
+	{ ID id-extended-UEIdentityIndexValue	CRITICALITY ignore	TYPE Extended-UEIdentityIndexValue	PRESENCE optional}|
+	{ ID id-NB-IoT-Paging-eDRXInformation	CRITICALITY ignore	TYPE NB-IoT-Paging-eDRXInformation	PRESENCE optional}|
+	{ ID id-NB-IoT-UEIdentityIndexValue		CRITICALITY ignore	TYPE NB-IoT-UEIdentityIndexValue		PRESENCE optional},
+	...
+}
+
+TAIList::= SEQUENCE (SIZE(1.. maxnoofTAIs)) OF ProtocolIE-SingleContainer {{TAIItemIEs}}
+
+TAIItemIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-TAIItem	 CRITICALITY ignore		TYPE TAIItem	PRESENCE mandatory },
+	...
+}
+
+TAIItem ::= SEQUENCE {
+	tAI 							TAI,
+	iE-Extensions					ProtocolExtensionContainer { {TAIItemExtIEs} } OPTIONAL,
+	...
+}
+
+
+TAIItemExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- UE CONTEXT RELEASE ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- UE Context Release Request
+--
+-- **************************************************************
+
+UEContextReleaseRequest ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{UEContextReleaseRequest-IEs}},
+	...
+}
+
+UEContextReleaseRequest-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	}|
+	{ ID id-GWContextReleaseIndication	CRITICALITY reject	TYPE GWContextReleaseIndication		PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- UE Context Release Command
+--
+-- **************************************************************
+
+UEContextReleaseCommand ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{UEContextReleaseCommand-IEs}},
+	...
+}
+
+UEContextReleaseCommand-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-UE-S1AP-IDs					CRITICALITY reject	TYPE UE-S1AP-IDs					PRESENCE mandatory	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- UE Context Release Complete
+--
+-- **************************************************************
+
+UEContextReleaseComplete ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{UEContextReleaseComplete-IEs}},
+	...
+}
+
+UEContextReleaseComplete-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID								CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID								CRITICALITY ignore	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics						CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional}|
+-- Extension for Release 12 to support User Location Information -- 
+	{ ID id-UserLocationInformation						CRITICALITY ignore	TYPE UserLocationInformation				PRESENCE optional}|
+-- Extension for Release 13 to support Paging Optimisation
+	{ ID id-InformationOnRecommendedCellsAndENBsForPaging	CRITICALITY ignore	TYPE InformationOnRecommendedCellsAndENBsForPaging		PRESENCE optional}|
+-- Extension for Release 13 to support coverage enhancement paging –
+	{ ID id-CellIdentifierAndCELevelForCECapableUEs		CRITICALITY ignore	TYPE CellIdentifierAndCELevelForCECapableUEs	PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- UE CONTEXT MODIFICATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- UE Context Modification Request
+--
+-- **************************************************************
+
+UEContextModificationRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextModificationRequestIEs} },
+	...
+}
+
+UEContextModificationRequestIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-SecurityKey						CRITICALITY reject	TYPE SecurityKey						PRESENCE optional}|
+	{ ID id-SubscriberProfileIDforRFP		CRITICALITY ignore	TYPE SubscriberProfileIDforRFP			PRESENCE optional}|
+	{ ID id-uEaggregateMaximumBitrate		CRITICALITY ignore	TYPE UEAggregateMaximumBitrate			PRESENCE optional}|
+	{ ID id-CSFallbackIndicator				CRITICALITY reject	TYPE CSFallbackIndicator				PRESENCE optional}|
+	{ ID id-UESecurityCapabilities			CRITICALITY reject	TYPE UESecurityCapabilities				PRESENCE optional}|
+	{ ID id-CSGMembershipStatus				CRITICALITY ignore	TYPE CSGMembershipStatus				PRESENCE optional}|
+	{ ID id-RegisteredLAI					CRITICALITY ignore	TYPE LAI								PRESENCE optional}|
+	{ ID id-AdditionalCSFallbackIndicator	CRITICALITY ignore	TYPE AdditionalCSFallbackIndicator	PRESENCE conditional}|
+	{ ID id-ProSeAuthorized					CRITICALITY ignore	TYPE ProSeAuthorized					PRESENCE optional}|
+	{ ID id-SRVCCOperationPossible			CRITICALITY ignore	TYPE SRVCCOperationPossible				PRESENCE optional}|
+	{ ID id-SRVCCOperationNotPossible		CRITICALITY ignore	TYPE SRVCCOperationNotPossible			PRESENCE optional}|
+	{ ID id-V2XServicesAuthorized			CRITICALITY ignore	TYPE V2XServicesAuthorized				PRESENCE optional}|
+	{ ID id-UESidelinkAggregateMaximumBitrate		CRITICALITY ignore	TYPE UESidelinkAggregateMaximumBitrate	PRESENCE optional},
+	...
+}
+-- **************************************************************
+--
+-- UE Context Modification Response
+--
+-- **************************************************************
+
+UEContextModificationResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextModificationResponseIEs} },
+	...
+}
+
+UEContextModificationResponseIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+-- **************************************************************
+--
+-- UE Context Modification Failure
+--
+-- **************************************************************
+
+UEContextModificationFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextModificationFailureIEs} },
+	...
+}
+
+UEContextModificationFailureIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause							PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- UE RADIO CAPABILITY MATCH ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- UE Radio Capability Match Request
+--
+-- **************************************************************
+
+UERadioCapabilityMatchRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UERadioCapabilityMatchRequestIEs} },
+	...
+}
+
+UERadioCapabilityMatchRequestIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-UERadioCapability			CRITICALITY ignore	TYPE UERadioCapability				PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- UE Radio Capability Match Response
+--
+-- **************************************************************
+
+UERadioCapabilityMatchResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UERadioCapabilityMatchResponseIEs} },
+	...
+}
+
+UERadioCapabilityMatchResponseIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory	}|
+	{ ID id-VoiceSupportMatchIndicator	CRITICALITY reject	TYPE VoiceSupportMatchIndicator		PRESENCE mandatory	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- NAS TRANSPORT ELEMENTARY PROCEDURES
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- DOWNLINK NAS TRANSPORT
+--
+-- **************************************************************
+
+DownlinkNASTransport ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{DownlinkNASTransport-IEs}},
+	...
+}
+
+DownlinkNASTransport-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-NAS-PDU						CRITICALITY reject	TYPE NAS-PDU						PRESENCE mandatory}|
+	{ ID id-HandoverRestrictionList		CRITICALITY ignore	TYPE HandoverRestrictionList		PRESENCE optional}|
+	{ ID id-SubscriberProfileIDforRFP	CRITICALITY ignore	TYPE SubscriberProfileIDforRFP		PRESENCE optional}|
+	{ ID id-SRVCCOperationPossible		CRITICALITY ignore	TYPE SRVCCOperationPossible			PRESENCE optional}|
+	{ ID id-UERadioCapability			CRITICALITY ignore	TYPE UERadioCapability				PRESENCE optional}|
+	{ ID id-DLNASPDUDeliveryAckRequest	CRITICALITY ignore	TYPE DLNASPDUDeliveryAckRequest	PRESENCE optional}|
+	{ ID id-EnhancedCoverageRestricted	CRITICALITY ignore	TYPE EnhancedCoverageRestricted			PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- INITIAL UE MESSAGE
+--
+-- **************************************************************
+
+InitialUEMessage ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{InitialUEMessage-IEs}},
+	...
+}
+
+InitialUEMessage-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-NAS-PDU						CRITICALITY reject	TYPE NAS-PDU						PRESENCE mandatory}|
+	{ ID id-TAI							CRITICALITY reject	TYPE TAI							PRESENCE mandatory}|
+	{ ID id-EUTRAN-CGI					CRITICALITY ignore	TYPE EUTRAN-CGI						PRESENCE mandatory}|
+	{ ID id-RRC-Establishment-Cause		CRITICALITY ignore	TYPE RRC-Establishment-Cause		PRESENCE mandatory}|
+	{ ID id-S-TMSI						CRITICALITY reject	TYPE S-TMSI							PRESENCE optional}|
+	{ ID id-CSG-Id						CRITICALITY reject	TYPE CSG-Id							PRESENCE optional}|
+	{ ID id-GUMMEI-ID					CRITICALITY reject	TYPE GUMMEI							PRESENCE optional}|
+	{ ID id-CellAccessMode				CRITICALITY reject	TYPE CellAccessMode					PRESENCE optional}|
+	{ ID id-GW-TransportLayerAddress	CRITICALITY ignore	TYPE TransportLayerAddress			PRESENCE optional}|
+	{ ID id-RelayNode-Indicator			CRITICALITY reject	TYPE RelayNode-Indicator			PRESENCE optional}|
+	{ ID id-GUMMEIType					CRITICALITY ignore	TYPE GUMMEIType						PRESENCE optional}|
+-- Extension for Release 11 to support BBAI -- 
+	{ ID id-Tunnel-Information-for-BBF	CRITICALITY ignore	TYPE TunnelInformation				PRESENCE optional}|
+	{ ID id-SIPTO-L-GW-TransportLayerAddress	CRITICALITY ignore	TYPE TransportLayerAddress	PRESENCE optional}|
+	{ ID id-LHN-ID						CRITICALITY ignore	TYPE LHN-ID							PRESENCE optional}|
+	{ ID id-MME-Group-ID				CRITICALITY ignore	TYPE MME-Group-ID					PRESENCE optional}|
+	{ ID id-UE-Usage-Type				CRITICALITY ignore	TYPE UE-Usage-Type					PRESENCE optional}|
+	{ ID id-CE-mode-B-SupportIndicator	CRITICALITY ignore	TYPE CE-mode-B-SupportIndicator		PRESENCE optional}|
+	{ ID id-DCN-ID						CRITICALITY ignore	TYPE DCN-ID							PRESENCE optional}|
+	{ ID id-Coverage-Level           	CRITICALITY ignore	TYPE Coverage-Level				PRESENCE optional},
+
+	...
+}
+
+
+-- **************************************************************
+--
+-- UPLINK NAS TRANSPORT
+--
+-- **************************************************************
+
+UplinkNASTransport ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{UplinkNASTransport-IEs}},
+	...
+}
+
+UplinkNASTransport-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-NAS-PDU						CRITICALITY reject	TYPE NAS-PDU						PRESENCE mandatory}|
+	{ ID id-EUTRAN-CGI					CRITICALITY ignore	TYPE EUTRAN-CGI						PRESENCE mandatory}|
+	{ ID id-TAI							CRITICALITY ignore	TYPE TAI							PRESENCE mandatory}|
+	{ ID id-GW-TransportLayerAddress	CRITICALITY ignore	TYPE TransportLayerAddress			PRESENCE optional}|
+	{ ID id-SIPTO-L-GW-TransportLayerAddress	CRITICALITY ignore	TYPE TransportLayerAddress	PRESENCE optional}|
+	{ ID id-LHN-ID						CRITICALITY ignore	TYPE LHN-ID							PRESENCE optional},
+	...
+}
+-- **************************************************************
+--
+-- NAS NON DELIVERY INDICATION
+--
+-- **************************************************************
+
+NASNonDeliveryIndication ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{NASNonDeliveryIndication-IEs}},
+	...
+}
+
+NASNonDeliveryIndication-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-NAS-PDU						CRITICALITY ignore	TYPE NAS-PDU					PRESENCE mandatory	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- REROUTE NAS REQUEST
+--
+-- **************************************************************
+
+RerouteNASRequest ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{RerouteNASRequest-IEs}},
+	...
+}
+
+RerouteNASRequest-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-eNB-UE-S1AP-ID			CRITICALITY reject	TYPE ENB-UE-S1AP-ID			PRESENCE mandatory}|
+	{ ID id-MME-UE-S1AP-ID			CRITICALITY ignore	TYPE MME-UE-S1AP-ID			PRESENCE optional}|
+	{ ID id-S1-Message				CRITICALITY reject	TYPE OCTET STRING			PRESENCE mandatory}|
+	{ ID id-MME-Group-ID			CRITICALITY reject	TYPE MME-Group-ID			PRESENCE mandatory}|
+	{ ID id-Additional-GUTI			CRITICALITY ignore	TYPE Additional-GUTI		PRESENCE optional}|
+	{ ID id-UE-Usage-Type			CRITICALITY ignore	TYPE UE-Usage-Type			PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- NAS DELIVERY INDICATION
+--
+-- **************************************************************
+
+NASDeliveryIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container { { NASDeliveryIndicationIEs} },
+	...
+}
+
+NASDeliveryIndicationIEs S1AP-PROTOCOL-IES ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- RESET ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Reset
+--
+-- **************************************************************
+
+Reset ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {ResetIEs} },
+	...
+}
+
+ResetIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory	}|
+	{ ID id-ResetType					CRITICALITY reject	TYPE ResetType					PRESENCE mandatory	},
+	...
+}
+
+ResetType ::= CHOICE {
+	s1-Interface					ResetAll,
+	partOfS1-Interface				UE-associatedLogicalS1-ConnectionListRes,
+	...
+}
+
+
+
+ResetAll ::= ENUMERATED {
+	reset-all,
+	...
+}
+
+UE-associatedLogicalS1-ConnectionListRes ::= SEQUENCE (SIZE(1.. maxnoofIndividualS1ConnectionsToReset)) OF ProtocolIE-SingleContainer { { UE-associatedLogicalS1-ConnectionItemRes } }
+
+UE-associatedLogicalS1-ConnectionItemRes S1AP-PROTOCOL-IES ::= {
+	{ ID id-UE-associatedLogicalS1-ConnectionItem	CRITICALITY reject	TYPE UE-associatedLogicalS1-ConnectionItem	PRESENCE mandatory},
+	...
+}
+
+
+-- **************************************************************
+--
+-- Reset Acknowledge
+--
+-- **************************************************************
+
+ResetAcknowledge ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {ResetAcknowledgeIEs} },
+	...
+}
+
+ResetAcknowledgeIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-UE-associatedLogicalS1-ConnectionListResAck		CRITICALITY ignore	TYPE UE-associatedLogicalS1-ConnectionListResAck			PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+UE-associatedLogicalS1-ConnectionListResAck ::= SEQUENCE (SIZE(1.. maxnoofIndividualS1ConnectionsToReset)) OF ProtocolIE-SingleContainer { { UE-associatedLogicalS1-ConnectionItemResAck } }
+
+UE-associatedLogicalS1-ConnectionItemResAck 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-UE-associatedLogicalS1-ConnectionItem	 CRITICALITY ignore 	TYPE UE-associatedLogicalS1-ConnectionItem  	PRESENCE mandatory },
+	...
+}
+
+-- **************************************************************
+--
+-- ERROR INDICATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Error Indication
+--
+-- **************************************************************
+
+ErrorIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{ErrorIndicationIEs}},
+	...
+}
+
+ErrorIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID				PRESENCE optional	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID				PRESENCE optional	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- S1 SETUP ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- S1 Setup Request
+--
+-- **************************************************************
+
+S1SetupRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {S1SetupRequestIEs} },
+	...
+}
+
+S1SetupRequestIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Global-ENB-ID				CRITICALITY reject	TYPE Global-ENB-ID				PRESENCE mandatory}|
+	{ ID id-eNBname						CRITICALITY ignore	TYPE ENBname					PRESENCE optional}|
+	{ ID id-SupportedTAs				CRITICALITY reject	TYPE SupportedTAs				PRESENCE mandatory}|
+	{ ID id-DefaultPagingDRX			CRITICALITY ignore	TYPE PagingDRX					PRESENCE mandatory}|
+	{ ID id-CSG-IdList					CRITICALITY reject	TYPE CSG-IdList					PRESENCE optional}|
+	{ ID id-UE-RetentionInformation		CRITICALITY ignore	TYPE UE-RetentionInformation	PRESENCE optional}|
+	{ ID id-NB-IoT-DefaultPagingDRX		CRITICALITY ignore	TYPE NB-IoT-DefaultPagingDRX	PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- S1 Setup Response
+--
+-- **************************************************************
+
+S1SetupResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {S1SetupResponseIEs} },
+	...
+}
+
+
+S1SetupResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MMEname						CRITICALITY ignore	TYPE MMEname					PRESENCE optional}|
+	{ ID id-ServedGUMMEIs				CRITICALITY reject	TYPE ServedGUMMEIs				PRESENCE mandatory}|
+	{ ID id-RelativeMMECapacity			CRITICALITY ignore	TYPE RelativeMMECapacity		PRESENCE mandatory}|
+	{ ID id-MMERelaySupportIndicator	CRITICALITY ignore	TYPE MMERelaySupportIndicator	PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-UE-RetentionInformation		CRITICALITY ignore	TYPE UE-RetentionInformation	PRESENCE optional}|
+	{ ID id-ServedDCNs					CRITICALITY ignore	TYPE ServedDCNs					PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- S1 Setup Failure
+--
+-- **************************************************************
+
+S1SetupFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {S1SetupFailureIEs} },
+	...
+}
+
+S1SetupFailureIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory	}|
+	{ ID id-TimeToWait					CRITICALITY ignore	TYPE TimeToWait					PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- ENB CONFIGURATION UPDATE ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- eNB Configuration Update 
+--
+-- **************************************************************
+
+ENBConfigurationUpdate ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {ENBConfigurationUpdateIEs} },
+	...
+}
+
+ENBConfigurationUpdateIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-eNBname						CRITICALITY ignore	TYPE ENBname					PRESENCE optional}|
+	{ ID id-SupportedTAs				CRITICALITY reject	TYPE SupportedTAs				PRESENCE optional}|
+	{ ID id-CSG-IdList					CRITICALITY reject	TYPE CSG-IdList					PRESENCE optional}|
+	{ ID id-DefaultPagingDRX			CRITICALITY ignore	TYPE PagingDRX					PRESENCE optional}|
+	{ ID id-NB-IoT-DefaultPagingDRX		CRITICALITY ignore	TYPE NB-IoT-DefaultPagingDRX	PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- eNB Configuration Update Acknowledge
+--
+-- **************************************************************
+
+ENBConfigurationUpdateAcknowledge ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {ENBConfigurationUpdateAcknowledgeIEs} },
+	...
+}
+
+
+ENBConfigurationUpdateAcknowledgeIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics	PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- eNB Configuration Update Failure
+--
+-- **************************************************************
+
+ENBConfigurationUpdateFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {ENBConfigurationUpdateFailureIEs} },
+	...
+}
+
+ENBConfigurationUpdateFailureIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory	}|
+	{ ID id-TimeToWait					CRITICALITY ignore	TYPE TimeToWait					PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional	},
+...
+}
+
+
+-- **************************************************************
+--
+-- MME CONFIGURATION UPDATE ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- MME Configuration Update 
+--
+-- **************************************************************
+
+MMEConfigurationUpdate ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {MMEConfigurationUpdateIEs} },
+	...
+}
+
+MMEConfigurationUpdateIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MMEname					CRITICALITY ignore	TYPE MMEname				PRESENCE optional	}|
+	{ ID id-ServedGUMMEIs			CRITICALITY reject	TYPE ServedGUMMEIs			PRESENCE optional	}|
+	{ ID id-RelativeMMECapacity		CRITICALITY reject	TYPE RelativeMMECapacity	PRESENCE optional	}|
+	{ ID id-ServedDCNs				CRITICALITY ignore	TYPE ServedDCNs				PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- MME Configuration Update Acknowledge
+--
+-- **************************************************************
+
+MMEConfigurationUpdateAcknowledge ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {MMEConfigurationUpdateAcknowledgeIEs} },
+	...
+}
+
+
+MMEConfigurationUpdateAcknowledgeIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- MME Configuration Update Failure
+--
+-- **************************************************************
+
+MMEConfigurationUpdateFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {MMEConfigurationUpdateFailureIEs} },
+	...
+}
+
+MMEConfigurationUpdateFailureIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory	}|
+	{ ID id-TimeToWait					CRITICALITY ignore	TYPE TimeToWait					PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- DOWNLINK S1 CDMA2000 TUNNELLING ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Downlink S1 CDMA2000 Tunnelling
+--
+-- **************************************************************
+
+DownlinkS1cdma2000tunnelling ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {DownlinkS1cdma2000tunnellingIEs} },
+	...
+}
+
+DownlinkS1cdma2000tunnellingIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID						CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID						CRITICALITY reject	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-E-RABSubjecttoDataForwardingList	CRITICALITY ignore	TYPE E-RABSubjecttoDataForwardingList	PRESENCE optional	}|
+	{ ID id-cdma2000HOStatus					CRITICALITY ignore	TYPE Cdma2000HOStatus					PRESENCE optional	}|
+	{ ID id-cdma2000RATType						CRITICALITY reject	TYPE Cdma2000RATType					PRESENCE mandatory	}|
+	{ ID id-cdma2000PDU							CRITICALITY reject	TYPE Cdma2000PDU						PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- UPLINK S1 CDMA2000 TUNNELLING ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Uplink S1 CDMA2000 Tunnelling
+--
+-- **************************************************************
+
+UplinkS1cdma2000tunnelling ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {UplinkS1cdma2000tunnellingIEs} },
+	...
+}
+
+UplinkS1cdma2000tunnellingIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID							CRITICALITY reject	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory	}|
+	{ ID id-cdma2000RATType							CRITICALITY reject	TYPE Cdma2000RATType					PRESENCE mandatory	}|
+	{ ID id-cdma2000SectorID						CRITICALITY reject	TYPE Cdma2000SectorID					PRESENCE mandatory	}|
+	{ ID id-cdma2000HORequiredIndication			CRITICALITY ignore	TYPE Cdma2000HORequiredIndication		PRESENCE optional	}|
+	{ ID id-cdma2000OneXSRVCCInfo					CRITICALITY reject	TYPE Cdma2000OneXSRVCCInfo			PRESENCE optional	}|
+	{ ID id-cdma2000OneXRAND						CRITICALITY reject	TYPE Cdma2000OneXRAND					PRESENCE optional	}|
+	{ ID id-cdma2000PDU								CRITICALITY reject	TYPE Cdma2000PDU						PRESENCE mandatory	}|
+	{ ID id-EUTRANRoundTripDelayEstimationInfo		CRITICALITY ignore	TYPE EUTRANRoundTripDelayEstimationInfo		PRESENCE optional	},
+	-- Extension for Release 9 to assist target HRPD access with the acquisition of the UE --
+	...
+}
+
+
+-- **************************************************************
+--
+-- UE CAPABILITY INFO INDICATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- UE Capability Info Indication
+--
+-- **************************************************************
+
+UECapabilityInfoIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UECapabilityInfoIndicationIEs} },
+	...
+}
+
+UECapabilityInfoIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-UERadioCapability			CRITICALITY ignore	TYPE UERadioCapability				PRESENCE mandatory}|
+	{ ID id-UERadioCapabilityForPaging	CRITICALITY ignore	TYPE UERadioCapabilityForPaging		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- eNB STATUS TRANSFER ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- eNB Status Transfer
+--
+-- **************************************************************
+
+ENBStatusTransfer ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {ENBStatusTransferIEs} },
+	...
+}
+
+ENBStatusTransferIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID								CRITICALITY reject	TYPE MME-UE-S1AP-ID		PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID								CRITICALITY reject	TYPE ENB-UE-S1AP-ID		PRESENCE mandatory}|
+	{ ID id-eNB-StatusTransfer-TransparentContainer		CRITICALITY reject	TYPE ENB-StatusTransfer-TransparentContainer	PRESENCE mandatory},
+	...
+}
+
+
+-- **************************************************************
+--
+-- MME STATUS TRANSFER ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- MME Status Transfer
+--
+-- **************************************************************
+
+MMEStatusTransfer ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {MMEStatusTransferIEs} },
+	...
+}
+
+MMEStatusTransferIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID								CRITICALITY reject	TYPE MME-UE-S1AP-ID			PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID								CRITICALITY reject	TYPE ENB-UE-S1AP-ID			PRESENCE mandatory}|
+	{ ID id-eNB-StatusTransfer-TransparentContainer		CRITICALITY reject	TYPE ENB-StatusTransfer-TransparentContainer		PRESENCE mandatory},
+	...
+}
+
+
+-- **************************************************************
+--
+-- TRACE ELEMENTARY PROCEDURES
+--
+-- **************************************************************
+-- **************************************************************
+--
+-- Trace Start
+--
+-- **************************************************************
+
+TraceStart ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {TraceStartIEs} },
+	...
+}
+
+TraceStartIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-TraceActivation				CRITICALITY ignore	TYPE TraceActivation			PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- Trace Failure Indication
+--
+-- **************************************************************
+
+TraceFailureIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {TraceFailureIndicationIEs} },
+	...
+}
+
+TraceFailureIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-E-UTRAN-Trace-ID			CRITICALITY ignore	TYPE E-UTRAN-Trace-ID			PRESENCE mandatory	}|
+	{ ID id-Cause						CRITICALITY ignore	TYPE Cause						PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- DEACTIVATE TRACE ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Deactivate Trace
+--
+-- **************************************************************
+
+DeactivateTrace ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { DeactivateTraceIEs} },
+	...
+}
+
+DeactivateTraceIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID		CRITICALITY reject	TYPE MME-UE-S1AP-ID		PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID		CRITICALITY reject	TYPE ENB-UE-S1AP-ID		PRESENCE mandatory	}|
+	{ ID id-E-UTRAN-Trace-ID	CRITICALITY ignore	TYPE E-UTRAN-Trace-ID	PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- CELL TRAFFIC TRACE ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Cell Traffic Trace
+--
+-- **************************************************************
+
+CellTrafficTrace ::= SEQUENCE {
+     protocolIEs		ProtocolIE-Container	{ { CellTrafficTraceIEs } },
+     ...
+}
+
+CellTrafficTraceIEs S1AP-PROTOCOL-IES ::= {
+	{ID id-MME-UE-S1AP-ID					CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ID id-eNB-UE-S1AP-ID					CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ID id-E-UTRAN-Trace-ID					CRITICALITY ignore	TYPE E-UTRAN-Trace-ID			PRESENCE mandatory	}|
+	{ID id-EUTRAN-CGI						CRITICALITY ignore	TYPE EUTRAN-CGI					PRESENCE mandatory	}|
+	{ID id-TraceCollectionEntityIPAddress	CRITICALITY ignore	TYPE TransportLayerAddress		PRESENCE mandatory	}|
+	{ID id-PrivacyIndicator					CRITICALITY ignore	TYPE PrivacyIndicator			PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- LOCATION ELEMENTARY PROCEDURES
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Location Reporting Control
+--
+-- **************************************************************
+
+LocationReportingControl ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { LocationReportingControlIEs} },
+	...
+}
+
+LocationReportingControlIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID			CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID			CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-RequestType				CRITICALITY ignore	TYPE RequestType				PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- Location Report Failure Indication
+--
+-- **************************************************************
+
+LocationReportingFailureIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { LocationReportingFailureIndicationIEs} },
+	...
+}
+
+LocationReportingFailureIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID			CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID			CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-Cause					CRITICALITY ignore	TYPE Cause						PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- Location Report 
+--
+-- **************************************************************
+
+LocationReport ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { LocationReportIEs} },
+	...
+}
+
+LocationReportIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID			CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID			CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-EUTRAN-CGI				CRITICALITY ignore	TYPE EUTRAN-CGI					PRESENCE mandatory	}|
+	{ ID id-TAI						CRITICALITY ignore	TYPE TAI						PRESENCE mandatory	}|
+	{ ID id-RequestType				CRITICALITY ignore	TYPE RequestType				PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- OVERLOAD ELEMENTARY PROCEDURES
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Overload Start
+--
+-- **************************************************************
+
+OverloadStart ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {OverloadStartIEs} },
+	...
+}
+
+OverloadStartIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-OverloadResponse					CRITICALITY reject	TYPE OverloadResponse				PRESENCE mandatory	}|
+	{ ID id-GUMMEIList							CRITICALITY ignore	TYPE GUMMEIList						PRESENCE optional	}|
+	{ ID id-TrafficLoadReductionIndication		CRITICALITY ignore	TYPE TrafficLoadReductionIndication	PRESENCE optional	},
+	...
+}
+-- **************************************************************
+--
+-- Overload Stop
+--
+-- **************************************************************
+
+OverloadStop ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {OverloadStopIEs} },
+	...
+}
+
+OverloadStopIEs S1AP-PROTOCOL-IES ::= {	
+{ ID id-GUMMEIList								CRITICALITY ignore	TYPE GUMMEIList						PRESENCE optional	},
+	...
+}
+-- **************************************************************
+--
+-- WRITE-REPLACE WARNING ELEMENTARY PROCEDURE 
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Write-Replace Warning Request
+--
+-- **************************************************************
+
+
+WriteReplaceWarningRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {WriteReplaceWarningRequestIEs} },
+	...
+}
+
+WriteReplaceWarningRequestIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MessageIdentifier					CRITICALITY reject	TYPE MessageIdentifier					PRESENCE mandatory	}|
+	{ ID id-SerialNumber						CRITICALITY reject	TYPE SerialNumber						PRESENCE mandatory	}|
+	{ ID id-WarningAreaList						CRITICALITY ignore	TYPE WarningAreaList					PRESENCE optional	}|
+	{ ID id-RepetitionPeriod					CRITICALITY reject	TYPE RepetitionPeriod					PRESENCE mandatory	}|
+	{ ID id-ExtendedRepetitionPeriod			CRITICALITY reject	TYPE ExtendedRepetitionPeriod			PRESENCE optional	}|
+	{ ID id-NumberofBroadcastRequest			CRITICALITY reject	TYPE NumberofBroadcastRequest			PRESENCE mandatory	}|
+	{ ID id-WarningType							CRITICALITY ignore	TYPE WarningType						PRESENCE optional	}|
+	{ ID id-WarningSecurityInfo					CRITICALITY ignore	TYPE WarningSecurityInfo				PRESENCE optional	}|
+	{ ID id-DataCodingScheme					CRITICALITY ignore	TYPE DataCodingScheme					PRESENCE optional	}|
+	{ ID id-WarningMessageContents				CRITICALITY ignore	TYPE WarningMessageContents				PRESENCE optional	}|
+	{ ID id-ConcurrentWarningMessageIndicator	CRITICALITY reject	TYPE ConcurrentWarningMessageIndicator	PRESENCE optional	},
+	...
+}
+-- **************************************************************
+--
+-- Write-Replace Warning Response
+--
+-- **************************************************************
+
+WriteReplaceWarningResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container		{ {WriteReplaceWarningResponseIEs} },
+	...
+}
+
+WriteReplaceWarningResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MessageIdentifier				CRITICALITY reject	TYPE MessageIdentifier					PRESENCE mandatory	}|
+	{ ID id-SerialNumber					CRITICALITY reject	TYPE SerialNumber						PRESENCE mandatory	}|
+	{ ID id-BroadcastCompletedAreaList		CRITICALITY ignore	TYPE BroadcastCompletedAreaList			PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics			CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- eNB DIRECT INFORMATION TRANSFER ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- eNB Direct Information Transfer
+--
+-- **************************************************************
+
+ENBDirectInformationTransfer ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{ ENBDirectInformationTransferIEs}},
+	...
+}
+
+ENBDirectInformationTransferIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Inter-SystemInformationTransferTypeEDT	CRITICALITY reject	TYPE Inter-SystemInformationTransferType		PRESENCE mandatory	},
+	...
+}
+
+Inter-SystemInformationTransferType ::= CHOICE {
+	rIMTransfer		RIMTransfer,
+	...
+}
+
+-- **************************************************************
+--
+-- MME DIRECT INFORMATION TRANSFER ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- MME Direct Information Transfer
+--
+-- **************************************************************
+
+MMEDirectInformationTransfer ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{ MMEDirectInformationTransferIEs}},
+	...
+}
+
+MMEDirectInformationTransferIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Inter-SystemInformationTransferTypeMDT	CRITICALITY reject	TYPE Inter-SystemInformationTransferType	PRESENCE mandatory	},
+	...
+}
+-- **************************************************************
+--
+-- eNB CONFIGURATION TRANSFER ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- eNB Configuration Transfer
+--
+-- **************************************************************
+
+ENBConfigurationTransfer ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{ ENBConfigurationTransferIEs}},
+	...
+}
+
+ENBConfigurationTransferIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-SONConfigurationTransferECT		CRITICALITY ignore	TYPE SONConfigurationTransfer	PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- MME CONFIGURATION TRANSFER ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- MME Configuration Transfer
+--
+-- **************************************************************
+
+MMEConfigurationTransfer ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{ MMEConfigurationTransferIEs}},
+	...
+}
+
+MMEConfigurationTransferIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-SONConfigurationTransferMCT		CRITICALITY ignore	TYPE SONConfigurationTransfer	PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- PRIVATE MESSAGE ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Private Message
+--
+-- **************************************************************
+
+PrivateMessage ::= SEQUENCE {
+	privateIEs			PrivateIE-Container       {{PrivateMessageIEs}},
+	...
+}
+
+PrivateMessageIEs S1AP-PRIVATE-IES ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- KILL PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- Kill Request
+--
+-- **************************************************************
+
+
+KillRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {KillRequestIEs} },
+	...
+}
+
+KillRequestIEs S1AP-PROTOCOL-IES ::= {	
+	{ ID id-MessageIdentifier			CRITICALITY reject	TYPE MessageIdentifier		PRESENCE mandatory}|
+	{ ID id-SerialNumber				CRITICALITY reject	TYPE SerialNumber			PRESENCE mandatory}|
+	{ ID id-WarningAreaList				CRITICALITY ignore	TYPE WarningAreaList		PRESENCE optional}|
+	{ ID id-KillAllWarningMessages		CRITICALITY reject	TYPE KillAllWarningMessages	PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- Kill Response
+--
+-- **************************************************************
+
+KillResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container		{ {KillResponseIEs} },
+	...
+}
+
+KillResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MessageIdentifier			CRITICALITY reject	TYPE MessageIdentifier					PRESENCE mandatory	}|
+	{ ID id-SerialNumber				CRITICALITY reject	TYPE SerialNumber						PRESENCE mandatory	}|
+	{ ID id-BroadcastCancelledAreaList	CRITICALITY ignore	TYPE BroadcastCancelledAreaList			PRESENCE optional	}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional	},
+	...
+}
+
+-- **************************************************************
+--
+-- PWS RESTART INDICATION PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- PWS Restart Indication
+--
+-- **************************************************************
+
+PWSRestartIndication::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{ PWSRestartIndicationIEs}},
+	...
+}
+
+PWSRestartIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-ECGIListForRestart				CRITICALITY reject	TYPE ECGIListForRestart					PRESENCE mandatory}|
+	{ ID id-Global-ENB-ID					CRITICALITY reject	TYPE Global-ENB-ID						PRESENCE mandatory}|
+	{ ID id-TAIListForRestart				CRITICALITY reject	TYPE TAIListForRestart					PRESENCE mandatory}|
+	{ ID id-EmergencyAreaIDListForRestart	CRITICALITY reject	TYPE EmergencyAreaIDListForRestart	PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- PWS Failure Indication
+--
+-- **************************************************************
+
+PWSFailureIndication::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{ PWSFailureIndicationIEs}},
+	...
+}
+
+PWSFailureIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-PWSfailedECGIList		CRITICALITY reject	TYPE PWSfailedECGIList	PRESENCE mandatory}|
+	{ ID id-Global-ENB-ID			CRITICALITY reject	TYPE Global-ENB-ID		PRESENCE mandatory},
+	...
+}
+
+-- **************************************************************
+--
+-- LPPA TRANSPORT ELEMENTARY PROCEDURES
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- DOWNLINK UE ASSOCIATED LPPA TRANSPORT
+--
+-- **************************************************************
+
+DownlinkUEAssociatedLPPaTransport ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{DownlinkUEAssociatedLPPaTransport-IEs}},
+	...
+}
+
+DownlinkUEAssociatedLPPaTransport-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID			CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID			CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-Routing-ID				CRITICALITY reject	TYPE Routing-ID					PRESENCE mandatory	}|
+	{ ID id-LPPa-PDU    			CRITICALITY reject	TYPE LPPa-PDU					PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- UPLINK UE ASSOCIATED LPPA TRANSPORT
+--
+-- **************************************************************
+
+UplinkUEAssociatedLPPaTransport ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{UplinkUEAssociatedLPPaTransport-IEs}},
+	...
+}
+
+UplinkUEAssociatedLPPaTransport-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID			CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-eNB-UE-S1AP-ID			CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory	}|
+	{ ID id-Routing-ID				CRITICALITY reject	TYPE Routing-ID					PRESENCE mandatory	}|
+	{ ID id-LPPa-PDU				CRITICALITY reject	TYPE LPPa-PDU					PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- DOWNLINK NON UE ASSOCIATED LPPA TRANSPORT
+--
+-- **************************************************************
+
+DownlinkNonUEAssociatedLPPaTransport ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       {{DownlinkNonUEAssociatedLPPaTransport-IEs}},
+	...
+}
+
+DownlinkNonUEAssociatedLPPaTransport-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Routing-ID				CRITICALITY reject	TYPE Routing-ID					PRESENCE mandatory	}|
+	{ ID id-LPPa-PDU				CRITICALITY reject	TYPE LPPa-PDU					PRESENCE mandatory	},
+	...
+}
+
+-- **************************************************************
+--
+-- UPLINK NON UE ASSOCIATED LPPA TRANSPORT
+--
+-- **************************************************************
+
+UplinkNonUEAssociatedLPPaTransport ::= SEQUENCE {
+	protocolIEs		ProtocolIE-Container       {{UplinkNonUEAssociatedLPPaTransport-IEs}},
+	...
+}
+
+UplinkNonUEAssociatedLPPaTransport-IEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Routing-ID				CRITICALITY reject	TYPE Routing-ID					PRESENCE mandatory	}|
+	{ ID id-LPPa-PDU				CRITICALITY reject	TYPE LPPa-PDU					PRESENCE mandatory	},
+	...
+}
+
+
+-- **************************************************************
+--
+-- E-RAB MODIFICATION INDICATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- E-RAB Modification Indication
+--
+-- **************************************************************
+
+E-RABModificationIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { E-RABModificationIndicationIEs} },
+	...
+}
+
+E-RABModificationIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY reject	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID							CRITICALITY reject	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-E-RABToBeModifiedListBearerModInd		CRITICALITY reject	TYPE E-RABToBeModifiedListBearerModInd		PRESENCE mandatory}|
+	{ ID id-E-RABNotToBeModifiedListBearerModInd	CRITICALITY reject	TYPE E-RABNotToBeModifiedListBearerModInd	PRESENCE optional}|
+	{ ID id-CSGMembershipInfo						CRITICALITY reject	TYPE CSGMembershipInfo					PRESENCE optional}|
+-- Extension for Release 11 to support BBAI -- 
+	{ ID id-Tunnel-Information-for-BBF				CRITICALITY ignore	TYPE TunnelInformation					PRESENCE optional},
+	...
+}
+
+E-RABToBeModifiedListBearerModInd ::= E-RAB-IE-ContainerList { {E-RABToBeModifiedItemBearerModIndIEs} }
+
+E-RABToBeModifiedItemBearerModIndIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABToBeModifiedItemBearerModInd		CRITICALITY reject	TYPE E-RABToBeModifiedItemBearerModInd		PRESENCE mandatory},
+	...
+}
+
+E-RABToBeModifiedItemBearerModInd ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	transportLayerAddress			TransportLayerAddress,
+	dL-GTP-TEID						GTP-TEID,
+	iE-Extensions					ProtocolExtensionContainer { { E-RABToBeModifiedItemBearerModInd-ExtIEs} }			OPTIONAL,
+	...
+}
+
+E-RABToBeModifiedItemBearerModInd-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABNotToBeModifiedListBearerModInd ::= E-RAB-IE-ContainerList { {E-RABNotToBeModifiedItemBearerModIndIEs} }
+
+E-RABNotToBeModifiedItemBearerModIndIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABNotToBeModifiedItemBearerModInd		CRITICALITY reject	TYPE E-RABNotToBeModifiedItemBearerModInd		PRESENCE mandatory},
+	...
+}
+
+E-RABNotToBeModifiedItemBearerModInd ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	transportLayerAddress			TransportLayerAddress,
+	dL-GTP-TEID						GTP-TEID,
+	iE-Extensions					ProtocolExtensionContainer { { E-RABNotToBeModifiedItemBearerModInd-ExtIEs} }		OPTIONAL,
+	...
+}
+
+E-RABNotToBeModifiedItemBearerModInd-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CSGMembershipInfo ::= SEQUENCE {
+	cSGMembershipStatus		CSGMembershipStatus,
+	cSG-Id					CSG-Id,
+	cellAccessMode			CellAccessMode	OPTIONAL,
+	pLMNidentity			PLMNidentity	OPTIONAL,
+	iE-Extensions			ProtocolExtensionContainer { { CSGMembershipInfo-ExtIEs} }		OPTIONAL,
+	...
+}
+
+CSGMembershipInfo-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- E-RAB Modification Confirm
+--
+-- **************************************************************
+
+E-RABModificationConfirm ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container { {E-RABModificationConfirmIEs} },
+	...
+}
+
+E-RABModificationConfirmIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID							CRITICALITY ignore	TYPE MME-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID							CRITICALITY ignore	TYPE ENB-UE-S1AP-ID					PRESENCE mandatory}|
+	{ ID id-E-RABModifyListBearerModConf			CRITICALITY ignore	TYPE E-RABModifyListBearerModConf	PRESENCE optional}|
+	{ ID id-E-RABFailedToModifyListBearerModConf	CRITICALITY ignore	TYPE E-RABList						PRESENCE optional}|
+	{ ID id-E-RABToBeReleasedListBearerModConf		CRITICALITY ignore	TYPE E-RABList						PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics					CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-CSGMembershipStatus						CRITICALITY ignore	TYPE CSGMembershipStatus			PRESENCE optional},
+	...
+}
+
+E-RABModifyListBearerModConf ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABModifyItemBearerModConfIEs} }
+
+E-RABModifyItemBearerModConfIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABModifyItemBearerModConf		CRITICALITY ignore	TYPE E-RABModifyItemBearerModConf		PRESENCE mandatory},
+	...
+}
+
+E-RABModifyItemBearerModConf ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	iE-Extensions				ProtocolExtensionContainer { {E-RABModifyItemBearerModConfExtIEs} } OPTIONAL,
+	...
+}
+
+
+E-RABModifyItemBearerModConfExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- **************************************************************
+--
+-- UE CONTEXT MODIFICATION INDICATION ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- UE Context Modification Indication
+--
+-- **************************************************************
+
+UEContextModificationIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextModificationIndicationIEs} },
+	...
+}
+
+UEContextModificationIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID			CRITICALITY reject	TYPE MME-UE-S1AP-ID			PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID			CRITICALITY reject	TYPE ENB-UE-S1AP-ID			PRESENCE mandatory}|
+	{ ID id-CSGMembershipInfo		CRITICALITY reject	TYPE CSGMembershipInfo		PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- UE Context Modification Confirm
+--
+-- **************************************************************
+
+UEContextModificationConfirm ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container { {UEContextModificationConfirmIEs} },
+	...
+}
+
+UEContextModificationConfirmIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-CSGMembershipStatus			CRITICALITY ignore	TYPE CSGMembershipStatus		PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- UE CONTEXT SUSPEND ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- UE Context Suspend Request
+--
+-- **************************************************************
+
+UEContextSuspendRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextSuspendRequestIEs} },
+	...
+}
+
+UEContextSuspendRequestIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID									CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID									CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-InformationOnRecommendedCellsAndENBsForPaging	CRITICALITY ignore	TYPE InformationOnRecommendedCellsAndENBsForPaging PRESENCE optional}|
+	{ ID id-CellIdentifierAndCELevelForCECapableUEs			CRITICALITY ignore	TYPE CellIdentifierAndCELevelForCECapableUEs	PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- UE Context Suspend Response
+--
+-- **************************************************************
+
+UEContextSuspendResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container { {UEContextSuspendResponseIEs} },
+	...
+}
+
+UEContextSuspendResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics		CRITICALITY ignore	TYPE CriticalityDiagnostics		PRESENCE optional}|
+	{ ID id-SecurityContext				CRITICALITY reject	TYPE SecurityContext			PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- UE CONTEXT RESUME ELEMENTARY PROCEDURE
+--
+-- **************************************************************
+
+-- **************************************************************
+--
+-- UE Context Resume Request
+--
+-- **************************************************************
+
+UEContextResumeRequest ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextResumeRequestIEs} },
+	...
+}
+
+UEContextResumeRequestIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID										CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID									CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-E-RABFailedToResumeListResumeReq 				CRITICALITY reject	TYPE E-RABFailedToResumeListResumeReq		PRESENCE optional}|
+	{ ID id-RRC-Resume-Cause								CRITICALITY ignore	TYPE RRC-Establishment-Cause	PRESENCE optional},
+	...
+}
+
+E-RABFailedToResumeListResumeReq ::= E-RAB-IE-ContainerList { {E-RABFailedToResumeItemResumeReqIEs} }
+
+E-RABFailedToResumeItemResumeReqIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABFailedToResumeItemResumeReq	CRITICALITY reject	TYPE E-RABFailedToResumeItemResumeReq	PRESENCE mandatory},
+	...
+}
+
+E-RABFailedToResumeItemResumeReq ::= SEQUENCE {
+	e-RAB-ID							E-RAB-ID,
+	cause								Cause,
+	iE-Extensions						ProtocolExtensionContainer { { E-RABFailedToResumeItemResumeReq-ExtIEs} }		OPTIONAL,
+	...
+}
+
+E-RABFailedToResumeItemResumeReq-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- UE Context Resume Response
+--
+-- **************************************************************
+
+UEContextResumeResponse ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextResumeResponseIEs} },
+	...
+}
+
+UEContextResumeResponseIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID						CRITICALITY ignore	TYPE MME-UE-S1AP-ID							PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID						CRITICALITY ignore	TYPE ENB-UE-S1AP-ID							PRESENCE mandatory}|
+	{ ID id-E-RABFailedToResumeListResumeRes	CRITICALITY reject	TYPE E-RABFailedToResumeListResumeRes		PRESENCE optional}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics					PRESENCE optional}|
+	{ ID id-SecurityContext						CRITICALITY reject	TYPE SecurityContext						PRESENCE optional},
+	...
+}
+
+E-RABFailedToResumeListResumeRes ::= E-RAB-IE-ContainerList { {E-RABFailedToResumeItemResumeResIEs} }
+
+E-RABFailedToResumeItemResumeResIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABFailedToResumeItemResumeRes	CRITICALITY reject	TYPE E-RABFailedToResumeItemResumeRes	PRESENCE mandatory},
+	...
+}
+
+E-RABFailedToResumeItemResumeRes ::= SEQUENCE {
+	e-RAB-ID							E-RAB-ID,
+	cause								Cause,
+	iE-Extensions						ProtocolExtensionContainer { { E-RABFailedToResumeItemResumeRes-ExtIEs} }		OPTIONAL,
+	...
+}
+
+E-RABFailedToResumeItemResumeRes-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- **************************************************************
+--
+-- UE Context Resume Failure
+--
+-- **************************************************************
+
+UEContextResumeFailure ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { UEContextResumeFailureIEs} },
+	...
+}
+
+UEContextResumeFailureIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID						CRITICALITY ignore	TYPE MME-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID						CRITICALITY ignore	TYPE ENB-UE-S1AP-ID						PRESENCE mandatory}|
+	{ ID id-Cause								CRITICALITY ignore	TYPE Cause								PRESENCE mandatory}|
+	{ ID id-CriticalityDiagnostics				CRITICALITY ignore	TYPE CriticalityDiagnostics				PRESENCE optional},
+	...
+}
+
+-- **************************************************************
+--
+-- Connection Establishment Indication
+--
+-- **************************************************************
+
+ConnectionEstablishmentIndication::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container { {ConnectionEstablishmentIndicationIEs} },
+	...
+}
+
+ConnectionEstablishmentIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY ignore	TYPE MME-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY ignore	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-UERadioCapability			CRITICALITY ignore	TYPE UERadioCapability			PRESENCE optional }|
+	{ ID id-EnhancedCoverageRestricted	CRITICALITY ignore	TYPE EnhancedCoverageRestricted	PRESENCE optional }|
+	{ ID id-DL-CP-SecurityInformation	CRITICALITY ignore	TYPE DL-CP-SecurityInformation	PRESENCE optional },
+	...
+}
+
+-- **************************************************************
+--
+-- Retrieve UE Information 
+--
+-- **************************************************************
+
+RetrieveUEInformation ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { { RetrieveUEInformationIEs} },
+	...
+}
+
+RetrieveUEInformationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-S-TMSI						CRITICALITY reject	TYPE S-TMSI				PRESENCE mandatory},
+...
+
+}
+
+
+-- **************************************************************
+
+-- UE Information Transfer
+--
+-- **************************************************************
+UEInformationTransfer ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container       { {  UEInformationTransferIEs} },
+	...
+}
+
+UEInformationTransferIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-S-TMSI						CRITICALITY reject 	TYPE S-TMSI						PRESENCE mandatory}|
+	{ ID id-UE-Level-QoS-Parameters		CRITICALITY ignore	TYPE E-RABLevelQoSParameters	PRESENCE optional}|
+	{ ID id-UERadioCapability			CRITICALITY ignore	TYPE UERadioCapability			PRESENCE optional},
+	...
+}
+
+
+-- **************************************************************
+--
+-- eNB CP Relocation Indication
+--
+-- **************************************************************
+
+ENBCPRelocationIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container { { ENBCPRelocationIndicationIEs} },
+	...
+}
+
+ENBCPRelocationIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-S-TMSI						CRITICALITY reject	TYPE S-TMSI						PRESENCE mandatory}|
+	{ ID id-EUTRAN-CGI					CRITICALITY ignore	TYPE EUTRAN-CGI					PRESENCE mandatory}|
+	{ ID id-TAI							CRITICALITY ignore	TYPE TAI						PRESENCE mandatory}|
+	{ ID id-UL-CP-SecurityInformation	CRITICALITY reject	TYPE UL-CP-SecurityInformation	PRESENCE mandatory},
+	...
+}
+
+
+-- **************************************************************
+--
+-- MME CP Relocation Indication
+--
+-- **************************************************************
+
+MMECPRelocationIndication ::= SEQUENCE {
+	protocolIEs			ProtocolIE-Container { { MMECPRelocationIndicationIEs} },
+	...
+}
+
+MMECPRelocationIndicationIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-MME-UE-S1AP-ID				CRITICALITY reject	TYPE MME-UE-S1AP-ID				PRESENCE mandatory}|
+	{ ID id-eNB-UE-S1AP-ID				CRITICALITY reject	TYPE ENB-UE-S1AP-ID				PRESENCE mandatory},
+	...
+}
+
+END
+
+
+
+-- **************************************************************
+--
+-- Information Element Definitions
+--
+-- **************************************************************
+
+S1AP-IEs {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) s1ap (1) version1 (1) s1ap-IEs (2) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+IMPORTS
+	id-E-RABInformationListItem,
+	id-E-RABItem,
+	id-Bearers-SubjectToStatusTransfer-Item,
+	id-Time-Synchronisation-Info,
+	id-x2TNLConfigurationInfo,
+	id-eNBX2ExtendedTransportLayerAddresses,
+	id-MDTConfiguration,
+	id-Time-UE-StayedInCell-EnhancedGranularity,
+	id-HO-Cause,
+	id-M3Configuration,
+	id-M4Configuration,
+	id-M5Configuration,
+	id-MDT-Location-Info,
+	id-SignallingBasedMDTPLMNList,
+	id-MobilityInformation,
+	id-ULCOUNTValueExtended,
+	id-DLCOUNTValueExtended,
+	id-ReceiveStatusOfULPDCPSDUsExtended,
+	id-eNBIndirectX2TransportLayerAddresses,
+	id-Muting-Availability-Indication,
+	id-Muting-Pattern-Information,
+	id-Synchronisation-Information,
+	id-uE-HistoryInformationFromTheUE,
+	id-LoggedMBSFNMDT,
+	id-SON-Information-Report,
+	id-RecommendedCellItem,
+	id-RecommendedENBItem,
+	id-ProSeUEtoNetworkRelaying,
+	id-ULCOUNTValuePDCP-SNlength18,
+	id-DLCOUNTValuePDCP-SNlength18,
+	id-ReceiveStatusOfULPDCPSDUsPDCP-SNlength18,
+	id-M6Configuration,
+	id-M7Configuration,
+	id-RAT-Type,
+	maxnoofCSGs,
+	maxnoofE-RABs,
+	maxnoofErrors,
+	maxnoofBPLMNs,
+	maxnoofPLMNsPerMME,
+	maxnoofTACs,
+	maxnoofEPLMNs,
+	maxnoofEPLMNsPlusOne,
+	maxnoofForbLACs,
+	maxnoofForbTACs,
+	maxnoofCells,
+	maxnoofCellID,
+	maxnoofDCNs,
+	maxnoofEmergencyAreaID,
+	maxnoofTAIforWarning,
+	maxnoofCellinTAI,
+	maxnoofCellinEAI,
+	maxnoofeNBX2TLAs,
+	maxnoofeNBX2ExtTLAs,
+	maxnoofeNBX2GTPTLAs,
+	maxnoofRATs,
+	maxnoofGroupIDs,
+	maxnoofMMECs,
+	maxnoofTAforMDT,
+	maxnoofCellIDforMDT,
+	maxnoofMDTPLMNs,
+	maxnoofCellsforRestart,
+	maxnoofRestartTAIs,
+	maxnoofRestartEmergencyAreaIDs,
+	maxnoofMBSFNAreaMDT,
+	maxEARFCN,
+	maxnoofCellsineNB,
+	maxnoofRecommendedCells,
+	maxnoofRecommendedENBs
+
+
+
+FROM S1AP-Constants
+
+	Criticality,
+	ProcedureCode,
+	ProtocolIE-ID,
+	TriggeringMessage
+FROM S1AP-CommonDataTypes
+
+	ProtocolExtensionContainer{},
+	S1AP-PROTOCOL-EXTENSION,
+	ProtocolIE-SingleContainer{},
+	S1AP-PROTOCOL-IES
+
+FROM S1AP-Containers;	
+
+-- A
+
+Additional-GUTI::= SEQUENCE {
+	gUMMEI					GUMMEI,
+	m-TMSI					M-TMSI,
+	iE-Extensions			ProtocolExtensionContainer { {Additional-GUTI-ExtIEs} } OPTIONAL,
+	...
+}
+
+Additional-GUTI-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AreaScopeOfMDT ::= CHOICE {	
+	cellBased					CellBasedMDT,
+	tABased						TABasedMDT,
+	pLMNWide					NULL,
+	...,
+	tAIBased					TAIBasedMDT
+}
+
+AllocationAndRetentionPriority ::= SEQUENCE {
+	priorityLevel				PriorityLevel,
+	pre-emptionCapability		Pre-emptionCapability,
+	pre-emptionVulnerability	Pre-emptionVulnerability,
+	iE-Extensions				ProtocolExtensionContainer { {AllocationAndRetentionPriority-ExtIEs} } OPTIONAL,
+	...
+}
+
+AllocationAndRetentionPriority-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AssistanceDataForCECapableUEs ::= SEQUENCE {
+	cellIdentifierAndCELevelForCECapableUEs		CellIdentifierAndCELevelForCECapableUEs,
+	iE-Extensions								ProtocolExtensionContainer { { InformationForCECapableUEs-ExtIEs} } OPTIONAL,
+	...
+}
+
+InformationForCECapableUEs-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AssistanceDataForPaging ::= SEQUENCE {
+	assistanceDataForRecommendedCells	AssistanceDataForRecommendedCells		OPTIONAL,
+	assistanceDataForCECapableUEs		AssistanceDataForCECapableUEs			OPTIONAL,
+	pagingAttemptInformation			PagingAttemptInformation				OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { { AssistanceDataForPaging-ExtIEs} }	OPTIONAL,
+	...
+}
+
+AssistanceDataForPaging-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+AssistanceDataForRecommendedCells ::= SEQUENCE {
+	recommendedCellsForPaging	RecommendedCellsForPaging, 
+	iE-Extensions				ProtocolExtensionContainer { { AssistanceDataForRecommendedCells-ExtIEs} }	OPTIONAL,
+	...
+}
+
+AssistanceDataForRecommendedCells-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- B
+
+Bearers-SubjectToStatusTransferList ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { { Bearers-SubjectToStatusTransfer-ItemIEs } }
+
+Bearers-SubjectToStatusTransfer-ItemIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-Bearers-SubjectToStatusTransfer-Item	CRITICALITY ignore	TYPE Bearers-SubjectToStatusTransfer-Item 	PRESENCE mandatory	},
+	...
+}
+
+Bearers-SubjectToStatusTransfer-Item ::= SEQUENCE {
+	e-RAB-ID								E-RAB-ID,
+	uL-COUNTvalue							COUNTvalue,
+	dL-COUNTvalue							COUNTvalue,
+	receiveStatusofULPDCPSDUs				ReceiveStatusofULPDCPSDUs			OPTIONAL,
+	iE-Extensions							ProtocolExtensionContainer { {Bearers-SubjectToStatusTransfer-ItemExtIEs} } OPTIONAL,
+	...
+}
+
+Bearers-SubjectToStatusTransfer-ItemExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-ULCOUNTValueExtended						CRITICALITY ignore	EXTENSION COUNTValueExtended				PRESENCE optional}|
+	{ ID id-DLCOUNTValueExtended						CRITICALITY ignore	EXTENSION COUNTValueExtended				PRESENCE optional}|
+	{ ID id-ReceiveStatusOfULPDCPSDUsExtended			CRITICALITY ignore	EXTENSION ReceiveStatusOfULPDCPSDUsExtended		PRESENCE optional}|
+	{ ID id-ULCOUNTValuePDCP-SNlength18					CRITICALITY ignore	EXTENSION COUNTvaluePDCP-SNlength18			PRESENCE optional}|
+	{ ID id-DLCOUNTValuePDCP-SNlength18					CRITICALITY ignore	EXTENSION COUNTvaluePDCP-SNlength18			PRESENCE optional}|
+	{ ID id-ReceiveStatusOfULPDCPSDUsPDCP-SNlength18	CRITICALITY ignore	EXTENSION ReceiveStatusOfULPDCPSDUsPDCP-SNlength18	PRESENCE optional},
+	...
+}
+
+BearerType ::= ENUMERATED {
+	non-IP,
+	...
+}
+
+BitRate	::= INTEGER (0..10000000000) 
+
+BPLMNs ::= SEQUENCE (SIZE(1.. maxnoofBPLMNs)) OF PLMNidentity
+
+BroadcastCancelledAreaList ::= CHOICE {
+	cellID-Cancelled				CellID-Cancelled,
+	tAI-Cancelled					TAI-Cancelled,
+	emergencyAreaID-Cancelled		EmergencyAreaID-Cancelled,
+	...
+}
+
+BroadcastCompletedAreaList ::= CHOICE {
+	cellID-Broadcast				CellID-Broadcast,
+	tAI-Broadcast					TAI-Broadcast,
+	emergencyAreaID-Broadcast		EmergencyAreaID-Broadcast,
+	...
+}
+
+
+-- C
+
+CancelledCellinEAI ::= SEQUENCE (SIZE(1..maxnoofCellinEAI)) OF CancelledCellinEAI-Item
+
+CancelledCellinEAI-Item ::= SEQUENCE {
+	eCGI					EUTRAN-CGI,
+	numberOfBroadcasts		NumberOfBroadcasts,
+	iE-Extensions			ProtocolExtensionContainer { {CancelledCellinEAI-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+CancelledCellinEAI-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CancelledCellinTAI ::= SEQUENCE (SIZE(1..maxnoofCellinTAI)) OF CancelledCellinTAI-Item
+
+CancelledCellinTAI-Item ::= SEQUENCE{
+	eCGI				EUTRAN-CGI,
+	numberOfBroadcasts	NumberOfBroadcasts,
+	iE-Extensions		ProtocolExtensionContainer { {CancelledCellinTAI-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+CancelledCellinTAI-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Cause ::= CHOICE {
+	radioNetwork		CauseRadioNetwork,
+	transport			CauseTransport,
+	nas					CauseNas,
+	protocol			CauseProtocol,
+	misc				CauseMisc,
+	...
+}
+
+CauseMisc ::= ENUMERATED {
+	control-processing-overload,
+	not-enough-user-plane-processing-resources,
+	hardware-failure,
+	om-intervention,
+	unspecified,
+	unknown-PLMN,
+...
+}
+
+CauseProtocol ::= ENUMERATED {
+	transfer-syntax-error,
+	abstract-syntax-error-reject,
+	abstract-syntax-error-ignore-and-notify,
+	message-not-compatible-with-receiver-state,
+	semantic-error,
+	abstract-syntax-error-falsely-constructed-message,
+	unspecified,
+	...
+}
+
+CauseRadioNetwork ::= ENUMERATED {
+	unspecified,
+	tx2relocoverall-expiry,
+	successful-handover,
+	release-due-to-eutran-generated-reason,
+	handover-cancelled,	
+	partial-handover,	
+	ho-failure-in-target-EPC-eNB-or-target-system,
+	ho-target-not-allowed,
+	tS1relocoverall-expiry,
+	tS1relocprep-expiry,
+	cell-not-available,
+	unknown-targetID,
+	no-radio-resources-available-in-target-cell,
+	unknown-mme-ue-s1ap-id,
+	unknown-enb-ue-s1ap-id,
+	unknown-pair-ue-s1ap-id,
+	handover-desirable-for-radio-reason,
+	time-critical-handover,
+	resource-optimisation-handover,
+	reduce-load-in-serving-cell,
+	user-inactivity,
+	radio-connection-with-ue-lost,
+	load-balancing-tau-required,
+	cs-fallback-triggered,
+	ue-not-available-for-ps-service,
+	radio-resources-not-available,
+	failure-in-radio-interface-procedure,
+	invalid-qos-combination,
+	interrat-redirection,
+	interaction-with-other-procedure,
+	unknown-E-RAB-ID,
+	multiple-E-RAB-ID-instances,
+	encryption-and-or-integrity-protection-algorithms-not-supported,
+	s1-intra-system-handover-triggered,
+	s1-inter-system-handover-triggered,
+	x2-handover-triggered,
+	...,
+	redirection-towards-1xRTT,
+	not-supported-QCI-value,
+	invalid-CSG-Id,
+	release-due-to-pre-emption
+
+}
+
+CauseTransport ::= ENUMERATED {
+	transport-resource-unavailable,
+	unspecified,
+	...
+}
+
+CauseNas ::= ENUMERATED {
+	normal-release,
+	authentication-failure,
+	detach,
+	unspecified,
+	...,
+	csg-subscription-expiry
+}
+
+CellAccessMode ::= ENUMERATED {
+	hybrid, 
+	...
+}
+
+CellIdentifierAndCELevelForCECapableUEs ::= SEQUENCE {
+	global-Cell-ID		EUTRAN-CGI,
+	cELevel				CELevel,
+	iE-Extensions		ProtocolExtensionContainer { { CellIdentifierAndCELevelForCECapableUEs-ExtIEs} } OPTIONAL,
+	...
+}
+
+CellIdentifierAndCELevelForCECapableUEs-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- Coverage Enhancement level encoded according to TS 36.331 [16] --
+CELevel ::= OCTET STRING
+
+CE-mode-B-SupportIndicator ::= ENUMERATED {
+	supported,
+	...
+}
+
+CellIdentity ::= BIT STRING (SIZE (28))
+
+CellID-Broadcast ::= SEQUENCE (SIZE(1..maxnoofCellID)) OF CellID-Broadcast-Item
+
+CellID-Broadcast-Item ::= SEQUENCE {
+	eCGI				EUTRAN-CGI,
+	iE-Extensions		ProtocolExtensionContainer { {CellID-Broadcast-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+CellID-Broadcast-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CellID-Cancelled::= SEQUENCE (SIZE(1..maxnoofCellID)) OF CellID-Cancelled-Item
+
+CellID-Cancelled-Item ::= SEQUENCE {
+	eCGI				EUTRAN-CGI,
+	numberOfBroadcasts	NumberOfBroadcasts,
+	iE-Extensions		ProtocolExtensionContainer { {CellID-Cancelled-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+CellID-Cancelled-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CellBasedMDT::= SEQUENCE {
+	cellIdListforMDT	CellIdListforMDT,
+	iE-Extensions		ProtocolExtensionContainer { {CellBasedMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+CellBasedMDT-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CellIdListforMDT ::= SEQUENCE (SIZE(1..maxnoofCellIDforMDT)) OF EUTRAN-CGI
+
+Cdma2000PDU	::= OCTET STRING
+
+Cdma2000RATType ::= ENUMERATED {
+	hRPD,
+	onexRTT,
+	...
+}
+
+Cdma2000SectorID ::= OCTET STRING
+
+Cdma2000HOStatus ::= ENUMERATED {
+	hOSuccess,
+	hOFailure,
+	...
+}
+
+Cdma2000HORequiredIndication ::= ENUMERATED {
+	true,
+	...
+}
+
+Cdma2000OneXSRVCCInfo ::= SEQUENCE {
+	cdma2000OneXMEID			Cdma2000OneXMEID,
+	cdma2000OneXMSI				Cdma2000OneXMSI,
+	cdma2000OneXPilot			Cdma2000OneXPilot,
+	iE-Extensions				ProtocolExtensionContainer { {Cdma2000OneXSRVCCInfo-ExtIEs} } OPTIONAL,
+	...
+}
+
+Cdma2000OneXSRVCCInfo-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Cdma2000OneXMEID ::= OCTET STRING
+
+Cdma2000OneXMSI ::= OCTET STRING
+
+Cdma2000OneXPilot ::= OCTET STRING
+
+Cdma2000OneXRAND ::= OCTET STRING
+
+
+Cell-Size ::= ENUMERATED {verysmall, small, medium, large, ...}
+
+CellType ::= SEQUENCE {
+	cell-Size				Cell-Size,
+	iE-Extensions			ProtocolExtensionContainer { { CellType-ExtIEs}}	OPTIONAL,
+	...
+}
+
+CellType-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CGI ::= SEQUENCE {
+	pLMNidentity	PLMNidentity,
+	lAC				LAC,
+	cI				CI,
+	rAC				RAC												OPTIONAL,
+	iE-Extensions	ProtocolExtensionContainer { {CGI-ExtIEs} }		OPTIONAL,
+	...
+	}
+
+CGI-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CI					::= OCTET STRING (SIZE (2))
+
+CNDomain ::= ENUMERATED {
+	ps, 
+	cs 
+}
+
+ConcurrentWarningMessageIndicator ::= ENUMERATED {
+	true
+}
+
+Correlation-ID		::= OCTET STRING (SIZE (4))
+
+CSFallbackIndicator ::= ENUMERATED { 
+	cs-fallback-required,
+	...,
+	cs-fallback-high-priority 
+}
+
+AdditionalCSFallbackIndicator ::= ENUMERATED { 
+	no-restriction,
+	restriction,
+	...
+}
+
+CSG-Id		::= BIT STRING (SIZE (27))
+
+
+CSG-IdList ::= SEQUENCE (SIZE (1.. maxnoofCSGs)) OF CSG-IdList-Item
+
+CSG-IdList-Item ::= SEQUENCE {
+	cSG-Id			CSG-Id,
+	iE-Extensions	ProtocolExtensionContainer { {CSG-IdList-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+CSG-IdList-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CSGMembershipStatus ::= ENUMERATED { 
+	member, 
+	not-member
+}
+
+
+COUNTvalue ::= SEQUENCE {
+	pDCP-SN			PDCP-SN,
+	hFN				HFN,
+	iE-Extensions	ProtocolExtensionContainer { {COUNTvalue-ExtIEs} } OPTIONAL,
+	...
+}
+COUNTvalue-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+COUNTValueExtended  ::= SEQUENCE {
+	pDCP-SNExtended		PDCP-SNExtended,
+	hFNModified			HFNModified,
+	iE-Extensions		ProtocolExtensionContainer { {COUNTValueExtended-ExtIEs} } OPTIONAL,
+	...
+}
+
+COUNTValueExtended-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+COUNTvaluePDCP-SNlength18 ::= SEQUENCE {
+	pDCP-SNlength18				PDCP-SNlength18,
+	hFNforPDCP-SNlength18		HFNforPDCP-SNlength18,
+	iE-Extensions				ProtocolExtensionContainer { {COUNTvaluePDCP-SNlength18-ExtIEs} } OPTIONAL,
+	...
+}
+
+COUNTvaluePDCP-SNlength18-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Coverage-Level ::= ENUMERATED {
+	extendedcoverage,
+	...
+}
+
+CriticalityDiagnostics ::= SEQUENCE {
+	procedureCode					ProcedureCode														OPTIONAL,
+	triggeringMessage				TriggeringMessage													OPTIONAL,
+	procedureCriticality			Criticality															OPTIONAL,
+	iEsCriticalityDiagnostics		CriticalityDiagnostics-IE-List										OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer {{CriticalityDiagnostics-ExtIEs}}		OPTIONAL,
+	...
+}
+
+CriticalityDiagnostics-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1.. maxnoofErrors)) OF CriticalityDiagnostics-IE-Item
+
+CriticalityDiagnostics-IE-Item ::= SEQUENCE {
+	iECriticality			Criticality,
+	iE-ID					ProtocolIE-ID,
+	typeOfError 			TypeOfError,
+	iE-Extensions			ProtocolExtensionContainer {{CriticalityDiagnostics-IE-Item-ExtIEs}}	OPTIONAL,
+	...
+}
+
+CriticalityDiagnostics-IE-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+-- D
+
+DataCodingScheme ::= BIT STRING (SIZE (8))
+
+DCN-ID ::= INTEGER (0..65535)
+
+ServedDCNs ::= SEQUENCE (SIZE(0..maxnoofDCNs)) OF ServedDCNsItem
+
+ServedDCNsItem ::= SEQUENCE {
+	dCN-ID						DCN-ID,
+	relativeDCNCapacity			RelativeMMECapacity,
+	iE-Extensions			ProtocolExtensionContainer { {ServedDCNsItem-ExtIEs} }	OPTIONAL,
+	...
+}
+
+ServedDCNsItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+DL-CP-SecurityInformation ::= SEQUENCE {
+	dl-NAS-MAC				DL-NAS-MAC,
+	iE-Extensions			ProtocolExtensionContainer { { DL-CP-SecurityInformation-ExtIEs} }	OPTIONAL,
+	...
+}
+
+DL-CP-SecurityInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+DL-Forwarding ::= ENUMERATED {
+	dL-Forwarding-proposed,
+	...
+}
+
+DL-NAS-MAC ::= BIT STRING (SIZE (16))
+
+Direct-Forwarding-Path-Availability ::= ENUMERATED {
+	directPathAvailable,
+	...
+}
+
+Data-Forwarding-Not-Possible ::= ENUMERATED {
+	data-Forwarding-not-Possible,
+	...
+}
+
+DLNASPDUDeliveryAckRequest ::= ENUMERATED {
+	requested,
+	...
+}
+
+-- E
+
+EARFCN ::= INTEGER(0..maxEARFCN, ...)
+
+ECGIList ::= SEQUENCE (SIZE(1..maxnoofCellID)) OF EUTRAN-CGI
+
+PWSfailedECGIList ::= SEQUENCE (SIZE(1..maxnoofCellsineNB)) OF EUTRAN-CGI
+
+EmergencyAreaIDList ::= SEQUENCE (SIZE(1..maxnoofEmergencyAreaID)) OF EmergencyAreaID
+
+EmergencyAreaID ::= OCTET STRING (SIZE (3))
+
+EmergencyAreaID-Broadcast ::= SEQUENCE (SIZE(1..maxnoofEmergencyAreaID)) OF EmergencyAreaID-Broadcast-Item
+
+EmergencyAreaID-Broadcast-Item ::= SEQUENCE {
+	emergencyAreaID			EmergencyAreaID,
+	completedCellinEAI		CompletedCellinEAI,
+	iE-Extensions			ProtocolExtensionContainer { {EmergencyAreaID-Broadcast-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+EmergencyAreaID-Broadcast-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+EmergencyAreaID-Cancelled ::= SEQUENCE (SIZE(1..maxnoofEmergencyAreaID)) OF EmergencyAreaID-Cancelled-Item
+
+EmergencyAreaID-Cancelled-Item ::= SEQUENCE {
+	emergencyAreaID			EmergencyAreaID,
+	cancelledCellinEAI		CancelledCellinEAI,
+	iE-Extensions			ProtocolExtensionContainer { {EmergencyAreaID-Cancelled-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+EmergencyAreaID-Cancelled-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+CompletedCellinEAI ::= SEQUENCE (SIZE(1..maxnoofCellinEAI)) OF CompletedCellinEAI-Item
+
+CompletedCellinEAI-Item ::= SEQUENCE {
+	eCGI					EUTRAN-CGI,
+	iE-Extensions			ProtocolExtensionContainer { {CompletedCellinEAI-Item-ExtIEs} }	OPTIONAL,
+	...
+}
+
+CompletedCellinEAI-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ECGI-List ::= SEQUENCE (SIZE(1..maxnoofCellsineNB)) OF EUTRAN-CGI
+
+EmergencyAreaIDListForRestart	::= SEQUENCE (SIZE(1..maxnoofRestartEmergencyAreaIDs)) OF EmergencyAreaID
+
+ENB-ID ::= CHOICE {
+	macroENB-ID			BIT STRING (SIZE(20)),
+	homeENB-ID			BIT STRING (SIZE(28)),
+	... ,
+	short-macroENB-ID 	BIT STRING (SIZE(18)),
+	long-macroENB-ID		BIT STRING (SIZE(21))
+}
+
+GERAN-Cell-ID ::= SEQUENCE {
+	lAI				LAI,
+    rAC				RAC, 
+	cI				CI,
+	iE-Extensions			ProtocolExtensionContainer { { GERAN-Cell-ID-ExtIEs} }	OPTIONAL,
+	...
+}
+
+GERAN-Cell-ID-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Global-ENB-ID ::= SEQUENCE {
+	pLMNidentity			PLMNidentity,
+	eNB-ID					ENB-ID,
+	iE-Extensions			ProtocolExtensionContainer { {GlobalENB-ID-ExtIEs} }		OPTIONAL,
+	...
+}
+
+GlobalENB-ID-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+GUMMEIList::= SEQUENCE (SIZE (1.. maxnoofMMECs)) OF GUMMEI
+
+ENB-StatusTransfer-TransparentContainer		::= SEQUENCE {
+	bearers-SubjectToStatusTransferList		Bearers-SubjectToStatusTransferList,
+	iE-Extensions			ProtocolExtensionContainer { {ENB-StatusTransfer-TransparentContainer-ExtIEs} }	OPTIONAL,
+	...
+}
+
+ENB-StatusTransfer-TransparentContainer-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ENB-UE-S1AP-ID				::= INTEGER (0..16777215)
+
+ENBname ::= PrintableString (SIZE (1..150,...))
+
+ENBX2TLAs ::= SEQUENCE (SIZE(1.. maxnoofeNBX2TLAs)) OF TransportLayerAddress
+
+EncryptionAlgorithms ::= BIT STRING (SIZE (16,...))
+
+EnhancedCoverageRestricted ::= ENUMERATED {
+	restricted,
+	...
+}
+
+EPLMNs ::= SEQUENCE (SIZE(1..maxnoofEPLMNs)) OF PLMNidentity
+EventType	::= ENUMERATED {
+	direct,
+	change-of-serve-cell,
+	stop-change-of-serve-cell,
+	...
+}
+
+E-RAB-ID		::= INTEGER (0..15, ...)
+
+E-RABInformationList	::= SEQUENCE (SIZE (1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { { E-RABInformationListIEs } }
+
+E-RABInformationListIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABInformationListItem			CRITICALITY ignore	TYPE E-RABInformationListItem			PRESENCE mandatory	},
+	...
+}
+
+E-RABInformationListItem ::= SEQUENCE {
+	e-RAB-ID						E-RAB-ID,
+	dL-Forwarding					DL-Forwarding		OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {E-RABInformationListItem-ExtIEs} }			OPTIONAL,
+	...
+}
+
+E-RABInformationListItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+E-RABList ::= SEQUENCE (SIZE(1.. maxnoofE-RABs)) OF ProtocolIE-SingleContainer { {E-RABItemIEs} }
+
+E-RABItemIEs 	S1AP-PROTOCOL-IES ::= {
+	{ ID id-E-RABItem	 CRITICALITY ignore 	TYPE E-RABItem 	PRESENCE mandatory },
+	...
+}
+
+E-RABItem ::= SEQUENCE {
+	e-RAB-ID					E-RAB-ID,
+	cause						Cause,
+	iE-Extensions				ProtocolExtensionContainer { {E-RABItem-ExtIEs} } OPTIONAL,
+	...
+}
+
+E-RABItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+E-RABLevelQoSParameters ::= SEQUENCE {
+	qCI			QCI,
+	allocationRetentionPriority		AllocationAndRetentionPriority,
+	gbrQosInformation					GBR-QosInformation												OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { {E-RABQoSParameters-ExtIEs} }	OPTIONAL,
+	...
+}
+
+E-RABQoSParameters-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+EUTRAN-CGI ::= SEQUENCE {
+	pLMNidentity			PLMNidentity,
+	cell-ID					CellIdentity,
+	iE-Extensions			ProtocolExtensionContainer { {EUTRAN-CGI-ExtIEs} } OPTIONAL,
+	...
+}
+
+EUTRAN-CGI-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+EUTRANRoundTripDelayEstimationInfo ::= INTEGER (0..2047)
+
+ExpectedUEBehaviour ::= SEQUENCE {
+	expectedActivity		ExpectedUEActivityBehaviour OPTIONAL,
+	expectedHOInterval		ExpectedHOInterval		 	OPTIONAL,
+	iE-Extensions		ProtocolExtensionContainer { { ExpectedUEBehaviour-ExtIEs} } OPTIONAL,
+	...
+}
+
+ExpectedUEBehaviour-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ExpectedUEActivityBehaviour ::= SEQUENCE {
+	expectedActivityPeriod					ExpectedActivityPeriod					OPTIONAL,
+	expectedIdlePeriod						ExpectedIdlePeriod						OPTIONAL,
+	sourceofUEActivityBehaviourInformation	SourceOfUEActivityBehaviourInformation	OPTIONAL,
+	iE-Extensions		ProtocolExtensionContainer { { ExpectedUEActivityBehaviour-ExtIEs} } OPTIONAL,
+	...
+}
+
+ExpectedUEActivityBehaviour-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ExpectedActivityPeriod ::= INTEGER (1..30|40|50|60|80|100|120|150|180|181,...)
+
+ExpectedIdlePeriod ::= INTEGER (1..30|40|50|60|80|100|120|150|180|181,...)
+
+SourceOfUEActivityBehaviourInformation ::= ENUMERATED {
+	subscription-information,
+	statistics,
+	...
+}
+
+ExpectedHOInterval ::= ENUMERATED {
+	sec15, sec30, sec60, sec90, sec120, sec180, long-time,
+	...
+}
+
+ExtendedRNC-ID					::= INTEGER (4096..65535)
+
+ExtendedRepetitionPeriod ::= INTEGER (4096..131071) 
+
+Extended-UEIdentityIndexValue ::= BIT STRING (SIZE (14))
+
+-- F
+
+ForbiddenInterRATs ::= ENUMERATED {
+	all,
+	geran,
+	utran,
+	cdma2000,
+	...,
+	geranandutran,
+	cdma2000andutran
+
+}
+
+ForbiddenTAs ::= SEQUENCE (SIZE(1.. maxnoofEPLMNsPlusOne)) OF ForbiddenTAs-Item
+
+ForbiddenTAs-Item ::= SEQUENCE {
+	pLMN-Identity		PLMNidentity,
+	forbiddenTACs		ForbiddenTACs,
+	iE-Extensions		ProtocolExtensionContainer { {ForbiddenTAs-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+ForbiddenTAs-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ForbiddenTACs ::= SEQUENCE (SIZE(1..maxnoofForbTACs)) OF TAC
+
+ForbiddenLAs ::= SEQUENCE (SIZE(1..maxnoofEPLMNsPlusOne)) OF ForbiddenLAs-Item
+
+ForbiddenLAs-Item ::= SEQUENCE {
+	pLMN-Identity		PLMNidentity,
+	forbiddenLACs		ForbiddenLACs,
+	iE-Extensions		ProtocolExtensionContainer { {ForbiddenLAs-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+ForbiddenLAs-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ForbiddenLACs ::= SEQUENCE (SIZE(1..maxnoofForbLACs)) OF LAC
+
+-- G
+
+GBR-QosInformation ::= SEQUENCE {
+	e-RAB-MaximumBitrateDL			BitRate,
+	e-RAB-MaximumBitrateUL			BitRate,
+	e-RAB-GuaranteedBitrateDL		BitRate,
+	e-RAB-GuaranteedBitrateUL		BitRate,
+	iE-Extensions					ProtocolExtensionContainer { { GBR-QosInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+GBR-QosInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+GTP-TEID					::= OCTET STRING (SIZE (4))
+
+GUMMEI			::= SEQUENCE {
+	pLMN-Identity		PLMNidentity,
+	mME-Group-ID		MME-Group-ID,
+	mME-Code			MME-Code,
+	iE-Extensions		ProtocolExtensionContainer { {GUMMEI-ExtIEs} } OPTIONAL,
+	...
+}
+
+GUMMEI-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+GUMMEIType ::= ENUMERATED {
+	native,
+	mapped,
+	...
+}
+
+GWContextReleaseIndication ::= ENUMERATED {
+	true,
+	...
+}
+
+-- H
+
+HandoverRestrictionList ::= SEQUENCE {
+	servingPLMN					PLMNidentity,
+	equivalentPLMNs				EPLMNs					OPTIONAL,
+	forbiddenTAs				ForbiddenTAs			OPTIONAL,
+	forbiddenLAs				ForbiddenLAs			OPTIONAL,
+	forbiddenInterRATs			ForbiddenInterRATs		OPTIONAL, 
+	iE-Extensions				ProtocolExtensionContainer { {HandoverRestrictionList-ExtIEs} }	OPTIONAL,
+	...
+}
+
+HandoverRestrictionList-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+HandoverType ::= ENUMERATED {
+	intralte,
+	ltetoutran,
+	ltetogeran,
+	utrantolte,
+	gerantolte,
+	...
+}
+
+HFN ::= INTEGER (0..1048575)
+
+HFNModified ::= INTEGER (0..131071)
+
+HFNforPDCP-SNlength18 ::= INTEGER (0..16383)
+
+-- I
+
+Masked-IMEISV ::= BIT STRING (SIZE (64))
+
+ImmediateMDT ::= SEQUENCE { 
+	measurementsToActivate		MeasurementsToActivate,
+	m1reportingTrigger			M1ReportingTrigger,
+	m1thresholdeventA2			M1ThresholdEventA2				OPTIONAL,
+-- Included in case of event-triggered, or event-triggered periodic reporting for measurement M1
+	m1periodicReporting			M1PeriodicReporting				OPTIONAL,
+-- Included in case of periodic or event-triggered periodic reporting
+	iE-Extensions				ProtocolExtensionContainer { { ImmediateMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+ImmediateMDT-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-M3Configuration		CRITICALITY ignore	EXTENSION M3Configuration		PRESENCE conditional}|
+	{ ID id-M4Configuration		CRITICALITY ignore	EXTENSION M4Configuration		PRESENCE conditional}|
+	{ ID id-M5Configuration		CRITICALITY ignore	EXTENSION M5Configuration		PRESENCE conditional}|
+	{ ID id-MDT-Location-Info	CRITICALITY ignore	EXTENSION MDT-Location-Info		PRESENCE optional}|
+	{ ID id-M6Configuration		CRITICALITY ignore	EXTENSION M6Configuration		PRESENCE conditional}|
+	{ ID id-M7Configuration		CRITICALITY ignore	EXTENSION M7Configuration		PRESENCE conditional},
+	...
+}
+
+IMSI	::=	OCTET STRING (SIZE (3..8))
+
+InformationOnRecommendedCellsAndENBsForPaging ::= SEQUENCE {
+	recommendedCellsForPaging	RecommendedCellsForPaging,
+	recommendENBsForPaging		RecommendedENBsForPaging,
+	iE-Extensions				ProtocolExtensionContainer { { InformationOnRecommendedCellsAndENBsForPaging-ExtIEs} }	OPTIONAL,
+	...
+}
+
+InformationOnRecommendedCellsAndENBsForPaging-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+IntegrityProtectionAlgorithms ::= BIT STRING (SIZE (16,...))
+
+IntendedNumberOfPagingAttempts ::= INTEGER (1..16, ...)
+
+InterfacesToTrace ::= BIT STRING (SIZE (8))
+
+
+
+-- J
+-- K
+
+KillAllWarningMessages ::= ENUMERATED {true}
+
+-- L
+
+
+LAC	::= OCTET STRING (SIZE (2))
+
+LAI ::= SEQUENCE {
+	pLMNidentity				PLMNidentity,
+	lAC				LAC,
+	iE-Extensions			ProtocolExtensionContainer { {LAI-ExtIEs} } OPTIONAL,
+	...
+}
+
+LAI-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+LastVisitedCell-Item ::= CHOICE {
+	e-UTRAN-Cell					LastVisitedEUTRANCellInformation,
+	uTRAN-Cell						LastVisitedUTRANCellInformation,
+	gERAN-Cell						LastVisitedGERANCellInformation,
+	...
+}
+LastVisitedEUTRANCellInformation ::= SEQUENCE {
+	global-Cell-ID					EUTRAN-CGI,
+	cellType						CellType,
+	time-UE-StayedInCell			Time-UE-StayedInCell,
+	iE-Extensions					ProtocolExtensionContainer { { LastVisitedEUTRANCellInformation-ExtIEs} } OPTIONAL,
+	...
+}
+LastVisitedEUTRANCellInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+-- Extension for Rel-11 to support enhanced granularity for time UE stayed in cell --
+	{ ID id-Time-UE-StayedInCell-EnhancedGranularity	CRITICALITY ignore	EXTENSION Time-UE-StayedInCell-EnhancedGranularity	PRESENCE optional}|
+	{ ID id-HO-Cause									CRITICALITY ignore	EXTENSION Cause							PRESENCE optional},
+	...
+}
+LastVisitedUTRANCellInformation	::= OCTET STRING
+
+LastVisitedGERANCellInformation ::= CHOICE {
+	undefined						NULL,
+	...
+}
+
+L3-Information				::= OCTET STRING
+-- This is a dummy IE used only as a reference to the actual definition in relevant specification.
+
+LPPa-PDU ::=  OCTET STRING
+
+LHN-ID ::=  OCTET STRING(SIZE (32..256))
+
+Links-to-log ::= ENUMERATED {uplink, downlink, both-uplink-and-downlink, ...} 
+
+ListeningSubframePattern ::= SEQUENCE {
+	pattern-period				ENUMERATED {ms1280, ms2560, ms5120, ms10240, ...},
+	pattern-offset				INTEGER (0..10239, ...),
+	iE-Extensions				ProtocolExtensionContainer { { ListeningSubframePattern-ExtIEs} } OPTIONAL,
+	...
+}
+
+ListeningSubframePattern-ExtIEs	S1AP-PROTOCOL-EXTENSION ::= {
+...
+}
+
+LoggedMDT ::= SEQUENCE {
+	loggingInterval				LoggingInterval,
+	loggingDuration				LoggingDuration,
+	iE-Extensions				ProtocolExtensionContainer { {LoggedMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+LoggedMDT-ExtIEs	S1AP-PROTOCOL-EXTENSION ::= {
+...
+}
+
+LoggingInterval ::= ENUMERATED {ms128, ms256, ms512, ms1024, ms2048, ms3072, ms4096, ms6144}
+
+LoggingDuration ::= ENUMERATED {m10, m20, m40, m60, m90, m120}
+
+LoggedMBSFNMDT ::= SEQUENCE {
+	loggingInterval				LoggingInterval,
+	loggingDuration				LoggingDuration,
+	mBSFN-ResultToLog			MBSFN-ResultToLog		OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { { LoggedMBSFNMDT-ExtIEs } } OPTIONAL,
+	...
+}
+
+LoggedMBSFNMDT-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- M
+
+M3Configuration ::= SEQUENCE {
+	m3period			M3period,
+	iE-Extensions		ProtocolExtensionContainer { { M3Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M3Configuration-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M3period ::= ENUMERATED {ms100, ms1000, ms10000, ... } 
+
+M4Configuration ::= SEQUENCE {
+	m4period			M4period,
+	m4-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M4Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M4Configuration-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M4period ::= ENUMERATED {ms1024, ms2048, ms5120, ms10240, min1, ... } 
+
+M5Configuration ::= SEQUENCE {
+	m5period			M5period,
+	m5-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M5Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M5Configuration-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M5period ::= ENUMERATED {ms1024, ms2048, ms5120, ms10240, min1, ... } 
+
+M6Configuration ::= SEQUENCE {
+	m6report-Interval	M6report-Interval,
+	m6delay-threshold	M6delay-threshold		OPTIONAL,
+-- This IE shall be present if the M6 Links to log IE is set to “uplink” or to “both-uplink-and-downlink” --
+	m6-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M6Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M6Configuration-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M6report-Interval ::= ENUMERATED { ms1024, ms2048, ms5120, ms10240, ... }
+
+M6delay-threshold ::= ENUMERATED { ms30, ms40, ms50, ms60, ms70, ms80, ms90, ms100, ms150, ms300, ms500, ms750, ... }
+
+M7Configuration ::= SEQUENCE {
+	m7period			M7period,
+	m7-links-to-log		Links-to-log,
+	iE-Extensions		ProtocolExtensionContainer { { M7Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+
+M7Configuration-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+M7period ::= INTEGER(1..60, ...)
+
+MDT-Activation 	::= ENUMERATED { 
+	immediate-MDT-only,
+	immediate-MDT-and-Trace,
+	logged-MDT-only,
+	...,
+	logged-MBSFN-MDT
+}
+
+MDT-Location-Info ::= BIT STRING (SIZE (8))
+
+MDT-Configuration ::= SEQUENCE {
+	mdt-Activation		MDT-Activation,
+	areaScopeOfMDT		AreaScopeOfMDT,
+	mDTMode				MDTMode,
+	iE-Extensions		ProtocolExtensionContainer { { MDT-Configuration-ExtIEs} } OPTIONAL,
+	...
+}
+MDT-Configuration-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-SignallingBasedMDTPLMNList			CRITICALITY ignore	EXTENSION MDTPLMNList	PRESENCE optional	},
+	...
+}
+
+ManagementBasedMDTAllowed ::= ENUMERATED {allowed, ...}
+
+MBSFN-ResultToLog ::= SEQUENCE (SIZE(1..maxnoofMBSFNAreaMDT)) OF MBSFN-ResultToLogInfo
+
+MBSFN-ResultToLogInfo ::= SEQUENCE {
+	mBSFN-AreaId		INTEGER (0..255)		OPTIONAL,
+	carrierFreq			EARFCN,	
+	iE-Extensions		ProtocolExtensionContainer { { MBSFN-ResultToLogInfo-ExtIEs} } OPTIONAL,
+	...
+}
+
+MBSFN-ResultToLogInfo-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+MDTPLMNList ::= SEQUENCE (SIZE(1..maxnoofMDTPLMNs)) OF PLMNidentity
+
+PrivacyIndicator ::= ENUMERATED {
+	immediate-MDT,
+	logged-MDT,
+	...
+}
+
+MDTMode ::= CHOICE {
+	immediateMDT				ImmediateMDT,
+	loggedMDT					LoggedMDT,
+	...,
+	mDTMode-Extension			MDTMode-Extension
+}
+
+MDTMode-Extension ::= ProtocolIE-SingleContainer {{ MDTMode-ExtensionIE }}
+
+MDTMode-ExtensionIE S1AP-PROTOCOL-IES ::= {
+	{ ID id-LoggedMBSFNMDT		CRITICALITY ignore	TYPE LoggedMBSFNMDT		PRESENCE mandatory}
+}
+
+MeasurementsToActivate ::= BIT STRING (SIZE (8))
+
+MeasurementThresholdA2 ::= CHOICE { 
+	threshold-RSRP				Threshold-RSRP,
+	threshold-RSRQ				Threshold-RSRQ,
+	...
+}
+
+MessageIdentifier	::= BIT STRING (SIZE (16))
+
+MobilityInformation ::= BIT STRING (SIZE(32))
+
+MMEname ::= PrintableString (SIZE (1..150,...))
+
+MMEPagingTarget ::= CHOICE {
+	global-ENB-ID		Global-ENB-ID,
+	tAI					TAI,
+	...
+}
+
+MMERelaySupportIndicator ::= ENUMERATED {true, ...}
+
+MME-Group-ID	::= OCTET STRING (SIZE (2))
+
+MME-Code		::= OCTET STRING (SIZE (1))
+
+MME-UE-S1AP-ID	::= INTEGER (0..4294967295)
+M-TMSI			::= OCTET STRING (SIZE (4))
+
+MSClassmark2	::= OCTET STRING
+MSClassmark3	::= OCTET STRING
+
+MutingAvailabilityIndication ::= ENUMERATED {
+	available,
+	unavailable,
+	...
+}
+
+
+MutingPatternInformation ::= SEQUENCE {
+	muting-pattern-period				ENUMERATED {ms0, ms1280, ms2560, ms5120, ms10240, ...},
+	muting-pattern-offset				INTEGER (0..10239, ...)		OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { {MutingPatternInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+MutingPatternInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- N
+
+NAS-PDU ::=  OCTET STRING
+
+NASSecurityParametersfromE-UTRAN ::= OCTET STRING
+
+NASSecurityParameterstoE-UTRAN ::= OCTET STRING
+
+NB-IoT-DefaultPagingDRX ::= ENUMERATED {
+	v128,
+	v256,
+	v512,
+	v1024,
+	...
+	}
+
+NB-IoT-Paging-eDRXInformation ::= SEQUENCE { 
+	nB-IoT-paging-eDRX-Cycle		NB-IoT-Paging-eDRX-Cycle,
+	nB-IoT-pagingTimeWindow			NB-IoT-PagingTimeWindow			OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { { NB-IoT-Paging-eDRXInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+NB-IoT-Paging-eDRXInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+NB-IoT-Paging-eDRX-Cycle ::= ENUMERATED{hf2, hf4, hf6, hf8, hf10, hf12, hf14, hf16, hf32, hf64, hf128, hf256, hf512, hf1024, ...}
+
+NB-IoT-PagingTimeWindow ::= ENUMERATED{s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, ...}
+
+NB-IoT-UEIdentityIndexValue ::= BIT STRING (SIZE (12))
+
+NextPagingAreaScope ::= ENUMERATED {
+	same,
+	changed,
+	...
+}
+
+NumberofBroadcastRequest ::= INTEGER (0..65535)
+
+NumberOfBroadcasts ::= INTEGER (0..65535)
+
+-- O
+OldBSS-ToNewBSS-Information		::= OCTET STRING
+-- This is a dummy IE used only as a reference to the actual definition in relevant specification.
+
+OverloadAction ::= ENUMERATED {
+	reject-non-emergency-mo-dt,
+	reject-rrc-cr-signalling,
+	permit-emergency-sessions-and-mobile-terminated-services-only,
+	...,
+	permit-high-priority-sessions-and-mobile-terminated-services-only,
+	reject-delay-tolerant-access,
+	permit-high-priority-sessions-and-exception-reporting-and-mobile-terminated-services-only,
+	not-accept-mo-data-or-delay-tolerant-access-from-CP-CIoT
+
+}
+
+OverloadResponse ::= CHOICE {
+	overloadAction					OverloadAction,
+	...
+}
+
+
+-- P
+
+PagingAttemptInformation ::= SEQUENCE {
+	pagingAttemptCount					PagingAttemptCount,
+	intendedNumberOfPagingAttempts		IntendedNumberOfPagingAttempts,
+	nextPagingAreaScope					NextPagingAreaScope		OPTIONAL,
+	iE-Extensions						ProtocolExtensionContainer { { PagingAttemptInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+PagingAttemptInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+PagingAttemptCount ::= INTEGER (1..16, ...)
+
+Paging-eDRXInformation ::= SEQUENCE { 
+	paging-eDRX-Cycle			Paging-eDRX-Cycle,
+	pagingTimeWindow			PagingTimeWindow			OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { { Paging-eDRXInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+Paging-eDRXInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Paging-eDRX-Cycle ::= ENUMERATED{hfhalf, hf1, hf2, hf4, hf6, hf8, hf10, hf12, hf14, hf16, hf32, hf64, hf128, hf256, ...}
+
+PagingTimeWindow ::= ENUMERATED{s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, ...}
+
+PagingDRX ::= ENUMERATED {
+	v32,
+	v64,
+	v128,
+	v256,
+	...
+	}
+
+PagingPriority ::= ENUMERATED {
+	priolevel1,
+	priolevel2,
+	priolevel3,
+	priolevel4,
+	priolevel5,
+	priolevel6,
+	priolevel7,
+	priolevel8,
+	...
+}
+
+PDCP-SN ::= INTEGER (0..4095)
+
+PDCP-SNExtended ::= INTEGER (0..32767)
+
+PDCP-SNlength18 ::= INTEGER (0..262143)
+
+M1PeriodicReporting ::= SEQUENCE { 
+	reportInterval				ReportIntervalMDT,
+	reportAmount				ReportAmountMDT,
+	iE-Extensions				ProtocolExtensionContainer { { M1PeriodicReporting-ExtIEs} } OPTIONAL,
+	...
+}
+
+M1PeriodicReporting-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+PLMNidentity 				::= TBCD-STRING 
+
+Port-Number		::= OCTET STRING (SIZE (2))
+
+Pre-emptionCapability ::= ENUMERATED {
+	shall-not-trigger-pre-emption,
+	may-trigger-pre-emption
+}
+
+Pre-emptionVulnerability ::= ENUMERATED {
+	not-pre-emptable,
+	pre-emptable
+}
+
+PriorityLevel				::= INTEGER { spare (0), highest (1), lowest (14), no-priority (15) } (0..15)
+
+ProSeAuthorized ::= SEQUENCE {
+	proSeDirectDiscovery		ProSeDirectDiscovery									OPTIONAL,
+	proSeDirectCommunication	ProSeDirectCommunication								OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { {ProSeAuthorized-ExtIEs} }	OPTIONAL,
+	...
+}
+
+ProSeAuthorized-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ ID id-ProSeUEtoNetworkRelaying	CRITICALITY ignore	EXTENSION ProSeUEtoNetworkRelaying		PRESENCE optional},
+	...
+}
+
+ProSeDirectDiscovery ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+ProSeUEtoNetworkRelaying ::= ENUMERATED {
+	authorized,
+	not-authorized,
+	...
+}
+
+ProSeDirectCommunication ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+PS-ServiceNotAvailable ::= ENUMERATED {
+	ps-service-not-available,
+	...
+}
+
+-- Q
+
+QCI						::= INTEGER (0..255)
+
+-- R
+
+ReceiveStatusofULPDCPSDUs ::= BIT STRING (SIZE(4096))
+
+ReceiveStatusOfULPDCPSDUsExtended ::= BIT STRING (SIZE(1..16384))
+
+ReceiveStatusOfULPDCPSDUsPDCP-SNlength18 ::= BIT STRING (SIZE(1..131072))
+
+RecommendedCellsForPaging ::= SEQUENCE {
+	recommendedCellList			RecommendedCellList,
+	iE-Extensions				ProtocolExtensionContainer { { RecommendedCellsForPaging-ExtIEs} }	OPTIONAL,
+	...
+}
+
+RecommendedCellsForPaging-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RecommendedCellList ::= SEQUENCE (SIZE(1.. maxnoofRecommendedCells)) OF ProtocolIE-SingleContainer { { RecommendedCellItemIEs } }
+
+RecommendedCellItemIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-RecommendedCellItem	CRITICALITY ignore 	TYPE RecommendedCellItem		PRESENCE mandatory },
+	...
+}
+
+RecommendedCellItem::= SEQUENCE {
+	eUTRAN-CGI				EUTRAN-CGI,
+	timeStayedInCell		INTEGER (0..4095)		OPTIONAL,
+	iE-Extensions			ProtocolExtensionContainer { { RecommendedCellsForPagingItem-ExtIEs} }	OPTIONAL,
+	...
+}
+
+RecommendedCellsForPagingItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RecommendedENBsForPaging ::= SEQUENCE {
+	recommendedENBList		RecommendedENBList,
+	iE-Extensions			ProtocolExtensionContainer { { RecommendedENBsForPaging-ExtIEs} }	OPTIONAL,
+	...
+}
+
+RecommendedENBsForPaging-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RecommendedENBList::= SEQUENCE (SIZE(1.. maxnoofRecommendedENBs)) OF ProtocolIE-SingleContainer { { RecommendedENBItemIEs } }
+
+RecommendedENBItemIEs S1AP-PROTOCOL-IES ::= {
+	{ ID id-RecommendedENBItem	CRITICALITY ignore	TYPE RecommendedENBItem		PRESENCE mandatory },
+	...
+}
+
+RecommendedENBItem ::= SEQUENCE {
+	mMEPagingTarget			MMEPagingTarget,
+	iE-Extensions			ProtocolExtensionContainer { { RecommendedENBItem-ExtIEs} }	OPTIONAL,
+	...
+}
+
+RecommendedENBItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RelativeMMECapacity				::= INTEGER (0..255)
+
+RelayNode-Indicator ::= ENUMERATED {
+	true,
+	...
+}
+
+RAC					::= OCTET STRING (SIZE (1))
+
+RAT-Type ::= ENUMERATED {
+	nbiot,
+	...
+}
+
+ReportAmountMDT ::= ENUMERATED{r1, r2, r4, r8, r16, r32, r64, rinfinity}
+
+ReportIntervalMDT ::= ENUMERATED {ms120, ms240, ms480, ms640, ms1024, ms2048, ms5120, ms10240, min1, min6, min12, min30, min60} 
+
+M1ReportingTrigger ::= ENUMERATED{
+	periodic,
+	a2eventtriggered,
+	...,
+	a2eventtriggered-periodic
+}
+
+RequestType	::= SEQUENCE {
+	eventType 				EventType,
+	reportArea 				ReportArea,
+	iE-Extensions			ProtocolExtensionContainer { { RequestType-ExtIEs} }	OPTIONAL,
+	...
+}
+
+
+RequestType-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RIMTransfer ::= SEQUENCE {
+	rIMInformation			RIMInformation,
+	rIMRoutingAddress		RIMRoutingAddress		OPTIONAL,
+	iE-Extensions			ProtocolExtensionContainer { { RIMTransfer-ExtIEs} }	OPTIONAL,
+	...
+}
+
+RIMTransfer-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RIMInformation ::= OCTET STRING
+
+RIMRoutingAddress ::= CHOICE {
+	gERAN-Cell-ID			GERAN-Cell-ID,
+	...,
+	targetRNC-ID			TargetRNC-ID,
+	eHRPD-Sector-ID			OCTET STRING (SIZE(16))
+}
+
+ReportArea ::= ENUMERATED {
+	ecgi,
+	...
+}
+
+RepetitionPeriod ::= INTEGER (0..4095)
+
+RLFReportInformation ::= SEQUENCE {
+	uE-RLF-Report-Container							UE-RLF-Report-Container,
+	uE-RLF-Report-Container-for-extended-bands		UE-RLF-Report-Container-for-extended-bands		OPTIONAL,
+	iE-Extensions									ProtocolExtensionContainer {{ RLFReportInformation-ExtIEs}} OPTIONAL,
+	...
+}
+
+RLFReportInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+RNC-ID ::= INTEGER (0..4095)
+
+RRC-Container ::= OCTET STRING
+
+RRC-Establishment-Cause ::= ENUMERATED {
+	emergency,
+	highPriorityAccess,
+	mt-Access,
+	mo-Signalling,
+	mo-Data,
+	...,
+	delay-TolerantAccess,
+	mo-VoiceCall,
+	mo-ExceptionData
+}
+
+ECGIListForRestart ::= SEQUENCE (SIZE(1..maxnoofCellsforRestart)) OF EUTRAN-CGI
+
+Routing-ID ::= INTEGER (0..255)
+
+-- S
+
+
+SecurityKey	::= BIT STRING (SIZE(256))
+
+
+
+SecurityContext ::= SEQUENCE {
+	nextHopChainingCount		INTEGER (0..7),
+	nextHopParameter			SecurityKey,
+	iE-Extensions				ProtocolExtensionContainer { { SecurityContext-ExtIEs} }	OPTIONAL,
+	...
+}
+
+
+SecurityContext-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+SerialNumber ::= BIT STRING (SIZE (16))
+
+SONInformation ::= CHOICE{
+	sONInformationRequest		SONInformationRequest,
+	sONInformationReply			SONInformationReply,
+	...
+--	...,
+--	sONInformation-Extension	SONInformation-Extension
+}
+
+SONInformation-Extension ::= ProtocolIE-SingleContainer {{ SONInformation-ExtensionIE }}
+
+SONInformation-ExtensionIE S1AP-PROTOCOL-IES ::= {
+	{ ID id-SON-Information-Report	CRITICALITY ignore	TYPE SONInformationReport	PRESENCE mandatory}
+}
+
+SONInformationRequest ::= ENUMERATED { 
+	x2TNL-Configuration-Info,
+	...,
+	time-Synchronisation-Info,
+	activate-Muting,
+	deactivate-Muting}
+
+SONInformationReply ::= SEQUENCE {
+	x2TNLConfigurationInfo			X2TNLConfigurationInfo			OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer {{SONInformationReply-ExtIEs}} OPTIONAL,
+	...
+}
+
+SONInformationReply-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+-- Extension for Release 9 to transfer Time synchronisation information --
+	{ID id-Time-Synchronisation-Info		CRITICALITY ignore	EXTENSION TimeSynchronisationInfo		PRESENCE optional},
+	...,
+	{ID id-Muting-Pattern-Information		CRITICALITY ignore	EXTENSION MutingPatternInformation	PRESENCE optional}
+}
+
+SONInformationReport ::= CHOICE{
+	rLFReportInformation		RLFReportInformation,
+	...
+}
+
+SONConfigurationTransfer ::= SEQUENCE {
+	targeteNB-ID					TargeteNB-ID,
+	sourceeNB-ID					SourceeNB-ID,
+	sONInformation					SONInformation,
+	iE-Extensions			ProtocolExtensionContainer { { SONConfigurationTransfer-ExtIEs} }			OPTIONAL,
+...
+}
+
+SONConfigurationTransfer-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+-- Extension for Release 10 to transfer the IP addresses of the eNB initiating the ANR action --
+	{ID id-x2TNLConfigurationInfo		CRITICALITY ignore	EXTENSION X2TNLConfigurationInfo				PRESENCE conditional
+	-- This IE shall be present if the SON Information IE contains the SON Information Request IE and the SON Information Request IE is set to “X2TNL Configuration Info” --}|
+-- Extension for Release 12 to transfer information concerning the source cell of synchronisation and the aggressor cell --
+	{ID id-Synchronisation-Information	CRITICALITY ignore	EXTENSION SynchronisationInformation			PRESENCE conditional
+	-- This IE shall be present if the SON Information IE contains the SON Information Request IE set to “ Activate Muting ” --},
+	...
+}
+
+
+SynchronisationInformation ::= SEQUENCE {
+	sourceStratumLevel				StratumLevel				OPTIONAL,
+	listeningSubframePattern		ListeningSubframePattern	OPTIONAL,
+	aggressoreCGI-List				ECGI-List					OPTIONAL,
+	iE-Extensions					ProtocolExtensionContainer { {SynchronisationInformation-ExtIEs} } OPTIONAL,
+	...
+}
+
+SynchronisationInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+Source-ToTarget-TransparentContainer ::= OCTET STRING
+-- This IE includes a transparent container from the source RAN node to the target RAN node. 
+-- The octets of the OCTET STRING are encoded according to the specifications of the target system.
+
+SourceBSS-ToTargetBSS-TransparentContainer		::= OCTET STRING
+-- This is a dummy IE used only as a reference to the actual definition in relevant specification.
+
+SourceeNB-ID ::= SEQUENCE {
+	global-ENB-ID	Global-ENB-ID,
+	selected-TAI	TAI,
+	iE-Extensions	ProtocolExtensionContainer { {SourceeNB-ID-ExtIEs} } OPTIONAL
+}
+
+SourceeNB-ID-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+SRVCCOperationNotPossible ::= ENUMERATED {
+	notPossible,
+	...
+}
+
+SRVCCOperationPossible ::= ENUMERATED {
+	possible,
+	...
+}
+
+SRVCCHOIndication ::= ENUMERATED {
+	pSandCS,
+	cSonly,
+	...
+}
+
+SourceeNB-ToTargeteNB-TransparentContainer		::= SEQUENCE {
+	rRC-Container				RRC-Container,
+	e-RABInformationList		E-RABInformationList			OPTIONAL,
+	targetCell-ID				EUTRAN-CGI,
+	subscriberProfileIDforRFP	SubscriberProfileIDforRFP		OPTIONAL,
+	uE-HistoryInformation		UE-HistoryInformation,
+	iE-Extensions				ProtocolExtensionContainer { {SourceeNB-ToTargeteNB-TransparentContainer-ExtIEs} } OPTIONAL,
+	...
+}
+
+SourceeNB-ToTargeteNB-TransparentContainer-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	{ID id-MobilityInformation				CRITICALITY ignore	EXTENSION MobilityInformation				PRESENCE optional}|
+	{ID id-uE-HistoryInformationFromTheUE	CRITICALITY ignore	EXTENSION UE-HistoryInformationFromTheUE		PRESENCE optional},
+	...
+}
+
+
+SourceRNC-ToTargetRNC-TransparentContainer		::= OCTET STRING
+-- This is a dummy IE used only as a reference to the actual definition in relevant specification.
+
+
+ServedGUMMEIs ::= SEQUENCE (SIZE (1.. maxnoofRATs)) OF ServedGUMMEIsItem
+
+ServedGUMMEIsItem ::= SEQUENCE {
+	servedPLMNs				ServedPLMNs,
+	servedGroupIDs			ServedGroupIDs,
+	servedMMECs				ServedMMECs,
+	iE-Extensions			ProtocolExtensionContainer { {ServedGUMMEIsItem-ExtIEs} }	OPTIONAL,
+	...
+}
+
+ServedGUMMEIsItem-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ServedGroupIDs ::= SEQUENCE (SIZE(1.. maxnoofGroupIDs)) OF MME-Group-ID
+ServedMMECs ::= SEQUENCE (SIZE(1.. maxnoofMMECs)) OF MME-Code
+
+ServedPLMNs ::= SEQUENCE (SIZE(1.. maxnoofPLMNsPerMME)) OF PLMNidentity
+
+SubscriberProfileIDforRFP ::= INTEGER (1..256) 
+
+SupportedTAs ::= SEQUENCE (SIZE(1.. maxnoofTACs)) OF SupportedTAs-Item
+
+SupportedTAs-Item ::=	SEQUENCE  {
+	tAC					TAC,
+	broadcastPLMNs		BPLMNs,
+	iE-Extensions		ProtocolExtensionContainer { {SupportedTAs-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+SupportedTAs-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	-- Extension for Release 13 to transfer RAT-Type per TAC --
+	{ID id-RAT-Type		CRITICALITY reject	EXTENSION RAT-Type		PRESENCE optional},
+	...
+}
+
+StratumLevel ::= INTEGER (0..3, ...)
+
+SynchronisationStatus ::= ENUMERATED { synchronous, asynchronous, ... }
+
+TimeSynchronisationInfo ::= SEQUENCE {
+	stratumLevel					StratumLevel,
+	synchronisationStatus			SynchronisationStatus,
+	iE-Extensions					ProtocolExtensionContainer { { TimeSynchronisationInfo-ExtIEs} } OPTIONAL,
+	...
+}
+
+TimeSynchronisationInfo-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	-- Extension for Release 12 to transfer Muting Availability Indication --
+	{ID id-Muting-Availability-Indication		CRITICALITY ignore	EXTENSION MutingAvailabilityIndication	PRESENCE optional},
+	...
+}
+
+S-TMSI ::= SEQUENCE {
+	mMEC	MME-Code,
+	m-TMSI	M-TMSI,
+	iE-Extensions		ProtocolExtensionContainer { {S-TMSI-ExtIEs} } OPTIONAL,
+	...
+}
+
+S-TMSI-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+-- T
+
+TAC ::= OCTET STRING (SIZE (2))
+
+TAIBasedMDT ::= SEQUENCE {
+	tAIListforMDT			TAIListforMDT,
+	iE-Extensions			ProtocolExtensionContainer { {TAIBasedMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+TAIBasedMDT-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TAIListforMDT ::= SEQUENCE (SIZE(1..maxnoofTAforMDT)) OF TAI
+
+TAIListforWarning ::= SEQUENCE (SIZE(1..maxnoofTAIforWarning)) OF TAI
+
+TAI ::= SEQUENCE {
+	pLMNidentity			PLMNidentity,
+	tAC						TAC,
+	iE-Extensions			ProtocolExtensionContainer { {TAI-ExtIEs} } OPTIONAL,
+	...
+}
+
+TAI-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TAI-Broadcast ::= SEQUENCE (SIZE(1..maxnoofTAIforWarning)) OF TAI-Broadcast-Item
+
+TAI-Broadcast-Item ::= SEQUENCE {
+	tAI					TAI,
+	completedCellinTAI	CompletedCellinTAI,
+	iE-Extensions		ProtocolExtensionContainer { {TAI-Broadcast-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+TAI-Broadcast-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TAI-Cancelled ::= SEQUENCE (SIZE(1..maxnoofTAIforWarning)) OF TAI-Cancelled-Item
+
+TAI-Cancelled-Item ::= SEQUENCE {
+	tAI					TAI,
+	cancelledCellinTAI	CancelledCellinTAI,
+	iE-Extensions		ProtocolExtensionContainer { {TAI-Cancelled-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+TAI-Cancelled-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TABasedMDT ::= SEQUENCE {
+	tAListforMDT		TAListforMDT,
+	iE-Extensions		ProtocolExtensionContainer { {TABasedMDT-ExtIEs} } OPTIONAL,
+	...
+}
+
+TABasedMDT-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TAListforMDT ::= SEQUENCE (SIZE(1..maxnoofTAforMDT)) OF TAC
+
+CompletedCellinTAI ::= SEQUENCE (SIZE(1..maxnoofCellinTAI)) OF CompletedCellinTAI-Item
+
+CompletedCellinTAI-Item ::= SEQUENCE{
+	eCGI				EUTRAN-CGI,
+	iE-Extensions		ProtocolExtensionContainer { {CompletedCellinTAI-Item-ExtIEs} } OPTIONAL,
+	...
+}
+
+CompletedCellinTAI-Item-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TBCD-STRING ::= OCTET STRING (SIZE (3))
+
+TargetID ::= CHOICE {
+	targeteNB-ID		TargeteNB-ID,
+	targetRNC-ID		TargetRNC-ID,
+	cGI					CGI,
+	...
+}
+
+TargeteNB-ID ::= SEQUENCE {
+	global-ENB-ID		Global-ENB-ID,
+	selected-TAI		TAI,
+	iE-Extensions		ProtocolExtensionContainer { {TargeteNB-ID-ExtIEs} } OPTIONAL,
+	...
+}
+
+TargeteNB-ID-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TargetRNC-ID ::= SEQUENCE {
+	lAI					LAI,
+	rAC					RAC 		OPTIONAL,
+	rNC-ID				RNC-ID,
+	extendedRNC-ID		ExtendedRNC-ID		OPTIONAL,
+	iE-Extensions		ProtocolExtensionContainer { {TargetRNC-ID-ExtIEs} } OPTIONAL,
+	...
+	}
+
+
+TargetRNC-ID-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+TargeteNB-ToSourceeNB-TransparentContainer		::= SEQUENCE {
+	rRC-Container		RRC-Container,
+	iE-Extensions		ProtocolExtensionContainer { {TargeteNB-ToSourceeNB-TransparentContainer-ExtIEs} } OPTIONAL,
+	...
+}
+
+TargeteNB-ToSourceeNB-TransparentContainer-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Target-ToSource-TransparentContainer ::= OCTET STRING
+-- This IE includes a transparent container from the target RAN node to the source RAN node. 
+-- The octets of the OCTET STRING are coded according to the specifications of the target system.
+
+TargetRNC-ToSourceRNC-TransparentContainer		::= OCTET STRING
+-- This is a dummy IE used only as a reference to the actual definition in relevant specification.
+
+TargetBSS-ToSourceBSS-TransparentContainer		::= OCTET STRING
+-- This is a dummy IE used only as a reference to the actual definition in relevant specification.
+
+M1ThresholdEventA2 ::= SEQUENCE { 
+	measurementThreshold	MeasurementThresholdA2,
+	iE-Extensions			ProtocolExtensionContainer { { M1ThresholdEventA2-ExtIEs} } OPTIONAL,
+	...
+}
+
+M1ThresholdEventA2-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+Threshold-RSRP ::= INTEGER(0..97)
+
+Threshold-RSRQ ::= INTEGER(0..34)
+
+TimeToWait ::= ENUMERATED {v1s, v2s, v5s, v10s, v20s, v60s, ...}
+
+Time-UE-StayedInCell ::= INTEGER (0..4095)
+
+Time-UE-StayedInCell-EnhancedGranularity ::= INTEGER (0..40950)
+
+TransportInformation ::= SEQUENCE {
+	transportLayerAddress				TransportLayerAddress,
+	uL-GTP-TEID							GTP-TEID,
+	...
+}
+
+TransportLayerAddress		::= BIT STRING (SIZE(1..160, ...))
+
+TraceActivation ::= SEQUENCE {
+	e-UTRAN-Trace-ID					E-UTRAN-Trace-ID,
+	interfacesToTrace					InterfacesToTrace,
+     traceDepth							TraceDepth,
+     traceCollectionEntityIPAddress		TransportLayerAddress,
+	iE-Extensions						ProtocolExtensionContainer { { TraceActivation-ExtIEs} }	OPTIONAL,
+	...
+}
+
+TraceActivation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+-- Extension for Rel-10 to support MDT --
+	{ ID id-MDTConfiguration	CRITICALITY ignore	EXTENSION MDT-Configuration		PRESENCE optional },
+	...
+}
+
+TraceDepth ::= ENUMERATED { 
+	minimum,
+	medium,
+	maximum,
+	minimumWithoutVendorSpecificExtension,
+	mediumWithoutVendorSpecificExtension,
+	maximumWithoutVendorSpecificExtension,
+	...
+}
+
+E-UTRAN-Trace-ID ::=  OCTET STRING (SIZE (8))
+
+TrafficLoadReductionIndication ::= INTEGER (1..99)
+
+TunnelInformation ::= SEQUENCE {
+	transportLayerAddress	TransportLayerAddress,
+	uDP-Port-Number			Port-Number			OPTIONAL,
+	iE-Extensions			ProtocolExtensionContainer { {Tunnel-Information-ExtIEs} } OPTIONAL,
+	...
+}
+
+Tunnel-Information-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+TypeOfError ::= ENUMERATED {
+	not-understood,
+	missing,
+	...
+}
+
+TAIListForRestart ::= SEQUENCE (SIZE(1..maxnoofRestartTAIs)) OF TAI
+
+-- U
+
+UEAggregateMaximumBitrate ::= SEQUENCE {
+	uEaggregateMaximumBitRateDL		BitRate,
+	uEaggregateMaximumBitRateUL		BitRate,
+	iE-Extensions					ProtocolExtensionContainer { {UEAggregate-MaximumBitrates-ExtIEs} } OPTIONAL,
+	...
+}
+
+UEAggregate-MaximumBitrates-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UE-RetentionInformation ::= ENUMERATED {
+	ues-retained,
+	...}
+
+UE-S1AP-IDs ::= CHOICE{
+	uE-S1AP-ID-pair		UE-S1AP-ID-pair,
+	mME-UE-S1AP-ID		MME-UE-S1AP-ID,
+	...
+}
+
+UE-S1AP-ID-pair ::= SEQUENCE{
+	mME-UE-S1AP-ID		MME-UE-S1AP-ID,
+	eNB-UE-S1AP-ID		ENB-UE-S1AP-ID,
+	iE-Extensions		ProtocolExtensionContainer { {UE-S1AP-ID-pair-ExtIEs} } OPTIONAL,
+	...
+}
+UE-S1AP-ID-pair-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+
+UE-associatedLogicalS1-ConnectionItem ::= SEQUENCE {
+	mME-UE-S1AP-ID		MME-UE-S1AP-ID OPTIONAL,
+	eNB-UE-S1AP-ID		ENB-UE-S1AP-ID OPTIONAL,
+	iE-Extensions		ProtocolExtensionContainer { { UE-associatedLogicalS1-ConnectionItemExtIEs} } OPTIONAL,
+	...
+}
+
+
+UE-associatedLogicalS1-ConnectionItemExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UEIdentityIndexValue	::=	BIT STRING (SIZE (10))
+
+UE-HistoryInformation ::= SEQUENCE (SIZE(1..maxnoofCells)) OF LastVisitedCell-Item
+
+UE-HistoryInformationFromTheUE ::= OCTET STRING
+-- This IE is a transparent container and shall be encoded as the VisitedCellInfoList field contained in the UEInformationResponse message as defined in TS 36.331 [16]
+
+UEPagingID ::= CHOICE {
+	s-TMSI		S-TMSI,
+	iMSI		IMSI,
+	...
+	}
+
+UERadioCapability ::= OCTET STRING
+
+UERadioCapabilityForPaging ::= OCTET STRING
+
+UE-RLF-Report-Container ::= OCTET STRING
+-- This IE is a transparent container and shall be encoded as the rlf-Report-r9 field contained in the UEInformationResponse message as defined in TS 36.331 [16]
+
+UE-RLF-Report-Container-for-extended-bands ::= OCTET STRING
+-- This IE is a transparent container and shall be encoded as the rlf-Report-v9e0 contained in the UEInformationResponse message as defined in TS 36.331 [16]
+
+UESecurityCapabilities ::= SEQUENCE {
+	encryptionAlgorithms			EncryptionAlgorithms,
+	integrityProtectionAlgorithms	IntegrityProtectionAlgorithms,
+	iE-Extensions					ProtocolExtensionContainer { { UESecurityCapabilities-ExtIEs} }	OPTIONAL,
+...
+}
+
+UESecurityCapabilities-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UESidelinkAggregateMaximumBitrate ::= SEQUENCE {
+	uESidelinkAggregateMaximumBitRate		BitRate,
+	iE-Extensions					ProtocolExtensionContainer { {UE-Sidelink-Aggregate-MaximumBitrates-ExtIEs} } OPTIONAL,
+	...
+}
+
+UE-Sidelink-Aggregate-MaximumBitrates-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UE-Usage-Type ::= INTEGER (0..255) 
+
+UL-CP-SecurityInformation ::= SEQUENCE {
+	ul-NAS-MAC				UL-NAS-MAC,
+	ul-NAS-Count			UL-NAS-Count,
+	iE-Extensions			ProtocolExtensionContainer { { UL-CP-SecurityInformation-ExtIEs} }	OPTIONAL,
+	...
+}
+
+UL-CP-SecurityInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UL-NAS-MAC ::= BIT STRING (SIZE (16))
+
+UL-NAS-Count ::= BIT STRING (SIZE (5))
+
+
+UserLocationInformation ::= SEQUENCE {
+	eutran-cgi 				EUTRAN-CGI,
+	tai						TAI,
+	iE-Extensions			ProtocolExtensionContainer { { UserLocationInformation-ExtIEs} }	OPTIONAL,
+	...
+}
+
+UserLocationInformation-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+UEUserPlaneCIoTSupportIndicator ::= ENUMERATED {
+	supported,
+	...
+}
+
+-- V
+
+VoiceSupportMatchIndicator ::= ENUMERATED { 
+	supported,
+	not-supported,
+	...
+}
+
+V2XServicesAuthorized ::= SEQUENCE {
+	vehicleUE			VehicleUE											OPTIONAL,
+	pedestrianUE 		PedestrianUE						OPTIONAL,
+	iE-Extensions		ProtocolExtensionContainer { {V2XServicesAuthorized-ExtIEs} }	OPTIONAL,
+	...
+}
+
+V2XServicesAuthorized-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+VehicleUE ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+PedestrianUE ::= ENUMERATED { 
+	authorized,
+	not-authorized,
+	...
+}
+
+-- W
+
+WarningAreaList ::= CHOICE {
+	cellIDList						ECGIList,
+	trackingAreaListforWarning		TAIListforWarning,
+	emergencyAreaIDList				EmergencyAreaIDList,
+	...
+}
+
+
+WarningType ::= OCTET STRING (SIZE (2))
+
+WarningSecurityInfo ::= OCTET STRING (SIZE (50))
+
+
+WarningMessageContents ::= OCTET STRING (SIZE(1..9600))
+
+
+-- X
+
+
+X2TNLConfigurationInfo ::= SEQUENCE {
+	eNBX2TransportLayerAddresses	ENBX2TLAs,
+	iE-Extensions					ProtocolExtensionContainer { { X2TNLConfigurationInfo-ExtIEs} } OPTIONAL,
+	...
+}
+
+X2TNLConfigurationInfo-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+-- Extension for Release 10 to transfer the IPsec and U-plane addresses during ANR action --
+	{ID id-eNBX2ExtendedTransportLayerAddresses		CRITICALITY ignore	EXTENSION ENBX2ExtTLAs	PRESENCE optional}|
+-- Extension for Release 12 to transfer the IP addresses of the X2 GW --
+	{ID id-eNBIndirectX2TransportLayerAddresses	CRITICALITY ignore	EXTENSION ENBIndirectX2TransportLayerAddresses	PRESENCE optional},
+	...
+}
+
+ENBX2ExtTLAs ::= SEQUENCE (SIZE(1.. maxnoofeNBX2ExtTLAs)) OF ENBX2ExtTLA
+
+ENBX2ExtTLA ::= SEQUENCE {
+	iPsecTLA					TransportLayerAddress		OPTIONAL,
+	gTPTLAa						ENBX2GTPTLAs				OPTIONAL,
+	iE-Extensions				ProtocolExtensionContainer { { ENBX2ExtTLA-ExtIEs} } OPTIONAL,
+	...
+}
+
+ENBX2ExtTLA-ExtIEs S1AP-PROTOCOL-EXTENSION ::= {
+	...
+}
+
+ENBX2GTPTLAs ::= SEQUENCE (SIZE(1.. maxnoofeNBX2GTPTLAs)) OF TransportLayerAddress
+
+ENBIndirectX2TransportLayerAddresses ::= SEQUENCE (SIZE(1..maxnoofeNBX2TLAs)) OF TransportLayerAddress
+
+-- Y
+-- Z
+
+END
+
+
+
+-- **************************************************************
+--
+-- Common definitions
+--
+-- **************************************************************
+
+S1AP-CommonDataTypes {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) s1ap (1) version1 (1) s1ap-CommonDataTypes (3) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+Criticality		::= ENUMERATED { reject, ignore, notify }
+
+Presence		::= ENUMERATED { optional, conditional, mandatory }
+
+PrivateIE-ID	::= CHOICE {
+	local				INTEGER (0..65535),
+	global				OBJECT IDENTIFIER
+}
+
+ProcedureCode		::= INTEGER (0..255)
+
+ProtocolExtensionID	::= INTEGER (0..65535)
+
+ProtocolIE-ID		::= INTEGER (0..65535)
+
+TriggeringMessage	::= ENUMERATED { initiating-message, successful-outcome, unsuccessfull-outcome }
+
+END
+
+
+-- **************************************************************
+--
+-- Constant definitions
+--
+-- **************************************************************
+
+S1AP-Constants { 
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) s1ap (1) version1 (1) s1ap-Constants (4) } 
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- IE parameter types from other modules.
+--
+-- **************************************************************
+
+IMPORTS
+	ProcedureCode,
+	ProtocolIE-ID
+
+FROM S1AP-CommonDataTypes;
+
+
+-- **************************************************************
+--
+-- Elementary Procedures
+--
+-- **************************************************************
+
+id-HandoverPreparation						ProcedureCode ::= 0
+id-HandoverResourceAllocation				ProcedureCode ::= 1
+id-HandoverNotification						ProcedureCode ::= 2
+id-PathSwitchRequest						ProcedureCode ::= 3
+id-HandoverCancel							ProcedureCode ::= 4
+id-E-RABSetup								ProcedureCode ::= 5
+id-E-RABModify								ProcedureCode ::= 6
+id-E-RABRelease								ProcedureCode ::= 7
+id-E-RABReleaseIndication					ProcedureCode ::= 8
+id-InitialContextSetup						ProcedureCode ::= 9
+id-Paging									ProcedureCode ::= 10
+id-downlinkNASTransport						ProcedureCode ::= 11
+id-initialUEMessage							ProcedureCode ::= 12
+id-uplinkNASTransport						ProcedureCode ::= 13
+id-Reset									ProcedureCode ::= 14
+id-ErrorIndication							ProcedureCode ::= 15
+id-NASNonDeliveryIndication					ProcedureCode ::= 16
+id-S1Setup									ProcedureCode ::= 17
+id-UEContextReleaseRequest					ProcedureCode ::= 18
+id-DownlinkS1cdma2000tunnelling				ProcedureCode ::= 19
+id-UplinkS1cdma2000tunnelling				ProcedureCode ::= 20
+id-UEContextModification					ProcedureCode ::= 21
+id-UECapabilityInfoIndication				ProcedureCode ::= 22
+id-UEContextRelease							ProcedureCode ::= 23
+id-eNBStatusTransfer						ProcedureCode ::= 24
+id-MMEStatusTransfer						ProcedureCode ::= 25
+id-DeactivateTrace							ProcedureCode ::= 26
+id-TraceStart								ProcedureCode ::= 27
+id-TraceFailureIndication					ProcedureCode ::= 28
+id-ENBConfigurationUpdate					ProcedureCode ::= 29
+id-MMEConfigurationUpdate					ProcedureCode ::= 30
+id-LocationReportingControl					ProcedureCode ::= 31
+id-LocationReportingFailureIndication		ProcedureCode ::= 32
+id-LocationReport							ProcedureCode ::= 33
+id-OverloadStart							ProcedureCode ::= 34
+id-OverloadStop								ProcedureCode ::= 35
+id-WriteReplaceWarning						ProcedureCode ::= 36
+id-eNBDirectInformationTransfer				ProcedureCode ::= 37
+id-MMEDirectInformationTransfer				ProcedureCode ::= 38
+id-PrivateMessage							ProcedureCode ::= 39
+id-eNBConfigurationTransfer					ProcedureCode ::= 40
+id-MMEConfigurationTransfer					ProcedureCode ::= 41
+id-CellTrafficTrace							ProcedureCode ::= 42
+id-Kill										ProcedureCode ::= 43
+id-downlinkUEAssociatedLPPaTransport		ProcedureCode ::= 44
+id-uplinkUEAssociatedLPPaTransport			ProcedureCode ::= 45
+id-downlinkNonUEAssociatedLPPaTransport		ProcedureCode ::= 46
+id-uplinkNonUEAssociatedLPPaTransport		ProcedureCode ::= 47
+id-UERadioCapabilityMatch					ProcedureCode ::= 48
+id-PWSRestartIndication						ProcedureCode ::= 49
+id-E-RABModificationIndication				ProcedureCode ::= 50
+id-PWSFailureIndication						ProcedureCode ::= 51
+id-RerouteNASRequest						ProcedureCode ::= 52
+id-UEContextModificationIndication			ProcedureCode ::= 53
+id-ConnectionEstablishmentIndication		ProcedureCode ::= 54
+id-UEContextSuspend							ProcedureCode ::= 55
+id-UEContextResume							ProcedureCode ::= 56
+id-NASDeliveryIndication					ProcedureCode ::= 57
+id-RetrieveUEInformation					ProcedureCode ::= 58
+id-UEInformationTransfer					ProcedureCode ::= 59
+id-eNBCPRelocationIndication				ProcedureCode ::= 60
+id-MMECPRelocationIndication				ProcedureCode ::= 61
+
+-- **************************************************************
+--
+-- Extension constants
+--
+-- **************************************************************
+
+maxPrivateIEs							INTEGER ::= 65535
+maxProtocolExtensions					INTEGER ::= 65535
+maxProtocolIEs							INTEGER ::= 65535
+-- **************************************************************
+--
+-- Lists
+--
+-- **************************************************************
+
+maxnoofCSGs								INTEGER ::= 256
+maxnoofE-RABs							INTEGER ::= 256
+maxnoofTAIs								INTEGER ::= 256
+maxnoofTACs								INTEGER ::= 256
+maxnoofErrors							INTEGER ::= 256
+maxnoofBPLMNs							INTEGER ::= 6
+maxnoofPLMNsPerMME						INTEGER ::= 32
+maxnoofEPLMNs							INTEGER ::= 15
+maxnoofEPLMNsPlusOne					INTEGER ::= 16
+maxnoofForbLACs							INTEGER ::= 4096
+maxnoofForbTACs							INTEGER ::= 4096
+maxnoofIndividualS1ConnectionsToReset	INTEGER ::= 256
+maxnoofCells							INTEGER ::= 16
+maxnoofCellsineNB						INTEGER ::= 256
+maxnoofTAIforWarning					INTEGER ::= 65535 
+maxnoofCellID							INTEGER ::= 65535 
+maxnoofDCNs								INTEGER ::= 32 
+maxnoofEmergencyAreaID					INTEGER ::= 65535 
+maxnoofCellinTAI						INTEGER ::= 65535 
+maxnoofCellinEAI						INTEGER ::= 65535 
+maxnoofeNBX2TLAs						INTEGER ::= 2
+maxnoofeNBX2ExtTLAs						INTEGER ::= 16
+maxnoofeNBX2GTPTLAs						INTEGER ::= 16
+maxnoofRATs								INTEGER ::= 8
+maxnoofGroupIDs							INTEGER ::= 65535
+maxnoofMMECs							INTEGER ::= 256
+maxnoofCellIDforMDT						INTEGER ::= 32
+maxnoofTAforMDT							INTEGER ::= 8
+maxnoofMDTPLMNs							INTEGER ::= 16
+maxnoofCellsforRestart					INTEGER ::= 256
+maxnoofRestartTAIs						INTEGER ::= 2048
+maxnoofRestartEmergencyAreaIDs			INTEGER ::= 256
+maxEARFCN								INTEGER ::= 262143
+maxnoofMBSFNAreaMDT						INTEGER ::= 8
+maxnoofRecommendedCells					INTEGER ::= 16
+maxnoofRecommendedENBs					INTEGER ::= 16
+
+-- **************************************************************
+--
+-- IEs
+--
+-- **************************************************************
+
+id-MME-UE-S1AP-ID									ProtocolIE-ID ::= 0
+id-HandoverType										ProtocolIE-ID ::= 1
+id-Cause											ProtocolIE-ID ::= 2
+id-SourceID											ProtocolIE-ID ::= 3
+id-TargetID											ProtocolIE-ID ::= 4
+id-eNB-UE-S1AP-ID									ProtocolIE-ID ::= 8
+id-E-RABSubjecttoDataForwardingList					ProtocolIE-ID ::= 12
+id-E-RABtoReleaseListHOCmd							ProtocolIE-ID ::= 13
+id-E-RABDataForwardingItem							ProtocolIE-ID ::= 14
+id-E-RABReleaseItemBearerRelComp					ProtocolIE-ID ::= 15
+id-E-RABToBeSetupListBearerSUReq					ProtocolIE-ID ::= 16
+id-E-RABToBeSetupItemBearerSUReq					ProtocolIE-ID ::= 17
+id-E-RABAdmittedList								ProtocolIE-ID ::= 18
+id-E-RABFailedToSetupListHOReqAck					ProtocolIE-ID ::= 19
+id-E-RABAdmittedItem								ProtocolIE-ID ::= 20
+id-E-RABFailedtoSetupItemHOReqAck					ProtocolIE-ID ::= 21
+id-E-RABToBeSwitchedDLList							ProtocolIE-ID ::= 22
+id-E-RABToBeSwitchedDLItem							ProtocolIE-ID ::= 23
+id-E-RABToBeSetupListCtxtSUReq						ProtocolIE-ID ::= 24
+id-TraceActivation									ProtocolIE-ID ::= 25
+id-NAS-PDU											ProtocolIE-ID ::= 26
+id-E-RABToBeSetupItemHOReq							ProtocolIE-ID ::= 27
+id-E-RABSetupListBearerSURes						ProtocolIE-ID ::= 28
+id-E-RABFailedToSetupListBearerSURes				ProtocolIE-ID ::= 29
+id-E-RABToBeModifiedListBearerModReq				ProtocolIE-ID ::= 30
+id-E-RABModifyListBearerModRes						ProtocolIE-ID ::= 31
+id-E-RABFailedToModifyList							ProtocolIE-ID ::= 32
+id-E-RABToBeReleasedList							ProtocolIE-ID ::= 33
+id-E-RABFailedToReleaseList							ProtocolIE-ID ::= 34
+id-E-RABItem										ProtocolIE-ID ::= 35
+id-E-RABToBeModifiedItemBearerModReq				ProtocolIE-ID ::= 36
+id-E-RABModifyItemBearerModRes						ProtocolIE-ID ::= 37
+id-E-RABReleaseItem									ProtocolIE-ID ::= 38
+id-E-RABSetupItemBearerSURes						ProtocolIE-ID ::= 39
+id-SecurityContext									ProtocolIE-ID ::= 40
+id-HandoverRestrictionList							ProtocolIE-ID ::= 41
+id-UEPagingID										ProtocolIE-ID ::= 43
+id-pagingDRX										ProtocolIE-ID ::= 44
+id-TAIList											ProtocolIE-ID ::= 46
+id-TAIItem											ProtocolIE-ID ::= 47
+id-E-RABFailedToSetupListCtxtSURes					ProtocolIE-ID ::= 48
+id-E-RABReleaseItemHOCmd							ProtocolIE-ID ::= 49
+id-E-RABSetupItemCtxtSURes							ProtocolIE-ID ::= 50
+id-E-RABSetupListCtxtSURes							ProtocolIE-ID ::= 51
+id-E-RABToBeSetupItemCtxtSUReq						ProtocolIE-ID ::= 52
+id-E-RABToBeSetupListHOReq							ProtocolIE-ID ::= 53
+id-GERANtoLTEHOInformationRes						ProtocolIE-ID ::= 55
+id-UTRANtoLTEHOInformationRes						ProtocolIE-ID ::= 57
+id-CriticalityDiagnostics 							ProtocolIE-ID ::= 58
+id-Global-ENB-ID									ProtocolIE-ID ::= 59
+id-eNBname											ProtocolIE-ID ::= 60
+id-MMEname											ProtocolIE-ID ::= 61
+id-ServedPLMNs										ProtocolIE-ID ::= 63
+id-SupportedTAs										ProtocolIE-ID ::= 64
+id-TimeToWait										ProtocolIE-ID ::= 65
+id-uEaggregateMaximumBitrate						ProtocolIE-ID ::= 66
+id-TAI												ProtocolIE-ID ::= 67
+id-E-RABReleaseListBearerRelComp					ProtocolIE-ID ::= 69
+id-cdma2000PDU										ProtocolIE-ID ::= 70
+id-cdma2000RATType									ProtocolIE-ID ::= 71
+id-cdma2000SectorID									ProtocolIE-ID ::= 72
+id-SecurityKey										ProtocolIE-ID ::= 73
+id-UERadioCapability								ProtocolIE-ID ::= 74
+id-GUMMEI-ID										ProtocolIE-ID ::= 75
+id-E-RABInformationListItem							ProtocolIE-ID ::= 78
+id-Direct-Forwarding-Path-Availability				ProtocolIE-ID ::= 79
+id-UEIdentityIndexValue								ProtocolIE-ID ::= 80
+id-cdma2000HOStatus									ProtocolIE-ID ::= 83
+id-cdma2000HORequiredIndication						ProtocolIE-ID ::= 84
+id-E-UTRAN-Trace-ID									ProtocolIE-ID ::= 86
+id-RelativeMMECapacity								ProtocolIE-ID ::= 87
+id-SourceMME-UE-S1AP-ID								ProtocolIE-ID ::= 88
+id-Bearers-SubjectToStatusTransfer-Item				ProtocolIE-ID ::= 89
+id-eNB-StatusTransfer-TransparentContainer			ProtocolIE-ID ::= 90
+id-UE-associatedLogicalS1-ConnectionItem			ProtocolIE-ID ::= 91
+id-ResetType										ProtocolIE-ID ::= 92
+id-UE-associatedLogicalS1-ConnectionListResAck		ProtocolIE-ID ::= 93
+id-E-RABToBeSwitchedULItem							ProtocolIE-ID ::= 94
+id-E-RABToBeSwitchedULList							ProtocolIE-ID ::= 95
+id-S-TMSI											ProtocolIE-ID ::= 96
+id-cdma2000OneXRAND									ProtocolIE-ID ::= 97
+id-RequestType										ProtocolIE-ID ::= 98
+id-UE-S1AP-IDs										ProtocolIE-ID ::= 99
+id-EUTRAN-CGI										ProtocolIE-ID ::= 100
+id-OverloadResponse									ProtocolIE-ID ::= 101
+id-cdma2000OneXSRVCCInfo							ProtocolIE-ID ::= 102
+id-E-RABFailedToBeReleasedList						ProtocolIE-ID ::= 103
+id-Source-ToTarget-TransparentContainer				ProtocolIE-ID ::= 104
+id-ServedGUMMEIs									ProtocolIE-ID ::= 105
+id-SubscriberProfileIDforRFP						ProtocolIE-ID ::= 106
+id-UESecurityCapabilities							ProtocolIE-ID ::= 107
+id-CSFallbackIndicator								ProtocolIE-ID ::= 108
+id-CNDomain											ProtocolIE-ID ::= 109
+id-E-RABReleasedList								ProtocolIE-ID ::= 110
+id-MessageIdentifier								ProtocolIE-ID ::= 111
+id-SerialNumber										ProtocolIE-ID ::= 112
+id-WarningAreaList									ProtocolIE-ID ::= 113
+id-RepetitionPeriod									ProtocolIE-ID ::= 114
+id-NumberofBroadcastRequest							ProtocolIE-ID ::= 115
+id-WarningType										ProtocolIE-ID ::= 116
+id-WarningSecurityInfo								ProtocolIE-ID ::= 117
+id-DataCodingScheme									ProtocolIE-ID ::= 118
+id-WarningMessageContents							ProtocolIE-ID ::= 119
+id-BroadcastCompletedAreaList						ProtocolIE-ID ::= 120
+id-Inter-SystemInformationTransferTypeEDT			ProtocolIE-ID ::= 121
+id-Inter-SystemInformationTransferTypeMDT			ProtocolIE-ID ::= 122
+id-Target-ToSource-TransparentContainer				ProtocolIE-ID ::= 123
+id-SRVCCOperationPossible							ProtocolIE-ID ::= 124
+id-SRVCCHOIndication								ProtocolIE-ID ::= 125
+id-NAS-DownlinkCount								ProtocolIE-ID ::= 126
+id-CSG-Id											ProtocolIE-ID ::= 127
+id-CSG-IdList										ProtocolIE-ID ::= 128
+id-SONConfigurationTransferECT						ProtocolIE-ID ::= 129
+id-SONConfigurationTransferMCT						ProtocolIE-ID ::= 130
+id-TraceCollectionEntityIPAddress					ProtocolIE-ID ::= 131
+id-MSClassmark2										ProtocolIE-ID ::= 132
+id-MSClassmark3										ProtocolIE-ID ::= 133
+id-RRC-Establishment-Cause							ProtocolIE-ID ::= 134
+id-NASSecurityParametersfromE-UTRAN					ProtocolIE-ID ::= 135
+id-NASSecurityParameterstoE-UTRAN					ProtocolIE-ID ::= 136
+id-DefaultPagingDRX									ProtocolIE-ID ::= 137
+id-Source-ToTarget-TransparentContainer-Secondary	ProtocolIE-ID ::= 138
+id-Target-ToSource-TransparentContainer-Secondary	ProtocolIE-ID ::= 139
+id-EUTRANRoundTripDelayEstimationInfo				ProtocolIE-ID ::= 140
+id-BroadcastCancelledAreaList						ProtocolIE-ID ::= 141
+id-ConcurrentWarningMessageIndicator				ProtocolIE-ID ::= 142
+id-Data-Forwarding-Not-Possible						ProtocolIE-ID ::= 143
+id-ExtendedRepetitionPeriod							ProtocolIE-ID ::= 144
+id-CellAccessMode									ProtocolIE-ID ::= 145
+id-CSGMembershipStatus 								ProtocolIE-ID ::= 146
+id-LPPa-PDU											ProtocolIE-ID ::= 147
+id-Routing-ID										ProtocolIE-ID ::= 148
+id-Time-Synchronisation-Info						ProtocolIE-ID ::= 149
+id-PS-ServiceNotAvailable							ProtocolIE-ID ::= 150
+id-PagingPriority									ProtocolIE-ID ::= 151
+id-x2TNLConfigurationInfo							ProtocolIE-ID ::= 152
+id-eNBX2ExtendedTransportLayerAddresses				ProtocolIE-ID ::= 153
+id-GUMMEIList										ProtocolIE-ID ::= 154
+id-GW-TransportLayerAddress							ProtocolIE-ID ::= 155
+id-Correlation-ID									ProtocolIE-ID ::= 156
+id-SourceMME-GUMMEI									ProtocolIE-ID ::= 157
+id-MME-UE-S1AP-ID-2									ProtocolIE-ID ::= 158
+id-RegisteredLAI									ProtocolIE-ID ::= 159
+id-RelayNode-Indicator								ProtocolIE-ID ::= 160
+id-TrafficLoadReductionIndication					ProtocolIE-ID ::= 161
+id-MDTConfiguration									ProtocolIE-ID ::= 162
+id-MMERelaySupportIndicator							ProtocolIE-ID ::= 163
+id-GWContextReleaseIndication						ProtocolIE-ID ::= 164
+id-ManagementBasedMDTAllowed						ProtocolIE-ID ::= 165
+id-PrivacyIndicator									ProtocolIE-ID ::= 166
+id-Time-UE-StayedInCell-EnhancedGranularity			ProtocolIE-ID ::= 167
+id-HO-Cause											ProtocolIE-ID ::= 168
+id-VoiceSupportMatchIndicator						ProtocolIE-ID ::= 169
+id-GUMMEIType										ProtocolIE-ID ::= 170
+id-M3Configuration									ProtocolIE-ID ::= 171
+id-M4Configuration									ProtocolIE-ID ::= 172
+id-M5Configuration									ProtocolIE-ID ::= 173
+id-MDT-Location-Info								ProtocolIE-ID ::= 174
+id-MobilityInformation								ProtocolIE-ID ::= 175
+id-Tunnel-Information-for-BBF						ProtocolIE-ID ::= 176
+id-ManagementBasedMDTPLMNList						ProtocolIE-ID ::= 177
+id-SignallingBasedMDTPLMNList						ProtocolIE-ID ::= 178
+id-ULCOUNTValueExtended								ProtocolIE-ID ::= 179
+id-DLCOUNTValueExtended								ProtocolIE-ID ::= 180
+id-ReceiveStatusOfULPDCPSDUsExtended				ProtocolIE-ID ::= 181
+id-ECGIListForRestart								ProtocolIE-ID ::= 182
+id-SIPTO-Correlation-ID								ProtocolIE-ID ::= 183
+id-SIPTO-L-GW-TransportLayerAddress					ProtocolIE-ID ::= 184
+id-TransportInformation								ProtocolIE-ID ::= 185
+id-LHN-ID											ProtocolIE-ID ::= 186
+id-AdditionalCSFallbackIndicator					ProtocolIE-ID ::= 187
+id-TAIListForRestart								ProtocolIE-ID ::= 188
+id-UserLocationInformation							ProtocolIE-ID ::= 189
+id-EmergencyAreaIDListForRestart					ProtocolIE-ID ::= 190
+id-KillAllWarningMessages							ProtocolIE-ID ::= 191
+id-Masked-IMEISV									ProtocolIE-ID ::= 192
+id-eNBIndirectX2TransportLayerAddresses				ProtocolIE-ID ::= 193
+id-uE-HistoryInformationFromTheUE					ProtocolIE-ID ::= 194
+id-ProSeAuthorized									ProtocolIE-ID ::= 195
+id-ExpectedUEBehaviour								ProtocolIE-ID ::= 196
+id-LoggedMBSFNMDT									ProtocolIE-ID ::= 197
+id-UERadioCapabilityForPaging						ProtocolIE-ID ::= 198
+id-E-RABToBeModifiedListBearerModInd				ProtocolIE-ID ::= 199
+id-E-RABToBeModifiedItemBearerModInd				ProtocolIE-ID ::= 200
+id-E-RABNotToBeModifiedListBearerModInd				ProtocolIE-ID ::= 201
+id-E-RABNotToBeModifiedItemBearerModInd				ProtocolIE-ID ::= 202
+id-E-RABModifyListBearerModConf						ProtocolIE-ID ::= 203
+id-E-RABModifyItemBearerModConf						ProtocolIE-ID ::= 204
+id-E-RABFailedToModifyListBearerModConf				ProtocolIE-ID ::= 205
+id-SON-Information-Report							ProtocolIE-ID ::= 206
+id-Muting-Availability-Indication					ProtocolIE-ID ::= 207
+id-Muting-Pattern-Information						ProtocolIE-ID ::= 208
+id-Synchronisation-Information						ProtocolIE-ID ::= 209
+id-E-RABToBeReleasedListBearerModConf				ProtocolIE-ID ::= 210
+id-AssistanceDataForPaging							ProtocolIE-ID ::= 211
+id-CellIdentifierAndCELevelForCECapableUEs			ProtocolIE-ID ::= 212
+id-InformationOnRecommendedCellsAndENBsForPaging	ProtocolIE-ID ::= 213
+id-RecommendedCellItem								ProtocolIE-ID ::= 214
+id-RecommendedENBItem								ProtocolIE-ID ::= 215
+id-ProSeUEtoNetworkRelaying							ProtocolIE-ID ::= 216
+id-ULCOUNTValuePDCP-SNlength18						ProtocolIE-ID ::= 217
+id-DLCOUNTValuePDCP-SNlength18						ProtocolIE-ID ::= 218
+id-ReceiveStatusOfULPDCPSDUsPDCP-SNlength18			ProtocolIE-ID ::= 219
+id-M6Configuration									ProtocolIE-ID ::= 220
+id-M7Configuration									ProtocolIE-ID ::= 221
+id-PWSfailedECGIList								ProtocolIE-ID ::= 222
+id-MME-Group-ID										ProtocolIE-ID ::= 223
+id-Additional-GUTI									ProtocolIE-ID ::= 224
+id-S1-Message										ProtocolIE-ID ::= 225
+id-CSGMembershipInfo								ProtocolIE-ID ::= 226
+id-Paging-eDRXInformation							ProtocolIE-ID ::= 227
+id-UE-RetentionInformation							ProtocolIE-ID ::= 228
+id-UE-Usage-Type									ProtocolIE-ID ::= 230
+id-extended-UEIdentityIndexValue					ProtocolIE-ID ::= 231
+id-RAT-Type											ProtocolIE-ID ::= 232
+id-BearerType										ProtocolIE-ID ::= 233
+id-NB-IoT-DefaultPagingDRX							ProtocolIE-ID ::= 234
+id-E-RABFailedToResumeListResumeReq					ProtocolIE-ID ::= 235
+id-E-RABFailedToResumeItemResumeReq					ProtocolIE-ID ::= 236
+id-E-RABFailedToResumeListResumeRes					ProtocolIE-ID ::= 237
+id-E-RABFailedToResumeItemResumeRes					ProtocolIE-ID ::= 238
+id-NB-IoT-Paging-eDRXInformation					ProtocolIE-ID ::= 239
+id-V2XServicesAuthorized							ProtocolIE-ID ::= 240
+id-UEUserPlaneCIoTSupportIndicator 					ProtocolIE-ID ::= 241
+id-CE-mode-B-SupportIndicator 						ProtocolIE-ID ::= 242
+id-SRVCCOperationNotPossible						ProtocolIE-ID ::= 243
+id-NB-IoT-UEIdentityIndexValue 						ProtocolIE-ID ::= 244
+id-RRC-Resume-Cause									ProtocolIE-ID ::= 245
+id-DCN-ID											ProtocolIE-ID ::= 246
+id-ServedDCNs					 					ProtocolIE-ID ::= 247
+id-UESidelinkAggregateMaximumBitrate 				ProtocolIE-ID ::= 248
+id-DLNASPDUDeliveryAckRequest						ProtocolIE-ID ::= 249
+id-Coverage-Level 									ProtocolIE-ID ::= 250
+id-EnhancedCoverageRestricted						ProtocolIE-ID ::= 251
+id-UE-Level-QoS-Parameters							ProtocolIE-ID ::= 252
+id-DL-CP-SecurityInformation						ProtocolIE-ID ::= 253
+id-UL-CP-SecurityInformation						ProtocolIE-ID ::= 254
+
+END
+
+
+-- **************************************************************
+--
+-- Container definitions
+--
+-- **************************************************************
+
+S1AP-Containers {
+itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 
+eps-Access (21) modules (3) s1ap (1) version1 (1) s1ap-Containers (5) }
+
+DEFINITIONS AUTOMATIC TAGS ::= 
+
+BEGIN
+
+-- **************************************************************
+--
+-- IE parameter types from other modules.
+--
+-- **************************************************************
+
+IMPORTS
+	Criticality,
+	Presence,
+	PrivateIE-ID,
+	ProtocolExtensionID,
+	ProtocolIE-ID
+FROM S1AP-CommonDataTypes
+
+	maxPrivateIEs,
+	maxProtocolExtensions,
+	maxProtocolIEs
+FROM S1AP-Constants;
+
+-- **************************************************************
+--
+-- Class Definition for Protocol IEs
+--
+-- **************************************************************
+
+S1AP-PROTOCOL-IES ::= CLASS {
+	&id				ProtocolIE-ID 					UNIQUE,
+	&criticality	Criticality,
+	&Value,
+	&presence		Presence
+}
+WITH SYNTAX {
+	ID				&id
+	CRITICALITY		&criticality
+	TYPE			&Value
+	PRESENCE		&presence
+}
+
+-- **************************************************************
+--
+-- Class Definition for Protocol IEs
+--
+-- **************************************************************
+
+S1AP-PROTOCOL-IES-PAIR ::= CLASS {
+	&id					ProtocolIE-ID 				UNIQUE,
+	&firstCriticality	Criticality,
+	&FirstValue,
+	&secondCriticality	Criticality,
+	&SecondValue,
+	&presence			Presence
+}
+WITH SYNTAX {
+	ID				&id
+	FIRST CRITICALITY		&firstCriticality
+	FIRST TYPE				&FirstValue
+	SECOND CRITICALITY		&secondCriticality
+	SECOND TYPE				&SecondValue
+	PRESENCE				&presence
+}
+
+-- **************************************************************
+--
+-- Class Definition for Protocol Extensions
+--
+-- **************************************************************
+
+S1AP-PROTOCOL-EXTENSION ::= CLASS {
+	&id				ProtocolExtensionID			UNIQUE,
+	&criticality	Criticality,
+	&Extension,
+	&presence		Presence
+}
+WITH SYNTAX {
+	ID				&id
+	CRITICALITY		&criticality
+	EXTENSION		&Extension
+	PRESENCE		&presence
+}
+
+-- **************************************************************
+--
+-- Class Definition for Private IEs
+--
+-- **************************************************************
+
+S1AP-PRIVATE-IES ::= CLASS {
+	&id				PrivateIE-ID,
+	&criticality	Criticality,
+	&Value,
+	&presence		Presence
+}
+WITH SYNTAX {
+	ID				&id
+	CRITICALITY		&criticality
+	TYPE			&Value
+	PRESENCE		&presence
+}
+
+-- **************************************************************
+--
+-- Container for Protocol IEs
+--
+-- **************************************************************
+
+ProtocolIE-Container {S1AP-PROTOCOL-IES : IEsSetParam} ::= 
+	SEQUENCE (SIZE (0..maxProtocolIEs)) OF
+	ProtocolIE-Field {{IEsSetParam}}
+
+ProtocolIE-SingleContainer {S1AP-PROTOCOL-IES : IEsSetParam} ::= 
+	ProtocolIE-Field {{IEsSetParam}}
+
+ProtocolIE-Field {S1AP-PROTOCOL-IES : IEsSetParam} ::= SEQUENCE {
+	id				S1AP-PROTOCOL-IES.&id				({IEsSetParam}),
+	criticality		S1AP-PROTOCOL-IES.&criticality		({IEsSetParam}{@id}),
+	value			S1AP-PROTOCOL-IES.&Value			({IEsSetParam}{@id})
+}
+
+-- **************************************************************
+--
+-- Container for Protocol IE Pairs
+--
+-- **************************************************************
+
+ProtocolIE-ContainerPair {S1AP-PROTOCOL-IES-PAIR : IEsSetParam} ::= 
+	SEQUENCE (SIZE (0..maxProtocolIEs)) OF
+	ProtocolIE-FieldPair {{IEsSetParam}}
+
+ProtocolIE-FieldPair {S1AP-PROTOCOL-IES-PAIR : IEsSetParam} ::= SEQUENCE {
+	id					S1AP-PROTOCOL-IES-PAIR.&id					({IEsSetParam}),
+	firstCriticality	S1AP-PROTOCOL-IES-PAIR.&firstCriticality	({IEsSetParam}{@id}),
+	firstValue			S1AP-PROTOCOL-IES-PAIR.&FirstValue			({IEsSetParam}{@id}),
+	secondCriticality	S1AP-PROTOCOL-IES-PAIR.&secondCriticality	({IEsSetParam}{@id}),
+	secondValue			S1AP-PROTOCOL-IES-PAIR.&SecondValue		({IEsSetParam}{@id})
+}
+
+-- **************************************************************
+--
+-- Container Lists for Protocol IE Containers
+--
+-- **************************************************************
+
+ProtocolIE-ContainerList {INTEGER : lowerBound, INTEGER : upperBound, S1AP-PROTOCOL-IES : IEsSetParam} ::=
+	SEQUENCE (SIZE (lowerBound..upperBound)) OF
+	ProtocolIE-SingleContainer {{IEsSetParam}}
+
+ProtocolIE-ContainerPairList {INTEGER : lowerBound, INTEGER : upperBound, S1AP-PROTOCOL-IES-PAIR : IEsSetParam} ::=
+	SEQUENCE (SIZE (lowerBound..upperBound)) OF
+	ProtocolIE-ContainerPair {{IEsSetParam}}
+
+-- **************************************************************
+--
+-- Container for Protocol Extensions
+--
+-- **************************************************************
+
+ProtocolExtensionContainer {S1AP-PROTOCOL-EXTENSION : ExtensionSetParam} ::= 
+	SEQUENCE (SIZE (1..maxProtocolExtensions)) OF
+	ProtocolExtensionField {{ExtensionSetParam}}
+
+ProtocolExtensionField {S1AP-PROTOCOL-EXTENSION : ExtensionSetParam} ::= SEQUENCE {
+	id					S1AP-PROTOCOL-EXTENSION.&id				({ExtensionSetParam}),
+	criticality			S1AP-PROTOCOL-EXTENSION.&criticality	({ExtensionSetParam}{@id}),
+	extensionValue		S1AP-PROTOCOL-EXTENSION.&Extension		({ExtensionSetParam}{@id})
+}
+
+-- **************************************************************
+--
+-- Container for Private IEs
+--
+-- **************************************************************
+
+PrivateIE-Container {S1AP-PRIVATE-IES : IEsSetParam } ::= 
+	SEQUENCE (SIZE (1.. maxPrivateIEs)) OF
+	PrivateIE-Field {{IEsSetParam}}
+
+PrivateIE-Field {S1AP-PRIVATE-IES : IEsSetParam} ::= SEQUENCE {
+	id					S1AP-PRIVATE-IES.&id				({IEsSetParam}),
+	criticality			S1AP-PRIVATE-IES.&criticality		({IEsSetParam}{@id}),
+	value				S1AP-PRIVATE-IES.&Value				({IEsSetParam}{@id})
+}
+
+END
diff --git a/openair3/S1AP/s1ap_common.c b/openair3/S1AP/s1ap_common.c
index 0bd132a228625f4371d97bd3ef9b2ffc1779ec85..7c4f970af2f18d61e626c4a7d8f70d607a8d663c 100644
--- a/openair3/S1AP/s1ap_common.c
+++ b/openair3/S1AP/s1ap_common.c
@@ -22,7 +22,7 @@
 /*! \file s1ap_common.c
  * \brief s1ap procedures for both eNB and MME
  * \author Sebastien ROUX and Navid Nikaein
- * \email navid.nikaein@eurecom.fr 
+ * \email navid.nikaein@eurecom.fr
  * \date 2012-2015
  * \version 0.1
  */
@@ -30,7 +30,7 @@
 #include <stdint.h>
 
 #include "s1ap_common.h"
-#include "S1AP-PDU.h"
+#include "S1AP_S1AP-PDU.h"
 
 int asn_debug = 0;
 int asn1_xer_print = 0;
@@ -53,144 +53,6 @@ inline void ASN_DEBUG(const char *fmt, ...)
 }
 #endif
 
-ssize_t s1ap_generate_initiating_message(
-  uint8_t               **buffer,
-  uint32_t               *length,
-  e_S1ap_ProcedureCode    procedureCode,
-  S1ap_Criticality_t      criticality,
-  asn_TYPE_descriptor_t  *td,
-  void                   *sptr)
+void s1ap_handle_criticality(S1AP_Criticality_t criticality)
 {
-  S1AP_PDU_t pdu;
-  ssize_t    encoded;
-
-  memset(&pdu, 0, sizeof(S1AP_PDU_t));
-
-  pdu.present = S1AP_PDU_PR_initiatingMessage;
-  pdu.choice.initiatingMessage.procedureCode = procedureCode;
-  pdu.choice.initiatingMessage.criticality   = criticality;
-  ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr);
-
-  if (asn1_xer_print) {
-    xer_fprint(stdout, &asn_DEF_S1AP_PDU, (void *)&pdu);
-  }
-
-  /* We can safely free list of IE from sptr */
-  ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
-
-  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_S1AP_PDU, 0, &pdu,
-                 (void **)buffer)) < 0) {
-    return -1;
-  }
-
-  *length = encoded;
-  return encoded;
-}
-
-ssize_t s1ap_generate_successfull_outcome(
-  uint8_t               **buffer,
-  uint32_t               *length,
-  e_S1ap_ProcedureCode         procedureCode,
-  S1ap_Criticality_t           criticality,
-  asn_TYPE_descriptor_t  *td,
-  void                   *sptr)
-{
-  S1AP_PDU_t pdu;
-  ssize_t    encoded;
-
-  memset(&pdu, 0, sizeof(S1AP_PDU_t));
-
-  pdu.present = S1AP_PDU_PR_successfulOutcome;
-  pdu.choice.successfulOutcome.procedureCode = procedureCode;
-  pdu.choice.successfulOutcome.criticality   = criticality;
-  ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
-
-  if (asn1_xer_print) {
-    xer_fprint(stdout, &asn_DEF_S1AP_PDU, (void *)&pdu);
-  }
-
-  /* We can safely free list of IE from sptr */
-  ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
-
-  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_S1AP_PDU, 0, &pdu,
-                 (void **)buffer)) < 0) {
-    return -1;
-  }
-
-  *length = encoded;
-
-  return encoded;
-}
-
-ssize_t s1ap_generate_unsuccessfull_outcome(
-  uint8_t               **buffer,
-  uint32_t               *length,
-  e_S1ap_ProcedureCode         procedureCode,
-  S1ap_Criticality_t           criticality,
-  asn_TYPE_descriptor_t  *td,
-  void                   *sptr)
-{
-  S1AP_PDU_t pdu;
-  ssize_t    encoded;
-
-  memset(&pdu, 0, sizeof(S1AP_PDU_t));
-
-  pdu.present = S1AP_PDU_PR_unsuccessfulOutcome;
-  pdu.choice.successfulOutcome.procedureCode = procedureCode;
-  pdu.choice.successfulOutcome.criticality   = criticality;
-  ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
-
-  if (asn1_xer_print) {
-    xer_fprint(stdout, &asn_DEF_S1AP_PDU, (void *)&pdu);
-  }
-
-  /* We can safely free list of IE from sptr */
-  ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
-
-  if ((encoded = aper_encode_to_new_buffer(&asn_DEF_S1AP_PDU, 0, &pdu,
-                 (void **)buffer)) < 0) {
-    return -1;
-  }
-
-  *length = encoded;
-
-  return encoded;
-}
-
-S1ap_IE_t *s1ap_new_ie(
-  S1ap_ProtocolIE_ID_t   id,
-  S1ap_Criticality_t     criticality,
-  asn_TYPE_descriptor_t *type,
-  void                  *sptr)
-{
-  S1ap_IE_t *buff;
-
-  if ((buff = malloc(sizeof(S1ap_IE_t))) == NULL) {
-    // Possible error on malloc
-    return NULL;
-  }
-
-  memset((void *)buff, 0, sizeof(S1ap_IE_t));
-
-  buff->id = id;
-  buff->criticality = criticality;
-
-  if (ANY_fromType_aper(&buff->value, type, sptr) < 0) {
-    fprintf(stderr, "Encoding of %s failed\n", type->name);
-    free(buff);
-    return NULL;
-  }
-
-  if (asn1_xer_print)
-    if (xer_fprint(stdout, &asn_DEF_S1ap_IE, buff) < 0) {
-      free(buff);
-      return NULL;
-    }
-
-  return buff;
-}
-
-void s1ap_handle_criticality(S1ap_Criticality_t criticality)
-{
-
 }
diff --git a/openair3/S1AP/s1ap_common.h b/openair3/S1AP/s1ap_common.h
index 003bdd2d62345371bf57fb520bf4ce545330bafb..09e8de0a05ceac208464a5593af3c1534d5d93b3 100644
--- a/openair3/S1AP/s1ap_common.h
+++ b/openair3/S1AP/s1ap_common.h
@@ -39,343 +39,19 @@ extern int asn_debug;
 inline void ASN_DEBUG(const char *fmt, ...);
 #endif
 
-#include "S1ap-Criticality.h"
-#include "S1ap-Presence.h"
-#include "S1ap-PrivateIE-ID.h"
-#include "S1ap-ProcedureCode.h"
-#include "S1ap-ProtocolExtensionID.h"
-#include "S1ap-ProtocolIE-ID.h"
-#include "S1ap-TriggeringMessage.h"
-#include "S1ap-AllocationAndRetentionPriority.h"
-#include "S1ap-Bearers-SubjectToStatusTransfer-List.h"
-#include "S1ap-Bearers-SubjectToStatusTransfer-Item.h"
-#include "S1ap-BitRate.h"
-#include "S1ap-BPLMNs.h"
-#include "S1ap-BroadcastCompletedAreaList.h"
-#include "S1ap-Cause.h"
-#include "S1ap-CauseMisc.h"
-#include "S1ap-CauseProtocol.h"
-#include "S1ap-CauseRadioNetwork.h"
-#include "S1ap-CauseTransport.h"
-#include "S1ap-CauseNas.h"
-#include "S1ap-CellIdentity.h"
-#include "S1ap-CellID-Broadcast.h"
-#include "S1ap-CellID-Broadcast-Item.h"
-#include "S1ap-Cdma2000PDU.h"
-#include "S1ap-Cdma2000RATType.h"
-#include "S1ap-Cdma2000SectorID.h"
-#include "S1ap-Cdma2000HOStatus.h"
-#include "S1ap-Cdma2000HORequiredIndication.h"
-#include "S1ap-Cdma2000OneXSRVCCInfo.h"
-#include "S1ap-Cdma2000OneXMEID.h"
-#include "S1ap-Cdma2000OneXMSI.h"
-#include "S1ap-Cdma2000OneXPilot.h"
-#include "S1ap-Cdma2000OneXRAND.h"
-#include "S1ap-Cell-Size.h"
-#include "S1ap-CellType.h"
-#include "S1ap-CGI.h"
-#include "S1ap-CI.h"
-#include "S1ap-CNDomain.h"
-#include "S1ap-CSFallbackIndicator.h"
-#include "S1ap-CSG-Id.h"
-#include "S1ap-CSG-IdList.h"
-#include "S1ap-CSG-IdList-Item.h"
-#include "S1ap-COUNTvalue.h"
-#include "S1ap-DataCodingScheme.h"
-#include "S1ap-DL-Forwarding.h"
-#include "S1ap-Direct-Forwarding-Path-Availability.h"
-#include "S1ap-ECGIList.h"
-#include "S1ap-EmergencyAreaIDList.h"
-#include "S1ap-EmergencyAreaID.h"
-#include "S1ap-EmergencyAreaID-Broadcast.h"
-#include "S1ap-EmergencyAreaID-Broadcast-Item.h"
-#include "S1ap-CompletedCellinEAI.h"
-#include "S1ap-CompletedCellinEAI-Item.h"
-#include "S1ap-ENB-ID.h"
-#include "S1ap-GERAN-Cell-ID.h"
-#include "S1ap-Global-ENB-ID.h"
-#include "S1ap-ENB-StatusTransfer-TransparentContainer.h"
-#include "S1ap-ENBname.h"
-#include "S1ap-ENBX2TLAs.h"
-#include "S1ap-EncryptionAlgorithms.h"
-#include "S1ap-EPLMNs.h"
-#include "S1ap-EventType.h"
-#include "S1ap-E-RAB-ID.h"
-#include "S1ap-E-RABInformationList.h"
-#include "S1ap-E-RABInformationListItem.h"
-#include "S1ap-E-RABList.h"
-#include "S1ap-E-RABItem.h"
-#include "S1ap-E-RABLevelQoSParameters.h"
-#include "S1ap-EUTRAN-CGI.h"
-#include "S1ap-ExtendedRNC-ID.h"
-#include "S1ap-ForbiddenInterRATs.h"
-#include "S1ap-ForbiddenTAs.h"
-#include "S1ap-ForbiddenTAs-Item.h"
-#include "S1ap-ForbiddenTACs.h"
-#include "S1ap-ForbiddenLAs.h"
-#include "S1ap-ForbiddenLAs-Item.h"
-#include "S1ap-ForbiddenLACs.h"
-#include "S1ap-GBR-QosInformation.h"
-#include "S1ap-GTP-TEID.h"
-#include "S1ap-GUMMEI.h"
-#include "S1ap-HandoverRestrictionList.h"
-#include "S1ap-HandoverType.h"
-#include "S1ap-HFN.h"
-#include "S1ap-IMSI.h"
-#include "S1ap-IntegrityProtectionAlgorithms.h"
-#include "S1ap-InterfacesToTrace.h"
-#include "S1ap-LAC.h"
-#include "S1ap-LAI.h"
-#include "S1ap-LastVisitedCell-Item.h"
-#include "S1ap-LastVisitedEUTRANCellInformation.h"
-#include "S1ap-LastVisitedUTRANCellInformation.h"
-#include "S1ap-LastVisitedGERANCellInformation.h"
-#include "S1ap-L3-Information.h"
-#include "S1ap-MessageIdentifier.h"
-#include "S1ap-MMEname.h"
-#include "S1ap-MME-Group-ID.h"
-#include "S1ap-MME-Code.h"
-#include "S1ap-M-TMSI.h"
-#include "S1ap-MSClassmark2.h"
-#include "S1ap-MSClassmark3.h"
-#include "S1ap-NAS-PDU.h"
-#include "S1ap-NASSecurityParametersfromE-UTRAN.h"
-#include "S1ap-NASSecurityParameterstoE-UTRAN.h"
-#include "S1ap-NumberofBroadcastRequest.h"
-#include "S1ap-NumberOfBroadcasts.h"
-#include "S1ap-OldBSS-ToNewBSS-Information.h"
-#include "S1ap-OverloadAction.h"
-#include "S1ap-OverloadResponse.h"
-#include "S1ap-PagingDRX.h"
-#include "S1ap-PDCP-SN.h"
-#include "S1ap-PLMNidentity.h"
-#include "S1ap-Pre-emptionCapability.h"
-#include "S1ap-Pre-emptionVulnerability.h"
-#include "S1ap-PriorityLevel.h"
-#include "S1ap-QCI.h"
-#include "S1ap-ReceiveStatusofULPDCPSDUs.h"
-#include "S1ap-RelativeMMECapacity.h"
-#include "S1ap-RAC.h"
-#include "S1ap-RequestType.h"
-#include "S1ap-RIMTransfer.h"
-#include "S1ap-RIMInformation.h"
-#include "S1ap-RIMRoutingAddress.h"
-#include "S1ap-ReportArea.h"
-#include "S1ap-RepetitionPeriod.h"
-#include "S1ap-RNC-ID.h"
-#include "S1ap-RRC-Container.h"
-#include "S1ap-RRC-Establishment-Cause.h"
-#include "S1ap-SecurityKey.h"
-#include "S1ap-SecurityContext.h"
-#include "S1ap-SerialNumber.h"
-#include "S1ap-SONInformation.h"
-#include "S1ap-SONInformationRequest.h"
-#include "S1ap-SONInformationReply.h"
-#include "S1ap-SONConfigurationTransfer.h"
-#include "S1ap-Source-ToTarget-TransparentContainer.h"
-#include "S1ap-SourceBSS-ToTargetBSS-TransparentContainer.h"
-#include "S1ap-SourceeNB-ID.h"
-#include "S1ap-SRVCCOperationPossible.h"
-#include "S1ap-SRVCCHOIndication.h"
-#include "S1ap-SourceeNB-ToTargeteNB-TransparentContainer.h"
-#include "S1ap-SourceRNC-ToTargetRNC-TransparentContainer.h"
-#include "S1ap-ServedGUMMEIs.h"
-#include "S1ap-ServedGUMMEIsItem.h"
-#include "S1ap-ServedGroupIDs.h"
-#include "S1ap-ServedMMECs.h"
-#include "S1ap-ServedPLMNs.h"
-#include "S1ap-SubscriberProfileIDforRFP.h"
-#include "S1ap-SupportedTAs.h"
-#include "S1ap-SupportedTAs-Item.h"
-#include "S1ap-S-TMSI.h"
-#include "S1ap-TAC.h"
-#include "S1ap-TAIItem.h"
-#include "S1ap-TAIList.h"
-#include "S1ap-TAIListforWarning.h"
-#include "S1ap-TAI.h"
-#include "S1ap-TAI-Broadcast.h"
-#include "S1ap-TAI-Broadcast-Item.h"
-#include "S1ap-CompletedCellinTAI.h"
-#include "S1ap-CompletedCellinTAI-Item.h"
-#include "S1ap-TargetID.h"
-#include "S1ap-TargeteNB-ID.h"
-#include "S1ap-TargetRNC-ID.h"
-#include "S1ap-TargeteNB-ToSourceeNB-TransparentContainer.h"
-#include "S1ap-Target-ToSource-TransparentContainer.h"
-#include "S1ap-TargetRNC-ToSourceRNC-TransparentContainer.h"
-#include "S1ap-TargetBSS-ToSourceBSS-TransparentContainer.h"
-#include "S1ap-TimeToWait.h"
-#include "S1ap-Time-UE-StayedInCell.h"
-#include "S1ap-TransportLayerAddress.h"
-#include "S1ap-TraceActivation.h"
-#include "S1ap-TraceDepth.h"
-#include "S1ap-E-UTRAN-Trace-ID.h"
-#include "S1ap-TypeOfError.h"
-#include "S1ap-UEAggregateMaximumBitrate.h"
-#include "S1ap-UE-associatedLogicalS1-ConnectionItem.h"
-#include "S1ap-UEIdentityIndexValue.h"
-#include "S1ap-UE-HistoryInformation.h"
-#include "S1ap-UEPagingID.h"
-#include "S1ap-UERadioCapability.h"
-#include "S1ap-UESecurityCapabilities.h"
-#include "S1ap-WarningAreaList.h"
-#include "S1ap-WarningType.h"
-#include "S1ap-WarningSecurityInfo.h"
-#include "S1ap-WarningMessageContents.h"
-#include "S1ap-X2TNLConfigurationInfo.h"
-#include "S1ap-CriticalityDiagnostics.h"
-#include "S1ap-CriticalityDiagnostics-IE-List.h"
-#include "S1ap-CriticalityDiagnostics-IE-Item.h"
-#include "S1ap-ResetType.h"
-#include "S1ap-Inter-SystemInformationTransferType.h"
-#include "S1ap-UE-S1AP-IDs.h"
-#include "S1ap-UE-S1AP-ID-pair.h"
-#include "S1ap-MME-UE-S1AP-ID.h"
-#include "S1ap-ENB-UE-S1AP-ID.h"
-#include "S1ap-TBCD-STRING.h"
-#include "S1ap-InitiatingMessage.h"
-#include "S1ap-SuccessfulOutcome.h"
-#include "S1ap-UnsuccessfulOutcome.h"
-#include "S1ap-HandoverRequired.h"
-#include "S1ap-HandoverCommand.h"
-#include "S1ap-HandoverNotify.h"
-#include "S1ap-HandoverPreparationFailure.h"
-#include "S1ap-HandoverRequest.h"
-#include "S1ap-HandoverRequestAcknowledge.h"
-#include "S1ap-HandoverFailure.h"
-#include "S1ap-PathSwitchRequest.h"
-#include "S1ap-PathSwitchRequestAcknowledge.h"
-#include "S1ap-PathSwitchRequestFailure.h"
-#include "S1ap-E-RABSetupRequest.h"
-#include "S1ap-E-RABSetupResponse.h"
-#include "S1ap-E-RABModifyRequest.h"
-#include "S1ap-E-RABModifyResponse.h"
-#include "S1ap-E-RABReleaseIndication.h"
-#include "S1ap-E-RABReleaseCommand.h"
-#include "S1ap-E-RABReleaseResponse.h"
-#include "S1ap-InitialContextSetupRequest.h"
-#include "S1ap-InitialContextSetupResponse.h"
-#include "S1ap-InitialContextSetupFailure.h"
-#include "S1ap-UEContextReleaseRequest.h"
-#include "S1ap-Paging.h"
-#include "S1ap-DownlinkNASTransport.h"
-#include "S1ap-InitialUEMessage.h"
-#include "S1ap-UplinkNASTransport.h"
-#include "S1ap-NASNonDeliveryIndication.h"
-#include "S1ap-HandoverCancel.h"
-#include "S1ap-HandoverCancelAcknowledge.h"
-#include "S1ap-Reset.h"
-#include "S1ap-ResetAcknowledge.h"
-#include "S1ap-S1SetupResponse.h"
-#include "S1ap-S1SetupRequest.h"
-#include "S1ap-S1SetupFailure.h"
-#include "S1ap-ErrorIndication.h"
-#include "S1ap-ENBConfigurationUpdate.h"
-#include "S1ap-ENBConfigurationUpdateAcknowledge.h"
-#include "S1ap-ENBConfigurationUpdateFailure.h"
-#include "S1ap-MMEConfigurationUpdate.h"
-#include "S1ap-MMEConfigurationUpdateAcknowledge.h"
-#include "S1ap-MMEConfigurationUpdateFailure.h"
-#include "S1ap-DownlinkS1cdma2000tunneling.h"
-#include "S1ap-UplinkS1cdma2000tunneling.h"
-#include "S1ap-UEContextModificationRequest.h"
-#include "S1ap-UEContextModificationResponse.h"
-#include "S1ap-UEContextModificationFailure.h"
-#include "S1ap-UECapabilityInfoIndication.h"
-#include "S1ap-UEContextReleaseCommand.h"
-#include "S1ap-UEContextReleaseComplete.h"
-#include "S1ap-ENBStatusTransfer.h"
-#include "S1ap-MMEStatusTransfer.h"
-#include "S1ap-DeactivateTrace.h"
-#include "S1ap-TraceStart.h"
-#include "S1ap-TraceFailureIndication.h"
-#include "S1ap-CellTrafficTrace.h"
-#include "S1ap-LocationReportingControl.h"
-#include "S1ap-LocationReportingFailureIndication.h"
-#include "S1ap-LocationReport.h"
-#include "S1ap-OverloadStart.h"
-#include "S1ap-OverloadStop.h"
-#include "S1ap-WriteReplaceWarningRequest.h"
-#include "S1ap-WriteReplaceWarningResponse.h"
-#include "S1ap-ENBDirectInformationTransfer.h"
-#include "S1ap-MMEDirectInformationTransfer.h"
-#include "S1ap-ENBConfigurationTransfer.h"
-#include "S1ap-MMEConfigurationTransfer.h"
-#include "S1ap-PrivateMessage.h"
-#include "S1ap-E-RABReleaseItemBearerRelComp.h"
-#include "S1ap-E-RABToBeSwitchedDLList.h"
-#include "S1ap-E-RABToBeSwitchedDLItem.h"
-#include "S1ap-E-RABToBeSwitchedULList.h"
-#include "S1ap-E-RABToBeSwitchedULItem.h"
-#include "S1ap-E-RABToBeSetupListBearerSUReq.h"
-#include "S1ap-E-RABToBeSetupItemBearerSUReq.h"
-#include "S1ap-E-RABDataForwardingList.h"
-#include "S1ap-E-RABDataForwardingItem.h"
-#include "S1ap-E-RABToBeSetupListHOReq.h"
-#include "S1ap-E-RABToBeSetupItemHOReq.h"
-#include "S1ap-E-RABAdmittedList.h"
-#include "S1ap-E-RABAdmittedItem.h"
-#include "S1ap-E-RABFailedToSetupListHOReqAck.h"
-#include "S1ap-E-RABToBeSetupItemCtxtSUReq.h"
-#include "S1ap-E-RABToBeSetupListCtxtSUReq.h"
-#include "S1ap-E-RABSetupItemBearerSURes.h"
-#include "S1ap-E-RABSetupListBearerSURes.h"
-#include "S1ap-E-RABSetupItemCtxtSURes.h"
-#include "S1ap-E-RABSetupListCtxtSURes.h"
-#include "S1ap-E-RABReleaseListBearerRelComp.h"
-#include "S1ap-E-RABModifyItemBearerModRes.h"
-#include "S1ap-E-RABModifyListBearerModRes.h"
-#include "S1ap-E-RABFailedToSetupItemHOReqAck.h"
-#include "S1ap-E-RABFailedToSetupListHOReqAck.h"
-#include "S1ap-E-RABToBeModifiedItemBearerModReq.h"
-#include "S1ap-E-RABToBeModifiedListBearerModReq.h"
-#include "S1ap-UE-associatedLogicalS1-ConnectionListResAck.h"
-#include "S1ap-IE.h"
-#include "S1AP-PDU.h"
-
-#if defined (UPDATE_RELEASE_9)
-# include "S1ap-BroadcastCancelledAreaList.h"
-# include "S1ap-CancelledCellinEAI.h"
-# include "S1ap-CancelledCellinEAI-Item.h"
-# include "S1ap-CancelledCellinTAI.h"
-# include "S1ap-CancelledCellinTAI-Item.h"
-# include "S1ap-CellAccessMode.h"
-# include "S1ap-CellID-Cancelled.h"
-# include "S1ap-CellID-Cancelled-Item.h"
-# include "S1ap-ConcurrentWarningMessageIndicator.h"
-# include "S1ap-CSGMembershipStatus.h"
-# include "S1ap-Data-Forwarding-Not-Possible.h"
-# include "S1ap-EmergencyAreaID-Cancelled.h"
-# include "S1ap-EmergencyAreaID-Cancelled-Item.h"
-# include "S1ap-E-RABList.h"
-# include "S1ap-EUTRANRoundTripDelayEstimationInfo.h"
-# include "S1ap-ExtendedRepetitionPeriod.h"
-# include "S1ap-LPPa-PDU.h"
-# include "S1ap-PS-ServiceNotAvailable.h"
-# include "S1ap-Routing-ID.h"
-# include "S1ap-StratumLevel.h"
-# include "S1ap-SynchronizationStatus.h"
-# include "S1ap-TimeSynchronizationInfo.h"
-# include "S1ap-TAI-Cancelled.h"
-# include "S1ap-TAI-Cancelled-Item.h"
-# include "S1ap-KillRequest.h"
-# include "S1ap-KillResponse.h"
-# include "S1ap-DownlinkUEAssociatedLPPaTransport.h"
-# include "S1ap-UplinkUEAssociatedLPPaTransport.h"
-# include "S1ap-DownlinkNonUEAssociatedLPPaTransport.h"
-# include "S1ap-UplinkNonUEAssociatedLPPaTransport.h"
-#endif /* (UPDATE_RELEASE_9) */
-
-#if defined(UPDATE_RELEASE_10)
-# include "S1ap-PagingPriority.h"
-# include "S1ap-RelayNode-Indicator.h"
-# include "S1ap-GWContextReleaseIndication.h"
-# include "S1ap-MMERelaySupportIndicator.h"
-# include "S1ap-ManagementBasedMDTAllowed.h"
-# include "S1ap-PrivacyIndicator.h"
-# include "S1ap-TrafficLoadReductionIndication.h"
-# include "S1ap-GUMMEIList.h"
-#endif /* (UPDATE_RELEASE_10) */
+#include "S1AP_ProtocolIE-Field.h"
+#include "S1AP_S1AP-PDU.h"
+#include "S1AP_InitiatingMessage.h"
+#include "S1AP_SuccessfulOutcome.h"
+#include "S1AP_UnsuccessfulOutcome.h"
+#include "S1AP_ProtocolIE-Field.h"
+#include "S1AP_ProtocolIE-FieldPair.h"
+#include "S1AP_ProtocolIE-ContainerPair.h"
+#include "S1AP_ProtocolExtensionField.h"
+#include "S1AP_ProtocolExtensionContainer.h"
+#include "S1AP_asn_constant.h"
+#include "S1AP_SupportedTAs-Item.h"
+#include "S1AP_ServedGUMMEIsItem.h"
 
 /* Checking version of ASN1C compiler */
 #if (ASN1C_ENVIRONMENT_VERSION < ASN1C_MINIMUM_VERSION)
@@ -411,84 +87,34 @@ extern int asn1_xer_print;
 # define S1AP_DEBUG(x, args...) do { fprintf(stdout, "[S1AP][D]"x, ##args); } while(0)
 #endif
 
-//Forward declaration
-struct s1ap_message_s;
+
+#define S1AP_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID, mandatory) \
+  do {\
+    IE_TYPE **ptr; \
+    ie = NULL; \
+    for (ptr = container->protocolIEs.list.array; \
+         ptr < &container->protocolIEs.list.array[container->protocolIEs.list.count]; \
+         ptr++) { \
+      if((*ptr)->id == IE_ID) { \
+        ie = *ptr; \
+        break; \
+      } \
+    } \
+    if (mandatory) DevAssert(ie != NULL); \
+  } while(0)
 
 /** \brief Function callback prototype.
  **/
 typedef int (*s1ap_message_decoded_callback)(
-  uint32_t               assoc_id,
-  uint32_t               stream,
-  struct s1ap_message_s *message_p
+  uint32_t         assoc_id,
+  uint32_t         stream,
+  S1AP_S1AP_PDU_t *pdu
 );
 
-/** \brief Encode a successfull outcome message
- \param buffer pointer to buffer in which data will be encoded
- \param length pointer to the length of buffer
- \param procedureCode Procedure code for the message
- \param criticality Criticality of the message
- \param td ASN1C type descriptor of the sptr
- \param sptr Deferenced pointer to the structure to encode
- @returns size in bytes encded on success or 0 on failure
- **/
-ssize_t s1ap_generate_successfull_outcome(
-  uint8_t               **buffer,
-  uint32_t               *length,
-  e_S1ap_ProcedureCode    procedureCode,
-  S1ap_Criticality_t      criticality,
-  asn_TYPE_descriptor_t  *td,
-  void                   *sptr);
-
-/** \brief Encode an initiating message
- \param buffer pointer to buffer in which data will be encoded
- \param length pointer to the length of buffer
- \param procedureCode Procedure code for the message
- \param criticality Criticality of the message
- \param td ASN1C type descriptor of the sptr
- \param sptr Deferenced pointer to the structure to encode
- @returns size in bytes encded on success or 0 on failure
- **/
-ssize_t s1ap_generate_initiating_message(
-  uint8_t               **buffer,
-  uint32_t               *length,
-  e_S1ap_ProcedureCode    procedureCode,
-  S1ap_Criticality_t      criticality,
-  asn_TYPE_descriptor_t  *td,
-  void                   *sptr);
-
-/** \brief Encode an unsuccessfull outcome message
- \param buffer pointer to buffer in which data will be encoded
- \param length pointer to the length of buffer
- \param procedureCode Procedure code for the message
- \param criticality Criticality of the message
- \param td ASN1C type descriptor of the sptr
- \param sptr Deferenced pointer to the structure to encode
- @returns size in bytes encded on success or 0 on failure
- **/
-ssize_t s1ap_generate_unsuccessfull_outcome(
-  uint8_t               **buffer,
-  uint32_t               *length,
-  e_S1ap_ProcedureCode    procedureCode,
-  S1ap_Criticality_t      criticality,
-  asn_TYPE_descriptor_t  *td,
-  void                   *sptr);
-
-/** \brief Generate a new IE
- \param id Protocol ie id of the IE
- \param criticality Criticality of the IE
- \param type ASN1 type descriptor of the IE value
- \param sptr Structure to be encoded in the value field
- @returns a pointer to the newly created IE structure or NULL in case of failure
- **/
-S1ap_IE_t *s1ap_new_ie(S1ap_ProtocolIE_ID_t   id,
-                       S1ap_Criticality_t     criticality,
-                       asn_TYPE_descriptor_t *type,
-                       void                  *sptr);
-
 /** \brief Handle criticality
  \param criticality Criticality of the IE
  @returns void
  **/
-void s1ap_handle_criticality(S1ap_Criticality_t criticality);
+void s1ap_handle_criticality(S1AP_Criticality_t criticality);
 
 #endif /* S1AP_COMMON_H_ */
diff --git a/openair3/S1AP/s1ap_eNB.c b/openair3/S1AP/s1ap_eNB.c
index 8085c239c304d85cdefeb6671fe57b3e2561c18c..548603bee7a6ba389fe369b4ef5b0f6ba8db6e47 100644
--- a/openair3/S1AP/s1ap_eNB.c
+++ b/openair3/S1AP/s1ap_eNB.c
@@ -20,8 +20,8 @@
  */
 
 /*! \file s1ap_eNB.c
- * \brief S1AP eNB task 
- * \author  S. Roux and Navid Nikaein 
+ * \brief S1AP eNB task
+ * \author  S. Roux and Navid Nikaein
  * \date 2010 - 2015
  * \email: navid.nikaein@eurecom.fr
  * \version 1.0
@@ -42,7 +42,6 @@
 #include "s1ap_eNB_default_values.h"
 
 #include "s1ap_common.h"
-#include "s1ap_ies_defs.h"
 
 #include "s1ap_eNB_defs.h"
 #include "s1ap_eNB.h"
@@ -81,16 +80,12 @@ uint32_t s1ap_generate_eNB_id(void)
   char     hostname[50];
   int      ret;
   uint32_t eNB_id;
-
   /* Retrieve the host name */
   ret = gethostname(hostname, sizeof(hostname));
   DevAssert(ret == 0);
-
   out = crypt(hostname, "eurecom");
   DevAssert(out != NULL);
-
   eNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]);
-
   return eNB_id;
 }
 
@@ -104,46 +99,32 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
   sctp_new_association_req_t *sctp_new_association_req_p  = NULL;
   s1ap_eNB_mme_data_t        *s1ap_mme_data_p             = NULL;
   struct s1ap_eNB_mme_data_s *mme                         = NULL;
- 
   DevAssert(instance_p != NULL);
   DevAssert(mme_ip_address != NULL);
-
   message_p = itti_alloc_new_message(TASK_S1AP, SCTP_NEW_ASSOCIATION_REQ);
-
   sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req;
-
   sctp_new_association_req_p->port = S1AP_PORT_NUMBER;
   sctp_new_association_req_p->ppid = S1AP_SCTP_PPID;
-
   sctp_new_association_req_p->in_streams  = in_streams;
   sctp_new_association_req_p->out_streams = out_streams;
-
   memcpy(&sctp_new_association_req_p->remote_address,
          mme_ip_address,
          sizeof(*mme_ip_address));
-
   memcpy(&sctp_new_association_req_p->local_address,
          local_ip_addr,
          sizeof(*local_ip_addr));
- 
   S1AP_INFO("[eNB %d] check the mme registration state\n",instance_p->instance);
-	      
   mme = s1ap_eNB_get_MME_from_instance(instance_p);
 
   if ( mme == NULL ) {
-    
     /* Create new MME descriptor */
     s1ap_mme_data_p = calloc(1, sizeof(*s1ap_mme_data_p));
     DevAssert(s1ap_mme_data_p != NULL);
-    
     s1ap_mme_data_p->cnx_id                = s1ap_eNB_fetch_add_global_cnx_id();
     sctp_new_association_req_p->ulp_cnx_id = s1ap_mme_data_p->cnx_id;
-    
     s1ap_mme_data_p->assoc_id          = -1;
     s1ap_mme_data_p->s1ap_eNB_instance = instance_p;
-    
     STAILQ_INIT(&s1ap_mme_data_p->served_gummei);
-  
     /* Insert the new descriptor in list of known MME
      * but not yet associated.
      */
@@ -154,27 +135,23 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
   } else if (mme->state == S1AP_ENB_STATE_WAITING) {
     instance_p->s1ap_mme_pending_nb ++;
     sctp_new_association_req_p->ulp_cnx_id = mme->cnx_id;
-
     S1AP_INFO("[eNB %d] MME already registered, retrive the data (state %d, cnx %d, mme_nb %d, mme_pending_nb %d)\n",
-	      instance_p->instance, 
-	      mme->state, mme->cnx_id,
-	      instance_p->s1ap_mme_nb, instance_p->s1ap_mme_pending_nb);
-
+              instance_p->instance,
+              mme->state, mme->cnx_id,
+              instance_p->s1ap_mme_nb, instance_p->s1ap_mme_pending_nb);
     /*s1ap_mme_data_p->cnx_id                = mme->cnx_id;
     sctp_new_association_req_p->ulp_cnx_id = mme->cnx_id;
-    
+
     s1ap_mme_data_p->assoc_id          = -1;
     s1ap_mme_data_p->s1ap_eNB_instance = instance_p;
-    */ 
+    */
   } else {
-    
     S1AP_WARN("[eNB %d] MME already registered but not in the waiting state, retrive the data (state %d, cnx %d, mme_nb %d, mme_pending_nb %d)\n",
-	      instance_p->instance, 
-	      mme->state, mme->cnx_id, 
-	      instance_p->s1ap_mme_nb, instance_p->s1ap_mme_pending_nb);
-    
+              instance_p->instance,
+              mme->state, mme->cnx_id,
+              instance_p->s1ap_mme_nb, instance_p->s1ap_mme_pending_nb);
   }
-    
+
   itti_send_msg_to_task(TASK_SCTP, instance_p->instance, message_p);
 }
 
@@ -183,14 +160,11 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
 {
   s1ap_eNB_instance_t *new_instance;
   uint8_t index;
-  
   DevAssert(s1ap_register_eNB != NULL);
-
   /* Look if the provided instance already exists */
   new_instance = s1ap_eNB_get_instance(instance);
-  
- 
-  if (new_instance != NULL) { 
+
+  if (new_instance != NULL) {
     /* Checks if it is a retry on the same eNB */
     DevCheck(new_instance->eNB_id == s1ap_register_eNB->eNB_id, new_instance->eNB_id, s1ap_register_eNB->eNB_id, 0);
     DevCheck(new_instance->cell_type == s1ap_register_eNB->cell_type, new_instance->cell_type, s1ap_register_eNB->cell_type, 0);
@@ -202,10 +176,8 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
   } else {
     new_instance = calloc(1, sizeof(s1ap_eNB_instance_t));
     DevAssert(new_instance != NULL);
-
     RB_INIT(&new_instance->s1ap_ue_head);
     RB_INIT(&new_instance->s1ap_mme_head);
-
     /* Copy usefull parameters */
     new_instance->instance         = instance;
     new_instance->eNB_name         = s1ap_register_eNB->eNB_name;
@@ -216,14 +188,12 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
     new_instance->mnc              = s1ap_register_eNB->mnc;
     new_instance->mnc_digit_length = s1ap_register_eNB->mnc_digit_length;
     new_instance->default_drx      = s1ap_register_eNB->default_drx;
-
     /* Add the new instance to the list of eNB (meaningfull in virtual mode) */
     s1ap_eNB_insert_new_instance(new_instance);
-
     S1AP_INFO("Registered new eNB[%d] and %s eNB id %u\n",
-               instance,
-               s1ap_register_eNB->cell_type == CELL_MACRO_ENB ? "macro" : "home",
-               s1ap_register_eNB->eNB_id);
+              instance,
+              s1ap_register_eNB->cell_type == CELL_MACRO_ENB ? "macro" : "home",
+              s1ap_register_eNB->eNB_id);
   }
 
   DevCheck(s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS,
@@ -232,7 +202,7 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
   /* Trying to connect to provided list of MME ip address */
   for (index = 0; index < s1ap_register_eNB->nb_mme; index++) {
     s1ap_eNB_register_mme(new_instance,
-    		          &s1ap_register_eNB->mme_ip_address[index],
+                          &s1ap_register_eNB->mme_ip_address[index],
                           &s1ap_register_eNB->enb_ip_address,
                           s1ap_register_eNB->sctp_in_streams,
                           s1ap_register_eNB->sctp_out_streams);
@@ -243,12 +213,9 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
 {
   s1ap_eNB_instance_t *instance_p;
   s1ap_eNB_mme_data_t *s1ap_mme_data_p;
-
   DevAssert(sctp_new_association_resp != NULL);
-
   instance_p = s1ap_eNB_get_instance(instance);
   DevAssert(instance_p != NULL);
-
   s1ap_mme_data_p = s1ap_eNB_get_MME(instance_p, -1,
                                      sctp_new_association_resp->ulp_cnx_id);
   DevAssert(s1ap_mme_data_p != NULL);
@@ -258,9 +225,7 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
               sctp_new_association_resp->sctp_state,
               instance,
               sctp_new_association_resp->ulp_cnx_id);
-
     s1ap_handle_s1_setup_message(s1ap_mme_data_p, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN);
-
     return;
   }
 
@@ -268,7 +233,6 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
   s1ap_mme_data_p->assoc_id    = sctp_new_association_resp->assoc_id;
   s1ap_mme_data_p->in_streams  = sctp_new_association_resp->in_streams;
   s1ap_mme_data_p->out_streams = sctp_new_association_resp->out_streams;
-
   /* Prepare new S1 Setup Request */
   s1ap_eNB_generate_s1_setup_request(instance_p, s1ap_mme_data_p);
 }
@@ -277,11 +241,10 @@ static
 void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind)
 {
   int result;
-
   DevAssert(sctp_data_ind != NULL);
 #if defined(TEST_S1C_MME)
   mme_test_s1_notify_sctp_data_ind(sctp_data_ind->assoc_id, sctp_data_ind->stream,
-          sctp_data_ind->buffer, sctp_data_ind->buffer_length);
+                                   sctp_data_ind->buffer, sctp_data_ind->buffer_length);
 #else
   s1ap_eNB_handle_message(sctp_data_ind->assoc_id, sctp_data_ind->stream,
                           sctp_data_ind->buffer, sctp_data_ind->buffer_length);
@@ -294,11 +257,8 @@ void *s1ap_eNB_task(void *arg)
 {
   MessageDef *received_msg = NULL;
   int         result;
-
   S1AP_DEBUG("Starting S1AP layer\n");
-
   s1ap_eNB_prepare_internal_data();
-
   itti_mark_task_ready(TASK_S1AP);
   MSC_START_USE();
 
@@ -306,116 +266,112 @@ void *s1ap_eNB_task(void *arg)
     itti_receive_msg(TASK_S1AP, &received_msg);
 
     switch (ITTI_MSG_ID(received_msg)) {
-    case TERMINATE_MESSAGE:
-      S1AP_WARN(" *** Exiting S1AP thread\n");
-      itti_exit_task();
+      case TERMINATE_MESSAGE:
+        S1AP_WARN(" *** Exiting S1AP thread\n");
+        itti_exit_task();
+        break;
+
+      case S1AP_REGISTER_ENB_REQ: {
+        /* Register a new eNB.
+         * in Virtual mode eNBs will be distinguished using the mod_id/
+         * Each eNB has to send an S1AP_REGISTER_ENB message with its
+         * own parameters.
+         */
+        s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                     &S1AP_REGISTER_ENB_REQ(received_msg));
+      }
       break;
 
-    case S1AP_REGISTER_ENB_REQ: {
-      /* Register a new eNB.
-       * in Virtual mode eNBs will be distinguished using the mod_id/
-       * Each eNB has to send an S1AP_REGISTER_ENB message with its
-       * own parameters.
-       */
-      s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                   &S1AP_REGISTER_ENB_REQ(received_msg));
-    }
-    break;
-
-    case SCTP_NEW_ASSOCIATION_RESP: {
-      s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                            &received_msg->ittiMsg.sctp_new_association_resp);
-    }
-    break;
-
-    case SCTP_DATA_IND: {
-      s1ap_eNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
-    }
-    break;
-
-    case S1AP_NAS_FIRST_REQ: {
-      s1ap_eNB_handle_nas_first_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                    &S1AP_NAS_FIRST_REQ(received_msg));
-    }
-    break;
-
-    case S1AP_UPLINK_NAS: {
-      s1ap_eNB_nas_uplink(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                          &S1AP_UPLINK_NAS(received_msg));
-    }
-    break;
+      case SCTP_NEW_ASSOCIATION_RESP: {
+        s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                              &received_msg->ittiMsg.sctp_new_association_resp);
+      }
+      break;
 
-    case S1AP_UE_CAPABILITIES_IND: {
-      s1ap_eNB_ue_capabilities(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                               &S1AP_UE_CAPABILITIES_IND(received_msg));
-    }
-    break;
+      case SCTP_DATA_IND: {
+        s1ap_eNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
+      }
+      break;
 
-    case S1AP_INITIAL_CONTEXT_SETUP_RESP: {
-      s1ap_eNB_initial_ctxt_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                 &S1AP_INITIAL_CONTEXT_SETUP_RESP(received_msg));
-    }
-    break;
+      case S1AP_NAS_FIRST_REQ: {
+        s1ap_eNB_handle_nas_first_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                      &S1AP_NAS_FIRST_REQ(received_msg));
+      }
+      break;
 
-    case S1AP_E_RAB_SETUP_RESP: {
-      s1ap_eNB_e_rab_setup_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-				&S1AP_E_RAB_SETUP_RESP(received_msg));
-    }
-    break;
+      case S1AP_UPLINK_NAS: {
+        s1ap_eNB_nas_uplink(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                            &S1AP_UPLINK_NAS(received_msg));
+      }
+      break;
 
-    case S1AP_E_RAB_MODIFY_RESP: {
-      s1ap_eNB_e_rab_modify_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-        &S1AP_E_RAB_MODIFY_RESP(received_msg));
-    }
-    break;
-      
-    case S1AP_NAS_NON_DELIVERY_IND: {
-      s1ap_eNB_nas_non_delivery_ind(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                    &S1AP_NAS_NON_DELIVERY_IND(received_msg));
-    }
-    break;
+      case S1AP_UE_CAPABILITIES_IND: {
+        s1ap_eNB_ue_capabilities(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                 &S1AP_UE_CAPABILITIES_IND(received_msg));
+      }
+      break;
 
-    case S1AP_UE_CONTEXT_RELEASE_COMPLETE: {
-      s1ap_ue_context_release_complete(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                       &S1AP_UE_CONTEXT_RELEASE_COMPLETE(received_msg));
-    }
-    break;
+      case S1AP_INITIAL_CONTEXT_SETUP_RESP: {
+        s1ap_eNB_initial_ctxt_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                   &S1AP_INITIAL_CONTEXT_SETUP_RESP(received_msg));
+      }
+      break;
 
-    case S1AP_UE_CONTEXT_RELEASE_REQ: {
-      s1ap_eNB_instance_t               *s1ap_eNB_instance_p           = NULL; // test
-      struct s1ap_eNB_ue_context_s      *ue_context_p                  = NULL; // test
+      case S1AP_E_RAB_SETUP_RESP: {
+        s1ap_eNB_e_rab_setup_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                  &S1AP_E_RAB_SETUP_RESP(received_msg));
+      }
+      break;
 
-      s1ap_ue_context_release_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                  &S1AP_UE_CONTEXT_RELEASE_REQ(received_msg));
+      case S1AP_E_RAB_MODIFY_RESP: {
+        s1ap_eNB_e_rab_modify_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                   &S1AP_E_RAB_MODIFY_RESP(received_msg));
+      }
+      break;
 
+      case S1AP_NAS_NON_DELIVERY_IND: {
+        s1ap_eNB_nas_non_delivery_ind(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                      &S1AP_NAS_NON_DELIVERY_IND(received_msg));
+      }
+      break;
 
-      s1ap_eNB_instance_p = s1ap_eNB_get_instance(ITTI_MESSAGE_GET_INSTANCE(received_msg)); // test
-      DevAssert(s1ap_eNB_instance_p != NULL); // test
+      case S1AP_UE_CONTEXT_RELEASE_COMPLETE: {
+        s1ap_ue_context_release_complete(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                         &S1AP_UE_CONTEXT_RELEASE_COMPLETE(received_msg));
+      }
+      break;
 
-      if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
-                          S1AP_UE_CONTEXT_RELEASE_REQ(received_msg).eNB_ue_s1ap_id)) == NULL) { // test
-        /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
-        S1AP_ERROR("Failed to find ue context associated with eNB ue s1ap id: %u\n",
-                   S1AP_UE_CONTEXT_RELEASE_REQ(received_msg).eNB_ue_s1ap_id); // test
-      }  // test
-    }
-    break;
+      case S1AP_UE_CONTEXT_RELEASE_REQ: {
+        s1ap_eNB_instance_t               *s1ap_eNB_instance_p           = NULL; // test
+        struct s1ap_eNB_ue_context_s      *ue_context_p                  = NULL; // test
+        s1ap_ue_context_release_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                    &S1AP_UE_CONTEXT_RELEASE_REQ(received_msg));
+        s1ap_eNB_instance_p = s1ap_eNB_get_instance(ITTI_MESSAGE_GET_INSTANCE(received_msg)); // test
+        DevAssert(s1ap_eNB_instance_p != NULL); // test
+
+        if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
+                            S1AP_UE_CONTEXT_RELEASE_REQ(received_msg).eNB_ue_s1ap_id)) == NULL) { // test
+          /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
+          S1AP_ERROR("Failed to find ue context associated with eNB ue s1ap id: %u\n",
+                     S1AP_UE_CONTEXT_RELEASE_REQ(received_msg).eNB_ue_s1ap_id); // test
+        }  // test
+      }
+      break;
 
-   case S1AP_E_RAB_RELEASE_RESPONSE: {
+      case S1AP_E_RAB_RELEASE_RESPONSE: {
         s1ap_eNB_e_rab_release_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
                                     &S1AP_E_RAB_RELEASE_RESPONSE(received_msg));
-    }
-    break;
-
-    default:
-      S1AP_ERROR("Received unhandled message: %d:%s\n",
-                 ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
+      }
       break;
+
+      default:
+        S1AP_ERROR("Received unhandled message: %d:%s\n",
+                   ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
+        break;
     }
 
     result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg);
     AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
-
     received_msg = NULL;
   }
 
@@ -425,62 +381,102 @@ void *s1ap_eNB_task(void *arg)
 static int s1ap_eNB_generate_s1_setup_request(
   s1ap_eNB_instance_t *instance_p, s1ap_eNB_mme_data_t *s1ap_mme_data_p)
 {
-  s1ap_message               message;
-
-  S1ap_S1SetupRequestIEs_t *s1SetupRequest_p;
-  S1ap_PLMNidentity_t       plmnIdentity;
-  S1ap_SupportedTAs_Item_t  ta;
-
+  S1AP_S1AP_PDU_t                     pdu;
+  S1AP_S1SetupRequest_t              *out;
+  S1AP_S1SetupRequestIEs_t           *ie;
+  S1AP_SupportedTAs_Item_t           *ta;
+  S1AP_PLMNidentity_t                *plmn;
   uint8_t  *buffer;
   uint32_t  len;
   int       ret = 0;
-
-  DevAssert(instance_p != NULL);
-  DevAssert(s1ap_mme_data_p != NULL);
-
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_initiatingMessage;
-  message.procedureCode = S1ap_ProcedureCode_id_S1Setup;
-  message.criticality   = S1ap_Criticality_reject;
-
-  s1SetupRequest_p = &message.msg.s1ap_S1SetupRequestIEs;
-  memset((void *)&plmnIdentity, 0, sizeof(S1ap_PLMNidentity_t));
-
-  memset((void *)&ta, 0, sizeof(S1ap_SupportedTAs_Item_t));
-
   s1ap_mme_data_p->state = S1AP_ENB_STATE_WAITING;
-
-  s1SetupRequest_p->global_ENB_ID.eNB_ID.present = S1ap_ENB_ID_PR_macroENB_ID;
-  MACRO_ENB_ID_TO_BIT_STRING(instance_p->eNB_id,
-                             &s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID);
+  /* Prepare the S1AP message to encode */
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
+  pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_S1Setup;
+  pdu.choice.initiatingMessage.criticality = S1AP_Criticality_reject;
+  pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_S1SetupRequest;
+  out = &pdu.choice.initiatingMessage.value.choice.S1SetupRequest;
+  ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_Global_ENB_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_S1SetupRequestIEs__value_PR_Global_ENB_ID;
   MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length,
-                    &s1SetupRequest_p->global_ENB_ID.pLMNidentity);
-
-  S1AP_INFO("%d -> %02x%02x%02x\n", instance_p->eNB_id, s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[0], s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[1],
-            s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[2]);
-
-  INT16_TO_OCTET_STRING(instance_p->tac, &ta.tAC);
-  MCC_MNC_TO_TBCD(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length, &plmnIdentity);
+                    &ie->value.choice.Global_ENB_ID.pLMNidentity);
+  ie->value.choice.Global_ENB_ID.eNB_ID.present = S1AP_ENB_ID_PR_macroENB_ID;
+  MACRO_ENB_ID_TO_BIT_STRING(instance_p->eNB_id,
+                             &ie->value.choice.Global_ENB_ID.eNB_ID.choice.macroENB_ID);
+  S1AP_INFO("%d -> %02x%02x%02x\n", instance_p->eNB_id,
+            ie->value.choice.Global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[0],
+            ie->value.choice.Global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[1],
+            ie->value.choice.Global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[2]);
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (instance_p->eNB_name) {
+    ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_eNBname;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_S1SetupRequestIEs__value_PR_ENBname;
+    OCTET_STRING_fromBuf(&ie->value.choice.ENBname, instance_p->eNB_name,
+                         strlen(instance_p->eNB_name));
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  ASN_SEQUENCE_ADD(&ta.broadcastPLMNs.list, &plmnIdentity);
-  ASN_SEQUENCE_ADD(&s1SetupRequest_p->supportedTAs.list, &ta);
+  ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_SupportedTAs;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_S1SetupRequestIEs__value_PR_SupportedTAs;
+  ta = (S1AP_SupportedTAs_Item_t *)calloc(1, sizeof(S1AP_SupportedTAs_Item_t));
+  INT16_TO_OCTET_STRING(instance_p->tac, &ta->tAC);
+  plmn = (S1AP_PLMNidentity_t *)calloc(1, sizeof(S1AP_PLMNidentity_t));
+  MCC_MNC_TO_TBCD(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length, plmn);
+  ASN_SEQUENCE_ADD(&ta->broadcastPLMNs.list, plmn);
+  ASN_SEQUENCE_ADD(&ie->value.choice.SupportedTAs.list, ta);
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_DefaultPagingDRX;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_S1SetupRequestIEs__value_PR_PagingDRX;
+  ie->value.choice.PagingDRX = instance_p->default_drx;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CSG_IdList;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_S1SetupRequestIEs__value_PR_CSG_IdList;
+    // ie->value.choice.CSG_IdList = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  s1SetupRequest_p->defaultPagingDRX = instance_p->default_drx;
+  /* optional */
+  if (0) {
+    ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_UE_RetentionInformation  ;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_S1SetupRequestIEs__value_PR_UE_RetentionInformation;
+    // ie->value.choice.UE_RetentionInformation = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  if (instance_p->eNB_name != NULL) {
-    s1SetupRequest_p->presenceMask |= S1AP_S1SETUPREQUESTIES_ENBNAME_PRESENT;
-    OCTET_STRING_fromBuf(&s1SetupRequest_p->eNBname, instance_p->eNB_name,
-                         strlen(instance_p->eNB_name));
+  /* optional */
+  if (0) {
+    ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_NB_IoT_DefaultPagingDRX;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_S1SetupRequestIEs__value_PR_NB_IoT_DefaultPagingDRX;
+    // ie->value.choice.NB_IoT_DefaultPagingDRX = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &len) < 0) {
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &len) < 0) {
     S1AP_ERROR("Failed to encode S1 setup request\n");
     return -1;
   }
 
   /* Non UE-Associated signalling -> stream = 0 */
   s1ap_eNB_itti_send_sctp_data_req(instance_p->instance, s1ap_mme_data_p->assoc_id, buffer, len, 0);
-
   return ret;
 }
diff --git a/openair3/S1AP/s1ap_eNB_context_management_procedures.c b/openair3/S1AP/s1ap_eNB_context_management_procedures.c
index 49c5ed28acdbc8b1fdf82edcc05f52a6d2cbbb39..f10ccf58dd52f725632b085ec5008bb1f23c1148 100644
--- a/openair3/S1AP/s1ap_eNB_context_management_procedures.c
+++ b/openair3/S1AP/s1ap_eNB_context_management_procedures.c
@@ -20,8 +20,8 @@
  */
 
 /*! \file s1ap_eNB_context_management_procedures.c
- * \brief S1AP context management procedures 
- * \author  S. Roux and Navid Nikaein 
+ * \brief S1AP context management procedures
+ * \author  S. Roux and Navid Nikaein
  * \date 2010 - 2015
  * \email: navid.nikaein@eurecom.fr
  * \version 1.0
@@ -41,7 +41,6 @@
 
 #include "s1ap_eNB_itti_messaging.h"
 
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_encoder.h"
 #include "s1ap_eNB_nnsf.h"
 #include "s1ap_eNB_ue_context.h"
@@ -54,27 +53,22 @@
 int s1ap_ue_context_release_complete(instance_t instance,
                                      s1ap_ue_release_complete_t *ue_release_complete_p)
 {
-  s1ap_eNB_instance_t          *s1ap_eNB_instance_p = NULL;
-  struct s1ap_eNB_ue_context_s *ue_context_p        = NULL;
-
-  S1ap_UEContextReleaseCompleteIEs_t *ue_ctxt_release_complete_ies_p = NULL;
-
-  s1ap_message  message;
-
+  s1ap_eNB_instance_t                 *s1ap_eNB_instance_p = NULL;
+  struct s1ap_eNB_ue_context_s        *ue_context_p        = NULL;
+  S1AP_S1AP_PDU_t                      pdu;
+  S1AP_UEContextReleaseComplete_t     *out;
+  S1AP_UEContextReleaseComplete_IEs_t *ie;
   uint8_t  *buffer;
   uint32_t length;
-  int      ret = -1;
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
-
   DevAssert(ue_release_complete_p != NULL);
   DevAssert(s1ap_eNB_instance_p != NULL);
 
   /*RB_FOREACH(ue_context_p, s1ap_ue_map, &s1ap_eNB_instance_p->s1ap_ue_head) {
-	  S1AP_WARN("in s1ap_ue_map: UE context eNB_ue_s1ap_id %u mme_ue_s1ap_id %u state %u\n",
-			  ue_context_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,
-			  ue_context_p->ue_state);
+    S1AP_WARN("in s1ap_ue_map: UE context eNB_ue_s1ap_id %u mme_ue_s1ap_id %u state %u\n",
+        ue_context_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,
+        ue_context_p->ue_state);
   }*/
   if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
                       ue_release_complete_p->eNB_ue_s1ap_id)) == NULL) {
@@ -85,20 +79,62 @@ int s1ap_ue_context_release_complete(instance_t instance,
   }
 
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_successfulOutcome;
-  message.procedureCode = S1ap_ProcedureCode_id_UEContextRelease;
-  //message.criticality   = S1ap_Criticality_reject;
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome;
+  pdu.choice.successfulOutcome.procedureCode = S1AP_ProcedureCode_id_UEContextRelease;
+  pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject;
+  pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_UEContextReleaseComplete;
+  out = &pdu.choice.successfulOutcome.value.choice.UEContextReleaseComplete;
+  ie = (S1AP_UEContextReleaseComplete_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseComplete_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_UEContextReleaseComplete_IEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_UEContextReleaseComplete_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseComplete_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_UEContextReleaseComplete_IEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_release_complete_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_UEContextReleaseComplete_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseComplete_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CriticalityDiagnostics;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UEContextReleaseComplete_IEs__value_PR_CriticalityDiagnostics;
+    // ie->value.choice.CriticalityDiagnostics = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  ue_ctxt_release_complete_ies_p = &message.msg.s1ap_UEContextReleaseCompleteIEs;
+  /* release 12 */
+  if (0) {
+    ie = (S1AP_UEContextReleaseComplete_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseComplete_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_UserLocationInformation;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UEContextReleaseComplete_IEs__value_PR_UserLocationInformation;
+    // ie->value.choice.UserLocationInformation = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  ue_ctxt_release_complete_ies_p->eNB_UE_S1AP_ID = ue_release_complete_p->eNB_ue_s1ap_id;
-  ue_ctxt_release_complete_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
-  //ue_ctxt_release_complete_ies_p->criticalityDiagnostics
-  //ue_ctxt_release_complete_ies_p->presenceMask
+  /* release 13 */
+  if (0) {
+    ie = (S1AP_UEContextReleaseComplete_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseComplete_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_InformationOnRecommendedCellsAndENBsForPaging;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UEContextReleaseComplete_IEs__value_PR_InformationOnRecommendedCellsAndENBsForPaging;
+    // ie->value.choice.InformationOnRecommendedCellsAndENBsForPaging = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+    ie = (S1AP_UEContextReleaseComplete_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseComplete_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CellIdentifierAndCELevelForCECapableUEs;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UEContextReleaseComplete_IEs__value_PR_CellIdentifierAndCELevelForCECapableUEs;
+    // ie->value.choice.CellIdentifierAndCELevelForCECapableUEs = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     /* Encode procedure has failed... */
     S1AP_ERROR("Failed to encode UE context release complete\n");
     return -1;
@@ -113,18 +149,12 @@ int s1ap_ue_context_release_complete(instance_t instance,
     0,0, //MSC_AS_TIME_ARGS(ctxt_pP),
     ue_ctxt_release_complete_ies_p->eNB_UE_S1AP_ID,
     ue_ctxt_release_complete_ies_p->mme_ue_s1ap_id);
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
-
   //LG s1ap_eNB_itti_send_sctp_close_association(s1ap_eNB_instance_p->instance,
   //                                 ue_context_p->mme_ref->assoc_id);
-
-
-
   // release UE context
   struct s1ap_eNB_ue_context_s *ue_context2_p = NULL;
 
@@ -137,29 +167,28 @@ int s1ap_ue_context_release_complete(instance_t instance,
     S1AP_WARN("Removing UE context eNB_ue_s1ap_id %u: did not find context\n",
               ue_context_p->eNB_ue_s1ap_id);
   }
+
   /*RB_FOREACH(ue_context_p, s1ap_ue_map, &s1ap_eNB_instance_p->s1ap_ue_head) {
-	  S1AP_WARN("in s1ap_ue_map: UE context eNB_ue_s1ap_id %u mme_ue_s1ap_id %u state %u\n",
-			  ue_context_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,
-			  ue_context_p->ue_state);
+    S1AP_WARN("in s1ap_ue_map: UE context eNB_ue_s1ap_id %u mme_ue_s1ap_id %u state %u\n",
+        ue_context_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,
+        ue_context_p->ue_state);
   }*/
-
-  return ret;
+  return 0;
 }
 
 
 int s1ap_ue_context_release_req(instance_t instance,
                                 s1ap_ue_release_req_t *ue_release_req_p)
 {
-  s1ap_eNB_instance_t               *s1ap_eNB_instance_p           = NULL;
-  struct s1ap_eNB_ue_context_s      *ue_context_p                  = NULL;
-  S1ap_UEContextReleaseRequestIEs_t *ue_ctxt_release_request_ies_p = NULL;
-  s1ap_message                       message;
-  uint8_t                           *buffer                        = NULL;
-  uint32_t                           length;
-
+  s1ap_eNB_instance_t                *s1ap_eNB_instance_p           = NULL;
+  struct s1ap_eNB_ue_context_s       *ue_context_p                  = NULL;
+  S1AP_S1AP_PDU_t                     pdu;
+  S1AP_UEContextReleaseRequest_t     *out;
+  S1AP_UEContextReleaseRequest_IEs_t *ie;
+  uint8_t                            *buffer                        = NULL;
+  uint32_t                            length;
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
-
   DevAssert(ue_release_req_p != NULL);
   DevAssert(s1ap_eNB_instance_p != NULL);
 
@@ -172,50 +201,74 @@ int s1ap_ue_context_release_req(instance_t instance,
   }
 
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
+  pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_UEContextReleaseRequest;
+  pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore;
+  pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_UEContextReleaseRequest;
+  out = &pdu.choice.initiatingMessage.value.choice.UEContextReleaseRequest;
+  ie = (S1AP_UEContextReleaseRequest_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseRequest_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UEContextReleaseRequest_IEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_UEContextReleaseRequest_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseRequest_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UEContextReleaseRequest_IEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_release_req_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_UEContextReleaseRequest_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseRequest_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_Cause;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_UEContextReleaseRequest_IEs__value_PR_Cause;
 
-  message.direction     = S1AP_PDU_PR_initiatingMessage;
-  message.procedureCode = S1ap_ProcedureCode_id_UEContextReleaseRequest;
-  //message.criticality   = S1ap_Criticality_reject;
-
-  ue_ctxt_release_request_ies_p = &message.msg.s1ap_UEContextReleaseRequestIEs;
+  switch (ue_release_req_p->cause) {
+    case S1AP_Cause_PR_radioNetwork:
+      ie->value.choice.Cause.present = S1AP_Cause_PR_radioNetwork;
+      ie->value.choice.Cause.choice.radioNetwork = ue_release_req_p->cause_value;
+      break;
+
+    case S1AP_Cause_PR_transport:
+      ie->value.choice.Cause.present = S1AP_Cause_PR_transport;
+      ie->value.choice.Cause.choice.transport = ue_release_req_p->cause_value;
+      break;
+
+    case S1AP_Cause_PR_nas:
+      ie->value.choice.Cause.present = S1AP_Cause_PR_nas;
+      ie->value.choice.Cause.choice.nas = ue_release_req_p->cause_value;
+      break;
+
+    case S1AP_Cause_PR_protocol:
+      ie->value.choice.Cause.present = S1AP_Cause_PR_protocol;
+      ie->value.choice.Cause.choice.protocol = ue_release_req_p->cause_value;
+      break;
+
+    case S1AP_Cause_PR_misc:
+      ie->value.choice.Cause.present = S1AP_Cause_PR_misc;
+      ie->value.choice.Cause.choice.misc = ue_release_req_p->cause_value;
+      break;
+
+    case S1AP_Cause_PR_NOTHING:
+    default:
+      ie->value.choice.Cause.present = S1AP_Cause_PR_NOTHING;
+      break;
+  }
 
-  ue_ctxt_release_request_ies_p->eNB_UE_S1AP_ID = ue_release_req_p->eNB_ue_s1ap_id;
-  ue_ctxt_release_request_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
 
-  switch (ue_release_req_p->cause) {
-  case S1AP_CAUSE_NOTHING:
-    ue_ctxt_release_request_ies_p->cause.present = S1ap_Cause_PR_NOTHING;
-    break;
-
-  case S1AP_CAUSE_RADIO_NETWORK:
-    ue_ctxt_release_request_ies_p->cause.present = S1ap_Cause_PR_radioNetwork;
-    ue_ctxt_release_request_ies_p->cause.choice.radioNetwork = ue_release_req_p->cause_value;
-    break;
-
-  case S1AP_CAUSE_TRANSPORT:
-    ue_ctxt_release_request_ies_p->cause.present = S1ap_Cause_PR_transport;
-    ue_ctxt_release_request_ies_p->cause.choice.transport = ue_release_req_p->cause_value;
-    break;
-
-  case S1AP_CAUSE_NAS:
-    ue_ctxt_release_request_ies_p->cause.present = S1ap_Cause_PR_nas;
-    ue_ctxt_release_request_ies_p->cause.choice.nas = ue_release_req_p->cause_value;
-    break;
-
-  case S1AP_CAUSE_PROTOCOL:
-    ue_ctxt_release_request_ies_p->cause.present = S1ap_Cause_PR_protocol;
-    ue_ctxt_release_request_ies_p->cause.choice.protocol = ue_release_req_p->cause_value;
-    break;
-
-  case S1AP_CAUSE_MISC:
-  default:
-    ue_ctxt_release_request_ies_p->cause.present = S1ap_Cause_PR_misc;
-    ue_ctxt_release_request_ies_p->cause.choice.misc = ue_release_req_p->cause_value;
-    break;
+  /* optional */
+  if (0) {
+    ie = (S1AP_UEContextReleaseRequest_IEs_t *)calloc(1, sizeof(S1AP_UEContextReleaseRequest_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_GWContextReleaseIndication;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_UEContextReleaseRequest_IEs__value_PR_GWContextReleaseIndication;
+    ie->value.choice.GWContextReleaseIndication = TRUE;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     /* Encode procedure has failed... */
     S1AP_ERROR("Failed to encode UE context release complete\n");
     return -1;
@@ -230,12 +283,10 @@ int s1ap_ue_context_release_req(instance_t instance,
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     ue_ctxt_release_request_ies_p->eNB_UE_S1AP_ID,
     ue_ctxt_release_request_ies_p->mme_ue_s1ap_id);
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
   return 0;
 }
 
diff --git a/openair3/S1AP/s1ap_eNB_decoder.c b/openair3/S1AP/s1ap_eNB_decoder.c
index eac52c53ba6fc52cf13340267630a41d1de68c8c..d3a2fad8f52a36e5b0208ae36037e830a8d68ed9 100644
--- a/openair3/S1AP/s1ap_eNB_decoder.c
+++ b/openair3/S1AP/s1ap_eNB_decoder.c
@@ -34,235 +34,172 @@
 #include "intertask_interface.h"
 
 #include "s1ap_common.h"
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_decoder.h"
 
-static int s1ap_eNB_decode_initiating_message(s1ap_message *message,
-    S1ap_InitiatingMessage_t *initiating_p)
+
+static int s1ap_eNB_decode_initiating_message(S1AP_S1AP_PDU_t *pdu)
 {
-  int         ret = -1;
   MessageDef *message_p;
-  char       *message_string = NULL;
-  size_t      message_string_size;
   MessagesIds message_id;
-
-  DevAssert(initiating_p != NULL);
-
-  message_string = calloc(10000, sizeof(char));
-
-  s1ap_string_total_size = 0;
-
-  message->procedureCode = initiating_p->procedureCode;
-  message->criticality   = initiating_p->criticality;
-
-  switch(initiating_p->procedureCode) {
-  case S1ap_ProcedureCode_id_downlinkNASTransport:
-    ret = s1ap_decode_s1ap_downlinknastransporties(
-            &message->msg.s1ap_DownlinkNASTransportIEs,
-            &initiating_p->value);
-    s1ap_xer_print_s1ap_downlinknastransport(s1ap_xer__print2sp,
-        message_string,
-        message);
-    message_id          = S1AP_DOWNLINK_NAS_LOG;
-    message_string_size = strlen(message_string);
-    message_p           = itti_alloc_new_message_sized(TASK_S1AP,
-                          message_id,
-                          message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_downlink_nas_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_downlink_nas_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    break;
-
-  case S1ap_ProcedureCode_id_InitialContextSetup:
-    ret = s1ap_decode_s1ap_initialcontextsetuprequesties(
-            &message->msg.s1ap_InitialContextSetupRequestIEs, &initiating_p->value);
-    s1ap_xer_print_s1ap_initialcontextsetuprequest(s1ap_xer__print2sp, message_string, message);
-    message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
-    message_string_size = strlen(message_string);
-    message_p           = itti_alloc_new_message_sized(TASK_S1AP,
-                          message_id,
-                          message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_initial_context_setup_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    break;
-
-  case S1ap_ProcedureCode_id_UEContextRelease:
-    ret = s1ap_decode_s1ap_uecontextreleasecommandies(
-            &message->msg.s1ap_UEContextReleaseCommandIEs, &initiating_p->value);
-    s1ap_xer_print_s1ap_uecontextreleasecommand(s1ap_xer__print2sp, message_string, message);
-    message_id = S1AP_UE_CONTEXT_RELEASE_COMMAND_LOG;
-    message_string_size = strlen(message_string);
-    message_p           = itti_alloc_new_message_sized(TASK_S1AP,
-                          message_id,
-                          message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_ue_context_release_command_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_ue_context_release_command_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    break;
-
-  case S1ap_ProcedureCode_id_Paging:
-    ret = s1ap_decode_s1ap_pagingies(
-            &message->msg.s1ap_PagingIEs, &initiating_p->value);
-    s1ap_xer_print_s1ap_paging(s1ap_xer__print2sp, message_string, message);
-    message_id = S1AP_PAGING_LOG;
-    message_string_size = strlen(message_string);
-    message_p           = itti_alloc_new_message_sized(TASK_S1AP,
-                          message_id,
-                          message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_paging_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_paging_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    S1AP_INFO("Paging initiating message\n");
-    free(message_string);
-    break;
-
-
-  case S1ap_ProcedureCode_id_E_RABSetup:
-    ret = s1ap_decode_s1ap_e_rabsetuprequesties(
-						&message->msg.s1ap_E_RABSetupRequestIEs, &initiating_p->value);
-    //s1ap_xer_print_s1ap_e_rabsetuprequest(s1ap_xer__print2sp, message_string, message);
-    message_id = S1AP_E_RAB_SETUP_REQUEST_LOG;
-    message_string_size = strlen(message_string);
-    message_p           = itti_alloc_new_message_sized(TASK_S1AP,
-                          message_id,
-                          message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_e_rab_setup_request_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_e_rab_setup_request_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    S1AP_INFO("E_RABSetup initiating message\n");
-    break;
-
-  case S1ap_ProcedureCode_id_E_RABModify:
-    ret = s1ap_decode_s1ap_e_rabmodifyrequesties(
-            &message->msg.s1ap_E_RABModifyRequestIEs, &initiating_p->value);
-    message_id = S1AP_E_RAB_MODIFY_REQUEST_LOG;
-    message_string_size = strlen(message_string);
-    message_p           = itti_alloc_new_message_sized(TASK_S1AP,
-                          message_id,
-                          message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_e_rab_modify_request_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_e_rab_modify_request_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    S1AP_INFO("E_RABModify initiating message\n");
-    break;
-
-  case S1ap_ProcedureCode_id_E_RABRelease:
-    ret = s1ap_decode_s1ap_e_rabreleasecommandies(
-            &message->msg.s1ap_E_RABReleaseCommandIEs, &initiating_p->value);
-    s1ap_xer_print_s1ap_e_rabreleasecommand(s1ap_xer__print2sp, message_string, message);
-    message_id = S1AP_E_RAB_RELEASE_REQUEST_LOG;
-    message_string_size = strlen(message_string);
-    message_p           = itti_alloc_new_message_sized(TASK_S1AP,
-                          message_id,
-                          message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_e_rab_release_request_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_e_rab_release_request_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    S1AP_INFO("TODO  E_RABRelease nitiating message\n");    
-    break;
-
-  default:
-    S1AP_ERROR("Unknown procedure ID (%d) for initiating message\n",
-               (int)initiating_p->procedureCode);
-    AssertFatal( 0 , "Unknown procedure ID (%d) for initiating message\n",
-                 (int)initiating_p->procedureCode);
-    return -1;
+  asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
+  DevAssert(pdu != NULL);
+
+  switch(pdu->choice.initiatingMessage.procedureCode) {
+    case S1AP_ProcedureCode_id_downlinkNASTransport:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_DOWNLINK_NAS_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id,
+                  res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_downlink_nas_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_downlink_nas_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_InitialContextSetup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id,
+                  res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_initial_context_setup_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_UEContextRelease:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_UE_CONTEXT_RELEASE_COMMAND_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id,
+                  res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_ue_context_release_command_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_ue_context_release_command_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_Paging:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_PAGING_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id,
+                  res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_paging_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_paging_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      S1AP_INFO("Paging initiating message\n");
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_E_RABSetup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_E_RAB_SETUP_REQUEST_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id,
+                  res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_e_rab_setup_request_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_e_rab_setup_request_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      S1AP_INFO("E_RABSetup initiating message\n");
+      break;
+
+    case S1AP_ProcedureCode_id_E_RABModify:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_E_RAB_MODIFY_REQUEST_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id,
+                  res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_e_rab_modify_request_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_e_rab_modify_request_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      S1AP_INFO("E_RABModify initiating message\n");
+      break;
+
+    case S1AP_ProcedureCode_id_E_RABRelease:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_E_RAB_RELEASE_REQUEST_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id,
+                  res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_e_rab_release_request_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_e_rab_release_request_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      S1AP_INFO("TODO  E_RABRelease nitiating message\n");
+      break;
+
+    default:
+      S1AP_ERROR("Unknown procedure ID (%d) for initiating message\n",
+                 (int)pdu->choice.initiatingMessage.procedureCode);
+      AssertFatal( 0, "Unknown procedure ID (%d) for initiating message\n",
+                   (int)pdu->choice.initiatingMessage.procedureCode);
+      return -1;
   }
 
-
-  return ret;
+  return 0;
 }
 
-static int s1ap_eNB_decode_successful_outcome(s1ap_message *message,
-    S1ap_SuccessfulOutcome_t *successfullOutcome_p)
+static int s1ap_eNB_decode_successful_outcome(S1AP_S1AP_PDU_t *pdu)
 {
-  int ret = -1;
   MessageDef *message_p;
-  char       *message_string = NULL;
-  size_t      message_string_size;
   MessagesIds message_id;
-
-  DevAssert(successfullOutcome_p != NULL);
-
-  message_string = malloc(sizeof(char) * 10000);
-  memset((void*)message_string,0,sizeof(char) * 10000);
-
-  s1ap_string_total_size = 0;
-
-  message->procedureCode = successfullOutcome_p->procedureCode;
-  message->criticality   = successfullOutcome_p->criticality;
-
-  switch(successfullOutcome_p->procedureCode) {
-  case S1ap_ProcedureCode_id_S1Setup:
-    ret = s1ap_decode_s1ap_s1setupresponseies(
-            &message->msg.s1ap_S1SetupResponseIEs, &successfullOutcome_p->value);
-    s1ap_xer_print_s1ap_s1setupresponse(s1ap_xer__print2sp, message_string, message);
-    message_id = S1AP_S1_SETUP_LOG;
-    break;
-
-  default:
-    S1AP_ERROR("Unknown procedure ID (%d) for successfull outcome message\n",
-               (int)successfullOutcome_p->procedureCode);
-    return -1;
+  asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
+  DevAssert(pdu != NULL);
+
+  switch(pdu->choice.successfulOutcome.procedureCode) {
+    case S1AP_ProcedureCode_id_S1Setup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_S1_SETUP_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_s1_setup_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_s1_setup_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    default:
+      S1AP_ERROR("Unknown procedure ID (%d) for successfull outcome message\n",
+                 (int)pdu->choice.successfulOutcome.procedureCode);
+      return -1;
   }
 
-  message_string_size = strlen(message_string);
-
-  message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-  message_p->ittiMsg.s1ap_s1_setup_log.size = message_string_size;
-  memcpy(&message_p->ittiMsg.s1ap_s1_setup_log.text, message_string, message_string_size);
-
-  itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-
-  free(message_string);
-
-  return ret;
+  return 0;
 }
 
-static int s1ap_eNB_decode_unsuccessful_outcome(s1ap_message *message,
-    S1ap_UnsuccessfulOutcome_t *unSuccessfullOutcome_p)
+static int s1ap_eNB_decode_unsuccessful_outcome(S1AP_S1AP_PDU_t *pdu)
 {
-  int ret = -1;
-  DevAssert(unSuccessfullOutcome_p != NULL);
-
-  message->procedureCode = unSuccessfullOutcome_p->procedureCode;
-  message->criticality   = unSuccessfullOutcome_p->criticality;
-
-  switch(unSuccessfullOutcome_p->procedureCode) {
-  case S1ap_ProcedureCode_id_S1Setup:
-    return s1ap_decode_s1ap_s1setupfailureies(
-             &message->msg.s1ap_S1SetupFailureIEs, &unSuccessfullOutcome_p->value);
-
-  default:
-    S1AP_ERROR("Unknown procedure ID (%d) for unsuccessfull outcome message\n",
-               (int)unSuccessfullOutcome_p->procedureCode);
-    break;
+  MessageDef *message_p;
+  MessagesIds message_id;
+  asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
+  DevAssert(pdu != NULL);
+
+  switch(pdu->choice.unsuccessfulOutcome.procedureCode) {
+    case S1AP_ProcedureCode_id_S1Setup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_S1_SETUP_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_s1_setup_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_s1_setup_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    default:
+      S1AP_ERROR("Unknown procedure ID (%d) for unsuccessfull outcome message\n",
+                 (int)pdu->choice.unsuccessfulOutcome.procedureCode);
+      return -1;
   }
 
-  return ret;
+  return 0;
 }
 
-int s1ap_eNB_decode_pdu(s1ap_message *message, const uint8_t * const buffer,
+int s1ap_eNB_decode_pdu(S1AP_S1AP_PDU_t *pdu, const uint8_t *const buffer,
                         const uint32_t length)
 {
-  S1AP_PDU_t  pdu;
-  S1AP_PDU_t *pdu_p = &pdu;
   asn_dec_rval_t dec_ret;
-
+  DevAssert(pdu != NULL);
   DevAssert(buffer != NULL);
-
-  memset((void *)pdu_p, 0, sizeof(S1AP_PDU_t));
-
   dec_ret = aper_decode(NULL,
-                        &asn_DEF_S1AP_PDU,
-                        (void **)&pdu_p,
+                        &asn_DEF_S1AP_S1AP_PDU,
+                        (void **)pdu,
                         buffer,
                         length,
                         0,
@@ -273,24 +210,19 @@ int s1ap_eNB_decode_pdu(s1ap_message *message, const uint8_t * const buffer,
     return -1;
   }
 
-  message->direction = pdu_p->present;
-
-  switch(pdu_p->present) {
-  case S1AP_PDU_PR_initiatingMessage:
-    return s1ap_eNB_decode_initiating_message(message,
-           &pdu_p->choice.initiatingMessage);
+  switch(pdu->present) {
+    case S1AP_S1AP_PDU_PR_initiatingMessage:
+      return s1ap_eNB_decode_initiating_message(pdu);
 
-  case S1AP_PDU_PR_successfulOutcome:
-    return s1ap_eNB_decode_successful_outcome(message,
-           &pdu_p->choice.successfulOutcome);
+    case S1AP_S1AP_PDU_PR_successfulOutcome:
+      return s1ap_eNB_decode_successful_outcome(pdu);
 
-  case S1AP_PDU_PR_unsuccessfulOutcome:
-    return s1ap_eNB_decode_unsuccessful_outcome(message,
-           &pdu_p->choice.unsuccessfulOutcome);
+    case S1AP_S1AP_PDU_PR_unsuccessfulOutcome:
+      return s1ap_eNB_decode_unsuccessful_outcome(pdu);
 
-  default:
-    S1AP_DEBUG("Unknown presence (%d) or not implemented\n", (int)pdu_p->present);
-    break;
+    default:
+      S1AP_DEBUG("Unknown presence (%d) or not implemented\n", (int)pdu->present);
+      break;
   }
 
   return -1;
diff --git a/openair3/S1AP/s1ap_eNB_decoder.h b/openair3/S1AP/s1ap_eNB_decoder.h
index f321f8227f14fc550ee944c7ef2871770252ec88..f8f58d85602f9c18ac1a1980455b54f3bb4ca2dd 100644
--- a/openair3/S1AP/s1ap_eNB_decoder.h
+++ b/openair3/S1AP/s1ap_eNB_decoder.h
@@ -20,12 +20,12 @@
  */
 
 #include <stdint.h>
-#include "s1ap_ies_defs.h"
+
 
 #ifndef S1AP_ENB_DECODER_H_
 #define S1AP_ENB_DECODER_H_
 
-int s1ap_eNB_decode_pdu(s1ap_message *message, const uint8_t * const buffer,
+int s1ap_eNB_decode_pdu(S1AP_S1AP_PDU_t *pdu, const uint8_t *const buffer,
                         const uint32_t length) __attribute__ ((warn_unused_result));
 
 #endif /* S1AP_ENB_DECODER_H_ */
diff --git a/openair3/S1AP/s1ap_eNB_encoder.c b/openair3/S1AP/s1ap_eNB_encoder.c
index 7bd8bc09aabf6165dffe649bc2700678fd90a03b..bc0c69792def7fec332f0723ed6e5e9a9d7fb640 100644
--- a/openair3/S1AP/s1ap_eNB_encoder.c
+++ b/openair3/S1AP/s1ap_eNB_encoder.c
@@ -32,615 +32,251 @@
 #include <stdint.h>
 
 #include "assertions.h"
-
 #include "conversions.h"
-
 #include "intertask_interface.h"
-
 #include "s1ap_common.h"
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_encoder.h"
 
-static inline int s1ap_eNB_encode_initiating(s1ap_message *message,
+static inline int s1ap_eNB_encode_initiating(S1AP_S1AP_PDU_t *pdu,
     uint8_t **buffer,
     uint32_t *len);
 
-static inline int s1ap_eNB_encode_successfull_outcome(s1ap_message *message,
+static inline int s1ap_eNB_encode_successfull_outcome(S1AP_S1AP_PDU_t *pdu,
     uint8_t **buffer, uint32_t *len);
 
-static inline int s1ap_eNB_encode_unsuccessfull_outcome(s1ap_message *message,
+static inline int s1ap_eNB_encode_unsuccessfull_outcome(S1AP_S1AP_PDU_t *pdu,
     uint8_t **buffer, uint32_t *len);
 
-static inline int s1ap_eNB_encode_s1_setup_request(
-  S1ap_S1SetupRequestIEs_t *s1SetupRequestIEs, uint8_t **buffer, uint32_t *length);
-
-static inline int s1ap_eNB_encode_trace_failure(S1ap_TraceFailureIndicationIEs_t
-    *trace_failure_ies_p, uint8_t **buffer,
-    uint32_t *length);
-
-static inline int s1ap_eNB_encode_initial_ue_message(S1ap_InitialUEMessageIEs_t
-    *initialUEmessageIEs_p, uint8_t **buffer,
-    uint32_t *length);
-
-static inline int s1ap_eNB_encode_uplink_nas_transport(S1ap_UplinkNASTransportIEs_t
-    *uplinkNASTransportIEs,
-    uint8_t **buffer,
-    uint32_t *length);
-
-static inline int s1ap_eNB_encode_ue_capability_info_indication(
-  S1ap_UECapabilityInfoIndicationIEs_t *ueCapabilityInfoIndicationIEs,
-  uint8_t **buffer,
-  uint32_t *length);
-
-static inline int s1ap_eNB_encode_initial_context_setup_response(
-  S1ap_InitialContextSetupResponseIEs_t *initialContextSetupResponseIEs,
-  uint8_t **buffer,
-  uint32_t *length);
-
-static inline
-int s1ap_eNB_encode_nas_non_delivery(
-  S1ap_NASNonDeliveryIndication_IEs_t *nasNonDeliveryIndicationIEs,
-  uint8_t                            **buffer,
-  uint32_t                            *length);
-
-static inline
-int s1ap_eNB_encode_ue_context_release_complete(
-  S1ap_UEContextReleaseCompleteIEs_t *s1ap_UEContextReleaseCompleteIEs,
-  uint8_t                           **buffer,
-  uint32_t                           *length);
-
-static inline
-int s1ap_eNB_encode_ue_context_release_request(
-  S1ap_UEContextReleaseRequestIEs_t *s1ap_UEContextReleaseRequestIEs,
-  uint8_t                              **buffer,
-  uint32_t                              *length);
-
-static inline
-int s1ap_eNB_encode_e_rab_setup_response(S1ap_E_RABSetupResponseIEs_t  *E_RABSetupResponseIEs,
-					 uint8_t                              **buffer,
-					 uint32_t                              *length);
-
-static inline
-int s1ap_eNB_encode_e_rab_modify_response(S1ap_E_RABModifyResponseIEs_t  *E_RABModifyResponseIEs,
-           uint8_t                              **buffer,
-           uint32_t                              *length);
-
-static inline
-int s1ap_eNB_encode_e_rab_release_response(S1ap_E_RABReleaseResponseIEs_t  *s1ap_E_RABReleaseResponseIEs,
-                     uint8_t                              **buffer,
-                     uint32_t                              *length);
-
-int s1ap_eNB_encode_pdu(s1ap_message *message, uint8_t **buffer, uint32_t *len)
+int s1ap_eNB_encode_pdu(S1AP_S1AP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
 {
-  DevAssert(message != NULL);
+  int ret = -1;
+  DevAssert(pdu != NULL);
   DevAssert(buffer != NULL);
   DevAssert(len != NULL);
 
-  switch(message->direction) {
-  case S1AP_PDU_PR_initiatingMessage:
-    return s1ap_eNB_encode_initiating(message, buffer, len);
+  switch(pdu->present) {
+    case S1AP_S1AP_PDU_PR_initiatingMessage:
+      ret = s1ap_eNB_encode_initiating(pdu, buffer, len);
+      break;
 
-  case S1AP_PDU_PR_successfulOutcome:
-    return s1ap_eNB_encode_successfull_outcome(message, buffer, len);
+    case S1AP_S1AP_PDU_PR_successfulOutcome:
+      ret = s1ap_eNB_encode_successfull_outcome(pdu, buffer, len);
+      break;
 
-  case S1AP_PDU_PR_unsuccessfulOutcome:
-    return s1ap_eNB_encode_unsuccessfull_outcome(message, buffer, len);
+    case S1AP_S1AP_PDU_PR_unsuccessfulOutcome:
+      ret = s1ap_eNB_encode_unsuccessfull_outcome(pdu, buffer, len);
+      break;
 
-  default:
-    S1AP_DEBUG("Unknown message outcome (%d) or not implemented",
-               (int)message->direction);
-    break;
+    default:
+      S1AP_DEBUG("Unknown message outcome (%d) or not implemented",
+                 (int)pdu->present);
+      return -1;
   }
 
-  return -1;
+  ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_S1AP_PDU, pdu);
+  return ret;
 }
 
 static inline
-int s1ap_eNB_encode_initiating(s1ap_message *s1ap_message_p,
+int s1ap_eNB_encode_initiating(S1AP_S1AP_PDU_t *pdu,
                                uint8_t **buffer, uint32_t *len)
 {
-  int ret = -1;
   MessageDef *message_p;
-  char       *message_string = NULL;
-  size_t      message_string_size;
   MessagesIds message_id;
-
-  DevAssert(s1ap_message_p != NULL);
-
-  message_string = calloc(10000, sizeof(char));
-
-  s1ap_string_total_size = 0;
-
-  switch(s1ap_message_p->procedureCode) {
-  case S1ap_ProcedureCode_id_S1Setup:
-    ret = s1ap_eNB_encode_s1_setup_request(
-            &s1ap_message_p->msg.s1ap_S1SetupRequestIEs, buffer, len);
-    s1ap_xer_print_s1ap_s1setuprequest(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id = S1AP_S1_SETUP_LOG;
-    break;
-
-  case S1ap_ProcedureCode_id_uplinkNASTransport:
-    ret = s1ap_eNB_encode_uplink_nas_transport(
-            &s1ap_message_p->msg.s1ap_UplinkNASTransportIEs, buffer, len);
-    s1ap_xer_print_s1ap_uplinknastransport(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id = S1AP_UPLINK_NAS_LOG;
-    break;
-
-  case S1ap_ProcedureCode_id_UECapabilityInfoIndication:
-    ret = s1ap_eNB_encode_ue_capability_info_indication(
-            &s1ap_message_p->msg.s1ap_UECapabilityInfoIndicationIEs, buffer, len);
-    s1ap_xer_print_s1ap_uecapabilityinfoindication(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id = S1AP_UE_CAPABILITY_IND_LOG;
-    break;
-
-  case S1ap_ProcedureCode_id_initialUEMessage:
-    ret = s1ap_eNB_encode_initial_ue_message(
-            &s1ap_message_p->msg.s1ap_InitialUEMessageIEs, buffer, len);
-    s1ap_xer_print_s1ap_initialuemessage(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id = S1AP_INITIAL_UE_MESSAGE_LOG;
-    break;
-
-  case S1ap_ProcedureCode_id_NASNonDeliveryIndication:
-    ret = s1ap_eNB_encode_nas_non_delivery(
-            &s1ap_message_p->msg.s1ap_NASNonDeliveryIndication_IEs, buffer, len);
-    s1ap_xer_print_s1ap_nasnondeliveryindication_(s1ap_xer__print2sp,
-        message_string, s1ap_message_p);
-    message_id = S1AP_NAS_NON_DELIVERY_IND_LOG;
-    break;
-
-  case S1ap_ProcedureCode_id_UEContextReleaseRequest:
-    ret = s1ap_eNB_encode_ue_context_release_request(
-            &s1ap_message_p->msg.s1ap_UEContextReleaseRequestIEs, buffer, len);
-    s1ap_xer_print_s1ap_uecontextreleaserequest(s1ap_xer__print2sp,
-        message_string, s1ap_message_p);
-    message_id = S1AP_UE_CONTEXT_RELEASE_REQ_LOG;
-    break;
-
-
-  default:
-    S1AP_DEBUG("Unknown procedure ID (%d) for initiating message\n",
-               (int)s1ap_message_p->procedureCode);
-    return ret;
-    break;
+  asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
+  DevAssert(pdu != NULL);
+
+  switch(pdu->choice.initiatingMessage.procedureCode) {
+    case S1AP_ProcedureCode_id_S1Setup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_S1_SETUP_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_s1_setup_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_s1_setup_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_uplinkNASTransport:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_UPLINK_NAS_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_uplink_nas_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_uplink_nas_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_UECapabilityInfoIndication:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_UE_CAPABILITY_IND_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_ue_capability_ind_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_ue_capability_ind_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_initialUEMessage:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_INITIAL_UE_MESSAGE_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_initial_ue_message_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_initial_ue_message_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_NASNonDeliveryIndication:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_NAS_NON_DELIVERY_IND_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_nas_non_delivery_ind_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_nas_non_delivery_ind_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_UEContextReleaseRequest:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_UE_CONTEXT_RELEASE_REQ_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_ue_context_release_req_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_ue_context_release_req_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    default:
+      S1AP_DEBUG("Unknown procedure ID (%d) for initiating message\n",
+                 (int)pdu->choice.initiatingMessage.procedureCode);
+      return -1;
   }
 
-  message_string_size = strlen(message_string);
-
-  message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-  message_p->ittiMsg.s1ap_s1_setup_log.size = message_string_size;
-  memcpy(&message_p->ittiMsg.s1ap_s1_setup_log.text, message_string, message_string_size);
-
-  itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-
-  free(message_string);
+  if (asn1_xer_print) {
+    xer_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, (void *)pdu);
+  }
 
-  return ret;
+  memset(&res, 0, sizeof(res));
+  res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+  *buffer = res.buffer;
+  *len = res.result.encoded;
+  return 0;
 }
 
 static inline
-int s1ap_eNB_encode_successfull_outcome(s1ap_message *s1ap_message_p,
+int s1ap_eNB_encode_successfull_outcome(S1AP_S1AP_PDU_t *pdu,
                                         uint8_t **buffer, uint32_t *len)
 {
-  int ret = -1;
   MessageDef *message_p;
-  char       *message_string = NULL;
-  size_t      message_string_size;
   MessagesIds message_id;
-
-  DevAssert(s1ap_message_p != NULL);
-
-  message_string = calloc(10000, sizeof(char));
-
-  s1ap_string_total_size = 0;
-  message_string_size = strlen(message_string);
-
-
-  switch(s1ap_message_p->procedureCode) {
-  case S1ap_ProcedureCode_id_InitialContextSetup:
-    ret = s1ap_eNB_encode_initial_context_setup_response(
-            &s1ap_message_p->msg.s1ap_InitialContextSetupResponseIEs, buffer, len);
-
-    s1ap_xer_print_s1ap_initialcontextsetupresponse(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
-    message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_initial_context_setup_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    break;
-
-  case S1ap_ProcedureCode_id_UEContextRelease:
-    ret = s1ap_eNB_encode_ue_context_release_complete(
-            &s1ap_message_p->msg.s1ap_UEContextReleaseCompleteIEs, buffer, len);
-    s1ap_xer_print_s1ap_uecontextreleasecomplete(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id = S1AP_UE_CONTEXT_RELEASE_COMPLETE_LOG;
-    message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_ue_context_release_complete_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_ue_context_release_complete_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    break;
-
-  case S1ap_ProcedureCode_id_E_RABSetup:
-
-    ret = s1ap_eNB_encode_e_rab_setup_response (
-           &s1ap_message_p->msg.s1ap_E_RABSetupResponseIEs, buffer, len);
-    //s1ap_xer_print_s1ap_e_rabsetupresponse (s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id =  S1AP_E_RAB_SETUP_RESPONSE_LOG ;
-    message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_e_rab_setup_response_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_e_rab_setup_response_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    S1AP_INFO("E_RABSetup successful message\n");
-    break;
-
-  case S1ap_ProcedureCode_id_E_RABModify:
-    ret = s1ap_eNB_encode_e_rab_modify_response (
-           &s1ap_message_p->msg.s1ap_E_RABModifyResponseIEs, buffer, len);
-    message_id =  S1AP_E_RAB_MODIFY_RESPONSE_LOG ;
-    message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_e_rab_modify_response_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_e_rab_modify_response_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    S1AP_INFO("E_RABModify successful message\n");
-    break;
-
-  case S1ap_ProcedureCode_id_E_RABRelease:
-    ret = s1ap_eNB_encode_e_rab_release_response (
-           &s1ap_message_p->msg.s1ap_E_RABReleaseResponseIEs, buffer, len);
-    s1ap_xer_print_s1ap_e_rabreleaseresponse(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id =  S1AP_E_RAB_RELEASE_RESPONSE_LOG ;
-    message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-    message_p->ittiMsg.s1ap_e_rab_release_response_log.size = message_string_size;
-    memcpy(&message_p->ittiMsg.s1ap_e_rab_release_response_log.text, message_string, message_string_size);
-    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-    free(message_string);
-    S1AP_INFO("E_RAB Release successful message\n");
-    break;
-
-  default:
-    S1AP_WARN("Unknown procedure ID (%d) for successfull outcome message\n",
-               (int)s1ap_message_p->procedureCode);
-    return ret;
-    break;
+  asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
+  DevAssert(pdu != NULL);
+
+  switch(pdu->choice.successfulOutcome.procedureCode) {
+    case S1AP_ProcedureCode_id_InitialContextSetup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_initial_context_setup_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_UEContextRelease:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_UE_CONTEXT_RELEASE_COMPLETE_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_ue_context_release_complete_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_ue_context_release_complete_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    case S1AP_ProcedureCode_id_E_RABSetup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_E_RAB_SETUP_RESPONSE_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_e_rab_setup_response_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_e_rab_setup_response_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      S1AP_INFO("E_RABSetup successful message\n");
+      break;
+
+    case S1AP_ProcedureCode_id_E_RABModify:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_E_RAB_MODIFY_RESPONSE_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_e_rab_modify_response_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_e_rab_modify_response_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      S1AP_INFO("E_RABModify successful message\n");
+      break;
+
+    case S1AP_ProcedureCode_id_E_RABRelease:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_E_RAB_RELEASE_RESPONSE_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_e_rab_release_response_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_e_rab_release_response_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      S1AP_INFO("E_RAB Release successful message\n");
+      break;
+
+    default:
+      S1AP_WARN("Unknown procedure ID (%d) for successfull outcome message\n",
+                (int)pdu->choice.successfulOutcome.procedureCode);
+      return -1;
   }
 
+  if (asn1_xer_print) {
+    xer_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, (void *)pdu);
+  }
 
-  return ret;
+  memset(&res, 0, sizeof(res));
+  res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+  *buffer = res.buffer;
+  *len = res.result.encoded;
+  return 0;
 }
 
 static inline
-int s1ap_eNB_encode_unsuccessfull_outcome(s1ap_message *s1ap_message_p,
+int s1ap_eNB_encode_unsuccessfull_outcome(S1AP_S1AP_PDU_t *pdu,
     uint8_t **buffer, uint32_t *len)
 {
-  int ret = -1;
   MessageDef *message_p;
-  char       *message_string = NULL;
-  size_t      message_string_size;
   MessagesIds message_id;
-
-  DevAssert(s1ap_message_p != NULL);
-
-  message_string = calloc(10000, sizeof(char));
-
-  s1ap_string_total_size = 0;
-
-  switch(s1ap_message_p->procedureCode) {
-  case S1ap_ProcedureCode_id_InitialContextSetup:
-    //             ret = s1ap_encode_s1ap_initialcontextsetupfailureies(
-    //                 &s1ap_message_p->ittiMsg.s1ap_InitialContextSetupFailureIEs, buffer, len);
-    s1ap_xer_print_s1ap_initialcontextsetupfailure(s1ap_xer__print2sp, message_string, s1ap_message_p);
-    message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
-    break;
-
-  default:
-    S1AP_DEBUG("Unknown procedure ID (%d) for unsuccessfull outcome message\n",
-               (int)s1ap_message_p->procedureCode);
-    return ret;
-    break;
-  }
-
-  message_string_size = strlen(message_string);
-
-  message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
-  message_p->ittiMsg.s1ap_initial_context_setup_log.size = message_string_size;
-  memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, message_string, message_string_size);
-
-  itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
-
-  free(message_string);
-
-  return ret;
-}
-
-static inline
-int s1ap_eNB_encode_ue_capability_info_indication(
-  S1ap_UECapabilityInfoIndicationIEs_t *ueCapabilityInfoIndicationIEs,
-  uint8_t                             **buffer,
-  uint32_t                             *length)
-{
-  S1ap_UECapabilityInfoIndication_t  ueCapabilityInfoIndication;
-  S1ap_UECapabilityInfoIndication_t *ueCapabilityInfoIndication_p =
-    &ueCapabilityInfoIndication;
-
-  memset((void *)ueCapabilityInfoIndication_p, 0,  sizeof(ueCapabilityInfoIndication));
-
-  if (s1ap_encode_s1ap_uecapabilityinfoindicationies(
-        ueCapabilityInfoIndication_p, ueCapabilityInfoIndicationIEs) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_initiating_message(buffer,
-                                          length,
-                                          S1ap_ProcedureCode_id_UECapabilityInfoIndication,
-                                          S1ap_Criticality_ignore,
-                                          &asn_DEF_S1ap_UECapabilityInfoIndication,
-                                          ueCapabilityInfoIndication_p);
-}
-
-static inline
-int s1ap_eNB_encode_uplink_nas_transport(
-  S1ap_UplinkNASTransportIEs_t *uplinkNASTransportIEs,
-  uint8_t                     **buffer,
-  uint32_t                     *length)
-{
-  S1ap_UplinkNASTransport_t  uplinkNASTransport;
-  S1ap_UplinkNASTransport_t *uplinkNASTransport_p = &uplinkNASTransport;
-
-  memset((void *)uplinkNASTransport_p, 0, sizeof(uplinkNASTransport));
-
-  if (s1ap_encode_s1ap_uplinknastransporties(
-        uplinkNASTransport_p, uplinkNASTransportIEs) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_initiating_message(buffer,
-                                          length,
-                                          S1ap_ProcedureCode_id_uplinkNASTransport,
-                                          S1ap_Criticality_ignore,
-                                          &asn_DEF_S1ap_UplinkNASTransport,
-                                          uplinkNASTransport_p);
-}
-
-static inline
-int s1ap_eNB_encode_nas_non_delivery(
-  S1ap_NASNonDeliveryIndication_IEs_t *nasNonDeliveryIndicationIEs,
-  uint8_t                            **buffer,
-  uint32_t                            *length)
-{
-  S1ap_NASNonDeliveryIndication_t  nasNonDeliveryIndication;
-  S1ap_NASNonDeliveryIndication_t *nasNonDeliveryIndication_p = &nasNonDeliveryIndication;
-
-  memset((void *)nasNonDeliveryIndication_p, 0, sizeof(nasNonDeliveryIndication));
-
-  if (s1ap_encode_s1ap_nasnondeliveryindication_ies(
-        nasNonDeliveryIndication_p, nasNonDeliveryIndicationIEs) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_initiating_message(buffer,
-                                          length,
-                                          S1ap_ProcedureCode_id_NASNonDeliveryIndication,
-                                          S1ap_Criticality_ignore,
-                                          &asn_DEF_S1ap_NASNonDeliveryIndication,
-                                          nasNonDeliveryIndication_p);
-}
-
-static inline
-int s1ap_eNB_encode_s1_setup_request(
-  S1ap_S1SetupRequestIEs_t *s1SetupRequestIEs,
-  uint8_t                 **buffer,
-  uint32_t                 *length)
-{
-  S1ap_S1SetupRequest_t  s1SetupRequest;
-  S1ap_S1SetupRequest_t *s1SetupRequest_p = &s1SetupRequest;
-
-  memset((void *)s1SetupRequest_p, 0, sizeof(s1SetupRequest));
-
-  if (s1ap_encode_s1ap_s1setuprequesties(s1SetupRequest_p, s1SetupRequestIEs) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_initiating_message(buffer,
-                                          length,
-                                          S1ap_ProcedureCode_id_S1Setup,
-                                          S1ap_Criticality_reject,
-                                          &asn_DEF_S1ap_S1SetupRequest,
-                                          s1SetupRequest_p);
-}
-
-static inline
-int s1ap_eNB_encode_initial_ue_message(
-  S1ap_InitialUEMessageIEs_t *initialUEmessageIEs_p,
-  uint8_t                   **buffer,
-  uint32_t                   *length)
-{
-  S1ap_InitialUEMessage_t  initialUEMessage;
-  S1ap_InitialUEMessage_t *initialUEMessage_p = &initialUEMessage;
-
-  memset((void *)initialUEMessage_p, 0, sizeof(initialUEMessage));
-
-  if (s1ap_encode_s1ap_initialuemessageies(
-        initialUEMessage_p, initialUEmessageIEs_p) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_initiating_message(buffer,
-                                          length,
-                                          S1ap_ProcedureCode_id_initialUEMessage,
-                                          S1ap_Criticality_ignore,
-                                          &asn_DEF_S1ap_InitialUEMessage,
-                                          initialUEMessage_p);
-}
-
-static inline
-int s1ap_eNB_encode_trace_failure(
-  S1ap_TraceFailureIndicationIEs_t *trace_failure_ies_p,
-  uint8_t                         **buffer,
-  uint32_t                         *length)
-{
-  S1ap_TraceFailureIndication_t  trace_failure;
-  S1ap_TraceFailureIndication_t *trace_failure_p = &trace_failure;
-
-  memset((void *)trace_failure_p, 0, sizeof(trace_failure));
-
-  if (s1ap_encode_s1ap_tracefailureindicationies(
-        trace_failure_p, trace_failure_ies_p) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_initiating_message(buffer,
-                                          length,
-                                          S1ap_ProcedureCode_id_TraceFailureIndication,
-                                          S1ap_Criticality_reject,
-                                          &asn_DEF_S1ap_TraceFailureIndication,
-                                          trace_failure_p);
-}
-
-static inline
-int s1ap_eNB_encode_initial_context_setup_response(
-  S1ap_InitialContextSetupResponseIEs_t *initialContextSetupResponseIEs,
-  uint8_t                              **buffer,
-  uint32_t                              *length)
-{
-  S1ap_InitialContextSetupResponse_t  initial_context_setup_response;
-  S1ap_InitialContextSetupResponse_t *initial_context_setup_response_p =
-    &initial_context_setup_response;
-
-  memset((void *)initial_context_setup_response_p, 0,
-         sizeof(initial_context_setup_response));
-
-  if (s1ap_encode_s1ap_initialcontextsetupresponseies(
-        initial_context_setup_response_p, initialContextSetupResponseIEs) < 0) {
-    return -1;
+  asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
+  DevAssert(pdu != NULL);
+
+  switch(pdu->choice.unsuccessfulOutcome.procedureCode) {
+    case S1AP_ProcedureCode_id_InitialContextSetup:
+      res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+      message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
+      message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, res.result.encoded + sizeof (IttiMsgText));
+      message_p->ittiMsg.s1ap_initial_context_setup_log.size = res.result.encoded;
+      memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, res.buffer, res.result.encoded);
+      itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
+      free(res.buffer);
+      break;
+
+    default:
+      S1AP_DEBUG("Unknown procedure ID (%d) for unsuccessfull outcome message\n",
+                 (int)pdu->choice.unsuccessfulOutcome.procedureCode);
+      return -1;
   }
 
-  return s1ap_generate_successfull_outcome(buffer,
-         length,
-         S1ap_ProcedureCode_id_InitialContextSetup,
-         S1ap_Criticality_reject,
-         &asn_DEF_S1ap_InitialContextSetupResponse,
-         initial_context_setup_response_p);
-}
-
-static inline
-int s1ap_eNB_encode_ue_context_release_complete(
-  S1ap_UEContextReleaseCompleteIEs_t *s1ap_UEContextReleaseCompleteIEs,
-  uint8_t                              **buffer,
-  uint32_t                              *length)
-{
-  S1ap_UEContextReleaseComplete_t  ue_context_release_complete;
-  S1ap_UEContextReleaseComplete_t *ue_context_release_complete_p =
-    &ue_context_release_complete;
-
-  memset((void *)ue_context_release_complete_p, 0,
-         sizeof(ue_context_release_complete));
-
-  if (s1ap_encode_s1ap_uecontextreleasecompleteies(
-        ue_context_release_complete_p, s1ap_UEContextReleaseCompleteIEs) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_successfull_outcome(buffer,
-         length,
-         S1ap_ProcedureCode_id_UEContextRelease,
-         S1ap_Criticality_reject,
-         &asn_DEF_S1ap_UEContextReleaseComplete,
-         ue_context_release_complete_p);
-}
-
-static inline
-int s1ap_eNB_encode_ue_context_release_request(
-  S1ap_UEContextReleaseRequestIEs_t *s1ap_UEContextReleaseRequestIEs,
-  uint8_t                              **buffer,
-  uint32_t                              *length)
-{
-  S1ap_UEContextReleaseRequest_t  ue_context_release_request;
-  S1ap_UEContextReleaseRequest_t *ue_context_release_request_p =
-    &ue_context_release_request;
-
-  memset((void *)ue_context_release_request_p, 0,
-         sizeof(ue_context_release_request));
-
-  if (s1ap_encode_s1ap_uecontextreleaserequesties(
-        ue_context_release_request_p, s1ap_UEContextReleaseRequestIEs) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_initiating_message(buffer,
-                                          length,
-                                          S1ap_ProcedureCode_id_UEContextReleaseRequest,
-                                          S1ap_Criticality_reject,
-                                          &asn_DEF_S1ap_UEContextReleaseRequest,
-                                          ue_context_release_request_p);
-}
-
-static inline
-int s1ap_eNB_encode_e_rab_setup_response(S1ap_E_RABSetupResponseIEs_t  *s1ap_E_RABSetupResponseIEs,
-					 uint8_t                              **buffer,
-					 uint32_t                              *length)
-{
-  S1ap_E_RABSetupResponse_t  e_rab_setup_response;
-  S1ap_E_RABSetupResponse_t  *e_rab_setup_response_p = &e_rab_setup_response;
-  
-  memset((void *)e_rab_setup_response_p, 0,
-         sizeof(e_rab_setup_response));
-
-  if (s1ap_encode_s1ap_e_rabsetupresponseies (e_rab_setup_response_p, s1ap_E_RABSetupResponseIEs) < 0) {
-    return -1;
-  }
-  
-  return s1ap_generate_successfull_outcome(buffer,
-         length,
-         S1ap_ProcedureCode_id_E_RABSetup,
-         S1ap_Criticality_reject,
-         &asn_DEF_S1ap_E_RABSetupResponse,
-         e_rab_setup_response_p);
-}
-
-static inline
-int s1ap_eNB_encode_e_rab_modify_response(S1ap_E_RABModifyResponseIEs_t  *s1ap_E_RABModifyResponseIEs,
-           uint8_t                              **buffer,
-           uint32_t                              *length)
-{
-  S1ap_E_RABModifyResponse_t  e_rab_modify_response;
-  S1ap_E_RABModifyResponse_t  *e_rab_modify_response_p = &e_rab_modify_response;
-
-  memset((void *)e_rab_modify_response_p, 0,
-         sizeof(e_rab_modify_response));
-
-  if (s1ap_encode_s1ap_e_rabmodifyresponseies (e_rab_modify_response_p, s1ap_E_RABModifyResponseIEs) < 0) {
-    return -1;
-  }
-
-  return s1ap_generate_successfull_outcome(buffer,
-         length,
-         S1ap_ProcedureCode_id_E_RABModify,
-         S1ap_Criticality_reject,
-         &asn_DEF_S1ap_E_RABModifyResponse,
-         e_rab_modify_response_p);
-}
-static inline
-int s1ap_eNB_encode_e_rab_release_response(S1ap_E_RABReleaseResponseIEs_t  *s1ap_E_RABReleaseResponseIEs,
-                     uint8_t                              **buffer,
-                     uint32_t                              *length)
-{
-    S1ap_E_RABReleaseResponse_t  e_rab_release_response;
-    S1ap_E_RABReleaseResponse_t  *e_rab_release_response_p = &e_rab_release_response;
-
-  memset((void *)e_rab_release_response_p, 0,
-         sizeof(e_rab_release_response));
-
-  if (s1ap_encode_s1ap_e_rabreleaseresponseies (e_rab_release_response_p, s1ap_E_RABReleaseResponseIEs) < 0) {
-    return -1;
+  if (asn1_xer_print) {
+    xer_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, (void *)pdu);
   }
 
-  return s1ap_generate_successfull_outcome(buffer,
-         length,
-         S1ap_ProcedureCode_id_E_RABRelease,
-         S1ap_Criticality_reject,
-         &asn_DEF_S1ap_E_RABReleaseResponse,
-         e_rab_release_response_p);
+  memset(&res, 0, sizeof(res));
+  res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_S1AP_S1AP_PDU, pdu);
+  *buffer = res.buffer;
+  *len = res.result.encoded;
+  return 0;
 }
diff --git a/openair3/S1AP/s1ap_eNB_encoder.h b/openair3/S1AP/s1ap_eNB_encoder.h
index 5b135a3f76c2c996811d338f1c53f8aac34cedd1..9ff5f032e7bf93bc4293311930248b1b86751333 100644
--- a/openair3/S1AP/s1ap_eNB_encoder.h
+++ b/openair3/S1AP/s1ap_eNB_encoder.h
@@ -22,7 +22,7 @@
 #ifndef S1AP_ENB_ENCODER_H_
 #define S1AP_ENB_ENCODER_H_
 
-int s1ap_eNB_encode_pdu(s1ap_message *message, uint8_t **buffer, uint32_t *len)
+int s1ap_eNB_encode_pdu(S1AP_S1AP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
 __attribute__ ((warn_unused_result));
 
 #endif /* S1AP_ENB_ENCODER_H_ */
diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c
index 0b02fc6db9ee4c0580ec108bdeb50bd162372d52..66277b12260bfb90f09b5aa0039b4e524b9fde12 100644
--- a/openair3/S1AP/s1ap_eNB_handlers.c
+++ b/openair3/S1AP/s1ap_eNB_handlers.c
@@ -34,7 +34,6 @@
 #include "asn1_conversions.h"
 
 #include "s1ap_common.h"
-#include "s1ap_ies_defs.h"
 // #include "s1ap_eNB.h"
 #include "s1ap_eNB_defs.h"
 #include "s1ap_eNB_handlers.h"
@@ -54,47 +53,47 @@
 static
 int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
                                       uint32_t               stream,
-                                      struct s1ap_message_s *message_p);
+                                      S1AP_S1AP_PDU_t       *pdu);
 static
 int s1ap_eNB_handle_s1_setup_failure(uint32_t               assoc_id,
                                      uint32_t               stream,
-                                     struct s1ap_message_s *message_p);
+                                     S1AP_S1AP_PDU_t       *pdu);
 
 static
 int s1ap_eNB_handle_error_indication(uint32_t               assoc_id,
-    uint32_t               stream,
-    struct s1ap_message_s *message_p);
+                                     uint32_t               stream,
+                                     S1AP_S1AP_PDU_t       *pdu);
 
 static
 int s1ap_eNB_handle_initial_context_request(uint32_t               assoc_id,
     uint32_t               stream,
-    struct s1ap_message_s *message_p);
+    S1AP_S1AP_PDU_t       *pdu);
 
 static
 int s1ap_eNB_handle_ue_context_release_command(uint32_t               assoc_id,
     uint32_t               stream,
-    struct s1ap_message_s *s1ap_message_p);
+    S1AP_S1AP_PDU_t       *pdu);
 
 
 static
 int s1ap_eNB_handle_e_rab_setup_request(uint32_t               assoc_id,
-					uint32_t               stream,
-					struct s1ap_message_s *s1ap_message_p);
+                                        uint32_t               stream,
+                                        S1AP_S1AP_PDU_t       *pdu);
 
 static
 int s1ap_eNB_handle_paging(uint32_t               assoc_id,
-    uint32_t               stream,
-    struct s1ap_message_s *message_p);
+                           uint32_t               stream,
+                           S1AP_S1AP_PDU_t       *pdu);
 
 static
 int s1ap_eNB_handle_e_rab_modify_request(uint32_t               assoc_id,
     uint32_t               stream,
-    struct s1ap_message_s *s1ap_message_p);
+    S1AP_S1AP_PDU_t       *pdu);
 
 static
 int s1ap_eNB_handle_e_rab_release_command(uint32_t               assoc_id,
     uint32_t               stream,
-    struct s1ap_message_s *s1ap_message_p);
+    S1AP_S1AP_PDU_t       *pdu);
 
 /* Handlers matrix. Only eNB related procedure present here */
 s1ap_message_decoded_callback messages_callback[][3] = {
@@ -174,7 +173,6 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut
       /* If there are no more associated MME, inform eNB app */
       if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb == 0) {
         MessageDef                 *message_p;
-
         message_p = itti_alloc_new_message(TASK_S1AP, S1AP_DEREGISTERED_ENB_IND);
         S1AP_DEREGISTERED_ENB_IND(message_p).nb_mme = 0;
         itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
@@ -193,7 +191,6 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut
     /* If there are no more pending messages, inform eNB app */
     if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb == 0) {
       MessageDef                 *message_p;
-
       message_p = itti_alloc_new_message(TASK_S1AP, S1AP_REGISTER_ENB_CNF);
       S1AP_REGISTER_ENB_CNF(message_p).nb_mme = mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb;
       itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
@@ -202,54 +199,56 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut
 }
 
 int s1ap_eNB_handle_message(uint32_t assoc_id, int32_t stream,
-                            const uint8_t * const data, const uint32_t data_length)
+                            const uint8_t *const data, const uint32_t data_length)
 {
-  struct s1ap_message_s message;
-
+  S1AP_S1AP_PDU_t pdu;
+  int ret = -1;
   DevAssert(data != NULL);
+  memset(&pdu, 0, sizeof(pdu));
 
-  memset(&message, 0, sizeof(struct s1ap_message_s));
-
-  if (s1ap_eNB_decode_pdu(&message, data, data_length) < 0) {
+  if (s1ap_eNB_decode_pdu(&pdu, data, data_length) < 0) {
     S1AP_ERROR("Failed to decode PDU\n");
     return -1;
   }
 
   /* Checking procedure Code and direction of message */
-  if (message.procedureCode > sizeof(messages_callback) / (3 * sizeof(
+  if (pdu.choice.initiatingMessage.procedureCode > sizeof(messages_callback) / (3 * sizeof(
         s1ap_message_decoded_callback))
-      || (message.direction > S1AP_PDU_PR_unsuccessfulOutcome)) {
+      || (pdu.present > S1AP_S1AP_PDU_PR_unsuccessfulOutcome)) {
     S1AP_ERROR("[SCTP %d] Either procedureCode %ld or direction %d exceed expected\n",
-               assoc_id, message.procedureCode, message.direction);
+               assoc_id, pdu.choice.initiatingMessage.procedureCode, pdu.present);
+    ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_S1AP_PDU, &pdu);
     return -1;
   }
 
   /* No handler present.
    * This can mean not implemented or no procedure for eNB (wrong direction).
    */
-  if (messages_callback[message.procedureCode][message.direction-1] == NULL) {
+  if (messages_callback[pdu.choice.initiatingMessage.procedureCode][pdu.present - 1] == NULL) {
     S1AP_ERROR("[SCTP %d] No handler for procedureCode %ld in %s\n",
-               assoc_id, message.procedureCode,
-               s1ap_direction2String[message.direction]);
+               assoc_id, pdu.choice.initiatingMessage.procedureCode,
+               s1ap_direction2String[pdu.present - 1]);
+    ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_S1AP_PDU, &pdu);
     return -1;
   }
 
   /* Calling the right handler */
-  return (*messages_callback[message.procedureCode][message.direction-1])
-         (assoc_id, stream, &message);
+  ret = (*messages_callback[pdu.choice.initiatingMessage.procedureCode][pdu.present - 1])
+        (assoc_id, stream, &pdu);
+  ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_S1AP_PDU, &pdu);
+  return ret;
 }
 
 static
 int s1ap_eNB_handle_s1_setup_failure(uint32_t               assoc_id,
                                      uint32_t               stream,
-                                     struct s1ap_message_s *message_p)
+                                     S1AP_S1AP_PDU_t       *pdu)
 {
-  S1ap_S1SetupFailureIEs_t   *s1_setup_failure_p;
+  S1AP_S1SetupFailure_t      *container;
+  S1AP_S1SetupFailureIEs_t   *ie;
   s1ap_eNB_mme_data_t        *mme_desc_p;
-
-  DevAssert(message_p != NULL);
-
-  s1_setup_failure_p = &message_p->msg.s1ap_S1SetupFailureIEs;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.unsuccessfulOutcome.value.choice.S1SetupFailure;
 
   /* S1 Setup Failure == Non UE-related procedure -> stream 0 */
   if (stream != 0) {
@@ -263,8 +262,11 @@ int s1ap_eNB_handle_s1_setup_failure(uint32_t               assoc_id,
     return -1;
   }
 
-  if ((s1_setup_failure_p->cause.present == S1ap_Cause_PR_misc) &&
-      (s1_setup_failure_p->cause.choice.misc == S1ap_CauseMisc_unspecified)) {
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupFailureIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, TRUE);
+
+  if ((ie->value.choice.Cause.present == S1AP_Cause_PR_misc) &&
+      (ie->value.choice.Cause.choice.misc == S1AP_CauseMisc_unspecified)) {
     S1AP_WARN("Received s1 setup failure for MME... MME is not ready\n");
   } else {
     S1AP_ERROR("Received s1 setup failure for MME... please check your parameters\n");
@@ -272,22 +274,20 @@ int s1ap_eNB_handle_s1_setup_failure(uint32_t               assoc_id,
 
   mme_desc_p->state = S1AP_ENB_STATE_WAITING;
   s1ap_handle_s1_setup_message(mme_desc_p, 0);
-
   return 0;
 }
 
 static
 int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
                                       uint32_t               stream,
-                                      struct s1ap_message_s *message_p)
+                                      S1AP_S1AP_PDU_t       *pdu)
 {
-  S1ap_S1SetupResponseIEs_t *s1SetupResponse_p;
+  S1AP_S1SetupResponse_t    *container;
+  S1AP_S1SetupResponseIEs_t *ie;
   s1ap_eNB_mme_data_t       *mme_desc_p;
   int i;
-
-  DevAssert(message_p != NULL);
-
-  s1SetupResponse_p = &message_p->msg.s1ap_S1SetupResponseIEs;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.successfulOutcome.value.choice.S1SetupResponse;
 
   /* S1 Setup Response == Non UE-related procedure -> stream 0 */
   if (stream != 0) {
@@ -302,32 +302,29 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
     return -1;
   }
 
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_ServedGUMMEIs, TRUE);
   /* The list of served gummei can contain at most 8 elements.
    * LTE related gummei is the first element in the list, i.e with an id of 0.
    */
-  S1AP_DEBUG("servedGUMMEIs.list.count %d\n",s1SetupResponse_p->servedGUMMEIs.list.count); 
-  DevAssert(s1SetupResponse_p->servedGUMMEIs.list.count > 0);
-  DevAssert(s1SetupResponse_p->servedGUMMEIs.list.count <= 8);
+  S1AP_DEBUG("servedGUMMEIs.list.count %d\n", ie->value.choice.ServedGUMMEIs.list.count);
+  DevAssert(ie->value.choice.ServedGUMMEIs.list.count > 0);
+  DevAssert(ie->value.choice.ServedGUMMEIs.list.count <= S1AP_maxnoofRATs);
 
-
-  for (i = 0; i < s1SetupResponse_p->servedGUMMEIs.list.count; i++) {
-    struct S1ap_ServedGUMMEIsItem *gummei_item_p;
-    struct served_gummei_s        *new_gummei_p;
+  for (i = 0; i < ie->value.choice.ServedGUMMEIs.list.count; i++) {
+    S1AP_ServedGUMMEIsItem_t *gummei_item_p;
+    struct served_gummei_s   *new_gummei_p;
     int j;
-
-    gummei_item_p = (struct S1ap_ServedGUMMEIsItem *)
-                    s1SetupResponse_p->servedGUMMEIs.list.array[i];
+    gummei_item_p = ie->value.choice.ServedGUMMEIs.list.array[i];
     new_gummei_p = calloc(1, sizeof(struct served_gummei_s));
-
     STAILQ_INIT(&new_gummei_p->served_plmns);
     STAILQ_INIT(&new_gummei_p->served_group_ids);
     STAILQ_INIT(&new_gummei_p->mme_codes);
-    
-    S1AP_DEBUG("servedPLMNs.list.count %d\n",gummei_item_p->servedPLMNs.list.count);
+    S1AP_DEBUG("servedPLMNs.list.count %d\n", gummei_item_p->servedPLMNs.list.count);
+
     for (j = 0; j < gummei_item_p->servedPLMNs.list.count; j++) {
-      S1ap_PLMNidentity_t *plmn_identity_p;
+      S1AP_PLMNidentity_t *plmn_identity_p;
       struct plmn_identity_s *new_plmn_identity_p;
-      
       plmn_identity_p = gummei_item_p->servedPLMNs.list.array[j];
       new_plmn_identity_p = calloc(1, sizeof(struct plmn_identity_s));
       TBCD_TO_MCC_MNC(plmn_identity_p, new_plmn_identity_p->mcc,
@@ -337,9 +334,8 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
     }
 
     for (j = 0; j < gummei_item_p->servedGroupIDs.list.count; j++) {
-      S1ap_MME_Group_ID_t           *mme_group_id_p;
+      S1AP_MME_Group_ID_t           *mme_group_id_p;
       struct served_group_id_s *new_group_id_p;
-
       mme_group_id_p = gummei_item_p->servedGroupIDs.list.array[j];
       new_group_id_p = calloc(1, sizeof(struct served_group_id_s));
       OCTET_STRING_TO_INT16(mme_group_id_p, new_group_id_p->mme_group_id);
@@ -348,12 +344,10 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
     }
 
     for (j = 0; j < gummei_item_p->servedMMECs.list.count; j++) {
-      S1ap_MME_Code_t        *mme_code_p;
+      S1AP_MME_Code_t        *mme_code_p;
       struct mme_code_s *new_mme_code_p;
-
       mme_code_p = gummei_item_p->servedMMECs.list.array[j];
       new_mme_code_p = calloc(1, sizeof(struct mme_code_s));
-
       OCTET_STRING_TO_INT8(mme_code_p, new_mme_code_p->mme_code);
       STAILQ_INSERT_TAIL(&new_gummei_p->mme_codes, new_mme_code_p, next);
       new_gummei_p->nb_mme_code++;
@@ -362,19 +356,20 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
     STAILQ_INSERT_TAIL(&mme_desc_p->served_gummei, new_gummei_p, next);
   }
 
-  /* Free contents of the list */
-  ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1ap_ServedGUMMEIs,
-                                (void *)&s1SetupResponse_p->servedGUMMEIs);
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_RelativeMMECapacity, TRUE);
   /* Set the capacity of this MME */
-  mme_desc_p->relative_mme_capacity = s1SetupResponse_p->relativeMMECapacity;
+  mme_desc_p->relative_mme_capacity = ie->value.choice.RelativeMMECapacity;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MMEname, FALSE);
 
   /* Optionaly set the mme name */
-  if (s1SetupResponse_p->presenceMask & S1AP_S1SETUPRESPONSEIES_MMENAME_PRESENT) {
-    mme_desc_p->mme_name = calloc(s1SetupResponse_p->mmEname.size + 1, sizeof(char));
-    memcpy(mme_desc_p->mme_name, s1SetupResponse_p->mmEname.buf,
-           s1SetupResponse_p->mmEname.size);
+  if (ie) {
+    mme_desc_p->mme_name = calloc(ie->value.choice.MMEname.size + 1, sizeof(char));
+    memcpy(mme_desc_p->mme_name, ie->value.choice.MMEname.buf,
+           ie->value.choice.MMEname.size);
     /* Convert the mme name to a printable string */
-    mme_desc_p->mme_name[s1SetupResponse_p->mmEname.size] = '\0';
+    mme_desc_p->mme_name[ie->value.choice.MMEname.size] = '\0';
   }
 
   /* The association is now ready as eNB and MME know parameters of each other.
@@ -383,25 +378,20 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
   mme_desc_p->state = S1AP_ENB_STATE_CONNECTED;
   mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb ++;
   s1ap_handle_s1_setup_message(mme_desc_p, 0);
-
 #if 0
   /* We call back our self
    * -> generate a dummy initial UE message
    */
   {
     s1ap_nas_first_req_t s1ap_nas_first_req;
-
     memset(&s1ap_nas_first_req, 0, sizeof(s1ap_nas_first_req_t));
-
     s1ap_nas_first_req.rnti = 0xC03A;
     s1ap_nas_first_req.establishment_cause = RRC_CAUSE_MO_DATA;
     s1ap_nas_first_req.ue_identity.presenceMask = UE_IDENTITIES_gummei;
-
     s1ap_nas_first_req.ue_identity.gummei.mcc = 208;
     s1ap_nas_first_req.ue_identity.gummei.mnc = 34;
     s1ap_nas_first_req.ue_identity.gummei.mme_code = 0;
     s1ap_nas_first_req.ue_identity.gummei.mme_group_id = 0;
-
     /* NAS Attach request with IMSI */
     static uint8_t nas_attach_req_imsi[] = {
       0x07, 0x41,
@@ -415,7 +405,6 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
       0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2,
       0x01, 0x27, 0x11,
     };
-
     /* NAS Attach request with GUTI */
     static uint8_t nas_attach_req_guti[] = {
       0x07, 0x41,
@@ -429,30 +418,26 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
       0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2,
       0x01, 0x27, 0x11,
     };
-
     s1ap_nas_first_req.nas_pdu.buffer = nas_attach_req_guti;
     s1ap_nas_first_req.nas_pdu.length = sizeof(nas_attach_req_guti);
-
     s1ap_eNB_handle_nas_first_req(mme_desc_p->s1ap_eNB_instance->instance,
                                   &s1ap_nas_first_req);
   }
 #endif
-
   return 0;
 }
 
 
 static
-int s1ap_eNB_handle_error_indication(uint32_t               assoc_id,
-                                     uint32_t               stream,
-                                     struct s1ap_message_s *message_p)
+int s1ap_eNB_handle_error_indication(uint32_t         assoc_id,
+                                     uint32_t         stream,
+                                     S1AP_S1AP_PDU_t *pdu)
 {
-  S1ap_ErrorIndicationIEs_t   *s1_error_indication_p;
+  S1AP_ErrorIndication_t    *container;
+  S1AP_ErrorIndicationIEs_t *ie;
   s1ap_eNB_mme_data_t        *mme_desc_p;
-
-  DevAssert(message_p != NULL);
-
-  s1_error_indication_p = &message_p->msg.s1ap_ErrorIndicationIEs;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.ErrorIndication;
 
   /* S1 Setup Failure == Non UE-related procedure -> stream 0 */
   if (stream != 0) {
@@ -465,255 +450,337 @@ int s1ap_eNB_handle_error_indication(uint32_t               assoc_id,
                "MME context\n", assoc_id);
     return -1;
   }
-  if ( s1_error_indication_p->presenceMask & S1AP_ERRORINDICATIONIES_MME_UE_S1AP_ID_PRESENT) {
-	  	S1AP_WARN("Received S1 Error indication MME UE S1AP ID 0x%lx\n", s1_error_indication_p->mme_ue_s1ap_id);
+
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_ErrorIndicationIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, FALSE);
+
+  /* optional */
+  if (!ie) {
+    S1AP_WARN("Received S1 Error indication MME UE S1AP ID 0x%lx\n", ie->value.choice.MME_UE_S1AP_ID);
   }
-  if ( s1_error_indication_p->presenceMask & S1AP_ERRORINDICATIONIES_ENB_UE_S1AP_ID_PRESENT) {
-  	S1AP_WARN("Received S1 Error indication eNB UE S1AP ID 0x%lx\n", s1_error_indication_p->eNB_UE_S1AP_ID);
+
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_ErrorIndicationIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, FALSE);
+
+  /* optional */
+  if (!ie) {
+    S1AP_WARN("Received S1 Error indication eNB UE S1AP ID 0x%lx\n", ie->value.choice.ENB_UE_S1AP_ID);
   }
 
-  if ( s1_error_indication_p->presenceMask & S1AP_ERRORINDICATIONIES_CAUSE_PRESENT) {
-    switch(s1_error_indication_p->cause.present) {
-      case S1ap_Cause_PR_NOTHING:
-    	S1AP_WARN("Received S1 Error indication cause NOTHING\n");
-      break;
-      case S1ap_Cause_PR_radioNetwork:
-      	switch (s1_error_indication_p->cause.choice.radioNetwork) {
-	      case S1ap_CauseRadioNetwork_unspecified:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_unspecified\n");
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_ErrorIndicationIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_Cause, FALSE);
+
+  /* optional */
+  if (ie) {
+    switch(ie->value.choice.Cause.present) {
+      case S1AP_Cause_PR_NOTHING:
+        S1AP_WARN("Received S1 Error indication cause NOTHING\n");
+        break;
+
+      case S1AP_Cause_PR_radioNetwork:
+        switch (ie->value.choice.Cause.choice.radioNetwork) {
+          case S1AP_CauseRadioNetwork_unspecified:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unspecified\n");
             break;
-  	      case S1ap_CauseRadioNetwork_tx2relocoverall_expiry:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_tx2relocoverall_expiry\n");
+
+          case S1AP_CauseRadioNetwork_tx2relocoverall_expiry:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_tx2relocoverall_expiry\n");
             break;
-  	      case S1ap_CauseRadioNetwork_successful_handover:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_successful_handover\n");
+
+          case S1AP_CauseRadioNetwork_successful_handover:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_successful_handover\n");
             break;
-  	      case S1ap_CauseRadioNetwork_release_due_to_eutran_generated_reason:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_release_due_to_eutran_generated_reason\n");
+
+          case S1AP_CauseRadioNetwork_release_due_to_eutran_generated_reason:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_release_due_to_eutran_generated_reason\n");
             break;
-  	      case S1ap_CauseRadioNetwork_handover_cancelled:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_handover_cancelled\n");
+
+          case S1AP_CauseRadioNetwork_handover_cancelled:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_handover_cancelled\n");
             break;
-  	      case S1ap_CauseRadioNetwork_partial_handover:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_partial_handover\n");
+
+          case S1AP_CauseRadioNetwork_partial_handover:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_partial_handover\n");
             break;
-  	      case S1ap_CauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system\n");
+
+          case S1AP_CauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system\n");
             break;
-  	      case S1ap_CauseRadioNetwork_ho_target_not_allowed:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_ho_target_not_allowed\n");
+
+          case S1AP_CauseRadioNetwork_ho_target_not_allowed:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_ho_target_not_allowed\n");
             break;
-  	      case S1ap_CauseRadioNetwork_tS1relocoverall_expiry:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_tS1relocoverall_expiry\n");
+
+          case S1AP_CauseRadioNetwork_tS1relocoverall_expiry:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_tS1relocoverall_expiry\n");
             break;
-  	      case S1ap_CauseRadioNetwork_tS1relocprep_expiry:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_tS1relocprep_expiry\n");
+
+          case S1AP_CauseRadioNetwork_tS1relocprep_expiry:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_tS1relocprep_expiry\n");
             break;
-  	      case S1ap_CauseRadioNetwork_cell_not_available:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_cell_not_available\n");
+
+          case S1AP_CauseRadioNetwork_cell_not_available:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_cell_not_available\n");
             break;
-  	      case S1ap_CauseRadioNetwork_unknown_targetID:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_unknown_targetID\n");
+
+          case S1AP_CauseRadioNetwork_unknown_targetID:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_targetID\n");
             break;
-  	      case S1ap_CauseRadioNetwork_no_radio_resources_available_in_target_cell:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_no_radio_resources_available_in_target_cell\n");
+
+          case S1AP_CauseRadioNetwork_no_radio_resources_available_in_target_cell:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_no_radio_resources_available_in_target_cell\n");
             break;
-  	      case S1ap_CauseRadioNetwork_unknown_mme_ue_s1ap_id:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_unknown_mme_ue_s1ap_id\n");
+
+          case S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id\n");
             break;
-  	      case S1ap_CauseRadioNetwork_unknown_enb_ue_s1ap_id:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_unknown_enb_ue_s1ap_id\n");
+
+          case S1AP_CauseRadioNetwork_unknown_enb_ue_s1ap_id:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_enb_ue_s1ap_id\n");
             break;
-  	      case S1ap_CauseRadioNetwork_unknown_pair_ue_s1ap_id:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_unknown_pair_ue_s1ap_id\n");
+
+          case S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id\n");
             break;
-  	      case S1ap_CauseRadioNetwork_handover_desirable_for_radio_reason:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_handover_desirable_for_radio_reason\n");
+
+          case S1AP_CauseRadioNetwork_handover_desirable_for_radio_reason:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_handover_desirable_for_radio_reason\n");
             break;
-  	      case S1ap_CauseRadioNetwork_time_critical_handover:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_time_critical_handover\n");
+
+          case S1AP_CauseRadioNetwork_time_critical_handover:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_time_critical_handover\n");
             break;
-  	      case S1ap_CauseRadioNetwork_resource_optimisation_handover:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_resource_optimisation_handover\n");
+
+          case S1AP_CauseRadioNetwork_resource_optimisation_handover:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_resource_optimisation_handover\n");
             break;
-  	      case S1ap_CauseRadioNetwork_reduce_load_in_serving_cell:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_reduce_load_in_serving_cell\n");
+
+          case S1AP_CauseRadioNetwork_reduce_load_in_serving_cell:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_reduce_load_in_serving_cell\n");
             break;
-  	      case S1ap_CauseRadioNetwork_user_inactivity:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_user_inactivity\n");
+
+          case S1AP_CauseRadioNetwork_user_inactivity:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_user_inactivity\n");
             break;
-  	      case S1ap_CauseRadioNetwork_radio_connection_with_ue_lost:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_radio_connection_with_ue_lost\n");
+
+          case S1AP_CauseRadioNetwork_radio_connection_with_ue_lost:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_radio_connection_with_ue_lost\n");
             break;
-  	      case S1ap_CauseRadioNetwork_load_balancing_tau_required:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_load_balancing_tau_required\n");
+
+          case S1AP_CauseRadioNetwork_load_balancing_tau_required:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_load_balancing_tau_required\n");
             break;
-  	      case S1ap_CauseRadioNetwork_cs_fallback_triggered:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_cs_fallback_triggered\n");
+
+          case S1AP_CauseRadioNetwork_cs_fallback_triggered:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_cs_fallback_triggered\n");
             break;
-  	      case S1ap_CauseRadioNetwork_ue_not_available_for_ps_service:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_ue_not_available_for_ps_service\n");
+
+          case S1AP_CauseRadioNetwork_ue_not_available_for_ps_service:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_ue_not_available_for_ps_service\n");
             break;
-  	      case S1ap_CauseRadioNetwork_radio_resources_not_available:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_radio_resources_not_available\n");
+
+          case S1AP_CauseRadioNetwork_radio_resources_not_available:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_radio_resources_not_available\n");
             break;
-  	      case S1ap_CauseRadioNetwork_failure_in_radio_interface_procedure:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_failure_in_radio_interface_procedure\n");
+
+          case S1AP_CauseRadioNetwork_failure_in_radio_interface_procedure:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_failure_in_radio_interface_procedure\n");
             break;
-  	      case S1ap_CauseRadioNetwork_invals1ap_id_qos_combination:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_invals1ap_id_qos_combination\n");
+
+          case S1AP_CauseRadioNetwork_invalid_qos_combination:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_invals1ap_id_qos_combination\n");
             break;
-  	      case S1ap_CauseRadioNetwork_interrat_redirection:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_interrat_redirection\n");
+
+          case S1AP_CauseRadioNetwork_interrat_redirection:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_interrat_redirection\n");
             break;
-  	      case S1ap_CauseRadioNetwork_interaction_with_other_procedure:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_interaction_with_other_procedure\n");
+
+          case S1AP_CauseRadioNetwork_interaction_with_other_procedure:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_interaction_with_other_procedure\n");
             break;
-  	      case S1ap_CauseRadioNetwork_unknown_E_RAB_ID:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_unknown_E_RAB_ID\n");
+
+          case S1AP_CauseRadioNetwork_unknown_E_RAB_ID:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_E_RAB_ID\n");
             break;
-  	      case S1ap_CauseRadioNetwork_multiple_E_RAB_ID_instances:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_multiple_E_RAB_ID_instances\n");
+
+          case S1AP_CauseRadioNetwork_multiple_E_RAB_ID_instances:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_multiple_E_RAB_ID_instances\n");
             break;
-  	      case S1ap_CauseRadioNetwork_encryption_and_or_integrity_protection_algorithms_not_supported:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_encryption_and_or_integrity_protection_algorithms_not_supported\n");
+
+          case S1AP_CauseRadioNetwork_encryption_and_or_integrity_protection_algorithms_not_supported:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_encryption_and_or_integrity_protection_algorithms_not_supported\n");
             break;
-  	      case S1ap_CauseRadioNetwork_s1_intra_system_handover_triggered:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_s1_intra_system_handover_triggered\n");
+
+          case S1AP_CauseRadioNetwork_s1_intra_system_handover_triggered:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_s1_intra_system_handover_triggered\n");
             break;
-  	      case S1ap_CauseRadioNetwork_s1_inter_system_handover_triggered:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_s1_inter_system_handover_triggered\n");
+
+          case S1AP_CauseRadioNetwork_s1_inter_system_handover_triggered:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_s1_inter_system_handover_triggered\n");
             break;
-  	      case S1ap_CauseRadioNetwork_x2_handover_triggered:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_x2_handover_triggered\n");
+
+          case S1AP_CauseRadioNetwork_x2_handover_triggered:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_x2_handover_triggered\n");
             break;
-  	      case S1ap_CauseRadioNetwork_redirection_towards_1xRTT:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_redirection_towards_1xRTT\n");
+
+          case S1AP_CauseRadioNetwork_redirection_towards_1xRTT:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_redirection_towards_1xRTT\n");
             break;
-  	      case S1ap_CauseRadioNetwork_not_supported_QCI_value:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_not_supported_QCI_value\n");
+
+          case S1AP_CauseRadioNetwork_not_supported_QCI_value:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_not_supported_QCI_value\n");
             break;
-  	      case S1ap_CauseRadioNetwork_invals1ap_id_CSG_Id:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseRadioNetwork_invals1ap_id_CSG_Id\n");
+
+          case S1AP_CauseRadioNetwork_invalid_CSG_Id:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_invals1ap_id_CSG_Id\n");
             break;
-      	  default:
+
+          default:
             S1AP_WARN("Received S1 Error indication cause radio network case not handled\n");
-      	}
-      break;
+        }
+
+        break;
 
-      case S1ap_Cause_PR_transport:
-      	switch (s1_error_indication_p->cause.choice.transport) {
-    	  case S1ap_CauseTransport_transport_resource_unavailable:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseTransport_transport_resource_unavailable\n");
+      case S1AP_Cause_PR_transport:
+        switch (ie->value.choice.Cause.choice.transport) {
+          case S1AP_CauseTransport_transport_resource_unavailable:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseTransport_transport_resource_unavailable\n");
             break;
-    	  case S1ap_CauseTransport_unspecified:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseTransport_unspecified\n");
+
+          case S1AP_CauseTransport_unspecified:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseTransport_unspecified\n");
             break;
-      	  default:
+
+          default:
             S1AP_WARN("Received S1 Error indication cause transport case not handled\n");
-      	}
-      break;
+        }
 
-      case S1ap_Cause_PR_nas:
-      	switch (s1_error_indication_p->cause.choice.nas) {
-    	  case S1ap_CauseNas_normal_release:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseNas_normal_release\n");
+        break;
+
+      case S1AP_Cause_PR_nas:
+        switch (ie->value.choice.Cause.choice.nas) {
+          case S1AP_CauseNas_normal_release:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseNas_normal_release\n");
             break;
-      	  case S1ap_CauseNas_authentication_failure:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseNas_authentication_failure\n");
+
+          case S1AP_CauseNas_authentication_failure:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseNas_authentication_failure\n");
             break;
-      	  case S1ap_CauseNas_detach:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseNas_detach\n");
+
+          case S1AP_CauseNas_detach:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseNas_detach\n");
             break;
-      	  case S1ap_CauseNas_unspecified:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseNas_unspecified\n");
+
+          case S1AP_CauseNas_unspecified:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseNas_unspecified\n");
             break;
-      	  case S1ap_CauseNas_csg_subscription_expiry:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseNas_csg_subscription_expiry\n");
+
+          case S1AP_CauseNas_csg_subscription_expiry:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseNas_csg_subscription_expiry\n");
             break;
-      	  default:
+
+          default:
             S1AP_WARN("Received S1 Error indication cause nas case not handled\n");
-      	}
-      break;
+        }
+
+        break;
 
-      case S1ap_Cause_PR_protocol:
-      	switch (s1_error_indication_p->cause.choice.protocol) {
-      	  case S1ap_CauseProtocol_transfer_syntax_error:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseProtocol_transfer_syntax_error\n");
+      case S1AP_Cause_PR_protocol:
+        switch (ie->value.choice.Cause.choice.protocol) {
+          case S1AP_CauseProtocol_transfer_syntax_error:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_transfer_syntax_error\n");
             break;
-      	  case S1ap_CauseProtocol_abstract_syntax_error_reject:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseProtocol_abstract_syntax_error_reject\n");
+
+          case S1AP_CauseProtocol_abstract_syntax_error_reject:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_abstract_syntax_error_reject\n");
             break;
-      	  case S1ap_CauseProtocol_abstract_syntax_error_ignore_and_notify:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseProtocol_abstract_syntax_error_ignore_and_notify\n");
+
+          case S1AP_CauseProtocol_abstract_syntax_error_ignore_and_notify:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_abstract_syntax_error_ignore_and_notify\n");
             break;
-      	  case S1ap_CauseProtocol_message_not_compatible_with_receiver_state:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseProtocol_message_not_compatible_with_receiver_state\n");
+
+          case S1AP_CauseProtocol_message_not_compatible_with_receiver_state:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_message_not_compatible_with_receiver_state\n");
             break;
-      	  case S1ap_CauseProtocol_semantic_error:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseProtocol_semantic_error\n");
+
+          case S1AP_CauseProtocol_semantic_error:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_semantic_error\n");
             break;
-      	  case S1ap_CauseProtocol_abstract_syntax_error_falsely_constructed_message:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseProtocol_abstract_syntax_error_falsely_constructed_message\n");
+
+          case S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message\n");
             break;
-      	  case S1ap_CauseProtocol_unspecified:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseProtocol_unspecified\n");
+
+          case S1AP_CauseProtocol_unspecified:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_unspecified\n");
             break;
-      	  default:
+
+          default:
             S1AP_WARN("Received S1 Error indication cause protocol case not handled\n");
-      	}
-      break;
+        }
+
+        break;
+
+      case S1AP_Cause_PR_misc:
+        switch (ie->value.choice.Cause.choice.protocol) {
+          case S1AP_CauseMisc_control_processing_overload:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_control_processing_overload\n");
+            break;
+
+          case S1AP_CauseMisc_not_enough_user_plane_processing_resources:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_not_enough_user_plane_processing_resources\n");
+            break;
 
-      case S1ap_Cause_PR_misc:
-        switch (s1_error_indication_p->cause.choice.protocol) {
-          case S1ap_CauseMisc_control_processing_overload:
-            S1AP_WARN("Received S1 Error indication S1ap_CauseMisc_control_processing_overload\n");
+          case S1AP_CauseMisc_hardware_failure:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_hardware_failure\n");
             break;
-          case S1ap_CauseMisc_not_enough_user_plane_processing_resources:
-        	S1AP_WARN("Received S1 Error indication S1ap_CauseMisc_not_enough_user_plane_processing_resources\n");
-        	break;
-          case S1ap_CauseMisc_hardware_failure:
-        	S1AP_WARN("Received S1 Error indication S1ap_CauseMisc_hardware_failure\n");
-        	break;
-          case S1ap_CauseMisc_om_intervention:
-        	S1AP_WARN("Received S1 Error indication S1ap_CauseMisc_om_intervention\n");
-        	break;
-          case S1ap_CauseMisc_unspecified:
-        	S1AP_WARN("Received S1 Error indication S1ap_CauseMisc_unspecified\n");
-        	break;
-          case S1ap_CauseMisc_unknown_PLMN:
-        	S1AP_WARN("Received S1 Error indication S1ap_CauseMisc_unknown_PLMN\n");
-        	break;
+
+          case S1AP_CauseMisc_om_intervention:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_om_intervention\n");
+            break;
+
+          case S1AP_CauseMisc_unspecified:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_unspecified\n");
+            break;
+
+          case S1AP_CauseMisc_unknown_PLMN:
+            S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_unknown_PLMN\n");
+            break;
+
           default:
             S1AP_WARN("Received S1 Error indication cause misc case not handled\n");
         }
-      break;
+
+        break;
     }
   }
-  if ( s1_error_indication_p->presenceMask & S1AP_ERRORINDICATIONIES_CRITICALITYDIAGNOSTICS_PRESENT) {
+
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_ErrorIndicationIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_CriticalityDiagnostics, FALSE);
+
+  if (ie) {
     // TODO continue
   }
-  // TODO continue
 
+  // TODO continue
   return 0;
 }
 
 
 static
-int s1ap_eNB_handle_initial_context_request(uint32_t               assoc_id,
+int s1ap_eNB_handle_initial_context_request(uint32_t   assoc_id,
     uint32_t               stream,
-    struct s1ap_message_s *s1ap_message_p)
+    S1AP_S1AP_PDU_t       *pdu)
 {
   int i;
-
   s1ap_eNB_mme_data_t   *mme_desc_p       = NULL;
   s1ap_eNB_ue_context_t *ue_desc_p        = NULL;
   MessageDef            *message_p        = NULL;
-
-  S1ap_InitialContextSetupRequestIEs_t *initialContextSetupRequest_p;
-  DevAssert(s1ap_message_p != NULL);
-
-  initialContextSetupRequest_p = &s1ap_message_p->msg.s1ap_InitialContextSetupRequestIEs;
+  S1AP_InitialContextSetupRequest_t    *container;
+  S1AP_InitialContextSetupRequestIEs_t *ie;
+  S1AP_ENB_UE_S1AP_ID_t    enb_ue_s1ap_id;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.InitialContextSetupRequest;
 
   if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received initial context setup request for non "
@@ -721,11 +788,15 @@ int s1ap_eNB_handle_initial_context_request(uint32_t               assoc_id,
     return -1;
   }
 
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, FALSE);
+  enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
+
   if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
-                   initialContextSetupRequest_p->eNB_UE_S1AP_ID)) == NULL) {
+                   enb_ue_s1ap_id)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received initial context setup request for non "
                "existing UE context 0x%06lx\n", assoc_id,
-               initialContextSetupRequest_p->eNB_UE_S1AP_ID);
+               enb_ue_s1ap_id);
     return -1;
   }
 
@@ -737,46 +808,52 @@ int s1ap_eNB_handle_initial_context_request(uint32_t               assoc_id,
   }
 
   ue_desc_p->rx_stream = stream;
-
-  ue_desc_p->mme_ue_s1ap_id = initialContextSetupRequest_p->mme_ue_s1ap_id;
-
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, TRUE);
+  ue_desc_p->mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
   message_p        = itti_alloc_new_message(TASK_S1AP, S1AP_INITIAL_CONTEXT_SETUP_REQ);
-
   S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_initial_id  = ue_desc_p->ue_initial_id;
   ue_desc_p->ue_initial_id = 0;
 
-  S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).eNB_ue_s1ap_id = ue_desc_p->eNB_ue_s1ap_id;
-  S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).nb_of_e_rabs =
-    initialContextSetupRequest_p->e_RABToBeSetupListCtxtSUReq.s1ap_E_RABToBeSetupItemCtxtSUReq.count;
-
-  S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_ul = 64;// TO DO(bitrate_t)(initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL);
-  S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_dl = 1024;//(bitrate_t)(initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL);
+  if (ue_desc_p->eNB_ue_s1ap_id != enb_ue_s1ap_id) {
+    /* TBD */
+  }
 
+  S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).eNB_ue_s1ap_id = ue_desc_p->eNB_ue_s1ap_id;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_uEaggregateMaximumBitrate, TRUE);
+  asn_INTEGER2ulong(&(ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateUL),
+                    &(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_ul));
+  asn_INTEGER2ulong(&(ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateDL),
+                    &(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_dl));
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_UESecurityCapabilities, TRUE);
   S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.encryption_algorithms =
-    BIT_STRING_to_uint16(&initialContextSetupRequest_p->ueSecurityCapabilities.encryptionAlgorithms);
+    BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.encryptionAlgorithms);
   S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.integrity_algorithms =
-    BIT_STRING_to_uint16(&initialContextSetupRequest_p->ueSecurityCapabilities.integrityProtectionAlgorithms);
-
+    BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.integrityProtectionAlgorithms);
   /* Copy the security key */
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_SecurityKey, TRUE);
   memcpy(&S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_key,
-         initialContextSetupRequest_p->securityKey.buf, initialContextSetupRequest_p->securityKey.size);
-
-  for (i = 0; i < initialContextSetupRequest_p->e_RABToBeSetupListCtxtSUReq.s1ap_E_RABToBeSetupItemCtxtSUReq.count; i++) {
-    S1ap_E_RABToBeSetupItemCtxtSUReq_t *item_p;
-
-    item_p = (S1ap_E_RABToBeSetupItemCtxtSUReq_t *)initialContextSetupRequest_p->e_RABToBeSetupListCtxtSUReq.s1ap_E_RABToBeSetupItemCtxtSUReq.array[i];
+         ie->value.choice.SecurityKey.buf, ie->value.choice.SecurityKey.size);
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_E_RABToBeSetupListCtxtSUReq, TRUE);
+  S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).nb_of_e_rabs =
+    ie->value.choice.E_RABToBeSetupListCtxtSUReq.list.count;
 
+  for (i = 0; i < ie->value.choice.E_RABToBeSetupListCtxtSUReq.list.count; i++) {
+    S1AP_E_RABToBeSetupItemCtxtSUReq_t *item_p;
+    item_p = &(((S1AP_E_RABToBeSetupItemCtxtSUReqIEs_t *)ie->value.choice.E_RABToBeSetupListCtxtSUReq.list.array[i])->value.choice.E_RABToBeSetupItemCtxtSUReq);
     S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].e_rab_id = item_p->e_RAB_ID;
 
     if (item_p->nAS_PDU != NULL) {
       /* Only copy NAS pdu if present */
       S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.length = item_p->nAS_PDU->size;
-
       S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer =
         malloc(sizeof(uint8_t) * item_p->nAS_PDU->size);
-
       memcpy(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer,
-             item_p->nAS_PDU->buf, item_p->nAS_PDU->size); 
+             item_p->nAS_PDU->buf, item_p->nAS_PDU->size);
       S1AP_DEBUG("Received NAS message with the E_RAB setup procedure\n");
     } else {
       S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.length = 0;
@@ -788,13 +865,10 @@ int s1ap_eNB_handle_initial_context_request(uint32_t               assoc_id,
            item_p->transportLayerAddress.buf, item_p->transportLayerAddress.size);
     S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].sgw_addr.length =
       item_p->transportLayerAddress.size * 8 - item_p->transportLayerAddress.bits_unused;
-
     /* GTP tunnel endpoint ID */
     OCTET_STRING_TO_INT32(&item_p->gTP_TEID, S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].gtp_teid);
-
     /* Set the QOS informations */
     S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.qci = item_p->e_RABlevelQoSParameters.qCI;
-
     S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.allocation_retention_priority.priority_level =
       item_p->e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel;
     S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.allocation_retention_priority.pre_emp_capability =
@@ -804,24 +878,24 @@ int s1ap_eNB_handle_initial_context_request(uint32_t               assoc_id,
   }
 
   itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
-
   return 0;
 }
 
 
 static
-int s1ap_eNB_handle_ue_context_release_command(uint32_t               assoc_id,
+int s1ap_eNB_handle_ue_context_release_command(uint32_t   assoc_id,
     uint32_t               stream,
-    struct s1ap_message_s *s1ap_message_p)
+    S1AP_S1AP_PDU_t       *pdu)
 {
   s1ap_eNB_mme_data_t   *mme_desc_p       = NULL;
   s1ap_eNB_ue_context_t *ue_desc_p        = NULL;
   MessageDef            *message_p        = NULL;
-
-  S1ap_UEContextReleaseCommandIEs_t *ueContextReleaseCommand_p;
-  DevAssert(s1ap_message_p != NULL);
-
-  ueContextReleaseCommand_p = &s1ap_message_p->msg.s1ap_UEContextReleaseCommandIEs;
+  S1AP_MME_UE_S1AP_ID_t  mme_ue_s1ap_id;
+  S1AP_ENB_UE_S1AP_ID_t  enb_ue_s1ap_id;
+  S1AP_UEContextReleaseCommand_t     *container;
+  S1AP_UEContextReleaseCommand_IEs_t *ie;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.UEContextReleaseCommand;
 
   if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received UE context release command for non "
@@ -829,80 +903,81 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t               assoc_id,
     return -1;
   }
 
-  S1ap_MME_UE_S1AP_ID_t    mme_ue_s1ap_id;
-  S1ap_ENB_UE_S1AP_ID_t    enb_ue_s1ap_id;
-
-  switch (ueContextReleaseCommand_p->uE_S1AP_IDs.present) {
-  case S1ap_UE_S1AP_IDs_PR_uE_S1AP_ID_pair:
-    enb_ue_s1ap_id = ueContextReleaseCommand_p->uE_S1AP_IDs.choice.uE_S1AP_ID_pair.eNB_UE_S1AP_ID;
-    mme_ue_s1ap_id = ueContextReleaseCommand_p->uE_S1AP_IDs.choice.uE_S1AP_ID_pair.mME_UE_S1AP_ID;
-
-    MSC_LOG_RX_MESSAGE(
-    		MSC_S1AP_ENB,
-    		MSC_S1AP_MME,
-    		NULL,0,
-    		"0 UEContextRelease/%s eNB_ue_s1ap_id "S1AP_UE_ID_FMT" mme_ue_s1ap_id "S1AP_UE_ID_FMT" len %u",
-  		s1ap_direction2String[s1ap_message_p->direction],
-  		enb_ue_s1ap_id,
-  		mme_ue_s1ap_id);
-
-    if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
-                     enb_ue_s1ap_id)) == NULL) {
-      S1AP_ERROR("[SCTP %d] Received UE context release command for non "
-                 "existing UE context 0x%06lx\n",
-                 assoc_id,
-                 enb_ue_s1ap_id);
-      /*MessageDef *msg_complete_p;
-      msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE);
-      S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
-      itti_send_msg_to_task(TASK_S1AP, ue_desc_p->eNB_instance->instance <=> 0, msg_complete_p);
-      */
-      return -1;
-    } else {
-      MSC_LOG_TX_MESSAGE(
-    		  MSC_S1AP_ENB,
-    		  MSC_RRC_ENB,
-    		  NULL,0,
-    		  "0 S1AP_UE_CONTEXT_RELEASE_COMMAND/%d eNB_ue_s1ap_id "S1AP_UE_ID_FMT" ",
-    		  enb_ue_s1ap_id);
-
-      message_p        = itti_alloc_new_message(TASK_S1AP, S1AP_UE_CONTEXT_RELEASE_COMMAND);
-      S1AP_UE_CONTEXT_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
-      itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
-      return 0;
-    }
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_UEContextReleaseCommand_IEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_UE_S1AP_IDs, TRUE);
+
+  switch (ie->value.choice.UE_S1AP_IDs.present) {
+    case S1AP_UE_S1AP_IDs_PR_uE_S1AP_ID_pair:
+      enb_ue_s1ap_id = ie->value.choice.UE_S1AP_IDs.choice.uE_S1AP_ID_pair.eNB_UE_S1AP_ID;
+      mme_ue_s1ap_id = ie->value.choice.UE_S1AP_IDs.choice.uE_S1AP_ID_pair.mME_UE_S1AP_ID;
+      MSC_LOG_RX_MESSAGE(
+        MSC_S1AP_ENB,
+        MSC_S1AP_MME,
+        NULL,0,
+        "0 UEContextRelease/%s eNB_ue_s1ap_id "S1AP_UE_ID_FMT" mme_ue_s1ap_id "S1AP_UE_ID_FMT" len %u",
+        s1ap_direction2String[pdu->present - 1],
+        enb_ue_s1ap_id,
+        mme_ue_s1ap_id);
+
+      if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
+                       enb_ue_s1ap_id)) == NULL) {
+        S1AP_ERROR("[SCTP %d] Received UE context release command for non "
+                   "existing UE context 0x%06lx\n",
+                   assoc_id,
+                   enb_ue_s1ap_id);
+        /*MessageDef *msg_complete_p;
+        msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE);
+        S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
+        itti_send_msg_to_task(TASK_S1AP, ue_desc_p->eNB_instance->instance <=> 0, msg_complete_p);
+        */
+        return -1;
+      } else {
+        MSC_LOG_TX_MESSAGE(
+          MSC_S1AP_ENB,
+          MSC_RRC_ENB,
+          NULL,0,
+          "0 S1AP_UE_CONTEXT_RELEASE_COMMAND/%d eNB_ue_s1ap_id "S1AP_UE_ID_FMT" ",
+          enb_ue_s1ap_id);
+        message_p        = itti_alloc_new_message(TASK_S1AP, S1AP_UE_CONTEXT_RELEASE_COMMAND);
+        S1AP_UE_CONTEXT_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
+        itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
+        return 0;
+      }
 
-    break;
+      break;
 
-//#warning "TODO mapping mme_ue_s1ap_id  enb_ue_s1ap_id?"
+    //#warning "TODO mapping mme_ue_s1ap_id  enb_ue_s1ap_id?"
 
-  case S1ap_UE_S1AP_IDs_PR_mME_UE_S1AP_ID:
-    mme_ue_s1ap_id = ueContextReleaseCommand_p->uE_S1AP_IDs.choice.mME_UE_S1AP_ID;
-    S1AP_ERROR("TO DO mapping mme_ue_s1ap_id  enb_ue_s1ap_id");
-    (void)mme_ue_s1ap_id; /* TODO: remove - it's to remove gcc warning about unused var */
+    case S1AP_UE_S1AP_IDs_PR_mME_UE_S1AP_ID:
+      mme_ue_s1ap_id = ie->value.choice.UE_S1AP_IDs.choice.uE_S1AP_ID_pair.mME_UE_S1AP_ID;
+      S1AP_ERROR("TO DO mapping mme_ue_s1ap_id  enb_ue_s1ap_id");
+      (void)mme_ue_s1ap_id; /* TODO: remove - it's to remove gcc warning about unused var */
 
-  case S1ap_UE_S1AP_IDs_PR_NOTHING:
-  default:
-    S1AP_ERROR("S1AP_UE_CONTEXT_RELEASE_COMMAND not processed, missing info elements");
-    return -1;
+    case S1AP_UE_S1AP_IDs_PR_NOTHING:
+    default:
+      S1AP_ERROR("S1AP_UE_CONTEXT_RELEASE_COMMAND not processed, missing info elements");
+      return -1;
   }
+
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_UEContextReleaseCommand_IEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_Cause, TRUE);
+  /* TBD */
 }
 
 static
-int s1ap_eNB_handle_e_rab_setup_request(uint32_t               assoc_id,
-					uint32_t               stream,
-					struct s1ap_message_s *s1ap_message_p) {
-
+int s1ap_eNB_handle_e_rab_setup_request(uint32_t         assoc_id,
+                                        uint32_t         stream,
+                                        S1AP_S1AP_PDU_t *pdu)
+{
   int i;
-
-  s1ap_eNB_mme_data_t   *mme_desc_p       = NULL;
-  s1ap_eNB_ue_context_t *ue_desc_p        = NULL;
-  MessageDef            *message_p        = NULL;
-
-  S1ap_E_RABSetupRequestIEs_t         *s1ap_E_RABSetupRequest;
-  DevAssert(s1ap_message_p != NULL);
-
-  s1ap_E_RABSetupRequest = &s1ap_message_p->msg.s1ap_E_RABSetupRequestIEs;
+  S1AP_ENB_UE_S1AP_ID_t         enb_ue_s1ap_id;
+  s1ap_eNB_mme_data_t          *mme_desc_p       = NULL;
+  s1ap_eNB_ue_context_t        *ue_desc_p        = NULL;
+  MessageDef                   *message_p        = NULL;
+  S1AP_E_RABSetupRequest_t     *container;
+  S1AP_E_RABSetupRequestIEs_t  *ie;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.E_RABSetupRequest;
 
   if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received initial context setup request for non "
@@ -910,15 +985,19 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t               assoc_id,
     return -1;
   }
 
-    
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, TRUE);
+
   if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
-                   s1ap_E_RABSetupRequest->eNB_UE_S1AP_ID)) == NULL) {
+                   ie->value.choice.ENB_UE_S1AP_ID)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received initial context setup request for non "
                "existing UE context 0x%06lx\n", assoc_id,
-               s1ap_E_RABSetupRequest->eNB_UE_S1AP_ID);
+               ie->value.choice.ENB_UE_S1AP_ID);
     return -1;
   }
 
+  enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
+
   /* Initial context request = UE-related procedure -> stream != 0 */
   if (stream == 0) {
     S1AP_ERROR("[SCTP %d] Received UE-related procedure on stream (%d)\n",
@@ -927,42 +1006,38 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t               assoc_id,
   }
 
   ue_desc_p->rx_stream = stream;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, TRUE);
 
-  if ( ue_desc_p->mme_ue_s1ap_id != s1ap_E_RABSetupRequest->mme_ue_s1ap_id){
-    S1AP_WARN("UE context mme_ue_s1ap_id is different form that of the message (%d != %ld)", 
-	      ue_desc_p->mme_ue_s1ap_id, s1ap_E_RABSetupRequest->mme_ue_s1ap_id);
-
+  if ( ue_desc_p->mme_ue_s1ap_id != ie->value.choice.MME_UE_S1AP_ID) {
+    S1AP_WARN("UE context mme_ue_s1ap_id is different form that of the message (%d != %ld)",
+              ue_desc_p->mme_ue_s1ap_id, ie->value.choice.MME_UE_S1AP_ID);
   }
+
   message_p        = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_SETUP_REQ);
- 
   S1AP_E_RAB_SETUP_REQ(message_p).ue_initial_id  = ue_desc_p->ue_initial_id;
-  
-  S1AP_E_RAB_SETUP_REQ(message_p).mme_ue_s1ap_id  = s1ap_E_RABSetupRequest->mme_ue_s1ap_id;
-  S1AP_E_RAB_SETUP_REQ(message_p).eNB_ue_s1ap_id  = s1ap_E_RABSetupRequest->eNB_UE_S1AP_ID;
-   
-   S1AP_E_RAB_SETUP_REQ(message_p).nb_e_rabs_tosetup =
-    s1ap_E_RABSetupRequest->e_RABToBeSetupListBearerSUReq.s1ap_E_RABToBeSetupItemBearerSUReq.count;
- 
-  for (i = 0; i < s1ap_E_RABSetupRequest->e_RABToBeSetupListBearerSUReq.s1ap_E_RABToBeSetupItemBearerSUReq.count; i++) {
-    S1ap_E_RABToBeSetupItemBearerSUReq_t *item_p;
-   
-    item_p = (S1ap_E_RABToBeSetupItemBearerSUReq_t *)s1ap_E_RABSetupRequest->e_RABToBeSetupListBearerSUReq.s1ap_E_RABToBeSetupItemBearerSUReq.array[i];
-
+  S1AP_E_RAB_SETUP_REQ(message_p).mme_ue_s1ap_id  = ie->value.choice.MME_UE_S1AP_ID;
+  S1AP_E_RAB_SETUP_REQ(message_p).eNB_ue_s1ap_id  = enb_ue_s1ap_id;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_E_RABToBeSetupListBearerSUReq, TRUE);
+  S1AP_E_RAB_SETUP_REQ(message_p).nb_e_rabs_tosetup =
+    ie->value.choice.E_RABToBeSetupListBearerSUReq.list.count;
+
+  for (i = 0; i < ie->value.choice.E_RABToBeSetupListBearerSUReq.list.count; i++) {
+    S1AP_E_RABToBeSetupItemBearerSUReq_t *item_p;
+    item_p = &(((S1AP_E_RABToBeSetupItemBearerSUReqIEs_t *)ie->value.choice.E_RABToBeSetupListBearerSUReq.list.array[i])->value.choice.E_RABToBeSetupItemBearerSUReq);
     S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].e_rab_id = item_p->e_RAB_ID;
 
     // check for the NAS PDU
     if (item_p->nAS_PDU.size > 0 ) {
       S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length = item_p->nAS_PDU.size;
-
       S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer = malloc(sizeof(uint8_t) * item_p->nAS_PDU.size);
-
       memcpy(S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer,
-             item_p->nAS_PDU.buf, item_p->nAS_PDU.size); 
+             item_p->nAS_PDU.buf, item_p->nAS_PDU.size);
       // S1AP_INFO("received a NAS PDU with size %d (%02x.%02x)\n",S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length, item_p->nAS_PDU.buf[0], item_p->nAS_PDU.buf[1]);
     } else {
       S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length = 0;
       S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer = NULL;
-      
       S1AP_WARN("NAS PDU is not provided, generate a E_RAB_SETUP Failure (TBD) back to MME \n");
       // return -1;
     }
@@ -972,18 +1047,15 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t               assoc_id,
            item_p->transportLayerAddress.buf, item_p->transportLayerAddress.size);
     S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.length =
       item_p->transportLayerAddress.size * 8 - item_p->transportLayerAddress.bits_unused;
-
-    /* S1AP_INFO("sgw addr %s  len: %d (size %d, index %d)\n", 
-	      S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.buffer,
-	      S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.length,
-	      item_p->transportLayerAddress.size, i);
+    /* S1AP_INFO("sgw addr %s  len: %d (size %d, index %d)\n",
+        S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.buffer,
+        S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.length,
+        item_p->transportLayerAddress.size, i);
     */
     /* GTP tunnel endpoint ID */
     OCTET_STRING_TO_INT32(&item_p->gTP_TEID, S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].gtp_teid);
-
     /* Set the QOS informations */
     S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.qci = item_p->e_RABlevelQoSParameters.qCI;
-
     S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.allocation_retention_priority.priority_level =
       item_p->e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel;
     S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.allocation_retention_priority.pre_emp_capability =
@@ -993,26 +1065,24 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t               assoc_id,
   }
 
   itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
-
   return 0;
 }
 
 static
 int s1ap_eNB_handle_paging(uint32_t               assoc_id,
-    uint32_t               stream,
-    struct s1ap_message_s *s1ap_message_p)
+                           uint32_t               stream,
+                           S1AP_S1AP_PDU_t       *pdu)
 {
-  S1ap_PagingIEs_t *paging_p;
   s1ap_eNB_mme_data_t   *mme_desc_p        = NULL;
   s1ap_eNB_instance_t   *s1ap_eNB_instance = NULL;
   MessageDef            *message_p         = NULL;
-
-  DevAssert(s1ap_message_p != NULL);
+  S1AP_Paging_t         *container;
+  S1AP_PagingIEs_t      *ie;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.Paging;
   // received Paging Message from MME
   S1AP_DEBUG("[SCTP %d] Received Paging Message From MME\n",assoc_id);
 
-  paging_p = &s1ap_message_p->msg.s1ap_PagingIEs;
-
   /* Paging procedure -> stream != 0 */
   if (stream == 0) {
     S1AP_ERROR("[SCTP %d] Received Paging procedure on stream (%d)\n",
@@ -1027,6 +1097,7 @@ int s1ap_eNB_handle_paging(uint32_t               assoc_id,
   }
 
   s1ap_eNB_instance = mme_desc_p->s1ap_eNB_instance;
+
   if (s1ap_eNB_instance == NULL) {
     S1AP_ERROR("[SCTP %d] Received Paging for non existing MME context : s1ap_eNB_instance is NULL\n",
                assoc_id);
@@ -1034,178 +1105,208 @@ int s1ap_eNB_handle_paging(uint32_t               assoc_id,
   }
 
   message_p = itti_alloc_new_message(TASK_S1AP, S1AP_PAGING_IND);
-
-  /* convert S1ap_PagingIEs_t to s1ap_paging_ind_t */
+  /* convert S1AP_PagingIEs_t to s1ap_paging_ind_t */
   /* convert UE Identity Index value */
-  S1AP_PAGING_IND(message_p).ue_index_value  = BIT_STRING_to_uint32(&paging_p->ueIdentityIndexValue);
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_UEIdentityIndexValue, TRUE);
+  S1AP_PAGING_IND(message_p).ue_index_value  = BIT_STRING_to_uint32(&ie->value.choice.UEIdentityIndexValue);
   S1AP_DEBUG("[SCTP %d] Received Paging ue_index_value (%d)\n",
-            assoc_id,(uint32_t)S1AP_PAGING_IND(message_p).ue_index_value);
-
+             assoc_id,(uint32_t)S1AP_PAGING_IND(message_p).ue_index_value);
   S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code = 0;
   S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi = 0;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_UEPagingID, TRUE);
 
   /* convert UE Paging Identity */
-  if (paging_p->uePagingID.present == S1ap_UEPagingID_PR_s_TMSI) {
-      S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_s_tmsi;
-      OCTET_STRING_TO_INT8(&paging_p->uePagingID.choice.s_TMSI.mMEC, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code);
-      OCTET_STRING_TO_INT32(&paging_p->uePagingID.choice.s_TMSI.m_TMSI, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi);
-  } else if (paging_p->uePagingID.present == S1ap_UEPagingID_PR_iMSI) {
-      S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_imsi;
-      S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length = 0;
-      for (int i = 0; i < paging_p->uePagingID.choice.iMSI.size; i++) {
-          S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i] = (uint8_t)(paging_p->uePagingID.choice.iMSI.buf[i] & 0x0F );
-          S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++;
-          S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1] = (uint8_t)((paging_p->uePagingID.choice.iMSI.buf[i]>>4) & 0x0F);
-          LOG_D(S1AP,"paging : i %d %d imsi %d %d \n",2*i,2*i+1,S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1]);
-          if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1] == 0x0F) {
-              if(i != paging_p->uePagingID.choice.iMSI.size - 1){
-                  /* invalid paging_p->uePagingID.choise.iMSI.buffer */
-                  S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI error(i %d 0x0F)\n", assoc_id,i);
-                  return -1;
-              }
-          } else {
-              S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++;
-          }
-      }
-      if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length >= S1AP_IMSI_LENGTH) {
-          /* invalid paging_p->uePagingID.choise.iMSI.size */
-          S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI.size(%d) is over IMSI length(%d)\n", assoc_id, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length, S1AP_IMSI_LENGTH);
+  if (ie->value.choice.UEPagingID.present == S1AP_UEPagingID_PR_s_TMSI) {
+    S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_s_tmsi;
+    OCTET_STRING_TO_INT8(&ie->value.choice.UEPagingID.choice.s_TMSI.mMEC, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code);
+    OCTET_STRING_TO_INT32(&ie->value.choice.UEPagingID.choice.s_TMSI.m_TMSI, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi);
+  } else if (ie->value.choice.UEPagingID.present == S1AP_UEPagingID_PR_iMSI) {
+    S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_imsi;
+    S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length = 0;
+
+    for (int i = 0; i < ie->value.choice.UEPagingID.choice.iMSI.size; i++) {
+      S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i] = (uint8_t)(ie->value.choice.UEPagingID.choice.iMSI.buf[i] & 0x0F );
+      S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++;
+      S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1] = (uint8_t)((ie->value.choice.UEPagingID.choice.iMSI.buf[i]>>4) & 0x0F);
+      LOG_D(S1AP,"paging : i %d %d imsi %d %d \n",2*i,2*i+1,S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1]);
+
+      if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1] == 0x0F) {
+        if(i != ie->value.choice.UEPagingID.choice.iMSI.size - 1) {
+          /* invalid paging_p->uePagingID.choise.iMSI.buffer */
+          S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI error(i %d 0x0F)\n", assoc_id,i);
           return -1;
-      }  
-} else {
-      /* invalid paging_p->uePagingID.present */
-      S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.present(%d) is unknown\n", assoc_id, paging_p->uePagingID.present);
+        }
+      } else {
+        S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++;
+      }
+    }
+
+    if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length >= S1AP_IMSI_LENGTH) {
+      /* invalid paging_p->uePagingID.choise.iMSI.size */
+      S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI.size(%d) is over IMSI length(%d)\n", assoc_id, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length, S1AP_IMSI_LENGTH);
       return -1;
+    }
+  } else {
+    /* invalid paging_p->uePagingID.present */
+    S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.present(%d) is unknown\n", assoc_id, ie->value.choice.UEPagingID.present);
+    return -1;
   }
 
 #if 0
+
   /* convert Paging DRX(optional) */
   if (paging_p->presenceMask & S1AP_PAGINGIES_PAGINGDRX_PRESENT) {
-      switch(paging_p->pagingDRX) {
-        case S1ap_PagingDRX_v32:
-          S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_32;
-         break;
-        case S1ap_PagingDRX_v64:
-          S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_64;
+    switch(paging_p->pagingDRX) {
+      case S1AP_PagingDRX_v32:
+        S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_32;
         break;
-        case S1ap_PagingDRX_v128:
-          S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_128;
+
+      case S1AP_PagingDRX_v64:
+        S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_64;
         break;
-        case S1ap_PagingDRX_v256:
-          S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256;
+
+      case S1AP_PagingDRX_v128:
+        S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_128;
         break;
-        default:
-          // when UE Paging DRX is no value
-          S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256;
+
+      case S1AP_PagingDRX_v256:
+        S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256;
         break;
-      }
+
+      default:
+        // when UE Paging DRX is no value
+        S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256;
+        break;
+    }
   }
+
 #endif
-  S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_pagingDRX, FALSE);
+
+  /* optional */
+  if (ie) {
+    S1AP_PAGING_IND(message_p).paging_drx = ie->value.choice.PagingDRX;
+  } else {
+    S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256;
+  }
+
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_CNDomain, TRUE);
 
   /* convert cnDomain */
-  if (paging_p->cnDomain == S1ap_CNDomain_ps) {
-      S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_PS;
-  } else if (paging_p->cnDomain == S1ap_CNDomain_cs) {
-      S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_CS;
+  if (ie->value.choice.CNDomain == S1AP_CNDomain_ps) {
+    S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_PS;
+  } else if (ie->value.choice.CNDomain == S1AP_CNDomain_cs) {
+    S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_CS;
   } else {
-      /* invalid paging_p->cnDomain */
-      S1AP_ERROR("[SCTP %d] Received Paging : cnDomain(%ld) is unknown\n", assoc_id, paging_p->cnDomain);
-      return -1;
+    /* invalid paging_p->cnDomain */
+    S1AP_ERROR("[SCTP %d] Received Paging : cnDomain(%ld) is unknown\n", assoc_id, ie->value.choice.CNDomain);
+    return -1;
   }
 
   memset (&S1AP_PAGING_IND(message_p).plmn_identity[0], 0, sizeof(plmn_identity_t)*256);
   memset (&S1AP_PAGING_IND(message_p).tac[0], 0, sizeof(int16_t)*256);
   S1AP_PAGING_IND(message_p).tai_size = 0;
-
-  for (int i = 0; i < paging_p->taiList.s1ap_TAIItem.count; i++) {
-     S1AP_INFO("[SCTP %d] Received Paging taiList: i %d, count %d\n", assoc_id, i, paging_p->taiList.s1ap_TAIItem.count);
-     S1ap_TAIItem_t s1ap_TAIItem;
-     memset (&s1ap_TAIItem, 0, sizeof(S1ap_TAIItem_t));
-
-     memcpy(&s1ap_TAIItem, paging_p->taiList.s1ap_TAIItem.array[i], sizeof(S1ap_TAIItem_t));
-
-     TBCD_TO_MCC_MNC(&s1ap_TAIItem.tAI.pLMNidentity, S1AP_PAGING_IND(message_p).plmn_identity[i].mcc,
-              S1AP_PAGING_IND(message_p).plmn_identity[i].mnc,
-              S1AP_PAGING_IND(message_p).plmn_identity[i].mnc_digit_length);
-     OCTET_STRING_TO_INT16(&s1ap_TAIItem.tAI.tAC, S1AP_PAGING_IND(message_p).tac[i]);
-     S1AP_PAGING_IND(message_p).tai_size++;
-     S1AP_DEBUG("[SCTP %d] Received Paging: MCC %d, MNC %d, TAC %d\n", assoc_id, S1AP_PAGING_IND(message_p).plmn_identity[i].mcc, S1AP_PAGING_IND(message_p).plmn_identity[i].mnc, S1AP_PAGING_IND(message_p).tac[i]);
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_TAIList, TRUE);
+  S1AP_INFO("[SCTP %d] Received Paging taiList: count %d\n", assoc_id, ie->value.choice.TAIList.list.count);
+
+  for (int i = 0; i < ie->value.choice.TAIList.list.count; i++) {
+    S1AP_TAIItem_t *item_p;
+    item_p = &(((S1AP_TAIItemIEs_t *)ie->value.choice.TAIList.list.array[i])->value.choice.TAIItem);
+    TBCD_TO_MCC_MNC(&(item_p->tAI.pLMNidentity), S1AP_PAGING_IND(message_p).plmn_identity[i].mcc,
+                    S1AP_PAGING_IND(message_p).plmn_identity[i].mnc,
+                    S1AP_PAGING_IND(message_p).plmn_identity[i].mnc_digit_length);
+    OCTET_STRING_TO_INT16(&(item_p->tAI.tAC), S1AP_PAGING_IND(message_p).tac[i]);
+    S1AP_PAGING_IND(message_p).tai_size++;
+    S1AP_DEBUG("[SCTP %d] Received Paging: MCC %d, MNC %d, TAC %d\n", assoc_id,
+               S1AP_PAGING_IND(message_p).plmn_identity[i].mcc,
+               S1AP_PAGING_IND(message_p).plmn_identity[i].mnc,
+               S1AP_PAGING_IND(message_p).tac[i]);
   }
 
 #if 0
- // CSG Id(optional) List is not used
+
+  // CSG Id(optional) List is not used
   if (paging_p->presenceMask & S1AP_PAGINGIES_CSG_IDLIST_PRESENT) {
-      // TODO
+    // TODO
   }
 
   /* convert pagingPriority (optional) if has value */
   if (paging_p->presenceMask & S1AP_PAGINGIES_PAGINGPRIORITY_PRESENT) {
-      switch(paging_p->pagingPriority) {
-      case S1ap_PagingPriority_priolevel1:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL1;
+    switch(paging_p->pagingPriority) {
+      case S1AP_PagingPriority_priolevel1:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL1;
         break;
-      case S1ap_PagingPriority_priolevel2:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL2;
+
+      case S1AP_PagingPriority_priolevel2:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL2;
         break;
-      case S1ap_PagingPriority_priolevel3:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL3;
+
+      case S1AP_PagingPriority_priolevel3:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL3;
         break;
-      case S1ap_PagingPriority_priolevel4:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL4;
+
+      case S1AP_PagingPriority_priolevel4:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL4;
         break;
-      case S1ap_PagingPriority_priolevel5:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL5;
+
+      case S1AP_PagingPriority_priolevel5:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL5;
         break;
-      case S1ap_PagingPriority_priolevel6:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL6;
+
+      case S1AP_PagingPriority_priolevel6:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL6;
         break;
-      case S1ap_PagingPriority_priolevel7:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL7;
+
+      case S1AP_PagingPriority_priolevel7:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL7;
         break;
-      case S1ap_PagingPriority_priolevel8:
-          S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL8;
+
+      case S1AP_PagingPriority_priolevel8:
+        S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL8;
         break;
+
       default:
         /* invalid paging_p->pagingPriority */
         S1AP_ERROR("[SCTP %d] Received paging : pagingPriority(%ld) is invalid\n", assoc_id, paging_p->pagingPriority);
         return -1;
-      }
+    }
   }
+
 #endif
   //paging parameter values
   S1AP_DEBUG("[SCTP %d] Received Paging parameters: ue_index_value %d  cn_domain %d paging_drx %d paging_priority %d\n",assoc_id,
-          S1AP_PAGING_IND(message_p).ue_index_value, S1AP_PAGING_IND(message_p).cn_domain,
-          S1AP_PAGING_IND(message_p).paging_drx, S1AP_PAGING_IND(message_p).paging_priority);
+             S1AP_PAGING_IND(message_p).ue_index_value, S1AP_PAGING_IND(message_p).cn_domain,
+             S1AP_PAGING_IND(message_p).paging_drx, S1AP_PAGING_IND(message_p).paging_priority);
   S1AP_DEBUG("[SCTP %d] Received Paging parameters(ue): presenceMask %d  s_tmsi.m_tmsi %d s_tmsi.mme_code %d IMSI length %d (0-5) %d%d%d%d%d%d\n",assoc_id,
-          S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi,
-          S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length,
-          S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[0], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[1],
-          S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[3],
-          S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[4], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[5]);
-
+             S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi,
+             S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length,
+             S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[0], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[1],
+             S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[3],
+             S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[4], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[5]);
   /* send message to RRC */
   itti_send_msg_to_task(TASK_RRC_ENB, s1ap_eNB_instance->instance, message_p);
-  
-   return 0;
+  return 0;
 }
 
 static
 int s1ap_eNB_handle_e_rab_modify_request(uint32_t               assoc_id,
-          uint32_t               stream,
-          struct s1ap_message_s *s1ap_message_p) {
-
+    uint32_t               stream,
+    S1AP_S1AP_PDU_t       *pdu)
+{
   int i;
-
-  s1ap_eNB_mme_data_t   *mme_desc_p       = NULL;
-  s1ap_eNB_ue_context_t *ue_desc_p        = NULL;
-  MessageDef            *message_p        = NULL;
-  int nb_of_e_rabs_failed = 0;
-
-  S1ap_E_RABModifyRequestIEs_t         *s1ap_E_RABModifyRequest;
-  DevAssert(s1ap_message_p != NULL);
-
-  s1ap_E_RABModifyRequest = &s1ap_message_p->msg.s1ap_E_RABModifyRequestIEs;
+  s1ap_eNB_mme_data_t           *mme_desc_p       = NULL;
+  s1ap_eNB_ue_context_t         *ue_desc_p        = NULL;
+  MessageDef                    *message_p        = NULL;
+  S1AP_E_RABModifyRequest_t     *container;
+  S1AP_E_RABModifyRequestIEs_t  *ie;
+  S1AP_ENB_UE_S1AP_ID_t         enb_ue_s1ap_id;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.E_RABModifyRequest;
 
   if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received E-RAB modify request for non "
@@ -1213,12 +1314,15 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t               assoc_id,
     return -1;
   }
 
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, TRUE);
+  enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
 
   if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
-                   s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID)) == NULL) {
+                   ie->value.choice.ENB_UE_S1AP_ID)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received E-RAB modify request for non "
                "existing UE context 0x%06lx\n", assoc_id,
-               s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID);
+               ie->value.choice.ENB_UE_S1AP_ID);
     return -1;
   }
 
@@ -1230,54 +1334,51 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t               assoc_id,
   }
 
   ue_desc_p->rx_stream = stream;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, TRUE);
 
-  if ( ue_desc_p->mme_ue_s1ap_id != s1ap_E_RABModifyRequest->mme_ue_s1ap_id){
+  if (ue_desc_p->mme_ue_s1ap_id != ie->value.choice.MME_UE_S1AP_ID) {
     S1AP_WARN("UE context mme_ue_s1ap_id is different form that of the message (%d != %ld)",
-        ue_desc_p->mme_ue_s1ap_id, s1ap_E_RABModifyRequest->mme_ue_s1ap_id);
+              ue_desc_p->mme_ue_s1ap_id, ie->value.choice.MME_UE_S1AP_ID);
     message_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP);
-
-    S1AP_E_RAB_MODIFY_RESP (message_p).eNB_ue_s1ap_id = s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID;
-//        S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs[S1AP_MAX_E_RAB];
-    S1AP_E_RAB_MODIFY_RESP (message_p).nb_of_e_rabs = 0;
-
-    for(nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.count; nb_of_e_rabs_failed++) {
-      S1AP_E_RAB_MODIFY_RESP (message_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id =
-            ((S1ap_E_RABToBeModifiedItemBearerModReq_t *)s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.array[nb_of_e_rabs_failed])->e_RAB_ID;
-      S1AP_E_RAB_MODIFY_RESP (message_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK;
-      S1AP_E_RAB_MODIFY_RESP (message_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = 13;//S1ap_CauseRadioNetwork_unknown_mme_ue_s1ap_id;
+    S1AP_E_RAB_MODIFY_RESP (message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
+    S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
+                               S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, TRUE);
+
+    for(i = 0; i < ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count; i++) {
+      S1AP_E_RABToBeModifiedItemBearerModReq_t *item_p;
+      item_p = &(((S1AP_E_RABToBeModifiedItemBearerModReqIEs_t *)
+                  ie->value.choice.E_RABToBeModifiedListBearerModReq.list.array[i])->value.choice.E_RABToBeModifiedItemBearerModReq);
+      S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[i].e_rab_id = item_p->e_RAB_ID;
+      S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[i].cause = S1AP_Cause_PR_radioNetwork;
+      S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[i].cause_value = S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id;
     }
-    S1AP_E_RAB_MODIFY_RESP (message_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed;
 
+    S1AP_E_RAB_MODIFY_RESP(message_p).nb_of_e_rabs_failed = ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count;
     s1ap_eNB_e_rab_modify_resp(mme_desc_p->s1ap_eNB_instance->instance,
                                &S1AP_E_RAB_MODIFY_RESP(message_p));
-
     message_p = NULL;
     return -1;
   }
 
   message_p        = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_MODIFY_REQ);
-
   S1AP_E_RAB_MODIFY_REQ(message_p).ue_initial_id  = ue_desc_p->ue_initial_id;
-
-  S1AP_E_RAB_MODIFY_REQ(message_p).mme_ue_s1ap_id  = s1ap_E_RABModifyRequest->mme_ue_s1ap_id;
-  S1AP_E_RAB_MODIFY_REQ(message_p).eNB_ue_s1ap_id  = s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID;
-
+  S1AP_E_RAB_MODIFY_REQ(message_p).mme_ue_s1ap_id  = ie->value.choice.MME_UE_S1AP_ID;
+  S1AP_E_RAB_MODIFY_REQ(message_p).eNB_ue_s1ap_id  = enb_ue_s1ap_id;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, TRUE);
   S1AP_E_RAB_MODIFY_REQ(message_p).nb_e_rabs_tomodify =
-    s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.count;
-
-  for (i = 0; i < s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.count; i++) {
-    S1ap_E_RABToBeModifiedItemBearerModReq_t *item_p;
-
-    item_p = (S1ap_E_RABToBeModifiedItemBearerModReq_t *)s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.array[i];
+    ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count;
 
+  for (i = 0; i < ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count; i++) {
+    S1AP_E_RABToBeModifiedItemBearerModReq_t *item_p;
+    item_p = &(((S1AP_E_RABToBeModifiedItemBearerModReqIEs_t *)ie->value.choice.E_RABToBeModifiedListBearerModReq.list.array[i])->value.choice.E_RABToBeModifiedItemBearerModReq);
     S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].e_rab_id = item_p->e_RAB_ID;
 
     // check for the NAS PDU
     if (item_p->nAS_PDU.size > 0 ) {
       S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.length = item_p->nAS_PDU.size;
-
       S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.buffer = malloc(sizeof(uint8_t) * item_p->nAS_PDU.size);
-
       memcpy(S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.buffer,
              item_p->nAS_PDU.buf, item_p->nAS_PDU.size);
     } else {
@@ -1288,44 +1389,46 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t               assoc_id,
 
     /* Set the QOS informations */
     S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.qci = item_p->e_RABLevelQoSParameters.qCI;
-
     S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.priority_level =
       item_p->e_RABLevelQoSParameters.allocationRetentionPriority.priorityLevel;
     S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.pre_emp_capability =
       item_p->e_RABLevelQoSParameters.allocationRetentionPriority.pre_emptionCapability;
     S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.pre_emp_vulnerability =
       item_p->e_RABLevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability;
-
   }
 
   itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
-
   return 0;
 }
 // handle e-rab release command and send it to rrc_end
 static
 int s1ap_eNB_handle_e_rab_release_command(uint32_t               assoc_id,
-                                          uint32_t               stream,
-                                          struct s1ap_message_s *s1ap_message_p) {
-
+    uint32_t               stream,
+    S1AP_S1AP_PDU_t       *pdu)
+{
   int i;
-
   s1ap_eNB_mme_data_t   *mme_desc_p       = NULL;
   s1ap_eNB_ue_context_t *ue_desc_p        = NULL;
   MessageDef            *message_p        = NULL;
+  S1AP_E_RABReleaseCommand_t     *container;
+  S1AP_E_RABReleaseCommandIEs_t  *ie;
+  S1AP_ENB_UE_S1AP_ID_t           enb_ue_s1ap_id;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.E_RABReleaseCommand;
 
-  S1ap_E_RABReleaseCommandIEs_t         *s1ap_E_RABReleaseCommand;
-  DevAssert(s1ap_message_p != NULL);
-  s1ap_E_RABReleaseCommand = &s1ap_message_p->msg.s1ap_E_RABReleaseCommandIEs;
-  
   if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received E-RAB release command for non existing MME context\n", assoc_id);
     return -1;
   }
+
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, TRUE);
+  enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
+
   if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
-          s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID)) == NULL) {
+                   ie->value.choice.ENB_UE_S1AP_ID)) == NULL) {
     S1AP_ERROR("[SCTP %d] Received E-RAB release command for non existing UE context 0x%06lx\n", assoc_id,
-               s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID);
+               ie->value.choice.ENB_UE_S1AP_ID);
     return -1;
   }
 
@@ -1337,42 +1440,45 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t               assoc_id,
   }
 
   ue_desc_p->rx_stream = stream;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, TRUE);
 
-  if ( ue_desc_p->mme_ue_s1ap_id != s1ap_E_RABReleaseCommand->mme_ue_s1ap_id){
+  if (ue_desc_p->mme_ue_s1ap_id != ie->value.choice.MME_UE_S1AP_ID) {
     S1AP_WARN("UE context mme_ue_s1ap_id is different form that of the message (%d != %ld)",
-          ue_desc_p->mme_ue_s1ap_id, s1ap_E_RABReleaseCommand->mme_ue_s1ap_id);
+              ue_desc_p->mme_ue_s1ap_id, ie->value.choice.MME_UE_S1AP_ID);
   }
 
   S1AP_DEBUG("[SCTP %d] Received E-RAB release command for eNB_UE_S1AP_ID %ld mme_ue_s1ap_id %ld\n",
-          assoc_id, s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID, s1ap_E_RABReleaseCommand->mme_ue_s1ap_id);
-
-  message_p        = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_RELEASE_COMMAND);
-
-  S1AP_E_RAB_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID;
-  S1AP_E_RAB_RELEASE_COMMAND(message_p).mme_ue_s1ap_id = s1ap_E_RABReleaseCommand->mme_ue_s1ap_id;
-  if(s1ap_E_RABReleaseCommand->nas_pdu.size > 0 ){
-    S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.length = s1ap_E_RABReleaseCommand->nas_pdu.size;
-
+             assoc_id, enb_ue_s1ap_id, ie->value.choice.MME_UE_S1AP_ID);
+  message_p = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_RELEASE_COMMAND);
+  S1AP_E_RAB_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
+  S1AP_E_RAB_RELEASE_COMMAND(message_p).mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_NAS_PDU, FALSE);
+
+  if(ie && ie->value.choice.NAS_PDU.size > 0) {
+    S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.length = ie->value.choice.NAS_PDU.size;
     S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer =
-      malloc(sizeof(uint8_t) * s1ap_E_RABReleaseCommand->nas_pdu.size);
-
+      malloc(sizeof(uint8_t) * ie->value.choice.NAS_PDU.size);
     memcpy(S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer,
-    		s1ap_E_RABReleaseCommand->nas_pdu.buf,
-    		s1ap_E_RABReleaseCommand->nas_pdu.size);
+           ie->value.choice.NAS_PDU.buf,
+           ie->value.choice.NAS_PDU.size);
   } else {
-	  S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.length = 0;
-	  S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer = NULL;
+    S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.length = 0;
+    S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer = NULL;
   }
 
-  S1AP_E_RAB_RELEASE_COMMAND(message_p).nb_e_rabs_torelease = s1ap_E_RABReleaseCommand->e_RABToBeReleasedList.s1ap_E_RABItem.count;
-  for(i=0; i < s1ap_E_RABReleaseCommand->e_RABToBeReleasedList.s1ap_E_RABItem.count; i++){
-	  S1ap_E_RABItem_t *item_p;
-	  item_p = (S1ap_E_RABItem_t*)s1ap_E_RABReleaseCommand->e_RABToBeReleasedList.s1ap_E_RABItem.array[i];
-	  S1AP_E_RAB_RELEASE_COMMAND(message_p).e_rab_release_params[i].e_rab_id = item_p->e_RAB_ID;
-	  S1AP_DEBUG("[SCTP] Received E-RAB release command for e-rab id %ld\n", item_p->e_RAB_ID);
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_E_RABToBeReleasedList, TRUE);
+  S1AP_E_RAB_RELEASE_COMMAND(message_p).nb_e_rabs_torelease = ie->value.choice.E_RABList.list.count;
+
+  for (i = 0; i < ie->value.choice.E_RABList.list.count; i++) {
+    S1AP_E_RABItem_t *item_p;
+    item_p = &(((S1AP_E_RABItemIEs_t *)ie->value.choice.E_RABList.list.array[i])->value.choice.E_RABItem);
+    S1AP_E_RAB_RELEASE_COMMAND(message_p).e_rab_release_params[i].e_rab_id = item_p->e_RAB_ID;
+    S1AP_DEBUG("[SCTP] Received E-RAB release command for e-rab id %ld\n", item_p->e_RAB_ID);
   }
 
   itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
-
   return 0;
 }
diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c
index d6d9b52c07a2cd6719b9bc63fbcda72bf4d11c4a..3ce4eb17fb054e5d4cefbd1f92f9fa113de2c90d 100644
--- a/openair3/S1AP/s1ap_eNB_nas_procedures.c
+++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c
@@ -21,7 +21,7 @@
 
 /*! \file s1ap_eNB_nas_procedures.c
  * \brief S1AP eNb NAS procedure handler
- * \author  S. Roux and Navid Nikaein 
+ * \author  S. Roux and Navid Nikaein
  * \date 2010 - 2015
  * \email: navid.nikaein@eurecom.fr
  * \version 1.0
@@ -41,7 +41,6 @@
 
 #include "s1ap_eNB_itti_messaging.h"
 
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_encoder.h"
 #include "s1ap_eNB_nnsf.h"
 #include "s1ap_eNB_ue_context.h"
@@ -57,26 +56,21 @@ int s1ap_eNB_handle_nas_first_req(
   s1ap_eNB_instance_t          *instance_p = NULL;
   struct s1ap_eNB_mme_data_s   *mme_desc_p = NULL;
   struct s1ap_eNB_ue_context_s *ue_desc_p  = NULL;
-
-  s1ap_message message;
-
-  S1ap_InitialUEMessageIEs_t *initial_ue_message_p = NULL;
-
+  S1AP_S1AP_PDU_t               pdu;
+  S1AP_InitialUEMessage_t      *out;
+  S1AP_InitialUEMessage_IEs_t  *ie;
   uint8_t  *buffer = NULL;
   uint32_t  length = 0;
-
   DevAssert(s1ap_nas_first_req_p != NULL);
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   instance_p = s1ap_eNB_get_instance(instance);
   DevAssert(instance_p != NULL);
-
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_initiatingMessage;
-  message.procedureCode = S1ap_ProcedureCode_id_initialUEMessage;
-
-  initial_ue_message_p = &message.msg.s1ap_InitialUEMessageIEs;
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
+  pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_initialUEMessage;
+  pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore;
+  pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_InitialUEMessage;
+  out = &pdu.choice.initiatingMessage.value.choice.InitialUEMessage;
 
   /* Select the MME corresponding to the provided GUMMEI. */
   if (s1ap_nas_first_req_p->ue_identity.presenceMask & UE_IDENTITIES_gummei) {
@@ -111,7 +105,6 @@ int s1ap_eNB_handle_nas_first_req(
      * In case eNB has no MME associated, the eNB should inform RRC and discard
      * this request.
      */
-
     S1AP_WARN("No MME is associated to the eNB\n");
     // TODO: Inform RRC
     return -1;
@@ -122,7 +115,6 @@ int s1ap_eNB_handle_nas_first_req(
    */
   ue_desc_p = s1ap_eNB_allocate_new_UE_context();
   DevAssert(ue_desc_p != NULL);
-
   /* Keep a reference to the selected MME */
   ue_desc_p->mme_ref       = mme_desc_p;
   ue_desc_p->ue_initial_id = s1ap_nas_first_req_p->ue_initial_id;
@@ -130,7 +122,6 @@ int s1ap_eNB_handle_nas_first_req(
 
   do {
     struct s1ap_eNB_ue_context_s *collision_p;
-
     /* Peek a random value for the eNB_ue_s1ap_id */
     ue_desc_p->eNB_ue_s1ap_id = (random() + random()) & 0x00ffffff;
 
@@ -144,70 +135,239 @@ int s1ap_eNB_handle_nas_first_req(
     }
   } while(1);
 
-  initial_ue_message_p->eNB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id;
-  /* Prepare the NAS PDU */
-  initial_ue_message_p->nas_pdu.buf  = s1ap_nas_first_req_p->nas_pdu.buffer;
-  initial_ue_message_p->nas_pdu.size = s1ap_nas_first_req_p->nas_pdu.length;
-
+  /* mandatory */
+  ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_NAS_PDU;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_NAS_PDU;
+  ie->value.choice.NAS_PDU.buf = s1ap_nas_first_req_p->nas_pdu.buffer;
+  ie->value.choice.NAS_PDU.size = s1ap_nas_first_req_p->nas_pdu.length;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_TAI;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_TAI;
+  /* Assuming TAI is the TAI from the cell */
+  INT16_TO_OCTET_STRING(instance_p->tac, &ie->value.choice.TAI.tAC);
+  MCC_MNC_TO_PLMNID(instance_p->mcc,
+                    instance_p->mnc,
+                    instance_p->mnc_digit_length,
+                    &ie->value.choice.TAI.pLMNidentity);
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_EUTRAN_CGI;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_EUTRAN_CGI;
+  /* Set the EUTRAN CGI
+   * The cell identity is defined on 28 bits but as we use macro enb id,
+   * we have to pad.
+   */
+  //#warning "TODO get cell id from RRC"
+  MACRO_ENB_ID_TO_CELL_IDENTITY(instance_p->eNB_id,
+                                0, // Cell ID
+                                &ie->value.choice.EUTRAN_CGI.cell_ID);
+  MCC_MNC_TO_TBCD(instance_p->mcc,
+                  instance_p->mnc,
+                  instance_p->mnc_digit_length,
+                  &ie->value.choice.EUTRAN_CGI.pLMNidentity);
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   /* Set the establishment cause according to those provided by RRC */
   DevCheck(s1ap_nas_first_req_p->establishment_cause < RRC_CAUSE_LAST,
            s1ap_nas_first_req_p->establishment_cause, RRC_CAUSE_LAST, 0);
-  initial_ue_message_p->rrC_Establishment_Cause = s1ap_nas_first_req_p->establishment_cause;
-
+  /* mandatory */
+  ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_RRC_Establishment_Cause;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_RRC_Establishment_Cause;
+  ie->value.choice.RRC_Establishment_Cause = s1ap_nas_first_req_p->establishment_cause;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
   if (s1ap_nas_first_req_p->ue_identity.presenceMask & UE_IDENTITIES_s_tmsi) {
     S1AP_DEBUG("S_TMSI_PRESENT\n");
-    initial_ue_message_p->presenceMask |= S1AP_INITIALUEMESSAGEIES_S_TMSI_PRESENT;
-
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_S_TMSI;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_S_TMSI;
     MME_CODE_TO_OCTET_STRING(s1ap_nas_first_req_p->ue_identity.s_tmsi.mme_code,
-                             &initial_ue_message_p->s_tmsi.mMEC);
+                             &ie->value.choice.S_TMSI.mMEC);
     M_TMSI_TO_OCTET_STRING(s1ap_nas_first_req_p->ue_identity.s_tmsi.m_tmsi,
-                           &initial_ue_message_p->s_tmsi.m_TMSI);
+                           &ie->value.choice.S_TMSI.m_TMSI);
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CSG_Id;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_CSG_Id;
+    // ie->value.choice.CSG_Id = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
   if (s1ap_nas_first_req_p->ue_identity.presenceMask & UE_IDENTITIES_gummei) {
     S1AP_DEBUG("GUMMEI_ID_PRESENT\n");
-    initial_ue_message_p->presenceMask |= S1AP_INITIALUEMESSAGEIES_GUMMEI_ID_PRESENT;
-
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_GUMMEI_ID;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_GUMMEI;
     MCC_MNC_TO_PLMNID(
       s1ap_nas_first_req_p->ue_identity.gummei.mcc,
       s1ap_nas_first_req_p->ue_identity.gummei.mnc,
       s1ap_nas_first_req_p->ue_identity.gummei.mnc_len,
-      &initial_ue_message_p->gummei_id.pLMN_Identity);
-
+      &ie->value.choice.GUMMEI.pLMN_Identity);
     MME_GID_TO_OCTET_STRING(s1ap_nas_first_req_p->ue_identity.gummei.mme_group_id,
-                            &initial_ue_message_p->gummei_id.mME_Group_ID);
+                            &ie->value.choice.GUMMEI.mME_Group_ID);
     MME_CODE_TO_OCTET_STRING(s1ap_nas_first_req_p->ue_identity.gummei.mme_code,
-                             &initial_ue_message_p->gummei_id.mME_Code);
+                             &ie->value.choice.GUMMEI.mME_Code);
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
-  /* Assuming TAI is the TAI from the cell */
-  INT16_TO_OCTET_STRING(instance_p->tac, &initial_ue_message_p->tai.tAC);
-  MCC_MNC_TO_PLMNID(instance_p->mcc,
-                    instance_p->mnc,
-                    instance_p->mnc_digit_length,
-                    &initial_ue_message_p->tai.pLMNidentity);
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CellAccessMode;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_CellAccessMode;
+    // ie->value.choice.CellAccessMode = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  /* Set the EUTRAN CGI
-   * The cell identity is defined on 28 bits but as we use macro enb id,
-   * we have to pad.
-   */
-//#warning "TODO get cell id from RRC"
-  MACRO_ENB_ID_TO_CELL_IDENTITY(instance_p->eNB_id,
-		  0, // Cell ID
-          &initial_ue_message_p->eutran_cgi.cell_ID);
-  MCC_MNC_TO_TBCD(instance_p->mcc,
-                  instance_p->mnc,
-                  instance_p->mnc_digit_length,
-                  &initial_ue_message_p->eutran_cgi.pLMNidentity);
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_GW_TransportLayerAddress;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_TransportLayerAddress;
+    // ie->value.choice.TransportLayerAddress =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_RelayNode_Indicator;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_RelayNode_Indicator;
+    // ie->value.choice.RelayNode_Indicator =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_GUMMEIType;
+    ie->criticality = S1AP_Criticality_reject;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_GUMMEIType;
+    // ie->value.choice.GUMMEIType =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */ /* release 11 */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_Tunnel_Information_for_BBF;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_TunnelInformation;
+    // ie->value.choice.TunnelInformation =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_SIPTO_L_GW_TransportLayerAddress;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_TransportLayerAddress;
+    // ie->value.choice.TransportLayerAddress = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_LHN_ID;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_LHN_ID;
+    // ie->value.choice.LHN_ID = ue_release_req_p->eNB_ue_s1ap_id;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_MME_Group_ID;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_MME_Group_ID;
+    // ie->value.choice.MME_Group_ID =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_UE_Usage_Type;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_UE_Usage_Type;
+    // ie->value.choice.UE_Usage_Type =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CE_mode_B_SupportIndicator;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_CE_mode_B_SupportIndicator;
+    // ie->value.choice.CE_mode_B_SupportIndicator = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_DCN_ID;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_DCN_ID;
+    // ie->value.choice.DCN_ID = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_Coverage_Level;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_Coverage_Level;
+    // ie->value.choice.Coverage_Level = ue_release_req_p->eNB_ue_s1ap_id;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     /* Failed to encode message */
     DevMessage("Failed to encode initial UE message\n");
   }
 
   /* Update the current S1AP UE state */
   ue_desc_p->ue_state = S1AP_UE_WAITING_CSR;
-
   /* Assign a stream for this UE :
    * From 3GPP 36.412 7)Transport layers:
    *  Within the SCTP association established between one MME and eNB pair:
@@ -227,7 +387,6 @@ int s1ap_eNB_handle_nas_first_req(
   }
 
   ue_desc_p->tx_stream = mme_desc_p->nextstream;
-
   MSC_LOG_TX_MESSAGE(
     MSC_S1AP_ENB,
     MSC_S1AP_MME,
@@ -236,29 +395,26 @@ int s1ap_eNB_handle_nas_first_req(
     MSC_AS_TIME_FMT" initialUEMessage initiatingMessage eNB_ue_s1ap_id %u",
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     initial_ue_message_p->eNB_UE_S1AP_ID);
-
   /* Send encoded message over sctp */
   s1ap_eNB_itti_send_sctp_data_req(instance_p->instance, mme_desc_p->assoc_id,
                                    buffer, length, ue_desc_p->tx_stream);
-
   return 0;
 }
 
 //------------------------------------------------------------------------------
-int s1ap_eNB_handle_nas_downlink(const uint32_t               assoc_id,
-                                 const uint32_t               stream,
-                                 struct s1ap_message_s* message_p)
+int s1ap_eNB_handle_nas_downlink(uint32_t         assoc_id,
+                                 uint32_t         stream,
+                                 S1AP_S1AP_PDU_t *pdu)
 //------------------------------------------------------------------------------
 {
-  const S1ap_DownlinkNASTransportIEs_t *downlink_NAS_transport_p = NULL;
-
-  s1ap_eNB_mme_data_t   *mme_desc_p                        = NULL;
-  s1ap_eNB_ue_context_t *ue_desc_p                         = NULL;
-  s1ap_eNB_instance_t   *s1ap_eNB_instance                 = NULL;
-
-  DevAssert(message_p != NULL);
-
-  downlink_NAS_transport_p = &message_p->msg.s1ap_DownlinkNASTransportIEs;
+  s1ap_eNB_mme_data_t             *mme_desc_p        = NULL;
+  s1ap_eNB_ue_context_t           *ue_desc_p         = NULL;
+  s1ap_eNB_instance_t             *s1ap_eNB_instance = NULL;
+  S1AP_DownlinkNASTransport_t     *container;
+  S1AP_DownlinkNASTransport_IEs_t *ie;
+  S1AP_ENB_UE_S1AP_ID_t            enb_ue_s1ap_id;
+  S1AP_MME_UE_S1AP_ID_t            mme_ue_s1ap_id;
+  DevAssert(pdu != NULL);
 
   /* UE-related procedure -> stream != 0 */
   if (stream == 0) {
@@ -275,19 +431,26 @@ int s1ap_eNB_handle_nas_downlink(const uint32_t               assoc_id,
   }
 
   s1ap_eNB_instance = mme_desc_p->s1ap_eNB_instance;
+  /* Prepare the S1AP message to encode */
+  container = &pdu->choice.initiatingMessage.value.choice.DownlinkNASTransport;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, TRUE);
+  mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, TRUE);
+  enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
 
   if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance,
-                   downlink_NAS_transport_p->eNB_UE_S1AP_ID)) == NULL) {
+                   ie->value.choice.ENB_UE_S1AP_ID)) == NULL) {
     MSC_LOG_RX_DISCARDED_MESSAGE(
       MSC_S1AP_ENB,
       MSC_S1AP_MME,
       (const char *)downlink_NAS_transport_p,
-      sizeof(S1ap_DownlinkNASTransportIEs_t),
+      sizeof(S1AP_DownlinkNASTransportIEs_t),
       MSC_AS_TIME_FMT" downlinkNASTransport  eNB_ue_s1ap_id %u mme_ue_s1ap_id %u",
       0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
-      downlink_NAS_transport_p->eNB_UE_S1AP_ID,
-      downlink_NAS_transport_p->mme_ue_s1ap_id);
-
+      enb_ue_s1ap_id
+      mme_ue_s1ap_id);
     /* TODO: fix this log - the original version is suspicious (twice downlink_NAS_transport_p->eNB_UE_S1AP_ID?) */
     /*S1AP_ERROR("[SCTP %d] Received NAS downlink message for non existing UE context eNB_UE_S1AP_ID: 0x%"PRIx32" %u\n",
                assoc_id,
@@ -295,12 +458,12 @@ int s1ap_eNB_handle_nas_downlink(const uint32_t               assoc_id,
                downlink_NAS_transport_p->eNB_UE_S1AP_ID);*/
     S1AP_ERROR("[SCTP %d] Received NAS downlink message for non existing UE context eNB_UE_S1AP_ID: 0x%lx\n",
                assoc_id,
-               downlink_NAS_transport_p->eNB_UE_S1AP_ID);
+               enb_ue_s1ap_id);
     return -1;
   }
 
   if (0 == ue_desc_p->rx_stream) {
-	ue_desc_p->rx_stream = stream;
+    ue_desc_p->rx_stream = stream;
   } else if (stream != ue_desc_p->rx_stream) {
     S1AP_ERROR("[SCTP %d] Received UE-related procedure on stream %u, expecting %u\n",
                assoc_id, stream, ue_desc_p->rx_stream);
@@ -311,13 +474,13 @@ int s1ap_eNB_handle_nas_downlink(const uint32_t               assoc_id,
    * UE s1ap id.
    */
   if (ue_desc_p->mme_ue_s1ap_id == 0) {
-    ue_desc_p->mme_ue_s1ap_id = downlink_NAS_transport_p->mme_ue_s1ap_id;
+    ue_desc_p->mme_ue_s1ap_id = mme_ue_s1ap_id;
   } else {
     /* We already have a mme ue s1ap id check the received is the same */
-    if (ue_desc_p->mme_ue_s1ap_id != downlink_NAS_transport_p->mme_ue_s1ap_id) {
+    if (ue_desc_p->mme_ue_s1ap_id != mme_ue_s1ap_id) {
       S1AP_ERROR("[SCTP %d] Mismatch in MME UE S1AP ID (0x%lx != 0x%"PRIx32"\n",
                  assoc_id,
-                 downlink_NAS_transport_p->mme_ue_s1ap_id,
+                 mme_ue_s1ap_id,
                  ue_desc_p->mme_ue_s1ap_id
                 );
       return -1;
@@ -328,22 +491,21 @@ int s1ap_eNB_handle_nas_downlink(const uint32_t               assoc_id,
     MSC_S1AP_ENB,
     MSC_S1AP_MME,
     (const char *)downlink_NAS_transport_p,
-    sizeof(S1ap_DownlinkNASTransportIEs_t),
+    sizeof(S1AP_DownlinkNASTransportIEs_t),
     MSC_AS_TIME_FMT" downlinkNASTransport  eNB_ue_s1ap_id %u mme_ue_s1ap_id %u",
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
-    downlink_NAS_transport_p->eNB_UE_S1AP_ID,
-    downlink_NAS_transport_p->mme_ue_s1ap_id);
-
+    enb_ue_s1ap_id,
+    mme_ue_s1ap_id);
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_NAS_PDU, TRUE);
   /* Forward the NAS PDU to RRC */
   s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance,
                                       ue_desc_p->ue_initial_id,
                                       ue_desc_p->eNB_ue_s1ap_id,
-                                      downlink_NAS_transport_p->nas_pdu.buf,
-                                      downlink_NAS_transport_p->nas_pdu.size);
-
+                                      ie->value.choice.NAS_PDU.buf,
+                                      ie->value.choice.NAS_PDU.size);
   // LG: Why set to 0 ??
   //ue_desc_p->ue_initial_id = 0;
-
   return 0;
 }
 
@@ -351,17 +513,14 @@ int s1ap_eNB_handle_nas_downlink(const uint32_t               assoc_id,
 int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_p)
 //------------------------------------------------------------------------------
 {
-  struct s1ap_eNB_ue_context_s *ue_context_p;
-  s1ap_eNB_instance_t          *s1ap_eNB_instance_p;
-  S1ap_UplinkNASTransportIEs_t *uplink_NAS_transport_p;
-
-  s1ap_message  message;
-
+  struct s1ap_eNB_ue_context_s  *ue_context_p;
+  s1ap_eNB_instance_t           *s1ap_eNB_instance_p;
+  S1AP_S1AP_PDU_t                pdu;
+  S1AP_UplinkNASTransport_t     *out;
+  S1AP_UplinkNASTransport_IEs_t *ie;
   uint8_t  *buffer;
-  uint32_t length;
-
+  uint32_t  length;
   DevAssert(s1ap_uplink_nas_p != NULL);
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
   DevAssert(s1ap_eNB_instance_p != NULL);
@@ -385,40 +544,93 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_
   }
 
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_initiatingMessage;
-  message.procedureCode = S1ap_ProcedureCode_id_uplinkNASTransport;
-
-  uplink_NAS_transport_p = &message.msg.s1ap_UplinkNASTransportIEs;
-
-  uplink_NAS_transport_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
-  uplink_NAS_transport_p->eNB_UE_S1AP_ID = ue_context_p->eNB_ue_s1ap_id;
-
-  uplink_NAS_transport_p->nas_pdu.buf  = s1ap_uplink_nas_p->nas_pdu.buffer;
-  uplink_NAS_transport_p->nas_pdu.size = s1ap_uplink_nas_p->nas_pdu.length;
-
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
+  pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_uplinkNASTransport;
+  pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore;
+  pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_UplinkNASTransport;
+  out = &pdu.choice.initiatingMessage.value.choice.UplinkNASTransport;
+  /* mandatory */
+  ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_context_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_NAS_PDU;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_NAS_PDU;
+  ie->value.choice.NAS_PDU.buf = s1ap_uplink_nas_p->nas_pdu.buffer;
+  ie->value.choice.NAS_PDU.size = s1ap_uplink_nas_p->nas_pdu.length;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_EUTRAN_CGI;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_EUTRAN_CGI;
   MCC_MNC_TO_PLMNID(
     s1ap_eNB_instance_p->mcc,
     s1ap_eNB_instance_p->mnc,
     s1ap_eNB_instance_p->mnc_digit_length,
-    &uplink_NAS_transport_p->eutran_cgi.pLMNidentity);
-
-//#warning "TODO get cell id from RRC"
+    &ie->value.choice.EUTRAN_CGI.pLMNidentity);
+  //#warning "TODO get cell id from RRC"
   MACRO_ENB_ID_TO_CELL_IDENTITY(s1ap_eNB_instance_p->eNB_id,
-          0,
-          &uplink_NAS_transport_p->eutran_cgi.cell_ID);
-
-  /* MCC/MNC should be repeated in TAI and EUTRAN CGI */
+                                0,
+                                &ie->value.choice.EUTRAN_CGI.cell_ID);
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_TAI;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_TAI;
   MCC_MNC_TO_PLMNID(
     s1ap_eNB_instance_p->mcc,
     s1ap_eNB_instance_p->mnc,
     s1ap_eNB_instance_p->mnc_digit_length,
-    &uplink_NAS_transport_p->tai.pLMNidentity);
+    &ie->value.choice.TAI.pLMNidentity);
+  TAC_TO_ASN1(s1ap_eNB_instance_p->tac, &ie->value.choice.TAI.tAC);
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_GW_TransportLayerAddress;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_TransportLayerAddress;
+    // ie->value.choice.TransportLayerAddress = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  TAC_TO_ASN1(s1ap_eNB_instance_p->tac, &uplink_NAS_transport_p->tai.tAC);
+  /* optional */
+  if (0) {
+    ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_SIPTO_L_GW_TransportLayerAddress;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_TransportLayerAddress;
+    // ie->value.choice.TransportLayerAddress = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_LHN_ID;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_LHN_ID;
+    // ie->value.choice.LHN_ID =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     S1AP_ERROR("Failed to encode uplink NAS transport\n");
     /* Encode procedure has failed... */
     return -1;
@@ -433,34 +645,27 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     uplink_NAS_transport_p->eNB_UE_S1AP_ID,
     uplink_NAS_transport_p->mme_ue_s1ap_id);
-
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
   return 0;
 }
 
 
 //------------------------------------------------------------------------------
-void s1ap_eNB_nas_non_delivery_ind(instance_t instance,
-                                   s1ap_nas_non_delivery_ind_t *s1ap_nas_non_delivery_ind)
+int s1ap_eNB_nas_non_delivery_ind(instance_t instance,
+                                  s1ap_nas_non_delivery_ind_t *s1ap_nas_non_delivery_ind)
 //------------------------------------------------------------------------------
 {
-  struct s1ap_eNB_ue_context_s *ue_context_p;
-  s1ap_eNB_instance_t          *s1ap_eNB_instance_p;
-
-  S1ap_NASNonDeliveryIndication_IEs_t *nas_non_delivery_p;
-
-  s1ap_message  message;
-
+  struct s1ap_eNB_ue_context_s        *ue_context_p;
+  s1ap_eNB_instance_t                 *s1ap_eNB_instance_p;
+  S1AP_S1AP_PDU_t                      pdu;
+  S1AP_NASNonDeliveryIndication_t     *out;
+  S1AP_NASNonDeliveryIndication_IEs_t *ie;
   uint8_t  *buffer;
-  uint32_t length;
-
+  uint32_t  length;
   DevAssert(s1ap_nas_non_delivery_ind != NULL);
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
   DevAssert(s1ap_eNB_instance_p != NULL);
@@ -473,35 +678,57 @@ void s1ap_eNB_nas_non_delivery_ind(instance_t instance,
       MSC_S1AP_ENB,
       MSC_AS_TIME_FMT" Sent of NAS_NON_DELIVERY_IND to MME failed, no context for eNB_ue_s1ap_id %06x",
       s1ap_nas_non_delivery_ind->eNB_ue_s1ap_id);
-    return;
+    return -1;
   }
 
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_initiatingMessage;
-  message.procedureCode = S1ap_ProcedureCode_id_NASNonDeliveryIndication;
-
-  nas_non_delivery_p = &message.msg.s1ap_NASNonDeliveryIndication_IEs;
-  nas_non_delivery_p->eNB_UE_S1AP_ID = ue_context_p->eNB_ue_s1ap_id;
-  nas_non_delivery_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
-  nas_non_delivery_p->nas_pdu.buf    = s1ap_nas_non_delivery_ind->nas_pdu.buffer;
-  nas_non_delivery_p->nas_pdu.size   = s1ap_nas_non_delivery_ind->nas_pdu.length;
-
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
+  pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_NASNonDeliveryIndication;
+  pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore;
+  pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_NASNonDeliveryIndication;
+  out = &pdu.choice.initiatingMessage.value.choice.NASNonDeliveryIndication;
+  /* mandatory */
+  ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_NASNonDeliveryIndication_IEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_NASNonDeliveryIndication_IEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_context_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_NASNonDeliveryIndication_IEs__value_PR_NAS_PDU;
+  ie->value.choice.NAS_PDU.buf = s1ap_nas_non_delivery_ind->nas_pdu.buffer;
+  ie->value.choice.NAS_PDU.size = s1ap_nas_non_delivery_ind->nas_pdu.length;
+  /* mandatory */
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
   /* Send a dummy cause */
-  nas_non_delivery_p->cause.present = S1ap_Cause_PR_radioNetwork;
-  nas_non_delivery_p->cause.choice.radioNetwork = S1ap_CauseRadioNetwork_radio_connection_with_ue_lost;
+  ie->value.present = S1AP_NASNonDeliveryIndication_IEs__value_PR_Cause;
+  ie->value.choice.Cause.present = S1AP_Cause_PR_radioNetwork;
+  ie->value.choice.Cause.choice.radioNetwork = S1AP_CauseRadioNetwork_radio_connection_with_ue_lost;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     S1AP_ERROR("Failed to encode NAS NON delivery indication\n");
     /* Encode procedure has failed... */
     MSC_LOG_EVENT(
       MSC_S1AP_ENB,
       MSC_AS_TIME_FMT" Sent of NAS_NON_DELIVERY_IND to MME failed (encoding)");
-    return;
+    return -1;
   }
 
-
   MSC_LOG_TX_MESSAGE(
     MSC_S1AP_ENB,
     MSC_S1AP_MME,
@@ -511,12 +738,11 @@ void s1ap_eNB_nas_non_delivery_ind(instance_t instance,
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     nas_non_delivery_p->eNB_UE_S1AP_ID,
     nas_non_delivery_p->mme_ue_s1ap_id);
-
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
+  return 0;
 }
 
 //------------------------------------------------------------------------------
@@ -524,21 +750,16 @@ int s1ap_eNB_initial_ctxt_resp(
   instance_t instance, s1ap_initial_context_setup_resp_t *initial_ctxt_resp_p)
 //------------------------------------------------------------------------------
 {
-  s1ap_eNB_instance_t          *s1ap_eNB_instance_p = NULL;
-  struct s1ap_eNB_ue_context_s *ue_context_p        = NULL;
-
-  S1ap_InitialContextSetupResponseIEs_t *initial_ies_p  = NULL;
-
-  s1ap_message  message;
-
-  uint8_t  *buffer  = NULL;
+  s1ap_eNB_instance_t                   *s1ap_eNB_instance_p = NULL;
+  struct s1ap_eNB_ue_context_s          *ue_context_p        = NULL;
+  S1AP_S1AP_PDU_t                        pdu;
+  S1AP_InitialContextSetupResponse_t    *out;
+  S1AP_InitialContextSetupResponseIEs_t *ie;
+  uint8_t  *buffer = NULL;
   uint32_t length;
-  int      ret = -1;
   int      i;
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
-
   DevAssert(initial_ctxt_resp_p != NULL);
   DevAssert(s1ap_eNB_instance_p != NULL);
 
@@ -562,40 +783,118 @@ int s1ap_eNB_initial_ctxt_resp(
   }
 
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome;
+  pdu.choice.successfulOutcome.procedureCode = S1AP_ProcedureCode_id_InitialContextSetup;
+  pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject;
+  pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_InitialContextSetupResponse;
+  out = &pdu.choice.successfulOutcome.value.choice.InitialContextSetupResponse;
+  /* mandatory */
+  ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_InitialContextSetupResponseIEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_InitialContextSetupResponseIEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = initial_ctxt_resp_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_InitialContextSetupResponseIEs__value_PR_E_RABSetupListCtxtSURes;
 
-  message.direction     = S1AP_PDU_PR_successfulOutcome;
-  message.procedureCode = S1ap_ProcedureCode_id_InitialContextSetup;
+  for (i = 0; i < initial_ctxt_resp_p->nb_of_e_rabs; i++) {
+    S1AP_E_RABSetupItemCtxtSUResIEs_t *item;
+    /* mandatory */
+    item = calloc(1, sizeof(S1AP_E_RABSetupItemCtxtSUResIEs_t));
+    item->id = S1AP_ProtocolIE_ID_id_E_RABSetupItemBearerSURes;
+    item->criticality = S1AP_Criticality_ignore;
+    item->value.present = S1AP_E_RABSetupItemBearerSUResIEs__value_PR_E_RABSetupItemBearerSURes;
+    item->value.choice.E_RABSetupItemCtxtSURes.e_RAB_ID = initial_ctxt_resp_p->e_rabs[i].e_rab_id;
+    GTP_TEID_TO_ASN1(initial_ctxt_resp_p->e_rabs[i].gtp_teid, &item->value.choice.E_RABSetupItemCtxtSURes.gTP_TEID);
+    item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf = initial_ctxt_resp_p->e_rabs[i].eNB_addr.buffer;
+    item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.size = initial_ctxt_resp_p->e_rabs[i].eNB_addr.length;
+    item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.bits_unused = 0;
+    S1AP_DEBUG("initial_ctxt_resp_p: e_rab ID %ld, enb_addr %d.%d.%d.%d, SIZE %ld \n",
+               item->value.choice.E_RABSetupItemCtxtSURes.e_RAB_ID,
+               item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf[0],
+               item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf[1],
+               item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf[2],
+               item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf[3],
+               item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.size);
+    ASN_SEQUENCE_ADD(&ie->value.choice.E_RABSetupListCtxtSURes.list, item);
+  }
 
-  initial_ies_p = &message.msg.s1ap_InitialContextSetupResponseIEs;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (initial_ctxt_resp_p->nb_of_e_rabs_failed) {
+    ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_E_RABFailedToSetupListCtxtSURes;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialContextSetupResponseIEs__value_PR_E_RABList;
+
+    for (i = 0; i < initial_ctxt_resp_p->nb_of_e_rabs_failed; i++) {
+      S1AP_E_RABItemIEs_t *item;
+      /* mandatory */
+      item = calloc(1, sizeof(S1AP_E_RABItemIEs_t));
+      item->id = S1AP_ProtocolIE_ID_id_E_RABItem;
+      item->criticality = S1AP_Criticality_ignore;
+      item->value.present = S1AP_E_RABItemIEs__value_PR_E_RABItem;
+      item->value.choice.E_RABItem.e_RAB_ID = initial_ctxt_resp_p->e_rabs_failed[i].e_rab_id;
+      item->value.choice.E_RABItem.cause.present = initial_ctxt_resp_p->e_rabs_failed[i].cause;
+
+      switch(item->value.choice.E_RABItem.cause.present)
+      {
+        case S1AP_Cause_PR_radioNetwork:
+          item->value.choice.E_RABItem.cause.choice.radioNetwork = initial_ctxt_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-  initial_ies_p->eNB_UE_S1AP_ID = initial_ctxt_resp_p->eNB_ue_s1ap_id;
-  initial_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
+        case S1AP_Cause_PR_transport:
+          item->value.choice.E_RABItem.cause.choice.transport = initial_ctxt_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-  for (i = 0; i < initial_ctxt_resp_p->nb_of_e_rabs; i++) {
-    S1ap_E_RABSetupItemCtxtSURes_t *new_item;
-
-    new_item = calloc(1, sizeof(S1ap_E_RABSetupItemCtxtSURes_t));
-
-    new_item->e_RAB_ID = initial_ctxt_resp_p->e_rabs[i].e_rab_id;
-    GTP_TEID_TO_ASN1(initial_ctxt_resp_p->e_rabs[i].gtp_teid, &new_item->gTP_TEID);
-    new_item->transportLayerAddress.buf = initial_ctxt_resp_p->e_rabs[i].eNB_addr.buffer;
-    new_item->transportLayerAddress.size = initial_ctxt_resp_p->e_rabs[i].eNB_addr.length;
-    new_item->transportLayerAddress.bits_unused = 0;
-
-    S1AP_DEBUG("initial_ctxt_resp_p: e_rab ID %ld, enb_addr %d.%d.%d.%d, SIZE %d \n", 
-	      new_item->e_RAB_ID,
-	      new_item->transportLayerAddress.buf[0],
-	      new_item->transportLayerAddress.buf[1],
-	      new_item->transportLayerAddress.buf[2],
-	      new_item->transportLayerAddress.buf[3],
-	      new_item->transportLayerAddress.size);
-
-    ASN_SEQUENCE_ADD(&initial_ies_p->e_RABSetupListCtxtSURes.s1ap_E_RABSetupItemCtxtSURes,
-                     new_item);
+        case S1AP_Cause_PR_nas:
+          item->value.choice.E_RABItem.cause.choice.nas = initial_ctxt_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_protocol:
+          item->value.choice.E_RABItem.cause.choice.protocol = initial_ctxt_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_misc:
+          item->value.choice.E_RABItem.cause.choice.misc = initial_ctxt_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_NOTHING:
+        default:
+          break;
+      }
+
+      S1AP_DEBUG("initial context setup response: failed e_rab ID %ld\n", item->value.choice.E_RABItem.e_RAB_ID);
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABList.list, item);
+    }
+
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CriticalityDiagnostics;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_InitialContextSetupResponseIEs__value_PR_CriticalityDiagnostics;
+    // ie->value.choice.CriticalityDiagnostics =;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     S1AP_ERROR("Failed to encode uplink NAS transport\n");
     /* Encode procedure has failed... */
     return -1;
@@ -610,13 +909,11 @@ int s1ap_eNB_initial_ctxt_resp(
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     initial_ies_p->eNB_UE_S1AP_ID,
     initial_ies_p->mme_ue_s1ap_id);
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
-  return ret;
+  return 0;
 }
 
 //------------------------------------------------------------------------------
@@ -626,18 +923,13 @@ int s1ap_eNB_ue_capabilities(instance_t instance,
 {
   s1ap_eNB_instance_t          *s1ap_eNB_instance_p;
   struct s1ap_eNB_ue_context_s *ue_context_p;
-
-  S1ap_UECapabilityInfoIndicationIEs_t *ue_cap_info_ind_ies_p;
-
-  s1ap_message  message;
-
+  S1AP_S1AP_PDU_t                       pdu;
+  S1AP_UECapabilityInfoIndication_t    *out;
+  S1AP_UECapabilityInfoIndicationIEs_t *ie;
   uint8_t  *buffer;
   uint32_t length;
-  int      ret = -1;
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
-
   DevAssert(ue_cap_info_ind_p != NULL);
   DevAssert(s1ap_eNB_instance_p != NULL);
 
@@ -661,27 +953,51 @@ int s1ap_eNB_ue_capabilities(instance_t instance,
   }
 
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_initiatingMessage;
-  message.procedureCode = S1ap_ProcedureCode_id_UECapabilityInfoIndication;
-
-  ue_cap_info_ind_ies_p = &message.msg.s1ap_UECapabilityInfoIndicationIEs;
-
-  ue_cap_info_ind_ies_p->ueRadioCapability.buf = ue_cap_info_ind_p->ue_radio_cap.buffer;
-  ue_cap_info_ind_ies_p->ueRadioCapability.size = ue_cap_info_ind_p->ue_radio_cap.length;
-
-  ue_cap_info_ind_ies_p->eNB_UE_S1AP_ID = ue_cap_info_ind_p->eNB_ue_s1ap_id;
-  ue_cap_info_ind_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
+  pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_UECapabilityInfoIndication;
+  pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore;
+  pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_UECapabilityInfoIndication;
+  out = &pdu.choice.initiatingMessage.value.choice.UECapabilityInfoIndication;
+  /* mandatory */
+  ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UECapabilityInfoIndicationIEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UECapabilityInfoIndicationIEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_cap_info_ind_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_UERadioCapability;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_UECapabilityInfoIndicationIEs__value_PR_UERadioCapability;
+  ie->value.choice.UERadioCapability.buf = ue_cap_info_ind_p->ue_radio_cap.buffer;
+  ie->value.choice.UERadioCapability.size = ue_cap_info_ind_p->ue_radio_cap.length;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_UERadioCapabilityForPaging;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_UECapabilityInfoIndicationIEs__value_PR_UERadioCapabilityForPaging;
+    // ie->value.choice.UERadioCapabilityForPaging = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     /* Encode procedure has failed... */
     S1AP_ERROR("Failed to encode UE capabilities indication\n");
     return -1;
   }
 
-  free(ue_cap_info_ind_p->ue_radio_cap.buffer);
-
   MSC_LOG_TX_MESSAGE(
     MSC_S1AP_ENB,
     MSC_S1AP_MME,
@@ -691,40 +1007,33 @@ int s1ap_eNB_ue_capabilities(instance_t instance,
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     ue_cap_info_ind_ies_p->eNB_UE_S1AP_ID,
     ue_cap_info_ind_ies_p->mme_ue_s1ap_id);
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
-  return ret;
+  return 0;
 }
 
 //------------------------------------------------------------------------------
-int s1ap_eNB_e_rab_setup_resp(instance_t instance, 
-			      s1ap_e_rab_setup_resp_t *e_rab_setup_resp_p)
+int s1ap_eNB_e_rab_setup_resp(instance_t instance,
+                              s1ap_e_rab_setup_resp_t *e_rab_setup_resp_p)
 //------------------------------------------------------------------------------
 {
   s1ap_eNB_instance_t          *s1ap_eNB_instance_p = NULL;
   struct s1ap_eNB_ue_context_s *ue_context_p        = NULL;
-
-  S1ap_E_RABSetupResponseIEs_t  *initial_ies_p  = NULL;
- 
-  s1ap_message  message;
-
+  S1AP_S1AP_PDU_t               pdu;
+  S1AP_E_RABSetupResponse_t    *out;
+  S1AP_E_RABSetupResponseIEs_t *ie;
   uint8_t  *buffer  = NULL;
   uint32_t length;
-  int      ret = -1;
   int      i;
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
-
   DevAssert(e_rab_setup_resp_p != NULL);
   DevAssert(s1ap_eNB_instance_p != NULL);
 
   if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
-					      e_rab_setup_resp_p->eNB_ue_s1ap_id)) == NULL) {
+                      e_rab_setup_resp_p->eNB_ue_s1ap_id)) == NULL) {
     /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
     S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: 0x%06x\n",
               e_rab_setup_resp_p->eNB_ue_s1ap_id);
@@ -741,85 +1050,136 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance,
               e_rab_setup_resp_p->eNB_ue_s1ap_id, ue_context_p->ue_state);
     return -1;
   }
- 
+
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_successfulOutcome;
-  message.procedureCode = S1ap_ProcedureCode_id_E_RABSetup;
-  message.criticality   = S1ap_Criticality_reject;
-
-  initial_ies_p = &message.msg.s1ap_E_RABSetupResponseIEs;
-  
-  initial_ies_p->eNB_UE_S1AP_ID = e_rab_setup_resp_p->eNB_ue_s1ap_id;
-  initial_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
-  
-  if ( e_rab_setup_resp_p->nb_of_e_rabs >= 1 )
-    initial_ies_p->presenceMask |= S1AP_E_RABSETUPRESPONSEIES_E_RABSETUPLISTBEARERSURES_PRESENT; 
-  
-  for (i = 0; i < e_rab_setup_resp_p->nb_of_e_rabs; i++) { 
-    S1ap_E_RABSetupItemBearerSURes_t *new_item;
-
-    new_item = calloc(1, sizeof(S1ap_E_RABSetupItemBearerSURes_t));
-
-    new_item->e_RAB_ID = e_rab_setup_resp_p->e_rabs[i].e_rab_id;
-    GTP_TEID_TO_ASN1(e_rab_setup_resp_p->e_rabs[i].gtp_teid, &new_item->gTP_TEID);
-        
-    /*
-    new_item->transportLayerAddress.buf = MALLOC(e_rab_setup_resp_p->e_rabs[i].eNB_addr.length);  
-    memcpy (new_item->transportLayerAddress.buf, 
-	    e_rab_setup_resp_p->e_rabs[i].eNB_addr.buffer,
-	    e_rab_setup_resp_p->e_rabs[i].eNB_addr.length);
-    
-    */
-    /*
-      new_item->transportLayerAddress.buf[0] = e_rab_setup_resp_p->e_rabs[i].eNB_addr.buffer[0];
-    new_item->transportLayerAddress.buf[1] = e_rab_setup_resp_p->e_rabs[i].eNB_addr.buffer[1];
-    new_item->transportLayerAddress.buf[2] = e_rab_setup_resp_p->e_rabs[i].eNB_addr.buffer[2];
-    new_item->transportLayerAddress.buf[3] = e_rab_setup_resp_p->e_rabs[i].eNB_addr.buffer[3];
-    */
-    new_item->transportLayerAddress.buf = e_rab_setup_resp_p->e_rabs[i].eNB_addr.buffer; 
-    new_item->transportLayerAddress.size = e_rab_setup_resp_p->e_rabs[i].eNB_addr.length;
-    new_item->transportLayerAddress.bits_unused = 0;
-    
-    S1AP_DEBUG("e_rab_setup_resp: e_rab ID %ld, teid %u, enb_addr %d.%d.%d.%d, SIZE %d\n", 
-	       new_item->e_RAB_ID,
-	       e_rab_setup_resp_p->e_rabs[i].gtp_teid,
-	       new_item->transportLayerAddress.buf[0],
-	       new_item->transportLayerAddress.buf[1],
-	       new_item->transportLayerAddress.buf[2],
-	       new_item->transportLayerAddress.buf[3],
-	       new_item->transportLayerAddress.size);
-    
-    S1ap_IE_t *ie = s1ap_new_ie(S1ap_ProtocolIE_ID_id_E_RABSetupItemBearerSURes,
-				S1ap_Criticality_ignore,
-				&asn_DEF_S1ap_E_RABSetupItemBearerSURes,
-				new_item);
-    /*
-    S1ap_IE_t *ie = s1ap_new_ie(S1ap_ProtocolIE_ID_id_E_RABSetupListBearerSURes,
-				S1ap_Criticality_ignore,
-				&asn_DEF_S1ap_E_RABSetupListBearerSURes,
-				new_item);
-    */
-    ASN_SEQUENCE_ADD(&initial_ies_p->e_RABSetupListBearerSURes.s1ap_E_RABSetupItemBearerSURes,
-                     ie);
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome;
+  pdu.choice.successfulOutcome.procedureCode = S1AP_ProcedureCode_id_E_RABModify;
+  pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject;
+  pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_E_RABSetupResponse;
+  out = &pdu.choice.successfulOutcome.value.choice.E_RABSetupResponse;
+  /* mandatory */
+  ie = (S1AP_E_RABSetupResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_E_RABSetupResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = e_rab_setup_resp_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (e_rab_setup_resp_p->nb_of_e_rabs > 0) {
+    ie = (S1AP_E_RABSetupResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_E_RABSetupListBearerSURes;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_E_RABSetupListBearerSURes;
+
+    for (i = 0; i < e_rab_setup_resp_p->nb_of_e_rabs; i++) {
+      S1AP_E_RABSetupItemBearerSUResIEs_t *item;
+      /* mandatory */
+      item = calloc(1, sizeof(S1AP_E_RABSetupItemBearerSUResIEs_t));
+      item->id = S1AP_ProtocolIE_ID_id_E_RABSetupItemBearerSURes;
+      item->criticality = S1AP_Criticality_ignore;
+      item->value.present = S1AP_E_RABSetupItemBearerSUResIEs__value_PR_E_RABSetupItemBearerSURes;
+      item->value.choice.E_RABSetupItemBearerSURes.e_RAB_ID = e_rab_setup_resp_p->e_rabs[i].e_rab_id;
+      GTP_TEID_TO_ASN1(e_rab_setup_resp_p->e_rabs[i].gtp_teid, &item->value.choice.E_RABSetupItemBearerSURes.gTP_TEID);
+      item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.buf = e_rab_setup_resp_p->e_rabs[i].eNB_addr.buffer;
+      item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.size = e_rab_setup_resp_p->e_rabs[i].eNB_addr.length;
+      item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.bits_unused = 0;
+      S1AP_DEBUG("e_rab_setup_resp: e_rab ID %ld, teid %u, enb_addr %d.%d.%d.%d, SIZE %ld\n",
+                 item->value.choice.E_RABSetupItemBearerSURes.e_RAB_ID,
+                 e_rab_setup_resp_p->e_rabs[i].gtp_teid,
+                 item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.buf[0],
+                 item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.buf[1],
+                 item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.buf[2],
+                 item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.buf[3],
+                 item->value.choice.E_RABSetupItemBearerSURes.transportLayerAddress.size);
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABSetupListBearerSURes.list, item);
+    }
+
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (e_rab_setup_resp_p->nb_of_e_rabs_failed > 0) {
+    ie = (S1AP_E_RABSetupResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_E_RABFailedToSetupListBearerSURes;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_E_RABList;
+
+    for (i = 0; i < e_rab_setup_resp_p->nb_of_e_rabs_failed; i++) {
+      S1AP_E_RABItemIEs_t *item;
+      item = calloc(1, sizeof(S1AP_E_RABItemIEs_t));
+      item->id = S1AP_ProtocolIE_ID_id_E_RABItem;
+      item->criticality = S1AP_Criticality_ignore;
+      item->value.present = S1AP_E_RABItemIEs__value_PR_E_RABItem;
+      item->value.choice.E_RABItem.e_RAB_ID = e_rab_setup_resp_p->e_rabs_failed[i].e_rab_id;
+      item->value.choice.E_RABItem.cause.present = e_rab_setup_resp_p->e_rabs_failed[i].cause;
+
+      switch(item->value.choice.E_RABItem.cause.present)
+      {
+        case S1AP_Cause_PR_radioNetwork:
+          item->value.choice.E_RABItem.cause.choice.radioNetwork = e_rab_setup_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_transport:
+          item->value.choice.E_RABItem.cause.choice.transport = e_rab_setup_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_nas:
+          item->value.choice.E_RABItem.cause.choice.nas = e_rab_setup_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_protocol:
+          item->value.choice.E_RABItem.cause.choice.protocol = e_rab_setup_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_misc:
+          item->value.choice.E_RABItem.cause.choice.misc = e_rab_setup_resp_p->e_rabs_failed[i].cause_value;
+          break;
+
+        case S1AP_Cause_PR_NOTHING:
+        default:
+          break;
+      }
+
+      S1AP_DEBUG("e_rab_modify_resp: failed e_rab ID %ld\n", item->value.choice.E_RABItem.e_RAB_ID);
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABList.list, item);
+    }
+
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (0) {
+    ie = (S1AP_E_RABSetupResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CriticalityDiagnostics;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_CriticalityDiagnostics;
+    // ie->value.choice.CriticalityDiagnostics = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
- 
-  /* S1ap_E_RABSetupListBearerSURes_t  e_RABSetupListBearerSURes;
-  memset(&e_RABSetupListBearerSURes, 0, sizeof(S1ap_E_RABSetupListBearerSURes_t));
+
+  /* S1AP_E_RABSetupListBearerSURes_t  e_RABSetupListBearerSURes;
+  memset(&e_RABSetupListBearerSURes, 0, sizeof(S1AP_E_RABSetupListBearerSURes_t));
   if (s1ap_encode_s1ap_e_rabsetuplistbearersures(&e_RABSetupListBearerSURes, &initial_ies_p->e_RABSetupListBearerSURes.s1ap_E_RABSetupItemBearerSURes) < 0 )
     return -1;
- ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1ap_E_RABSetupListBearerSURes, &e_RABSetupListBearerSURes);
+  ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_E_RABSetupListBearerSURes, &e_RABSetupListBearerSURes);
   */
   fprintf(stderr, "start encode\n");
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     S1AP_ERROR("Failed to encode uplink transport\n");
     /* Encode procedure has failed... */
     return -1;
   }
 
- 
-  
   MSC_LOG_TX_MESSAGE(
     MSC_S1AP_ENB,
     MSC_S1AP_MME,
@@ -829,40 +1189,33 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance,
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     initial_ies_p->eNB_UE_S1AP_ID,
     initial_ies_p->mme_ue_s1ap_id);
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
-  return ret;
+  return 0;
 }
 
 //------------------------------------------------------------------------------
 int s1ap_eNB_e_rab_modify_resp(instance_t instance,
-            s1ap_e_rab_modify_resp_t *e_rab_modify_resp_p)
+                               s1ap_e_rab_modify_resp_t *e_rab_modify_resp_p)
 //------------------------------------------------------------------------------
 {
-  s1ap_eNB_instance_t          *s1ap_eNB_instance_p = NULL;
-  struct s1ap_eNB_ue_context_s *ue_context_p        = NULL;
-
-  S1ap_E_RABModifyResponseIEs_t  *initial_ies_p  = NULL;
-
-  s1ap_message  message;
-
+  s1ap_eNB_instance_t           *s1ap_eNB_instance_p = NULL;
+  struct s1ap_eNB_ue_context_s  *ue_context_p        = NULL;
+  S1AP_S1AP_PDU_t                pdu;
+  S1AP_E_RABModifyResponse_t    *out;
+  S1AP_E_RABModifyResponseIEs_t *ie;
   uint8_t  *buffer  = NULL;
   uint32_t length;
-  int      ret = -1;
   int      i;
-
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
-
   DevAssert(e_rab_modify_resp_p != NULL);
   DevAssert(s1ap_eNB_instance_p != NULL);
 
   if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
-                e_rab_modify_resp_p->eNB_ue_s1ap_id)) == NULL) {
+                      e_rab_modify_resp_p->eNB_ue_s1ap_id)) == NULL) {
     /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
     S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: 0x%06x\n",
               e_rab_modify_resp_p->eNB_ue_s1ap_id);
@@ -881,87 +1234,111 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance,
   }
 
   /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_successfulOutcome;
-  message.procedureCode = S1ap_ProcedureCode_id_E_RABModify;
-  message.criticality   = S1ap_Criticality_reject;
-
-  initial_ies_p = &message.msg.s1ap_E_RABModifyResponseIEs;
-
-  initial_ies_p->eNB_UE_S1AP_ID = e_rab_modify_resp_p->eNB_ue_s1ap_id;
-  initial_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome;
+  pdu.choice.successfulOutcome.procedureCode = S1AP_ProcedureCode_id_E_RABModify;
+  pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject;
+  pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_E_RABModifyResponse;
+  out = &pdu.choice.successfulOutcome.value.choice.E_RABModifyResponse;
+  /* mandatory */
+  ie = (S1AP_E_RABModifyResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABModifyResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_E_RABModifyResponseIEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_E_RABModifyResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABModifyResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_E_RABModifyResponseIEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = e_rab_modify_resp_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (e_rab_modify_resp_p->nb_of_e_rabs > 0) {
+    ie = (S1AP_E_RABModifyResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABModifyResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_E_RABModifyListBearerModRes;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABModifyResponseIEs__value_PR_E_RABModifyListBearerModRes;
+
+    for (i = 0; i < e_rab_modify_resp_p->nb_of_e_rabs; i++) {
+      S1AP_E_RABModifyItemBearerModResIEs_t *item;
+      item = calloc(1, sizeof(S1AP_E_RABModifyItemBearerModResIEs_t));
+      item->id = S1AP_ProtocolIE_ID_id_E_RABModifyItemBearerModRes;
+      item->criticality = S1AP_Criticality_ignore;
+      item->value.present = S1AP_E_RABModifyItemBearerModResIEs__value_PR_E_RABModifyItemBearerModRes;
+      item->value.choice.E_RABModifyItemBearerModRes.e_RAB_ID = e_rab_modify_resp_p->e_rabs[i].e_rab_id;
+      S1AP_DEBUG("e_rab_modify_resp: modified e_rab ID %ld\n", item->value.choice.E_RABModifyItemBearerModRes.e_RAB_ID);
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABModifyListBearerModRes.list, item);
+    }
 
-  if ( e_rab_modify_resp_p->nb_of_e_rabs >= 1 )
-    initial_ies_p->presenceMask |= S1AP_E_RABMODIFYRESPONSEIES_E_RABMODIFYLISTBEARERMODRES_PRESENT;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-  for (i = 0; i < e_rab_modify_resp_p->nb_of_e_rabs; i++) {
-    S1ap_E_RABModifyItemBearerModRes_t *modify_item;
+  /* optional */
+  if (e_rab_modify_resp_p->nb_of_e_rabs_failed > 0) {
+    ie = (S1AP_E_RABModifyResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABModifyResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_E_RABFailedToModifyList;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABModifyResponseIEs__value_PR_E_RABList;
+
+    for (i = 0; i < e_rab_modify_resp_p->nb_of_e_rabs_failed; i++) {
+      S1AP_E_RABItemIEs_t *item;
+      item = calloc(1, sizeof(S1AP_E_RABItemIEs_t));
+      item->id = S1AP_ProtocolIE_ID_id_E_RABItem;
+      item->criticality = S1AP_Criticality_ignore;
+      item->value.present = S1AP_E_RABItemIEs__value_PR_E_RABItem;
+      item->value.choice.E_RABItem.e_RAB_ID = e_rab_modify_resp_p->e_rabs_failed[i].e_rab_id;
+      item->value.choice.E_RABItem.cause.present = e_rab_modify_resp_p->e_rabs_failed[i].cause;
+
+      switch(item->value.choice.E_RABItem.cause.present)
+      {
+        case S1AP_Cause_PR_radioNetwork:
+          item->value.choice.E_RABItem.cause.choice.radioNetwork = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    modify_item = calloc(1, sizeof(S1ap_E_RABModifyItemBearerModRes_t));
+        case S1AP_Cause_PR_transport:
+          item->value.choice.E_RABItem.cause.choice.transport = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    modify_item->e_RAB_ID = e_rab_modify_resp_p->e_rabs[i].e_rab_id;
+        case S1AP_Cause_PR_nas:
+          item->value.choice.E_RABItem.cause.choice.nas = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    S1AP_DEBUG("e_rab_modify_resp: modified e_rab ID %ld\n",
-        modify_item->e_RAB_ID);
+        case S1AP_Cause_PR_protocol:
+          item->value.choice.E_RABItem.cause.choice.protocol = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    S1ap_IE_t *ie = s1ap_new_ie(S1ap_ProtocolIE_ID_id_E_RABModifyItemBearerModRes,
-        S1ap_Criticality_ignore,
-        &asn_DEF_S1ap_E_RABModifyItemBearerModRes,
-        modify_item);
+        case S1AP_Cause_PR_misc:
+          item->value.choice.E_RABItem.cause.choice.misc = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    ASN_SEQUENCE_ADD(&initial_ies_p->e_RABModifyListBearerModRes.s1ap_E_RABModifyItemBearerModRes,
-                     ie);
-  }
+        case S1AP_Cause_PR_NOTHING:
+        default:
+          break;
+      }
 
-  if ( e_rab_modify_resp_p->nb_of_e_rabs_failed >= 1 )
-    initial_ies_p->presenceMask |= S1AP_E_RABMODIFYRESPONSEIES_E_RABFAILEDTOMODIFYLIST_PRESENT;
-
-  for (i = 0; i < e_rab_modify_resp_p->nb_of_e_rabs_failed; i++) {
-    S1ap_E_RABItem_t *failed_item;
-
-    failed_item = calloc(1, sizeof(S1ap_E_RABItem_t));
-
-    failed_item->e_RAB_ID = e_rab_modify_resp_p->e_rabs_failed[i].e_rab_id;
-    switch(e_rab_modify_resp_p->e_rabs_failed[i].cause)
-    {
-    case S1AP_CAUSE_RADIO_NETWORK:
-        failed_item->cause.present = S1ap_Cause_PR_radioNetwork;
-        failed_item->cause.choice.radioNetwork = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
-        break;
-    case S1AP_CAUSE_TRANSPORT:
-        failed_item->cause.present = S1ap_Cause_PR_transport;
-        failed_item->cause.choice.transport = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
-        break;
-    case S1AP_CAUSE_NAS:
-        failed_item->cause.present = S1ap_Cause_PR_nas;
-        failed_item->cause.choice.nas = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
-        break;
-    case S1AP_CAUSE_PROTOCOL:
-        failed_item->cause.present = S1ap_Cause_PR_protocol;
-        failed_item->cause.choice.protocol = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
-        break;
-    case S1AP_CAUSE_MISC:
-        failed_item->cause.present = S1ap_Cause_PR_misc;
-        failed_item->cause.choice.misc = e_rab_modify_resp_p->e_rabs_failed[i].cause_value;
-        break;
-    default:
-        break;
+      S1AP_DEBUG("e_rab_modify_resp: failed e_rab ID %ld\n", item->value.choice.E_RABItem.e_RAB_ID);
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABList.list, item);
     }
-    S1AP_DEBUG("e_rab_modify_resp: failed e_rab ID %ld\n",
-        failed_item->e_RAB_ID);
 
-    S1ap_IE_t *ie = s1ap_new_ie(S1ap_ProtocolIE_ID_id_E_RABItem,
-        S1ap_Criticality_ignore,
-        &asn_DEF_S1ap_E_RABItem,
-        failed_item);
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
-    ASN_SEQUENCE_ADD(&initial_ies_p->e_RABFailedToModifyList.s1ap_E_RABItem,
-                     ie);
+  /* optional */
+  if (0) {
+    ie = (S1AP_E_RABModifyResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABModifyResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CriticalityDiagnostics;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABModifyResponseIEs__value_PR_CriticalityDiagnostics;
+    // ie->value.choice.CriticalityDiagnostics = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
   fprintf(stderr, "start encode\n");
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     S1AP_ERROR("Failed to encode uplink transport\n");
     /* Encode procedure has failed... */
     return -1;
@@ -976,121 +1353,153 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance,
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     initial_ies_p->eNB_UE_S1AP_ID,
     initial_ies_p->mme_ue_s1ap_id);
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
-  return ret;
+  return 0;
 }
 //------------------------------------------------------------------------------
 int s1ap_eNB_e_rab_release_resp(instance_t instance,
-			      s1ap_e_rab_release_resp_t *e_rab_release_resp_p)
+                                s1ap_e_rab_release_resp_t *e_rab_release_resp_p)
 //------------------------------------------------------------------------------
 {
   s1ap_eNB_instance_t          *s1ap_eNB_instance_p = NULL;
   struct s1ap_eNB_ue_context_s *ue_context_p        = NULL;
-
-  S1ap_E_RABReleaseResponseIEs_t  *release_response_ies_p  = NULL;
-
-  s1ap_message  message;
-
+  S1AP_S1AP_PDU_t                 pdu;
+  S1AP_E_RABReleaseResponse_t    *out;
+  S1AP_E_RABReleaseResponseIEs_t *ie;
   uint8_t  *buffer  = NULL;
   uint32_t length;
-  int      ret = -1;
   int      i;
   /* Retrieve the S1AP eNB instance associated with Mod_id */
   s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
   DevAssert(e_rab_release_resp_p != NULL);
   DevAssert(s1ap_eNB_instance_p != NULL);
 
-  /* Prepare the S1AP message to encode */
-  memset(&message, 0, sizeof(s1ap_message));
-
-  message.direction     = S1AP_PDU_PR_successfulOutcome;
-  message.procedureCode = S1ap_ProcedureCode_id_E_RABRelease;
-  message.criticality = S1ap_Criticality_ignore;
-
   if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
-          e_rab_release_resp_p->eNB_ue_s1ap_id)) == NULL) {
+                      e_rab_release_resp_p->eNB_ue_s1ap_id)) == NULL) {
     /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
     S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n",
-            e_rab_release_resp_p->eNB_ue_s1ap_id);
+              e_rab_release_resp_p->eNB_ue_s1ap_id);
     return -1;
   }
 
-  release_response_ies_p = &message.msg.s1ap_E_RABReleaseResponseIEs;
-  release_response_ies_p->eNB_UE_S1AP_ID = e_rab_release_resp_p->eNB_ue_s1ap_id;
-  release_response_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
+  /* Prepare the S1AP message to encode */
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome;
+  pdu.choice.successfulOutcome.procedureCode = S1AP_ProcedureCode_id_E_RABRelease;
+  pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject;
+  pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_E_RABReleaseResponse;
+  out = &pdu.choice.successfulOutcome.value.choice.E_RABReleaseResponse;
+  /* mandatory */
+  ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_E_RABReleaseResponseIEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  /* mandatory */
+  ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_E_RABReleaseResponseIEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = e_rab_release_resp_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  /* optional */
+  if (e_rab_release_resp_p->nb_of_e_rabs_released > 0) {
+    ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_E_RABReleaseListBearerRelComp;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABReleaseResponseIEs__value_PR_E_RABReleaseListBearerRelComp;
+
+    for (i = 0; i < e_rab_release_resp_p->nb_of_e_rabs_released; i++) {
+      S1AP_E_RABReleaseItemBearerRelCompIEs_t *item;
+      item = calloc(1, sizeof(S1AP_E_RABReleaseItemBearerRelCompIEs_t));
+      item->id = S1AP_ProtocolIE_ID_id_E_RABReleaseItemBearerRelComp;
+      item->criticality = S1AP_Criticality_ignore;
+      item->value.present = S1AP_E_RABReleaseItemBearerRelCompIEs__value_PR_E_RABReleaseItemBearerRelComp;
+      item->value.choice.E_RABReleaseItemBearerRelComp.e_RAB_ID = e_rab_release_resp_p->e_rab_release[i].e_rab_id;
+      S1AP_DEBUG("e_rab_release_resp: e_rab ID %ld\n", item->value.choice.E_RABReleaseItemBearerRelComp.e_RAB_ID);
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABReleaseListBearerRelComp.list, item);
+    }
+
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
+
+  /* optional */
+  if (e_rab_release_resp_p->nb_of_e_rabs_failed > 0) {
+    ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_E_RABFailedToReleaseList;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABReleaseResponseIEs__value_PR_E_RABList;
+
+    for (i = 0; i < e_rab_release_resp_p->nb_of_e_rabs_failed; i++) {
+      S1AP_E_RABItemIEs_t *item;
+      item = calloc(1, sizeof(S1AP_E_RABItemIEs_t));
+      item->id = S1AP_ProtocolIE_ID_id_E_RABItem;
+      item->criticality = S1AP_Criticality_ignore;
+      item->value.present = S1AP_E_RABItemIEs__value_PR_E_RABItem;
+      item->value.choice.E_RABItem.e_RAB_ID = e_rab_release_resp_p->e_rabs_failed[i].e_rab_id;
+      item->value.choice.E_RABItem.cause.present = e_rab_release_resp_p->e_rabs_failed[i].cause;
+
+      switch(item->value.choice.E_RABItem.cause.present)
+      {
+        case S1AP_Cause_PR_radioNetwork:
+          item->value.choice.E_RABItem.cause.choice.radioNetwork = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-  if ( e_rab_release_resp_p->nb_of_e_rabs_released > 0 )
-      release_response_ies_p->presenceMask |= S1AP_E_RABRELEASERESPONSEIES_E_RABRELEASELISTBEARERRELCOMP_PRESENT;
+        case S1AP_Cause_PR_transport:
+          item->value.choice.E_RABItem.cause.choice.transport = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-  //release
-  for (i = 0; i < e_rab_release_resp_p->nb_of_e_rabs_released; i++) {
+        case S1AP_Cause_PR_nas:
+          item->value.choice.E_RABItem.cause.choice.nas = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    S1ap_E_RABReleaseItemBearerRelComp_t *new_item;
+        case S1AP_Cause_PR_protocol:
+          item->value.choice.E_RABItem.cause.choice.protocol = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    new_item = calloc(1, sizeof(S1ap_E_RABReleaseItemBearerRelComp_t));
+        case S1AP_Cause_PR_misc:
+          item->value.choice.E_RABItem.cause.choice.misc = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
+          break;
 
-    new_item->e_RAB_ID = e_rab_release_resp_p->e_rab_release[i].e_rab_id;
+        case S1AP_Cause_PR_NOTHING:
+        default:
+          break;
+      }
 
-    S1AP_DEBUG("e_rab_release_resp: e_rab ID %ld\n",new_item->e_RAB_ID);
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABList.list, item);
+    }
 
-    ASN_SEQUENCE_ADD(&release_response_ies_p->e_RABReleaseListBearerRelComp.s1ap_E_RABReleaseItemBearerRelComp,
-                     new_item);
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  }
 
+  /* optional */
+  if (0) {
+    ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_CriticalityDiagnostics;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABReleaseResponseIEs__value_PR_CriticalityDiagnostics;
+    // ie->value.choice.CriticalityDiagnostics = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
-  if ( e_rab_release_resp_p->nb_of_e_rabs_failed > 0 )
-      release_response_ies_p->presenceMask |= S1AP_E_RABRELEASERESPONSEIES_E_RABFAILEDTORELEASELIST_PRESENT;
-
-  //release failed
-  for (i = 0; i < e_rab_release_resp_p->nb_of_e_rabs_failed; i++) {
-      S1ap_E_RABItem_t     *new_rabitem;
-      new_rabitem = calloc(1, sizeof(S1ap_E_RABItem_t));
-      //e_rab_id
-      new_rabitem->e_RAB_ID = e_rab_release_resp_p->e_rabs_failed[i].e_rab_id;
-      //cause
-      switch(e_rab_release_resp_p->e_rabs_failed[i].cause)
-      {
-        case S1AP_CAUSE_NOTHING:
-          new_rabitem->cause.present = S1ap_Cause_PR_NOTHING;
-        break;
-
-        case S1AP_CAUSE_RADIO_NETWORK:
-          new_rabitem->cause.present = S1ap_Cause_PR_radioNetwork;
-          new_rabitem->cause.choice.radioNetwork = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
-        break;
-
-        case S1AP_CAUSE_TRANSPORT:
-          new_rabitem->cause.present = S1ap_Cause_PR_transport;
-          new_rabitem->cause.choice.transport = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
-        break;
-
-        case S1AP_CAUSE_NAS:
-          new_rabitem->cause.present = S1ap_Cause_PR_nas;
-          new_rabitem->cause.choice.nas = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
-        break;
-
-        case S1AP_CAUSE_PROTOCOL:
-          new_rabitem->cause.present = S1ap_Cause_PR_protocol;
-          new_rabitem->cause.choice.protocol = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
-        break;
-
-        case S1AP_CAUSE_MISC:
-        default:
-          new_rabitem->cause.present = S1ap_Cause_PR_misc;
-          new_rabitem->cause.choice.misc = e_rab_release_resp_p->e_rabs_failed[i].cause_value;
-        break;
-      }
-      S1AP_DEBUG("e_rab_release_resp: failed e_rab ID %ld\n",new_rabitem->e_RAB_ID);
-      ASN_SEQUENCE_ADD(&release_response_ies_p->e_RABFailedToReleaseList.s1ap_E_RABItem, new_rabitem);
+  /* optional */
+  if(0) {
+    ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t));
+    ie->id = S1AP_ProtocolIE_ID_id_UserLocationInformation;
+    ie->criticality = S1AP_Criticality_ignore;
+    ie->value.present = S1AP_E_RABReleaseResponseIEs__value_PR_UserLocationInformation;
+    // ie->value.choice.UserLocationInformation = ;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
   }
 
   fprintf(stderr, "start encode\n");
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     S1AP_ERROR("Failed to encode release response\n");
     /* Encode procedure has failed... */
     return -1;
@@ -1105,14 +1514,11 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance,
     0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
     e_rab_release_resp_p->eNB_ue_s1ap_id,
     ue_context_p->mme_ue_s1ap_id);
-
   /* UE associated signalling -> use the allocated stream */
   s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                    ue_context_p->mme_ref->assoc_id, buffer,
                                    length, ue_context_p->tx_stream);
-
   S1AP_INFO("e_rab_release_response sended eNB_UE_S1AP_ID %d  mme_ue_s1ap_id %d nb_of_e_rabs_released %d nb_of_e_rabs_failed %d\n",
-          e_rab_release_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,e_rab_release_resp_p->nb_of_e_rabs_released,e_rab_release_resp_p->nb_of_e_rabs_failed);
-
-  return ret;
+            e_rab_release_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,e_rab_release_resp_p->nb_of_e_rabs_released,e_rab_release_resp_p->nb_of_e_rabs_failed);
+  return 0;
 }
diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.h b/openair3/S1AP/s1ap_eNB_nas_procedures.h
index bb2a0488bfd898fb5ec87a62e0d205767c19d467..a7f144c0ca3653ab0a2665f8d1be619a1fe9d1a5 100644
--- a/openair3/S1AP/s1ap_eNB_nas_procedures.h
+++ b/openair3/S1AP/s1ap_eNB_nas_procedures.h
@@ -23,14 +23,14 @@
 #define S1AP_ENB_NAS_PROCEDURES_H_
 
 int s1ap_eNB_handle_nas_downlink(
-  const uint32_t               assoc_id,
-  const uint32_t               stream,
-  struct s1ap_message_s* message_p);
+  uint32_t         assoc_id,
+  uint32_t         stream,
+  S1AP_S1AP_PDU_t *pdu);
 
 int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_p);
 
-void s1ap_eNB_nas_non_delivery_ind(instance_t instance,
-                                   s1ap_nas_non_delivery_ind_t *s1ap_nas_non_delivery_ind);
+int s1ap_eNB_nas_non_delivery_ind(instance_t instance,
+                                  s1ap_nas_non_delivery_ind_t *s1ap_nas_non_delivery_ind);
 
 int s1ap_eNB_handle_nas_first_req(
   instance_t instance, s1ap_nas_first_req_t *s1ap_nas_first_req_p);
@@ -45,8 +45,8 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance,
                               s1ap_e_rab_setup_resp_t *e_rab_setup_resp_p);
 
 int s1ap_eNB_e_rab_modify_resp(instance_t instance,
-               s1ap_e_rab_modify_resp_t *e_rab_modify_resp_p);
+                               s1ap_e_rab_modify_resp_t *e_rab_modify_resp_p);
 
 int s1ap_eNB_e_rab_release_resp(instance_t instance,
-                  s1ap_e_rab_release_resp_t *e_rab_release_resp_p);
+                                s1ap_e_rab_release_resp_t *e_rab_release_resp_p);
 #endif /* S1AP_ENB_NAS_PROCEDURES_H_ */
diff --git a/openair3/S1AP/s1ap_eNB_overload.c b/openair3/S1AP/s1ap_eNB_overload.c
index 82167bfeeb5112f9ac0712a24679f89f56358124..e4066b7108533bbe74dd4b23498ce0eb757237ba 100644
--- a/openair3/S1AP/s1ap_eNB_overload.c
+++ b/openair3/S1AP/s1ap_eNB_overload.c
@@ -33,7 +33,6 @@
 #include "intertask_interface.h"
 
 #include "s1ap_common.h"
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_defs.h"
 
 #include "s1ap_eNB.h"
@@ -44,21 +43,20 @@
 
 #include "assertions.h"
 
-int s1ap_eNB_handle_overload_start(uint32_t               assoc_id,
-                                   uint32_t               stream,
-                                   struct s1ap_message_s *message_p)
+int s1ap_eNB_handle_overload_start(uint32_t         assoc_id,
+                                   uint32_t         stream,
+                                   S1AP_S1AP_PDU_t *pdu)
 {
-  S1ap_OverloadStartIEs_t *overload_start_p;
   s1ap_eNB_mme_data_t     *mme_desc_p;
-
-  DevAssert(message_p != NULL);
-
-  overload_start_p = &message_p->msg.s1ap_OverloadStartIEs;
-
-  DevCheck(overload_start_p->overloadResponse.present ==
-           S1ap_OverloadResponse_PR_overloadAction,
-           S1ap_OverloadResponse_PR_overloadAction, 0, 0);
-
+  S1AP_OverloadStart_t    *container;
+  S1AP_OverloadStartIEs_t *ie;
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.OverloadStart;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_OverloadStartIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_OverloadResponse, TRUE);
+  DevCheck(ie->value.choice.OverloadResponse.present ==
+           S1AP_OverloadResponse_PR_overloadAction,
+           S1AP_OverloadResponse_PR_overloadAction, 0, 0);
   /* Non UE-associated signalling -> stream 0 */
   DevCheck(stream == 0, stream, 0, 0);
 
@@ -72,24 +70,20 @@ int s1ap_eNB_handle_overload_start(uint32_t               assoc_id,
    */
   mme_desc_p->state = S1AP_ENB_OVERLOAD;
   mme_desc_p->overload_state =
-    overload_start_p->overloadResponse.choice.overloadAction;
-
+    ie->value.choice.OverloadResponse.choice.overloadAction;
   return 0;
 }
 
-int s1ap_eNB_handle_overload_stop(uint32_t               assoc_id,
-                                  uint32_t               stream,
-                                  struct s1ap_message_s *message_p)
+int s1ap_eNB_handle_overload_stop(uint32_t         assoc_id,
+                                  uint32_t         stream,
+                                  S1AP_S1AP_PDU_t *pdu)
 {
   /* We received Overload stop message, meaning that the MME is no more
    * overloaded. This is an empty message, with only message header and no
    * Information Element.
    */
-
-  DevAssert(message_p != NULL);
-
+  DevAssert(pdu != NULL);
   s1ap_eNB_mme_data_t *mme_desc_p;
-
   /* Non UE-associated signalling -> stream 0 */
   DevCheck(stream == 0, stream, 0, 0);
 
diff --git a/openair3/S1AP/s1ap_eNB_overload.h b/openair3/S1AP/s1ap_eNB_overload.h
index 1b0ee443de3a23b07c8f6db71310501bc3c0f52d..8133345deefd40340a1abc744241aa80bd1dcfc5 100644
--- a/openair3/S1AP/s1ap_eNB_overload.h
+++ b/openair3/S1AP/s1ap_eNB_overload.h
@@ -28,9 +28,9 @@
 // int s1ap_eNB_handle_overload_start(eNB_mme_desc_t *eNB_desc_p,
 //                                    sctp_queue_item_t *packet_p,
 //                                    struct s1ap_message_s *message_p);
-int s1ap_eNB_handle_overload_start(uint32_t               assoc_id,
-                                   uint32_t               stream,
-                                   struct s1ap_message_s *message_p);
+int s1ap_eNB_handle_overload_start(uint32_t         assoc_id,
+                                   uint32_t         stream,
+                                   S1AP_S1AP_PDU_t *pdu);
 
 /**
  * \brief Handle an overload stop message
@@ -38,8 +38,8 @@ int s1ap_eNB_handle_overload_start(uint32_t               assoc_id,
 // int s1ap_eNB_handle_overload_stop(eNB_mme_desc_t *eNB_desc_p,
 //                                   sctp_queue_item_t *packet_p,
 //                                   struct s1ap_message_s *message_p);
-int s1ap_eNB_handle_overload_stop(uint32_t               assoc_id,
-                                  uint32_t               stream,
-                                  struct s1ap_message_s *message_p);
+int s1ap_eNB_handle_overload_stop(uint32_t         assoc_id,
+                                  uint32_t         stream,
+                                  S1AP_S1AP_PDU_t *pdu);
 
 #endif /* S1AP_ENB_OVERLOAD_H_ */
diff --git a/openair3/S1AP/s1ap_eNB_trace.c b/openair3/S1AP/s1ap_eNB_trace.c
index e640c9292a856e1cac8d99a38fc2a33cb7ecc8fb..a04bd4ce936b46346074e831c6b0e2657d0c9fe8 100644
--- a/openair3/S1AP/s1ap_eNB_trace.c
+++ b/openair3/S1AP/s1ap_eNB_trace.c
@@ -28,7 +28,6 @@
 #include "s1ap_eNB_default_values.h"
 
 #include "s1ap_common.h"
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_defs.h"
 
 #include "s1ap_eNB.h"
@@ -40,29 +39,50 @@
 
 static
 void s1ap_eNB_generate_trace_failure(struct s1ap_eNB_ue_context_s *ue_desc_p,
-                                     S1ap_E_UTRAN_Trace_ID_t      *trace_id,
-                                     S1ap_Cause_t                 *cause_p)
+                                     S1AP_E_UTRAN_Trace_ID_t      *trace_id,
+                                     S1AP_Cause_t                 *cause_p)
 {
-  s1ap_message message;
-  S1ap_TraceFailureIndicationIEs_t *trace_failure_p;
-  uint8_t  *buffer;
-  uint32_t  length;
-
+  S1AP_S1AP_PDU_t                     pdu;
+  S1AP_TraceFailureIndication_t      *out;
+  S1AP_TraceFailureIndicationIEs_t   *ie;
+  uint8_t                            *buffer = NULL;
+  uint32_t                            length;
   DevAssert(ue_desc_p != NULL);
   DevAssert(trace_id  != NULL);
   DevAssert(cause_p   != NULL);
-
-  memset(&message, 0, sizeof(s1ap_message));
-
-  trace_failure_p = &message.msg.s1ap_TraceFailureIndicationIEs;
-
-  trace_failure_p->mme_ue_s1ap_id = ue_desc_p->mme_ue_s1ap_id;
-  trace_failure_p->eNB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id;
-
-  memcpy(&trace_failure_p->e_UTRAN_Trace_ID, trace_id, sizeof(S1ap_E_UTRAN_Trace_ID_t));
-  memcpy(&trace_failure_p->cause, cause_p, sizeof(S1ap_Cause_t));
-
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+  /* Prepare the S1AP message to encode */
+  memset(&pdu, 0, sizeof(pdu));
+  pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
+  pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_TraceFailureIndication;
+  pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore;
+  pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_TraceFailureIndication;
+  out = &pdu.choice.initiatingMessage.value.choice.TraceFailureIndication;
+  ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_MME_UE_S1AP_ID;
+  ie->value.choice.MME_UE_S1AP_ID = ue_desc_p->mme_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
+  ie->criticality = S1AP_Criticality_reject;
+  ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_ENB_UE_S1AP_ID;
+  ie->value.choice.ENB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id;
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_E_UTRAN_Trace_ID;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_E_UTRAN_Trace_ID;
+  memcpy(&ie->value.choice.E_UTRAN_Trace_ID, trace_id, sizeof(S1AP_E_UTRAN_Trace_ID_t));
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+  ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
+  ie->id = S1AP_ProtocolIE_ID_id_Cause;
+  ie->criticality = S1AP_Criticality_ignore;
+  ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_Cause;
+  memcpy(&ie->value.choice.Cause, cause_p, sizeof(S1AP_Cause_t));
+  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+  if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
     return;
   }
 
@@ -71,48 +91,44 @@ void s1ap_eNB_generate_trace_failure(struct s1ap_eNB_ue_context_s *ue_desc_p,
                                    length, ue_desc_p->tx_stream);
 }
 
-int s1ap_eNB_handle_trace_start(uint32_t               assoc_id,
-                                uint32_t               stream,
-                                struct s1ap_message_s *message_p)
+int s1ap_eNB_handle_trace_start(uint32_t         assoc_id,
+                                uint32_t         stream,
+                                S1AP_S1AP_PDU_t *pdu)
 {
-  S1ap_TraceStartIEs_t         *trace_start_p;
+  S1AP_TraceStart_t            *container;
+  S1AP_TraceStartIEs_t         *ie;
   struct s1ap_eNB_ue_context_s *ue_desc_p;
   struct s1ap_eNB_mme_data_s   *mme_ref_p;
-
-  DevAssert(message_p != NULL);
-
-  trace_start_p = &message_p->msg.s1ap_TraceStartIEs;
-
+  DevAssert(pdu != NULL);
+  container = &pdu->choice.initiatingMessage.value.choice.TraceStart;
+  S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_TraceStartIEs_t, ie, container,
+                             S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, TRUE);
   mme_ref_p = s1ap_eNB_get_MME(NULL, assoc_id, 0);
   DevAssert(mme_ref_p != NULL);
 
   if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance,
-                   trace_start_p->eNB_UE_S1AP_ID)) == NULL) {
+                   ie->value.choice.ENB_UE_S1AP_ID)) == NULL) {
     /* Could not find context associated with this eNB_ue_s1ap_id -> generate
      * trace failure indication.
      */
-    S1ap_E_UTRAN_Trace_ID_t trace_id;
-    S1ap_Cause_t cause;
-
-    memset(&trace_id, 0, sizeof(S1ap_E_UTRAN_Trace_ID_t));
-    memset(&cause, 0, sizeof(S1ap_Cause_t));
-
-    cause.present = S1ap_Cause_PR_radioNetwork;
-    cause.choice.radioNetwork = S1ap_CauseRadioNetwork_unknown_pair_ue_s1ap_id;
-
+    S1AP_E_UTRAN_Trace_ID_t trace_id;
+    S1AP_Cause_t cause;
+    memset(&trace_id, 0, sizeof(S1AP_E_UTRAN_Trace_ID_t));
+    memset(&cause, 0, sizeof(S1AP_Cause_t));
+    cause.present = S1AP_Cause_PR_radioNetwork;
+    cause.choice.radioNetwork = S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id;
     s1ap_eNB_generate_trace_failure(ue_desc_p, &trace_id, &cause);
   }
 
   return 0;
 }
 
-int s1ap_eNB_handle_deactivate_trace(uint32_t               assoc_id,
-                                     uint32_t               stream,
-                                     struct s1ap_message_s *message_p)
+int s1ap_eNB_handle_deactivate_trace(uint32_t         assoc_id,
+                                     uint32_t         stream,
+                                     S1AP_S1AP_PDU_t *message_p)
 {
-  //     S1ap_DeactivateTraceIEs_t *deactivate_trace_p;
+  //     S1AP_DeactivateTraceIEs_t *deactivate_trace_p;
   //
   //     deactivate_trace_p = &message_p->msg.deactivateTraceIEs;
-
   return 0;
 }
diff --git a/openair3/S1AP/s1ap_eNB_trace.h b/openair3/S1AP/s1ap_eNB_trace.h
index 922197afb42d9cd120494365d4de17b4275f5dfb..75f7a59dc4abdb18ae2180c252257fd2027a3057 100644
--- a/openair3/S1AP/s1ap_eNB_trace.h
+++ b/openair3/S1AP/s1ap_eNB_trace.h
@@ -32,15 +32,15 @@
 // int s1ap_eNB_handle_trace_start(eNB_mme_desc_t *eNB_desc_p,
 //                                 sctp_queue_item_t *packet_p,
 //                                 struct s1ap_message_s *message_p);
-int s1ap_eNB_handle_trace_start(uint32_t               assoc_id,
-                                uint32_t               stream,
-                                struct s1ap_message_s *message_p);
+int s1ap_eNB_handle_trace_start(uint32_t         assoc_id,
+                                uint32_t         stream,
+                                S1AP_S1AP_PDU_t *pdu);
 
 // int s1ap_eNB_handle_deactivate_trace(eNB_mme_desc_t *eNB_desc_p,
 //                                      sctp_queue_item_t *packet_p,
 //                                      struct s1ap_message_s *message_p);
-int s1ap_eNB_handle_deactivate_trace(uint32_t               assoc_id,
-                                     uint32_t               stream,
-                                     struct s1ap_message_s *message_p);
+int s1ap_eNB_handle_deactivate_trace(uint32_t         assoc_id,
+                                     uint32_t         stream,
+                                     S1AP_S1AP_PDU_t *pdu);
 
 #endif /* S1AP_ENB_TRACE_H_ */
diff --git a/openair3/TEST/EPC_TEST/play_scenario.h b/openair3/TEST/EPC_TEST/play_scenario.h
index f9601fe9044aca63d522b3e4085220bec52b8d18..a18bad230bfd8baea0078e43ecbe8b6f5f0525e5 100644
--- a/openair3/TEST/EPC_TEST/play_scenario.h
+++ b/openair3/TEST/EPC_TEST/play_scenario.h
@@ -252,12 +252,11 @@ typedef enum {
 
 typedef struct et_s1ap_s {
   //et_s1ap_pdu_type_t pdu_type;
-  S1AP_PDU_t           pdu; // decoded ASN1 C type: choice of initiatingMessage, successfulOutcome, unsuccessfulOutcome
+  S1AP_S1AP_PDU_t      pdu; // decoded ASN1 C type: choice of initiatingMessage, successfulOutcome, unsuccessfulOutcome
   uint16_t             xml_stream_pos_offset;
   uint16_t             binary_stream_pos;
   uint16_t             binary_stream_allocated_size;
   uint8_t             *binary_stream;
-  s1ap_message         message; // decoded message: information elements
   xmlDocPtr            doc; // XML representation of the S1AP PDU
 } et_s1ap_t;
 
@@ -300,9 +299,9 @@ typedef struct et_ip_s {
   union {
     struct in6_addr  ipv6;
     in_addr_t        ipv4;
-  }address;
+  } address;
   char str[INET6_ADDRSTRLEN+1];
-}et_ip_t;
+} et_ip_t;
 
 typedef struct et_ip_hdr_s {
   et_ip_t  src;
@@ -325,7 +324,7 @@ typedef struct et_packet_s {
   et_packet_status_t   status;
   long                 timer_id;         // ITTI timer id for waiting rx packets
   struct timeval       timestamp_packet; // timestamp when rx or tx packet
-}et_packet_t;
+} et_packet_t;
 
 
 typedef struct sctp_epoll_s {
@@ -401,23 +400,23 @@ typedef struct et_event_s {
 inline void et_free_pointer(void *p) {if (NULL != p) {free(p); p=NULL;}};
 
 //-------------------------
-void et_free_packet(et_packet_t* packet);
-void et_free_scenario(et_scenario_t* scenario);
+void et_free_packet(et_packet_t *packet);
+void et_free_scenario(et_scenario_t *scenario);
 //-------------------------
-void et_display_packet_s1ap_data(const et_s1ap_t * const s1ap);
-void et_display_packet_sctp_init(const sctp_inithdr_t * const sctp);
-void et_display_packet_sctp_initack(const sctp_initackhdr_t * const sctp);
-void et_display_packet_sctp_data(const sctp_datahdr_t * const sctp);
-void et_display_packet_sctp(const et_sctp_hdr_t * const sctp);
-void et_display_packet_ip(const et_ip_hdr_t * const ip);
-void et_display_packet(const et_packet_t * const packet);
-void et_display_scenario(const et_scenario_t * const scenario);
+void et_display_packet_s1ap_data(const et_s1ap_t *const s1ap);
+void et_display_packet_sctp_init(const sctp_inithdr_t *const sctp);
+void et_display_packet_sctp_initack(const sctp_initackhdr_t *const sctp);
+void et_display_packet_sctp_data(const sctp_datahdr_t *const sctp);
+void et_display_packet_sctp(const et_sctp_hdr_t *const sctp);
+void et_display_packet_ip(const et_ip_hdr_t *const ip);
+void et_display_packet(const et_packet_t *const packet);
+void et_display_scenario(const et_scenario_t *const scenario);
 //-------------------------
-int et_s1ap_decode_initiating_message(s1ap_message *message, S1ap_InitiatingMessage_t *initiating_p);
-int et_s1ap_decode_successful_outcome(s1ap_message *message, S1ap_SuccessfulOutcome_t *successfullOutcome_p);
-int et_s1ap_decode_unsuccessful_outcome(s1ap_message *message, S1ap_UnsuccessfulOutcome_t *unSuccessfullOutcome_p);
-int et_s1ap_decode_pdu(S1AP_PDU_t * const pdu, s1ap_message * const message, const uint8_t * const buffer, const uint32_t length);
-void et_decode_s1ap(et_s1ap_t * const s1ap);
+int et_s1ap_decode_initiating_message(s1ap_message *message, S1AP_InitiatingMessage_t *initiating_p);
+int et_s1ap_decode_successful_outcome(s1ap_message *message, S1AP_SuccessfulOutcome_t *successfullOutcome_p);
+int et_s1ap_decode_unsuccessful_outcome(s1ap_message *message, S1AP_UnsuccessfulOutcome_t *unSuccessfullOutcome_p);
+int et_s1ap_decode_pdu(S1AP_PDU_t *const pdu, s1ap_message *const message, const uint8_t *const buffer, const uint32_t length);
+void et_decode_s1ap(et_s1ap_t *const s1ap);
 //-------------------------
 int et_s1ap_eNB_compare_assoc_id( struct s1ap_eNB_mme_data_s *p1, struct s1ap_eNB_mme_data_s *p2);
 uint32_t et_s1ap_generate_eNB_id(void);
@@ -427,32 +426,32 @@ void et_s1ap_eNB_insert_new_instance(s1ap_eNB_instance_t *new_instance_p);
 struct s1ap_eNB_mme_data_s *et_s1ap_eNB_get_MME(s1ap_eNB_instance_t *instance_p,int32_t assoc_id, uint16_t cnx_id);
 s1ap_eNB_instance_t *et_s1ap_eNB_get_instance(instance_t instance);
 void et_s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,uint32_t buffer_length, uint16_t stream);
-int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packet_t * const rx_packet);
-asn_comp_rval_t* et_s1ap_is_matching(et_s1ap_t * const s1ap1, et_s1ap_t * const s1ap2, const uint32_t constraints);
-et_packet_t* et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t * const s1ap_data_ind);
-int et_scenario_set_packet_received(et_packet_t * const packet);
-int  et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t * const sctp_data_ind);
-void et_s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t * const sctp_data_ind);
+int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t *const spacket, et_packet_t *const rx_packet);
+asn_comp_rval_t *et_s1ap_is_matching(et_s1ap_t *const s1ap1, et_s1ap_t *const s1ap2, const uint32_t constraints);
+et_packet_t *et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t *const s1ap_data_ind);
+int et_scenario_set_packet_received(et_packet_t *const packet);
+int  et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t *const sctp_data_ind);
+void et_s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *const sctp_data_ind);
 void et_s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
-                                  net_ip_address_t    *mme_ip_address,
-                                  net_ip_address_t    *local_ip_addr,
-                                  uint16_t             in_streams,
-                                  uint16_t             out_streams);
+                              net_ip_address_t    *mme_ip_address,
+                              net_ip_address_t    *local_ip_addr,
+                              uint16_t             in_streams,
+                              uint16_t             out_streams);
 void et_s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shutdown);
 void et_s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *s1ap_register_eNB);
 void et_s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp);
-void * et_s1ap_eNB_task(void *arg);
+void *et_s1ap_eNB_task(void *arg);
 //-------------------------
 int et_generate_xml_scenario(
-    const char const * xml_in_dir_name,
-    const char const * xml_in_scenario_filename,
-    const char const * enb_config_filename,
-          char const * tsml_out_scenario_filename);
+  const char const *xml_in_dir_name,
+  const char const *xml_in_scenario_filename,
+  const char const *enb_config_filename,
+  char const *tsml_out_scenario_filename);
 //-------------------------
-void timeval_add (struct timeval * const result, const struct timeval * const a, const struct timeval * const b);
-int timeval_subtract (struct timeval * const result, struct timeval * const a, struct timeval * const b);
-void et_scenario_wait_rx_packet(et_packet_t * const packet);
-void et_scenario_schedule_tx_packet(et_packet_t * packet);
+void timeval_add (struct timeval *const result, const struct timeval *const a, const struct timeval *const b);
+int timeval_subtract (struct timeval *const result, struct timeval *const a, struct timeval *const b);
+void et_scenario_wait_rx_packet(et_packet_t *const packet);
+void et_scenario_schedule_tx_packet(et_packet_t *packet);
 et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event);
 et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_tx(et_event_t event);
 et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_rx(et_event_t event);
@@ -460,41 +459,41 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
 et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event);
 et_fsm_state_t et_scenario_fsm_notify_event(et_event_t event);
 //-------------------------
-void et_parse_s1ap(xmlDocPtr doc, const xmlNode const *s1ap_node, et_s1ap_t * const s1ap);
-void et_parse_sctp_data_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_datahdr_t * const sctp_hdr);
-void et_parse_sctp_init_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_inithdr_t * const sctp_hdr);
-void et_parse_sctp_init_ack_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_initackhdr_t * const sctp_hdr);
-void et_parse_sctp(xmlDocPtr doc, const xmlNode const *sctp_node, et_sctp_hdr_t * const sctp_hdr);
-et_packet_t* et_parse_xml_packet(xmlDocPtr doc, xmlNodePtr node);
-et_scenario_t* et_generate_scenario(const char  * const et_scenario_filename);
+void et_parse_s1ap(xmlDocPtr doc, const xmlNode const *s1ap_node, et_s1ap_t *const s1ap);
+void et_parse_sctp_data_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_datahdr_t *const sctp_hdr);
+void et_parse_sctp_init_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_inithdr_t *const sctp_hdr);
+void et_parse_sctp_init_ack_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_initackhdr_t *const sctp_hdr);
+void et_parse_sctp(xmlDocPtr doc, const xmlNode const *sctp_node, et_sctp_hdr_t *const sctp_hdr);
+et_packet_t *et_parse_xml_packet(xmlDocPtr doc, xmlNodePtr node);
+et_scenario_t *et_generate_scenario(const char   *const et_scenario_filename);
 //-------------------------
-asn_comp_rval_t * et_s1ap_ies_is_matching(const S1AP_PDU_PR present, s1ap_message * const m1, s1ap_message * const m2, const uint32_t constraints);
-void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, const S1ap_MME_UE_S1AP_ID_t new_id);
-void update_xpath_nodes_mme_ue_s1ap_id(et_s1ap_t * const s1ap_payload, xmlNodeSetPtr nodes, const S1ap_MME_UE_S1AP_ID_t new_id);
-int et_s1ap_update_mme_ue_s1ap_id(et_packet_t * const packet, const S1ap_MME_UE_S1AP_ID_t old_id, const S1ap_MME_UE_S1AP_ID_t new_id);
+asn_comp_rval_t *et_s1ap_ies_is_matching(const S1AP_PDU_PR present, s1ap_message *const m1, s1ap_message *const m2, const uint32_t constraints);
+void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t *const s1ap, xmlNode *node, const S1AP_MME_UE_S1AP_ID_t new_id);
+void update_xpath_nodes_mme_ue_s1ap_id(et_s1ap_t *const s1ap_payload, xmlNodeSetPtr nodes, const S1AP_MME_UE_S1AP_ID_t new_id);
+int et_s1ap_update_mme_ue_s1ap_id(et_packet_t *const packet, const S1AP_MME_UE_S1AP_ID_t old_id, const S1AP_MME_UE_S1AP_ID_t new_id);
 //-------------------------
-asn_comp_rval_t * et_sctp_data_is_matching(sctp_datahdr_t * const sctp1, sctp_datahdr_t * const sctp2, const uint32_t constraints);
-asn_comp_rval_t * et_sctp_is_matching(et_sctp_hdr_t * const sctp1, et_sctp_hdr_t * const sctp2, const uint32_t constraints);
+asn_comp_rval_t *et_sctp_data_is_matching(sctp_datahdr_t *const sctp1, sctp_datahdr_t *const sctp2, const uint32_t constraints);
+asn_comp_rval_t *et_sctp_is_matching(et_sctp_hdr_t *const sctp1, et_sctp_hdr_t *const sctp2, const uint32_t constraints);
 //------------------------------------------------------------------------------
-void et_print_hex_octets(const unsigned char * const byte_stream, const unsigned long int num);
-int  et_is_file_exists ( const char const * file_nameP, const char const *file_roleP);
+void et_print_hex_octets(const unsigned char *const byte_stream, const unsigned long int num);
+int  et_is_file_exists ( const char const *file_nameP, const char const *file_roleP);
 int  et_strip_extension( char *in_filename);
-void et_get_shift_arg( char * line_argument, shift_packet_t * const shift);
-int  et_split_path     ( char * pathP, char *** resP);
+void et_get_shift_arg( char *line_argument, shift_packet_t *const shift);
+int  et_split_path     ( char *pathP, char *** resP);
 void et_display_node   ( xmlNodePtr node, unsigned int indent);
 void et_display_tree   ( xmlNodePtr node, unsigned int indent);
-char * et_ip2ip_str(const et_ip_t * const ip);
-int et_compare_et_ip_to_net_ip_address(const et_ip_t * const ip, const net_ip_address_t * const net_ip);
-int et_hex2data(unsigned char * const data, const unsigned char * const hexstring, const unsigned int len);
-sctp_cid_t et_chunk_type_str2cid(const xmlChar * const chunk_type_str);
-const char * const et_chunk_type_cid2str(const sctp_cid_t chunk_type);
-const char * const et_error_match2str(const int err);
-et_packet_action_t et_action_str2et_action_t(const xmlChar * const action);
-void et_ip_str2et_ip(const xmlChar  * const ip_str, et_ip_t * const ip);
-void et_enb_config_init(const  char const * lib_config_file_name_pP);
+char *et_ip2ip_str(const et_ip_t *const ip);
+int et_compare_et_ip_to_net_ip_address(const et_ip_t *const ip, const net_ip_address_t *const net_ip);
+int et_hex2data(unsigned char *const data, const unsigned char *const hexstring, const unsigned int len);
+sctp_cid_t et_chunk_type_str2cid(const xmlChar *const chunk_type_str);
+const char *const et_chunk_type_cid2str(const sctp_cid_t chunk_type);
+const char *const et_error_match2str(const int err);
+et_packet_action_t et_action_str2et_action_t(const xmlChar *const action);
+void et_ip_str2et_ip(const xmlChar   *const ip_str, et_ip_t *const ip);
+void et_enb_config_init(const  char const *lib_config_file_name_pP);
 const Enb_properties_array_t *et_enb_config_get(void);
 void et_eNB_app_register(const Enb_properties_array_t *enb_properties);
 void *et_eNB_app_task(void *args_p);
-int et_play_scenario(et_scenario_t* const scenario, const struct shift_packet_s *shifts);
+int et_play_scenario(et_scenario_t *const scenario, const struct shift_packet_s *shifts);
 
 #endif /* PLAY_SCENARIO_H_ */
diff --git a/openair3/TEST/EPC_TEST/play_scenario_decode.c b/openair3/TEST/EPC_TEST/play_scenario_decode.c
index be63a171c5374ddeb6fa8457b9465a1a9b632155..cbf1fbd7e9a0b131a49103b0fa2b4140f7ed899c 100644
--- a/openair3/TEST/EPC_TEST/play_scenario_decode.c
+++ b/openair3/TEST/EPC_TEST/play_scenario_decode.c
@@ -29,140 +29,18 @@
 
 #include "intertask_interface.h"
 #include "platform_types.h"
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_decoder.h"
 #include "assertions.h"
 #include "play_scenario.h"
 
 //------------------------------------------------------------------------------
-int et_s1ap_decode_initiating_message(s1ap_message *message, S1ap_InitiatingMessage_t *initiating_p)
-{
-  int         ret = -1;
-
-  DevAssert(initiating_p != NULL);
-
-  message->procedureCode = initiating_p->procedureCode;
-  message->criticality   = initiating_p->criticality;
-
-  switch(initiating_p->procedureCode) {
-  case S1ap_ProcedureCode_id_downlinkNASTransport:
-    ret = s1ap_decode_s1ap_downlinknastransporties(&message->msg.s1ap_DownlinkNASTransportIEs,&initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_InitialContextSetup:
-    ret = s1ap_decode_s1ap_initialcontextsetuprequesties(&message->msg.s1ap_InitialContextSetupRequestIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_UEContextRelease:
-    ret = s1ap_decode_s1ap_uecontextreleasecommandies(&message->msg.s1ap_UEContextReleaseCommandIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_Paging:
-    ret = s1ap_decode_s1ap_pagingies(&message->msg.s1ap_PagingIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_uplinkNASTransport:
-    ret = s1ap_decode_s1ap_uplinknastransporties (&message->msg.s1ap_UplinkNASTransportIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_S1Setup:
-    ret = s1ap_decode_s1ap_s1setuprequesties (&message->msg.s1ap_S1SetupRequestIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_initialUEMessage:
-    ret = s1ap_decode_s1ap_initialuemessageies (&message->msg.s1ap_InitialUEMessageIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_UEContextReleaseRequest:
-    ret = s1ap_decode_s1ap_uecontextreleaserequesties (&message->msg.s1ap_UEContextReleaseRequestIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_UECapabilityInfoIndication:
-    ret = s1ap_decode_s1ap_uecapabilityinfoindicationies (&message->msg.s1ap_UECapabilityInfoIndicationIEs, &initiating_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_NASNonDeliveryIndication:
-    ret = s1ap_decode_s1ap_nasnondeliveryindication_ies (&message->msg.s1ap_NASNonDeliveryIndication_IEs, &initiating_p->value);
-    break;
-
-  default:
-    AssertFatal( 0 , "Unknown procedure ID (%d) for initiating message\n",
-                 (int)initiating_p->procedureCode);
-    return -1;
-  }
-  return ret;
-}
-
-//------------------------------------------------------------------------------
-int et_s1ap_decode_successful_outcome(s1ap_message *message, S1ap_SuccessfulOutcome_t *successfullOutcome_p)
-{
-  int         ret = -1;
-
-  DevAssert(successfullOutcome_p != NULL);
-
-  message->procedureCode = successfullOutcome_p->procedureCode;
-  message->criticality   = successfullOutcome_p->criticality;
-
-  switch(successfullOutcome_p->procedureCode) {
-  case S1ap_ProcedureCode_id_S1Setup:
-    ret = s1ap_decode_s1ap_s1setupresponseies(
-            &message->msg.s1ap_S1SetupResponseIEs, &successfullOutcome_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_InitialContextSetup:
-    ret = s1ap_decode_s1ap_initialcontextsetupresponseies (&message->msg.s1ap_InitialContextSetupResponseIEs, &successfullOutcome_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_UEContextRelease:
-      ret = s1ap_decode_s1ap_uecontextreleasecompleteies (&message->msg.s1ap_UEContextReleaseCompleteIEs, &successfullOutcome_p->value);
-    break;
-
-  default:
-    AssertFatal(0, "Unknown procedure ID (%d) for successfull outcome message\n",
-               (int)successfullOutcome_p->procedureCode);
-    return -1;
-  }
-  return ret;
-}
-
-//------------------------------------------------------------------------------
-int et_s1ap_decode_unsuccessful_outcome(s1ap_message *message, S1ap_UnsuccessfulOutcome_t *unSuccessfullOutcome_p)
-{
-  int ret = -1;
-
-  DevAssert(unSuccessfullOutcome_p != NULL);
-
-  message->procedureCode = unSuccessfullOutcome_p->procedureCode;
-  message->criticality   = unSuccessfullOutcome_p->criticality;
-
-  switch(unSuccessfullOutcome_p->procedureCode) {
-  case S1ap_ProcedureCode_id_S1Setup:
-    ret = s1ap_decode_s1ap_s1setupfailureies(&message->msg.s1ap_S1SetupFailureIEs, &unSuccessfullOutcome_p->value);
-    break;
-
-  case S1ap_ProcedureCode_id_InitialContextSetup:
-    ret = s1ap_decode_s1ap_initialcontextsetupfailureies (&message->msg.s1ap_InitialContextSetupFailureIEs, &unSuccessfullOutcome_p->value);
-    break;
-
-  default:
-    AssertFatal(0,"Unknown procedure ID (%d) for unsuccessfull outcome message\n",
-               (int)unSuccessfullOutcome_p->procedureCode);
-    break;
-  }
-  return ret;
-}
-
-//------------------------------------------------------------------------------
-int et_s1ap_decode_pdu(S1AP_PDU_t * const pdu, s1ap_message * const message, const uint8_t * const buffer, const uint32_t length)
+int et_s1ap_decode_pdu(S1AP_PDU_t *const pdu, const uint8_t *const buffer, const uint32_t length)
 {
   asn_dec_rval_t dec_ret;
-
   DevAssert(buffer != NULL);
-
-  memset((void *)pdu, 0, sizeof(S1AP_PDU_t));
-
+  memset((void *)pdu, 0, sizeof(S1AP_S1AP_PDU_t));
   dec_ret = aper_decode(NULL,
-                        &asn_DEF_S1AP_PDU,
+                        &asn_DEF_S1AP_S1AP_PDU,
                         (void **)&pdu,
                         buffer,
                         length,
@@ -174,32 +52,14 @@ int et_s1ap_decode_pdu(S1AP_PDU_t * const pdu, s1ap_message * const message, con
     return -1;
   }
 
-  message->direction = pdu->present;
-
-  switch(pdu->present) {
-  case S1AP_PDU_PR_initiatingMessage:
-    return et_s1ap_decode_initiating_message(message,
-           &pdu->choice.initiatingMessage);
-
-  case S1AP_PDU_PR_successfulOutcome:
-    return et_s1ap_decode_successful_outcome(message,
-           &pdu->choice.successfulOutcome);
-
-  case S1AP_PDU_PR_unsuccessfulOutcome:
-    return et_s1ap_decode_unsuccessful_outcome(message,
-           &pdu->choice.unsuccessfulOutcome);
-
-  default:
-    AssertFatal(0, "Unknown presence (%d) or not implemented\n", (int)pdu->present);
-    break;
-  }
-  return -1;
+  return dec_ret.code;
 }
+
 //------------------------------------------------------------------------------
-void et_decode_s1ap(et_s1ap_t * const s1ap)
+void et_decode_s1ap(et_s1ap_t *const s1ap)
 {
   if (NULL != s1ap) {
-    if (et_s1ap_decode_pdu(&s1ap->pdu, &s1ap->message, s1ap->binary_stream, s1ap->binary_stream_allocated_size) < 0) {
+    if (et_s1ap_decode_pdu(&s1ap->pdu, s1ap->binary_stream, s1ap->binary_stream_allocated_size) < 0) {
       AssertFatal (0, "ERROR %s() Cannot decode S1AP message!\n", __FUNCTION__);
     }
   }
diff --git a/openair3/TEST/EPC_TEST/play_scenario_display.c b/openair3/TEST/EPC_TEST/play_scenario_display.c
index e10cbdf9bf1b285d6965dcb77c3f4db80b284c84..ef238dc3eceea0c907f316da3ed1121db4727e8f 100644
--- a/openair3/TEST/EPC_TEST/play_scenario_display.c
+++ b/openair3/TEST/EPC_TEST/play_scenario_display.c
@@ -32,11 +32,10 @@
 #include "intertask_interface.h"
 #include "platform_types.h"
 #include "assertions.h"
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_decoder.h"
 #include "play_scenario.h"
 //-----------------------------------------------------------------------------
-void et_print_hex_octets(const unsigned char * const byte_stream, const unsigned long int num)
+void et_print_hex_octets(const unsigned char *const byte_stream, const unsigned long int num)
 {
   unsigned long octet_index = 0;
 
@@ -82,11 +81,14 @@ void et_print_hex_octets(const unsigned char * const byte_stream, const unsigned
 void et_display_node(xmlNodePtr node, unsigned int indent)
 {
   int i = 0;
+
   if (node->type == XML_ELEMENT_NODE) {
     xmlChar *path = xmlGetNodePath(node);
+
     for (i=0; i<indent; i++) {
       printf("  ");
     }
+
     if (node->children != NULL && node->children->type == XML_TEXT_NODE) {
       xmlChar *content = xmlNodeGetContent(node);
       printf("%s -> %s\n", path, content);
@@ -94,6 +96,7 @@ void et_display_node(xmlNodePtr node, unsigned int indent)
     } else {
       printf("%s\n", path);
     }
+
     xmlFree(path);
   }
 }
@@ -106,70 +109,91 @@ void et_display_tree(xmlNodePtr node, unsigned int indent)
     if (cur_node->type == XML_ELEMENT_NODE) {
       et_display_node(cur_node, indent);
     }
+
     et_display_tree(cur_node->children, indent++);
   }
 }
 //------------------------------------------------------------------------------
-void et_display_packet_s1ap_data(const et_s1ap_t * const s1ap)
+void et_display_packet_S1AP_data(const et_S1AP_t *const s1ap)
 {
   char       *message_string = NULL;
 
   if (s1ap) {
     message_string = calloc(20000, sizeof(char));
     AssertFatal (NULL != message_string, "ERROR malloc()failed!\n");
-    s1ap_string_total_size = 0;
+
     switch(s1ap->pdu.present) {
-    case S1AP_PDU_PR_initiatingMessage:
-      switch(s1ap->pdu.choice.initiatingMessage.procedureCode) {
-      case S1ap_ProcedureCode_id_downlinkNASTransport:      s1ap_xer_print_s1ap_downlinknastransport(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_InitialContextSetup:       s1ap_xer_print_s1ap_initialcontextsetuprequest(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_UEContextRelease:          s1ap_xer_print_s1ap_uecontextreleasecommand(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_Paging:                    s1ap_xer_print_s1ap_paging(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_uplinkNASTransport:        s1ap_xer_print_s1ap_uplinknastransport(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_S1Setup:                   s1ap_xer_print_s1ap_s1setuprequest(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_initialUEMessage:          s1ap_xer_print_s1ap_initialuemessage(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_UEContextReleaseRequest:   s1ap_xer_print_s1ap_uecontextreleaserequest(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_UECapabilityInfoIndication:s1ap_xer_print_s1ap_uecapabilityinfoindication(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_NASNonDeliveryIndication:  s1ap_xer_print_s1ap_nasnondeliveryindication_(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      default:
-        AssertFatal( 0 , "Unknown procedure ID (%d) for initiating message\n",
-                     (int)s1ap->pdu.choice.initiatingMessage.procedureCode);
-      }
-      break;
-    case S1AP_PDU_PR_successfulOutcome:
-      switch(s1ap->pdu.choice.successfulOutcome.procedureCode) {
-      case S1ap_ProcedureCode_id_S1Setup:                   s1ap_xer_print_s1ap_s1setupresponse(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_InitialContextSetup:       s1ap_xer_print_s1ap_initialcontextsetupresponse(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_UEContextRelease:          s1ap_xer_print_s1ap_uecontextreleasecomplete(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      default:
-        AssertFatal(0, "Unknown procedure ID (%d) for successfull outcome message\n",
-                   (int)s1ap->pdu.choice.successfulOutcome.procedureCode);
-      }
-      break;
+      case S1AP_S1AP_PDU_PR_initiatingMessage:
+        switch(s1ap->pdu.choice.initiatingMessage.procedureCode) {
+          case S1AP_ProcedureCode_id_downlinkNASTransport:      s1ap_xer_print_s1ap_downlinknastransport(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_InitialContextSetup:       s1ap_xer_print_s1ap_initialcontextsetuprequest(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_UEContextRelease:          s1ap_xer_print_s1ap_uecontextreleasecommand(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_Paging:                    s1ap_xer_print_s1ap_paging(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_uplinkNASTransport:        s1ap_xer_print_s1ap_uplinknastransport(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_S1Setup:                   s1ap_xer_print_s1ap_s1setuprequest(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_initialUEMessage:          s1ap_xer_print_s1ap_initialuemessage(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_UEContextReleaseRequest:   s1ap_xer_print_s1ap_uecontextreleaserequest(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_UECapabilityInfoIndication:s1ap_xer_print_s1ap_uecapabilityinfoindication(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_NASNonDeliveryIndication:  s1ap_xer_print_s1ap_nasnondeliveryindication_(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          default:
+            AssertFatal( 0, "Unknown procedure ID (%d) for initiating message\n",
+                         (int)s1ap->pdu.choice.initiatingMessage.procedureCode);
+        }
+
+        break;
+
+      case S1AP_S1AP_PDU_PR_successfulOutcome:
+        switch(s1ap->pdu.choice.successfulOutcome.procedureCode) {
+          case S1AP_ProcedureCode_id_S1Setup:                   s1ap_xer_print_s1ap_s1setupresponse(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_InitialContextSetup:       s1ap_xer_print_s1ap_initialcontextsetupresponse(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_UEContextRelease:          s1ap_xer_print_s1ap_uecontextreleasecomplete(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          default:
+            AssertFatal(0, "Unknown procedure ID (%d) for successfull outcome message\n",
+                        (int)s1ap->pdu.choice.successfulOutcome.procedureCode);
+        }
+
+        break;
+
+      case S1AP_S1AP_PDU_PR_unsuccessfulOutcome:
+        switch(s1ap->pdu.choice.unsuccessfulOutcome.procedureCode) {
+          case S1AP_ProcedureCode_id_S1Setup:                   s1ap_xer_print_s1ap_s1setupfailure(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          case S1AP_ProcedureCode_id_InitialContextSetup:       s1ap_xer_print_s1ap_initialcontextsetupfailure(s1ap_xer__print2sp, message_string, (S1AP_message *)&s1ap->message); break;
+
+          default:
+            et_free_pointer(message_string);
+            AssertFatal(0,"Unknown procedure ID (%d) for unsuccessfull outcome message\n",
+                        (int)s1ap->pdu.choice.unsuccessfulOutcome.procedureCode);
+            break;
+        }
+
+        break;
 
-    case S1AP_PDU_PR_unsuccessfulOutcome:
-      switch(s1ap->pdu.choice.unsuccessfulOutcome.procedureCode) {
-      case S1ap_ProcedureCode_id_S1Setup:                   s1ap_xer_print_s1ap_s1setupfailure(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
-      case S1ap_ProcedureCode_id_InitialContextSetup:       s1ap_xer_print_s1ap_initialcontextsetupfailure(s1ap_xer__print2sp, message_string, (s1ap_message *)&s1ap->message);break;
       default:
-        et_free_pointer(message_string);
-        AssertFatal(0,"Unknown procedure ID (%d) for unsuccessfull outcome message\n",
-                   (int)s1ap->pdu.choice.unsuccessfulOutcome.procedureCode);
+        AssertFatal(0, "Unknown presence (%d) or not implemented\n", (int)s1ap->pdu.present);
         break;
-      }
-      break;
-    default:
-      AssertFatal(0, "Unknown presence (%d) or not implemented\n", (int)s1ap->pdu.present);
-      break;
     }
+
     fprintf(stdout, "\t\tSCTP.data XML dump:\n%s\n", message_string);
     et_free_pointer(message_string);
   }
 }
 //------------------------------------------------------------------------------
-void et_display_packet_sctp_init(const sctp_inithdr_t * const sctp)
+void et_display_packet_sctp_init(const sctp_inithdr_t *const sctp)
 {
-
   if (sctp) {
     fprintf(stdout, "\t\tSCTP.init.init_tag               : %u\n", sctp->init_tag);
     fprintf(stdout, "\t\tSCTP.init.a_rwnd                 : %u\n", sctp->a_rwnd);
@@ -179,9 +203,8 @@ void et_display_packet_sctp_init(const sctp_inithdr_t * const sctp)
   }
 }
 //------------------------------------------------------------------------------
-void et_display_packet_sctp_initack(const sctp_initackhdr_t * const sctp)
+void et_display_packet_sctp_initack(const sctp_initackhdr_t *const sctp)
 {
-
   if (sctp) {
     fprintf(stdout, "\t\tSCTP.initack.init_tag               : %u\n", sctp->init_tag);
     fprintf(stdout, "\t\tSCTP.initack.a_rwnd                 : %u\n", sctp->a_rwnd);
@@ -191,17 +214,20 @@ void et_display_packet_sctp_initack(const sctp_initackhdr_t * const sctp)
   }
 }
 //------------------------------------------------------------------------------
-void et_display_packet_sctp_data(const sctp_datahdr_t * const sctp)
+void et_display_packet_sctp_data(const sctp_datahdr_t *const sctp)
 {
   if (sctp) {
     fprintf(stdout, "\t\tSCTP.data.tsn                 : %u\n", sctp->tsn);
     fprintf(stdout, "\t\tSCTP.data.stream              : %u\n", sctp->stream);
     fprintf(stdout, "\t\tSCTP.data.ssn                 : %u\n", sctp->ssn);
     fprintf(stdout, "\t\tSCTP.data.ppid                : %u\n", sctp->ppid);
+
     if (sctp->ppid == 18) {
       et_display_packet_s1ap_data(&sctp->payload);
     }
+
     fprintf(stdout, "\t\tSCTP.data.binary_stream_allocated_size : %u\n", sctp->payload.binary_stream_allocated_size);
+
     if (NULL != sctp->payload.binary_stream) {
       fprintf(stdout, "\t\tSCTP.data.binary_stream       :\n");
       et_print_hex_octets(sctp->payload.binary_stream, sctp->payload.binary_stream_allocated_size);
@@ -212,29 +238,33 @@ void et_display_packet_sctp_data(const sctp_datahdr_t * const sctp)
 }
 
 //------------------------------------------------------------------------------
-void et_display_packet_sctp(const et_sctp_hdr_t * const sctp)
+void et_display_packet_sctp(const et_sctp_hdr_t *const sctp)
 {
   if (sctp) {
     fprintf(stdout, "\t\tSCTP.src_port      : %u\n", sctp->src_port);
     fprintf(stdout, "\t\tSCTP.dst_port      : %u\n", sctp->dst_port);
     fprintf(stdout, "\t\tSCTP.chunk_type    : %s\n", et_chunk_type_cid2str(sctp->chunk_type));
+
     switch (sctp->chunk_type) {
       case SCTP_CID_DATA:
         et_display_packet_sctp_data(&sctp->u.data_hdr);
         break;
+
       case SCTP_CID_INIT:
         et_display_packet_sctp_initack(&sctp->u.init_hdr);
         break;
+
       case SCTP_CID_INIT_ACK:
         et_display_packet_sctp_initack(&sctp->u.init_ack_hdr);
         break;
+
       default:
         ;
     }
   }
 }
 //------------------------------------------------------------------------------
-void et_display_packet_ip(const et_ip_hdr_t * const ip)
+void et_display_packet_ip(const et_ip_hdr_t *const ip)
 {
   if (ip) {
     fprintf(stdout, "\t\tSource address      : %s\n", et_ip2ip_str(&ip->src));
@@ -243,61 +273,73 @@ void et_display_packet_ip(const et_ip_hdr_t * const ip)
 }
 
 //------------------------------------------------------------------------------
-void et_display_packet(const et_packet_t * const packet)
+void et_display_packet(const et_packet_t *const packet)
 {
   if (packet) {
     fprintf(stdout, "-------------------------------------------------------------------------------\n");
     fprintf(stdout, "\tPacket:\tnum %u  | original frame number %u \n", packet->packet_number, packet->original_frame_number);
     fprintf(stdout, "\tPacket:\ttime relative to 1st packet           %ld.%06lu\n",
-        packet->time_relative_to_first_packet.tv_sec, packet->time_relative_to_first_packet.tv_usec);
+            packet->time_relative_to_first_packet.tv_sec, packet->time_relative_to_first_packet.tv_usec);
     fprintf(stdout, "\tPacket:\ttime relative to last tx packet       %ld.%06lu\n",
-        packet->time_relative_to_last_sent_packet.tv_sec, packet->time_relative_to_last_sent_packet.tv_usec);
+            packet->time_relative_to_last_sent_packet.tv_sec, packet->time_relative_to_last_sent_packet.tv_usec);
     fprintf(stdout, "\tPacket:\ttime relative to last_received packet %ld.%06lu\n",
-        packet->time_relative_to_last_received_packet.tv_sec, packet->time_relative_to_last_received_packet.tv_usec);
+            packet->time_relative_to_last_received_packet.tv_sec, packet->time_relative_to_last_received_packet.tv_usec);
 
     switch(packet->action) {
-    case   ET_PACKET_ACTION_S1C_SEND:
-      fprintf(stdout, "\tPacket:\tAction SEND\n");
-      break;
-    case   ET_PACKET_ACTION_S1C_RECEIVE:
-      fprintf(stdout, "\tPacket:\tAction RECEIVE\n");
-      break;
-    default:
-      fprintf(stdout, "\tPacket:\tAction UNKNOWN\n");
+      case   ET_PACKET_ACTION_S1C_SEND:
+        fprintf(stdout, "\tPacket:\tAction SEND\n");
+        break;
+
+      case   ET_PACKET_ACTION_S1C_RECEIVE:
+        fprintf(stdout, "\tPacket:\tAction RECEIVE\n");
+        break;
+
+      default:
+        fprintf(stdout, "\tPacket:\tAction UNKNOWN\n");
     }
+
     switch(packet->status) {
-    case   ET_PACKET_STATUS_NONE:
-      fprintf(stdout, "\tPacket:\tStatus NONE\n");
-      break;
-    case   ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT:
-      fprintf(stdout, "\tPacket:\tStatus NOT_TAKEN_IN_ACCOUNT\n");
-      break;
-    case   ET_PACKET_STATUS_SCHEDULED_FOR_SENDING:
-      fprintf(stdout, "\tPacket:\tStatus SCHEDULED_FOR_SENDING\n");
-      break;
-    case   ET_PACKET_STATUS_SENT:
-      fprintf(stdout, "\tPacket:\tStatus SENT\n");
-      break;
-    case   ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING:
-      fprintf(stdout, "\tPacket:\tStatus SCHEDULED_FOR_RECEIVING\n");
-      break;
-    case   ET_PACKET_STATUS_RECEIVED:
-      fprintf(stdout, "\tPacket:\tStatus RECEIVED\n");
-      break;
-    default:
-      fprintf(stdout, "\tPacket:\tStatus UNKNOWN\n");
+      case   ET_PACKET_STATUS_NONE:
+        fprintf(stdout, "\tPacket:\tStatus NONE\n");
+        break;
+
+      case   ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT:
+        fprintf(stdout, "\tPacket:\tStatus NOT_TAKEN_IN_ACCOUNT\n");
+        break;
+
+      case   ET_PACKET_STATUS_SCHEDULED_FOR_SENDING:
+        fprintf(stdout, "\tPacket:\tStatus SCHEDULED_FOR_SENDING\n");
+        break;
+
+      case   ET_PACKET_STATUS_SENT:
+        fprintf(stdout, "\tPacket:\tStatus SENT\n");
+        break;
+
+      case   ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING:
+        fprintf(stdout, "\tPacket:\tStatus SCHEDULED_FOR_RECEIVING\n");
+        break;
+
+      case   ET_PACKET_STATUS_RECEIVED:
+        fprintf(stdout, "\tPacket:\tStatus RECEIVED\n");
+        break;
+
+      default:
+        fprintf(stdout, "\tPacket:\tStatus UNKNOWN\n");
     }
+
     et_display_packet_ip(&packet->ip_hdr);
     et_display_packet_sctp(&packet->sctp_hdr);
   }
 }
 //------------------------------------------------------------------------------
-void et_display_scenario(const et_scenario_t * const scenario)
+void et_display_scenario(const et_scenario_t *const scenario)
 {
   et_packet_t *packet = NULL;
+
   if (scenario) {
-    fprintf(stdout, "Scenario: %s\n", (scenario->name != NULL) ? (char*)scenario->name:"UNKNOWN NAME");
+    fprintf(stdout, "Scenario: %s\n", (scenario->name != NULL) ? (char *)scenario->name:"UNKNOWN NAME");
     packet = scenario->list_packet;
+
     while (packet) {
       et_display_packet(packet);
       packet = packet->next;
diff --git a/openair3/TEST/EPC_TEST/play_scenario_fsm.c b/openair3/TEST/EPC_TEST/play_scenario_fsm.c
index 1589b83cae6b58bc651f4b0debaed2e59b5a3505..8d8f5ec92145602141b4b007ff160b4a0c8653c0 100644
--- a/openair3/TEST/EPC_TEST/play_scenario_fsm.c
+++ b/openair3/TEST/EPC_TEST/play_scenario_fsm.c
@@ -34,7 +34,6 @@
 #include "platform_types.h"
 #include "assertions.h"
 #include "play_scenario.h"
-#include "s1ap_ies_defs.h"
 #include "play_scenario_s1ap_eNB_defs.h"
 #include "timer.h"
 
@@ -47,7 +46,7 @@ et_fsm_state_t    g_fsm_state = ET_FSM_STATE_NULL;
 uint32_t          g_constraints = ET_BIT_MASK_MATCH_SCTP_STREAM | ET_BIT_MASK_MATCH_SCTP_SSN;
 //------------------------------------------------------------------------------
 // it is assumed that if a time is negative tv_sec and tv_usec are both negative
-void timeval_add (struct timeval * const result, const struct timeval * const a, const struct timeval * const b)
+void timeval_add (struct timeval *const result, const struct timeval *const a, const struct timeval *const b)
 {
   AssertFatal(((a->tv_sec <= 0) && (a->tv_usec <= 0)) || ((a->tv_sec >= 0) && (a->tv_usec >= 0)), " Bad time format arg a\n");
   AssertFatal(((b->tv_sec <= 0) && (b->tv_usec <= 0)) || ((b->tv_sec >= 0) && (b->tv_usec >= 0)), " Bad time format arg b\n");
@@ -55,6 +54,7 @@ void timeval_add (struct timeval * const result, const struct timeval * const a,
   long long int r = a->tv_usec + b->tv_usec + (a->tv_sec + b->tv_sec) * 1000000;
   result->tv_sec  = r / (long long int)1000000;
   result->tv_usec = r % (long long int)1000000;
+
   if ((result != a) && (result != b)) {
     LOG_D(ENB_APP, "timeval_add(%ld.%06d, %ld.%06d)=%ld.%06d\n", a->tv_sec, a->tv_usec, b->tv_sec, b->tv_usec, result->tv_sec, result->tv_usec);
   }
@@ -63,7 +63,7 @@ void timeval_add (struct timeval * const result, const struct timeval * const a,
 //------------------------------------------------------------------------------
 // it is assumed that if a time is negative tv_sec and tv_usec are both negative
 // return true if result is positive
-int timeval_subtract (struct timeval * const result, struct timeval * const a, struct timeval * const b)
+int timeval_subtract (struct timeval *const result, struct timeval *const a, struct timeval *const b)
 {
   AssertFatal(((a->tv_sec <= 0) && (a->tv_usec <= 0)) || ((a->tv_sec >= 0) && (a->tv_usec >= 0)), " Bad time format arg a\n");
   AssertFatal(((b->tv_sec <= 0) && (b->tv_usec <= 0)) || ((b->tv_sec >= 0) && (b->tv_usec >= 0)), " Bad time format arg b\n");
@@ -71,26 +71,30 @@ int timeval_subtract (struct timeval * const result, struct timeval * const a, s
   long long int r = a->tv_usec - b->tv_usec + (a->tv_sec - b->tv_sec) * 1000000;
   result->tv_sec  = r / (long long int)1000000;
   result->tv_usec = r % (long long int)1000000;
+
   if ((result != a) && (result != b)) {
     LOG_D(ENB_APP, "timeval_subtract(%ld.%06d, %ld.%06d)=%ld.%06d\n", a->tv_sec, a->tv_usec, b->tv_sec, b->tv_usec, result->tv_sec, result->tv_usec);
   }
+
   return (result->tv_sec >= 0) && (result->tv_usec >= 0);
 }
 
 //------------------------------------------------------------------------------
-void et_scenario_wait_rx_packet(et_packet_t * const packet)
+void et_scenario_wait_rx_packet(et_packet_t *const packet)
 {
   packet->status = ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING;
   g_fsm_state    = ET_FSM_STATE_WAITING_RX_EVENT;
+
   if (timer_setup (ET_FSM_STATE_WAITING_RX_EVENT_DELAY_SEC, 0, TASK_S1AP, INSTANCE_DEFAULT, TIMER_ONE_SHOT,
-        packet, &packet->timer_id) < 0) {
+                   packet, &packet->timer_id) < 0) {
     AssertFatal(0, " Can not start waiting RX event timer\n");
   }
+
   g_scenario->timer_count++;
   LOG_D(ENB_APP, "Waiting RX packet num %d original frame number %u\n", packet->packet_number, packet->original_frame_number);
 }
 //------------------------------------------------------------------------------
-void et_scenario_schedule_tx_packet(et_packet_t * packet)
+void et_scenario_schedule_tx_packet(et_packet_t *packet)
 {
   s1ap_eNB_instance_t *s1ap_eNB_instance = NULL;
   struct timeval  now                   = { .tv_sec = 0, .tv_usec = 0 };
@@ -101,11 +105,9 @@ void et_scenario_schedule_tx_packet(et_packet_t * packet)
   int             last_packet_was_rx    = 0;
   int             we_are_too_late       = 0;
   int             original_frame_number = -1;
-
   AssertFatal(NULL != packet, "packet argument is NULL");
   s1ap_eNB_instance = et_s1ap_eNB_get_instance(packet->enb_instance);
   AssertFatal(NULL != s1ap_eNB_instance, "Cannot get s1ap_eNB_instance_t for eNB instance %d", packet->enb_instance);
-
   LOG_D(ENB_APP, "%s\n", __FUNCTION__);
   g_fsm_state = ET_FSM_STATE_WAITING_TX_EVENT;
 
@@ -118,8 +120,8 @@ void et_scenario_schedule_tx_packet(et_packet_t * packet)
       timeval_subtract(&offset_last_rx_packet,&now,&g_scenario->time_last_rx_packet);
       LOG_D(ENB_APP, "offset_last_tx_packet=%ld.%06d\n", offset_last_tx_packet.tv_sec, offset_last_tx_packet.tv_usec);
       LOG_D(ENB_APP, "offset_last_rx_packet=%ld.%06d\n", offset_last_rx_packet.tv_sec, offset_last_rx_packet.tv_usec);
-
       last_packet_was_rx = timeval_subtract(&offset_tx_rx,&offset_last_tx_packet,&offset_last_rx_packet);
+
       if (last_packet_was_rx) {
         LOG_D(ENB_APP, "last_packet_was_rx\n");
         we_are_too_late = timeval_subtract(&offset,&offset_last_rx_packet,&packet->time_relative_to_last_received_packet);
@@ -129,30 +131,32 @@ void et_scenario_schedule_tx_packet(et_packet_t * packet)
         we_are_too_late = timeval_subtract(&offset,&offset_last_tx_packet,&packet->time_relative_to_last_sent_packet);
         LOG_D(ENB_APP, "we_are_too_late=%d, offset=%ld.%06d\n", we_are_too_late, offset.tv_sec, offset.tv_usec);
       }
-      if ((0 == we_are_too_late) && (0 == g_max_speed)){
+
+      if ((0 == we_are_too_late) && (0 == g_max_speed)) {
         // set timer
-        if ((offset.tv_sec <= 0) || (offset.tv_usec <= 0)){
+        if ((offset.tv_sec <= 0) || (offset.tv_usec <= 0)) {
           offset.tv_sec = -offset.tv_sec;
           offset.tv_usec = -offset.tv_usec;
         }
 
         LOG_D(ENB_APP, "Send packet num %u original frame number %u in %ld.%06d sec\n",
-            packet->packet_number, packet->original_frame_number, offset.tv_sec, offset.tv_usec);
-
+              packet->packet_number, packet->original_frame_number, offset.tv_sec, offset.tv_usec);
         packet->status = ET_PACKET_STATUS_SCHEDULED_FOR_SENDING;
+
         if (timer_setup (offset.tv_sec, offset.tv_usec, TASK_S1AP, INSTANCE_DEFAULT, TIMER_ONE_SHOT,packet, &packet->timer_id) < 0) {
           AssertFatal(0, " Can not start TX event timer\n");
         }
+
         g_scenario->timer_count++;
         // Done g_fsm_state = ET_FSM_STATE_WAITING_TX_EVENT;
       } else {
         // send immediately
         AssertFatal(0 == gettimeofday(&packet->timestamp_packet, NULL), "gettimeofday() Failed");
         original_frame_number = packet->original_frame_number;
+
         do {
           g_scenario->time_last_tx_packet.tv_sec  = packet->timestamp_packet.tv_sec;
           g_scenario->time_last_tx_packet.tv_usec = packet->timestamp_packet.tv_usec;
-
           LOG_D(ENB_APP, "Sending packet num %d original frame number %u immediately\n",packet->packet_number, packet->original_frame_number);
           et_s1ap_eNB_itti_send_sctp_data_req(
             packet->enb_instance,
@@ -164,13 +168,17 @@ void et_scenario_schedule_tx_packet(et_packet_t * packet)
           g_scenario->next_packet = g_scenario->next_packet->next;
           packet = packet->next;
         } while ((NULL != packet) && (packet->original_frame_number == original_frame_number));
+
         g_fsm_state = ET_FSM_STATE_RUNNING;
       }
+
       break;
+
     case SCTP_CID_INIT:
     case SCTP_CID_INIT_ACK:
       AssertFatal(0, "Invalid case TX packet SCTP_CID_INIT or SCTP_CID_INIT_ACK");
       break;
+
     default:
       AssertFatal(0, "Invalid case TX packet SCTP_CID %d", packet->sctp_hdr.chunk_type);
   }
@@ -178,23 +186,22 @@ void et_scenario_schedule_tx_packet(et_packet_t * packet)
 //------------------------------------------------------------------------------
 et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event)
 {
-
-  switch (event.code){
+  switch (event.code) {
     case ET_EVENT_TICK:
       while (NULL != g_scenario->next_packet) {
         LOG_D(ENB_APP, "EVENT_TICK: Considering packet num %d original frame number %u\n", g_scenario->next_packet->packet_number, g_scenario->next_packet->original_frame_number);
+
         switch (g_scenario->next_packet->sctp_hdr.chunk_type) {
           case SCTP_CID_DATA :
+
             // no init in this scenario, may be sub-scenario
             if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
               if (g_scenario->next_packet->status == ET_PACKET_STATUS_NONE) {
                 et_scenario_schedule_tx_packet(g_scenario->next_packet);
                 pthread_mutex_unlock(&g_fsm_lock);
-
                 et_event_t continue_event;
                 continue_event.code = ET_EVENT_TICK;
                 et_scenario_fsm_notify_event(continue_event);
-
                 return g_fsm_state;
               } else if (g_scenario->next_packet->status != ET_PACKET_STATUS_SCHEDULED_FOR_SENDING) {
                 AssertFatal(0, "Invalid packet status %d", g_scenario->next_packet->status);
@@ -202,7 +209,6 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event)
             } else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
               if (g_scenario->next_packet->status == ET_PACKET_STATUS_RECEIVED) {
                 g_scenario->next_packet    = g_scenario->next_packet->next;
-
               } else if (g_scenario->next_packet->status == ET_PACKET_STATUS_NONE) {
                 et_scenario_wait_rx_packet(g_scenario->next_packet);
                 pthread_mutex_unlock(&g_fsm_lock);
@@ -213,6 +219,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event)
             } else {
               AssertFatal(0, "Invalid packet action %d", g_scenario->next_packet->action);
             }
+
             break;
 
           case SCTP_CID_INIT:
@@ -224,8 +231,8 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event)
           case SCTP_CID_ECN_ECNE:
           case SCTP_CID_ECN_CWR:
             LOG_D(ENB_APP, "EVENT_TICK: Ignoring packet num %d SCTP CID %s\n",
-                g_scenario->next_packet->packet_number,
-                et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
+                  g_scenario->next_packet->packet_number,
+                  et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
             g_scenario->next_packet->status = ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT;
             g_scenario->next_packet = g_scenario->next_packet->next;
             break;
@@ -236,20 +243,22 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event)
           case SCTP_CID_ERROR:
           case SCTP_CID_SHUTDOWN_COMPLETE:
             AssertFatal(0, "The scenario should be cleaned (packet %s cannot be processed at this time)",
-                et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
+                        et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
             break;
 
           default:
             LOG_D(ENB_APP, "EVENT_TICK: Ignoring packet num %d SCTP CID %s\n",
-                g_scenario->next_packet->packet_number,
-                et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
+                  g_scenario->next_packet->packet_number,
+                  et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
             g_scenario->next_packet->status = ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT;
             g_scenario->next_packet = g_scenario->next_packet->next;
         }
       }
+
       fprintf(stderr, "No Packet found in this scenario: %s\n", g_scenario->name);
       g_fsm_state = ET_FSM_STATE_NULL;
       pthread_mutex_unlock(&g_fsm_lock);
+
       if (0 == g_scenario->timer_count) {
         fprintf(stderr, "End of scenario: %s\n", g_scenario->name);
         fflush(stderr);
@@ -257,21 +266,27 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event)
         return 0;
         //exit(0);
       }
+
       fprintf(stderr, "Remaining timers running: %d\n", g_scenario->timer_count);
       return g_fsm_state;
       break;
+
     case ET_EVENT_RX_PACKET_TIME_OUT:
       AssertFatal(0, "Event ET_EVENT_RX_PACKET_TIME_OUT not handled in FSM state ET_FSM_STATE_RUNNING");
       break;
+
     case ET_EVENT_TX_TIMED_PACKET:
       AssertFatal(0, "Event ET_EVENT_TX_TIMED_PACKET not handled in FSM state ET_FSM_STATE_RUNNING");
       break;
+
     case ET_EVENT_RX_S1AP:
       et_s1ap_process_rx_packet(&event.u.s1ap_data_ind);
       break;
+
     default:
       AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_RUNNING", event.code);
   }
+
   pthread_mutex_unlock(&g_fsm_lock);
   return 0;
 }
@@ -283,7 +298,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_tx(et_event_t event)
   int           original_frame_number = -1;
   et_packet_t  *packet                = NULL;
 
-  switch (event.code){
+  switch (event.code) {
     case ET_EVENT_TICK:
       fprintf(stdout, "EVENT_TICK: waiting for tx event\n");
       break;
@@ -296,23 +311,23 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_tx(et_event_t event)
       // send immediately
       packet = event.u.tx_timed_packet;
       AssertFatal(0 == gettimeofday(&packet->timestamp_packet, NULL), "gettimeofday() Failed");
-
       original_frame_number = packet->original_frame_number;
+
       do {
         g_scenario->time_last_tx_packet.tv_sec  = packet->timestamp_packet.tv_sec;
         g_scenario->time_last_tx_packet.tv_usec = packet->timestamp_packet.tv_usec;
-
         LOG_D(ENB_APP, "Sending packet num %d original frame number %u immediately\n",packet->packet_number, packet->original_frame_number);
         et_s1ap_eNB_itti_send_sctp_data_req(
-            packet->enb_instance,
-            packet->sctp_hdr.u.data_hdr.assoc_id,
-            packet->sctp_hdr.u.data_hdr.payload.binary_stream,
-            packet->sctp_hdr.u.data_hdr.payload.binary_stream_allocated_size,
-            packet->sctp_hdr.u.data_hdr.stream);
+          packet->enb_instance,
+          packet->sctp_hdr.u.data_hdr.assoc_id,
+          packet->sctp_hdr.u.data_hdr.payload.binary_stream,
+          packet->sctp_hdr.u.data_hdr.payload.binary_stream_allocated_size,
+          packet->sctp_hdr.u.data_hdr.stream);
         packet->status = ET_PACKET_STATUS_SENT;
         packet = packet->next;
         g_scenario->next_packet    = packet;
       } while ( (NULL != packet) && (packet->original_frame_number == original_frame_number));
+
       g_fsm_state = ET_FSM_STATE_RUNNING;
       break;
 
@@ -320,6 +335,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_tx(et_event_t event)
     default:
       AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_WAITING_TX", event.code);
   }
+
   pthread_mutex_unlock(&g_fsm_lock);
   return 0;
 }
@@ -328,7 +344,8 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_tx(et_event_t event)
 et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_rx(et_event_t event)
 {
   int rv = 0;
-  switch (event.code){
+
+  switch (event.code) {
     case ET_EVENT_TICK:
       fprintf(stdout, "EVENT_TICK: waiting for rx event\n");
       break;
@@ -341,16 +358,19 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_rx(et_event_t event)
 
     case ET_EVENT_RX_S1AP:
       rv = et_s1ap_process_rx_packet(&event.u.s1ap_data_ind);
+
       // waited packet
       if (rv == 0) {
         g_fsm_state = ET_FSM_STATE_RUNNING;
       }
+
       break;
 
     case ET_EVENT_TX_TIMED_PACKET:
     default:
       AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_WAITING_RX", event.code);
   }
+
   pthread_mutex_unlock(&g_fsm_lock);
   return 0;
 }
@@ -358,8 +378,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_rx(et_event_t event)
 //------------------------------------------------------------------------------
 et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t event)
 {
-
-  switch (event.code){
+  switch (event.code) {
     case ET_EVENT_TICK:
       break;
 
@@ -370,22 +389,20 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
       while (NULL != g_scenario->next_packet) {
         switch (g_scenario->next_packet->sctp_hdr.chunk_type) {
           case SCTP_CID_DATA :
+
             // no init in this scenario, may be sub-scenario
             if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
               et_scenario_schedule_tx_packet(g_scenario->next_packet);
               pthread_mutex_unlock(&g_fsm_lock);
-
               et_event_t continue_event;
               continue_event.code = ET_EVENT_TICK;
               et_scenario_fsm_notify_event(continue_event);
-
               return g_fsm_state;
             } else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
               if (g_scenario->next_packet->status == ET_PACKET_STATUS_RECEIVED) {
                 g_scenario->last_rx_packet = g_scenario->next_packet;
                 g_scenario->time_last_rx_packet = g_scenario->last_rx_packet->timestamp_packet;
                 g_scenario->next_packet    = g_scenario->next_packet->next;
-
               } else if (g_scenario->next_packet->status == ET_PACKET_STATUS_NONE) {
                 et_scenario_wait_rx_packet(g_scenario->next_packet);
                 pthread_mutex_unlock(&g_fsm_lock);
@@ -396,7 +413,8 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
             } else {
               AssertFatal(0, "Invalid packet action %d", g_scenario->next_packet->action);
             }
-             break;
+
+            break;
 
           case SCTP_CID_INIT:
           case SCTP_CID_INIT_ACK:
@@ -416,7 +434,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
           case SCTP_CID_ERROR:
           case SCTP_CID_SHUTDOWN_COMPLETE:
             AssertFatal(0, "The scenario should be cleaned (packet %s cannot be processed at this time)",
-                et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
+                        et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
             break;
 
           default:
@@ -424,15 +442,18 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
             g_scenario->next_packet = g_scenario->next_packet->next;
         }
       }
+
       fprintf(stderr, "No Packet found in this scenario: %s\n", g_scenario->name);
       g_fsm_state = ET_FSM_STATE_NULL;
       pthread_mutex_unlock(&g_fsm_lock);
+
       if (0 == g_scenario->timer_count) {
         fprintf(stderr, "End of scenario: %s\n", g_scenario->name);
         fflush(stderr);
         fflush(stdout);
         exit(0);
       }
+
       fprintf(stderr, "Remaining timers running: %d\n", g_scenario->timer_count);
       return g_fsm_state;
       break;
@@ -440,13 +461,14 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
     default:
       AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_CONNECTING_S1C", event.code);
   }
+
   pthread_mutex_unlock(&g_fsm_lock);
   return 0;
 }
 //------------------------------------------------------------------------------
 et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
 {
-  switch (event.code){
+  switch (event.code) {
     case ET_EVENT_TICK:
       break;
 
@@ -459,24 +481,21 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
 
       while (NULL != g_scenario->next_packet) {
         switch (g_scenario->next_packet->sctp_hdr.chunk_type) {
-
           case SCTP_CID_DATA :
+
             // no init in this scenario, may be sub-scenario, ...
             if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
               et_scenario_schedule_tx_packet(g_scenario->next_packet);
               pthread_mutex_unlock(&g_fsm_lock);
-
               et_event_t continue_event;
               continue_event.code = ET_EVENT_TICK;
               et_scenario_fsm_notify_event(continue_event);
-
               return g_fsm_state;
             } else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
               if (g_scenario->next_packet->status == ET_PACKET_STATUS_RECEIVED) {
                 g_scenario->last_rx_packet = g_scenario->next_packet;
                 g_scenario->time_last_rx_packet = g_scenario->last_rx_packet->timestamp_packet;
                 g_scenario->next_packet    = g_scenario->next_packet->next;
-
               } else if (g_scenario->next_packet->status == ET_PACKET_STATUS_NONE) {
                 et_scenario_wait_rx_packet(g_scenario->next_packet);
                 pthread_mutex_unlock(&g_fsm_lock);
@@ -487,6 +506,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
             } else {
               AssertFatal(0, "Invalid packet action %d", g_scenario->next_packet->action);
             }
+
             break;
 
           case SCTP_CID_INIT:
@@ -519,7 +539,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
           case SCTP_CID_ERROR:
           case SCTP_CID_SHUTDOWN_COMPLETE:
             AssertFatal(0, "The scenario should be cleaned (packet %s cannot be processed at this time)",
-                et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
+                        et_chunk_type_cid2str(g_scenario->next_packet->sctp_hdr.chunk_type));
             break;
 
           default:
@@ -527,6 +547,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
             g_scenario->next_packet = g_scenario->next_packet->next;
         }
       }
+
       fprintf(stderr, "No Useful packet found in this scenario: %s\n", g_scenario->name);
       g_fsm_state = ET_FSM_STATE_NULL;
       pthread_mutex_unlock(&g_fsm_lock);
@@ -536,6 +557,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
     default:
       AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_NULL", event.code);
   }
+
   return 0;
 }
 
@@ -543,17 +565,23 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
 et_fsm_state_t et_scenario_fsm_notify_event(et_event_t event)
 {
   AssertFatal((event.code >= ET_EVENT_START) && (event.code < ET_EVENT_END), "Unknown et_event_t.code %d", event.code);
-
   pthread_mutex_lock(&g_fsm_lock);
-  switch (g_fsm_state){
+
+  switch (g_fsm_state) {
     case ET_FSM_STATE_NULL: return et_scenario_fsm_notify_event_state_null(event); break;
+
     case ET_FSM_STATE_CONNECTING_S1C: return et_scenario_fsm_notify_event_state_connecting_s1c(event); break;
+
     case ET_FSM_STATE_WAITING_TX_EVENT: return et_scenario_fsm_notify_event_state_waiting_tx(event); break;
+
     case ET_FSM_STATE_WAITING_RX_EVENT: return et_scenario_fsm_notify_event_state_waiting_rx(event); break;
+
     case ET_FSM_STATE_RUNNING: return et_scenario_fsm_notify_event_state_running(event); break;
+
     default:
       AssertFatal(0, "Case fsm_state %d not handled", g_fsm_state);
   }
+
   pthread_mutex_unlock(&g_fsm_lock);
   return g_fsm_state;
 }
diff --git a/openair3/TEST/EPC_TEST/play_scenario_s1ap.c b/openair3/TEST/EPC_TEST/play_scenario_s1ap.c
index 95df0fc306c0bf2ee72ca6275da11363166f693e..aca2b66bca32f9b9683b5d3ba04f068b30fc47b2 100644
--- a/openair3/TEST/EPC_TEST/play_scenario_s1ap.c
+++ b/openair3/TEST/EPC_TEST/play_scenario_s1ap.c
@@ -60,6 +60,7 @@ int et_s1ap_eNB_compare_assoc_id(
     if (p1->cnx_id < p2->cnx_id) {
       return -1;
     }
+
     if (p1->cnx_id > p2->cnx_id) {
       return 1;
     }
@@ -67,6 +68,7 @@ int et_s1ap_eNB_compare_assoc_id(
     if (p1->assoc_id < p2->assoc_id) {
       return -1;
     }
+
     if (p1->assoc_id > p2->assoc_id) {
       return 1;
     }
@@ -82,16 +84,12 @@ uint32_t et_s1ap_generate_eNB_id(void)
   char     hostname[50];
   int      ret;
   uint32_t eNB_id;
-
   /* Retrieve the host name */
   ret = gethostname(hostname, sizeof(hostname));
   DevAssert(ret == 0);
-
   out = crypt(hostname, "eurecom");
   DevAssert(out != NULL);
-
   eNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]);
-
   return eNB_id;
 }
 //------------------------------------------------------------------------------
@@ -111,7 +109,6 @@ void et_s1ap_eNB_prepare_internal_data(void)
 void et_s1ap_eNB_insert_new_instance(s1ap_eNB_instance_t *new_instance_p)
 {
   DevAssert(new_instance_p != NULL);
-
   STAILQ_INSERT_TAIL(&s1ap_eNB_internal_data.s1ap_eNB_instances_head,
                      new_instance_p, s1ap_eNB_entries);
 }
@@ -123,9 +120,7 @@ struct s1ap_eNB_mme_data_s *et_s1ap_eNB_get_MME(
 {
   struct s1ap_eNB_mme_data_s  temp;
   struct s1ap_eNB_mme_data_s *found;
-
   memset(&temp, 0, sizeof(struct s1ap_eNB_mme_data_s));
-
   temp.assoc_id = assoc_id;
   temp.cnx_id   = cnx_id;
 
@@ -149,7 +144,6 @@ struct s1ap_eNB_mme_data_s *et_s1ap_eNB_get_MME(
 s1ap_eNB_instance_t *et_s1ap_eNB_get_instance(instance_t instance)
 {
   s1ap_eNB_instance_t *temp = NULL;
-
   STAILQ_FOREACH(temp, &s1ap_eNB_internal_data.s1ap_eNB_instances_head,
                  s1ap_eNB_entries) {
     if (temp->instance == instance) {
@@ -157,208 +151,210 @@ s1ap_eNB_instance_t *et_s1ap_eNB_get_instance(instance_t instance)
       return temp;
     }
   }
-
   return NULL;
 }
 //------------------------------------------------------------------------------
 void et_s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
-                                      uint32_t buffer_length, uint16_t stream)
+    uint32_t buffer_length, uint16_t stream)
 {
   MessageDef      *message_p;
   sctp_data_req_t *sctp_data_req;
-
   message_p = itti_alloc_new_message(TASK_S1AP, SCTP_DATA_REQ);
-
   sctp_data_req = &message_p->ittiMsg.sctp_data_req;
-
   sctp_data_req->assoc_id      = assoc_id;
   sctp_data_req->buffer        = buffer;
   sctp_data_req->buffer_length = buffer_length;
   sctp_data_req->stream        = stream;
-
   itti_send_msg_to_task(TASK_SCTP, instance, message_p);
 }
 //------------------------------------------------------------------------------
-int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packet_t * const rx_packet)
+int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t *const spacket, et_packet_t *const rx_packet)
 {
   S1ap_MME_UE_S1AP_ID_t scenario_mme_ue_s1ap_id = 0;
   S1ap_MME_UE_S1AP_ID_t rx_mme_ue_s1ap_id       = 0;
   S1AP_PDU_PR           present;
-
   present = rx_packet->sctp_hdr.u.data_hdr.payload.pdu.present;
 
   switch (rx_packet->sctp_hdr.u.data_hdr.payload.message.procedureCode) {
-    case  S1ap_ProcedureCode_id_HandoverPreparation:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_HandoverPreparation:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverRequiredIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverRequiredIEs.mme_ue_s1ap_id;
       } else {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverCommandIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverCommandIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_HandoverResourceAllocation:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_HandoverResourceAllocation:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverRequestIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_successfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverRequestAcknowledgeIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverRequestAcknowledgeIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_unsuccessfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_unsuccessfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverFailureIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverFailureIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_HandoverNotification:
+    case  S1AP_ProcedureCode_id_HandoverNotification:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverNotifyIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverNotifyIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_PathSwitchRequest:
+    case  S1AP_ProcedureCode_id_PathSwitchRequest:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_PathSwitchRequestIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_PathSwitchRequestIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_HandoverCancel:
+    case  S1AP_ProcedureCode_id_HandoverCancel:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverCancelIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_HandoverCancelIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_E_RABSetup:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_E_RABSetup:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABSetupRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABSetupRequestIEs.mme_ue_s1ap_id;
       } else  {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABSetupResponseIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABSetupResponseIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_E_RABModify:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_E_RABModify:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABModifyRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABModifyRequestIEs.mme_ue_s1ap_id;
       } else  {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABModifyResponseIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABModifyResponseIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_E_RABRelease:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_E_RABRelease:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABReleaseCommandIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABReleaseCommandIEs.mme_ue_s1ap_id;
       } else  {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABReleaseResponseIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABReleaseResponseIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_E_RABReleaseIndication:
+    case  S1AP_ProcedureCode_id_E_RABReleaseIndication:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABReleaseIndicationIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_E_RABReleaseIndicationIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_InitialContextSetup:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_InitialContextSetup:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_InitialContextSetupRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_InitialContextSetupRequestIEs.mme_ue_s1ap_id;
       } else  {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_InitialContextSetupResponseIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_InitialContextSetupResponseIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_Paging:
+    case  S1AP_ProcedureCode_id_Paging:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_PagingIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_PagingIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_downlinkNASTransport:
+    case  S1AP_ProcedureCode_id_downlinkNASTransport:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkNASTransportIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkNASTransportIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_initialUEMessage:
+    case  S1AP_ProcedureCode_id_initialUEMessage:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_InitialUEMessageIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_InitialUEMessageIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_uplinkNASTransport:
+    case  S1AP_ProcedureCode_id_uplinkNASTransport:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkNASTransportIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkNASTransportIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_Reset:
+    case  S1AP_ProcedureCode_id_Reset:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ResetIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ResetIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_ErrorIndication:
+    case  S1AP_ProcedureCode_id_ErrorIndication:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ErrorIndicationIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ErrorIndicationIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_NASNonDeliveryIndication:
+    case  S1AP_ProcedureCode_id_NASNonDeliveryIndication:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_NASNonDeliveryIndication_IEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_NASNonDeliveryIndication_IEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_S1Setup:
-      /*if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_S1Setup:
+      /*if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_S1SetupRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_S1SetupRequestIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_successfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_S1SetupResponseIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_S1SetupResponseIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_unsuccessfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_unsuccessfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_S1SetupFailureIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_S1SetupFailureIEs.mme_ue_s1ap_id;
       }*/
       break;
 
-    case  S1ap_ProcedureCode_id_UEContextReleaseRequest:
+    case  S1AP_ProcedureCode_id_UEContextReleaseRequest:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseRequestIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseRequestIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_DownlinkS1cdma2000tunneling:
+    case  S1AP_ProcedureCode_id_DownlinkS1cdma2000tunneling:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkS1cdma2000tunnelingIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkS1cdma2000tunnelingIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_UplinkS1cdma2000tunneling:
+    case  S1AP_ProcedureCode_id_UplinkS1cdma2000tunneling:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkS1cdma2000tunnelingIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkS1cdma2000tunnelingIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_UEContextModification:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_UEContextModification:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextModificationRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextModificationRequestIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_successfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextModificationResponseIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextModificationResponseIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_unsuccessfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_unsuccessfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextModificationFailureIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextModificationFailureIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_UECapabilityInfoIndication:
+    case  S1AP_ProcedureCode_id_UECapabilityInfoIndication:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UECapabilityInfoIndicationIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UECapabilityInfoIndicationIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_UEContextRelease:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_UEContextRelease:
+      if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         switch (rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseCommandIEs.uE_S1AP_IDs.present) {
           case S1ap_UE_S1AP_IDs_PR_uE_S1AP_ID_pair:
             rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseCommandIEs.uE_S1AP_IDs.choice.uE_S1AP_ID_pair.mME_UE_S1AP_ID;
             scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseCommandIEs.uE_S1AP_IDs.choice.uE_S1AP_ID_pair.mME_UE_S1AP_ID;
             break;
+
           case S1ap_UE_S1AP_IDs_PR_mME_UE_S1AP_ID:
             rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseCommandIEs.uE_S1AP_IDs.choice.mME_UE_S1AP_ID;
             scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseCommandIEs.uE_S1AP_IDs.choice.mME_UE_S1AP_ID;
@@ -368,38 +364,39 @@ int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packe
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseCompleteIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UEContextReleaseCompleteIEs.mme_ue_s1ap_id;
       }
+
       break;
 
-    case  S1ap_ProcedureCode_id_eNBStatusTransfer:
+    case  S1AP_ProcedureCode_id_eNBStatusTransfer:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBStatusTransferIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBStatusTransferIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_MMEStatusTransfer:
+    case  S1AP_ProcedureCode_id_MMEStatusTransfer:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEStatusTransferIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEStatusTransferIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_DeactivateTrace:
+    case  S1AP_ProcedureCode_id_DeactivateTrace:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DeactivateTraceIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DeactivateTraceIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_TraceStart:
+    case  S1AP_ProcedureCode_id_TraceStart:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_TraceStartIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_TraceStartIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_TraceFailureIndication:
+    case  S1AP_ProcedureCode_id_TraceFailureIndication:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_TraceFailureIndicationIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_TraceFailureIndicationIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_ENBConfigurationUpdate:
-      /*if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_ENBConfigurationUpdate:
+      /*if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBConfigurationUpdateIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBConfigurationUpdateIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_successfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBConfigurationUpdateAcknowledgeIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBConfigurationUpdateAcknowledgeIEs.mme_ue_s1ap_id;
       } else {
@@ -408,11 +405,11 @@ int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packe
       }*/
       break;
 
-    case  S1ap_ProcedureCode_id_MMEConfigurationUpdate:
-      /*if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_MMEConfigurationUpdate:
+      /*if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEConfigurationUpdateIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEConfigurationUpdateIEs.mme_ue_s1ap_id;
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
+      } else if (present == S1AP_S1AP_PDU_PR_successfulOutcome) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEConfigurationUpdateAcknowledgeIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEConfigurationUpdateAcknowledgeIEs.mme_ue_s1ap_id;
       } else {
@@ -421,33 +418,33 @@ int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packe
       }*/
       break;
 
-    case  S1ap_ProcedureCode_id_LocationReportingControl:
+    case  S1AP_ProcedureCode_id_LocationReportingControl:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_LocationReportingControlIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_LocationReportingControlIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_LocationReportingFailureIndication:
+    case  S1AP_ProcedureCode_id_LocationReportingFailureIndication:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_LocationReportingFailureIndicationIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_LocationReportingFailureIndicationIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_LocationReport:
+    case  S1AP_ProcedureCode_id_LocationReport:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_LocationReportIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_LocationReportIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_OverloadStart:
+    case  S1AP_ProcedureCode_id_OverloadStart:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_OverloadStartIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_OverloadStartIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_OverloadStop:
+    case  S1AP_ProcedureCode_id_OverloadStop:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_OverloadStopIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_OverloadStopIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_WriteReplaceWarning:
-      /*if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_WriteReplaceWarning:
+      /*if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_WriteReplaceWarningRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_WriteReplaceWarningRequestIEs.mme_ue_s1ap_id;
       } else  {
@@ -456,29 +453,29 @@ int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packe
       }*/
       break;
 
-    case  S1ap_ProcedureCode_id_eNBDirectInformationTransfer:
+    case  S1AP_ProcedureCode_id_eNBDirectInformationTransfer:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBDirectInformationTransferIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_ENBDirectInformationTransferIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_MMEDirectInformationTransfer:
+    case  S1AP_ProcedureCode_id_MMEDirectInformationTransfer:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEDirectInformationTransferIEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_MMEDirectInformationTransferIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_PrivateMessage:
-    case  S1ap_ProcedureCode_id_eNBConfigurationTransfer:
-    case  S1ap_ProcedureCode_id_MMEConfigurationTransfer:
+    case  S1AP_ProcedureCode_id_PrivateMessage:
+    case  S1AP_ProcedureCode_id_eNBConfigurationTransfer:
+    case  S1AP_ProcedureCode_id_MMEConfigurationTransfer:
       AssertFatal(0, "TODO");
       break;
 
-    case  S1ap_ProcedureCode_id_CellTrafficTrace:
+    case  S1AP_ProcedureCode_id_CellTrafficTrace:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_CellTrafficTraceIEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_CellTrafficTraceIEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_Kill:
-      /*if (present == S1AP_PDU_PR_initiatingMessage) {
+    case  S1AP_ProcedureCode_id_Kill:
+      /*if (present == S1AP_S1AP_PDU_PR_initiatingMessage) {
         rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_KillRequestIEs.mme_ue_s1ap_id;
         scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_KillRequestIEs.mme_ue_s1ap_id;
       } else  {
@@ -487,22 +484,22 @@ int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packe
       }*/
       break;
 
-    case  S1ap_ProcedureCode_id_downlinkUEAssociatedLPPaTransport:
+    case  S1AP_ProcedureCode_id_downlinkUEAssociatedLPPaTransport:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_uplinkUEAssociatedLPPaTransport:
+    case  S1AP_ProcedureCode_id_uplinkUEAssociatedLPPaTransport:
       rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_downlinkNonUEAssociatedLPPaTransport:
+    case  S1AP_ProcedureCode_id_downlinkNonUEAssociatedLPPaTransport:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkNonUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_DownlinkNonUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       break;
 
-    case  S1ap_ProcedureCode_id_uplinkNonUEAssociatedLPPaTransport:
+    case  S1AP_ProcedureCode_id_uplinkNonUEAssociatedLPPaTransport:
       //rx_mme_ue_s1ap_id       = rx_packet->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkNonUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       //scenario_mme_ue_s1ap_id = spacket->sctp_hdr.u.data_hdr.payload.message.msg.s1ap_UplinkNonUEAssociatedLPPaTransport_IEs.mme_ue_s1ap_id;
       break;
@@ -510,58 +507,83 @@ int et_handle_s1ap_mismatch_mme_ue_s1ap_id(et_packet_t * const spacket, et_packe
     default:
       AssertFatal(0, "Unknown procedure code %ld", rx_packet->sctp_hdr.u.data_hdr.payload.message.procedureCode);
   }
+
   if (scenario_mme_ue_s1ap_id != rx_mme_ue_s1ap_id) {
     S1AP_DEBUG("%s() Updating  mme_ue_s1ap_id %u -> %u \n", __FUNCTION__, scenario_mme_ue_s1ap_id, rx_mme_ue_s1ap_id);
-    et_packet_t * p = spacket;
+    et_packet_t *p = spacket;
+
     while (p) {
       et_s1ap_update_mme_ue_s1ap_id(p, scenario_mme_ue_s1ap_id, rx_mme_ue_s1ap_id);
       p = p->next;
     }
+
     return 0;
   }
+
   return 1;
 }
 //------------------------------------------------------------------------------
-asn_comp_rval_t * et_s1ap_is_matching(et_s1ap_t * const s1ap1, et_s1ap_t * const s1ap2, const uint32_t constraints)
+asn_comp_rval_t *et_s1ap_is_matching(et_s1ap_t *const s1ap1, et_s1ap_t *const s1ap2, const uint32_t constraints)
 {
+#if 1
+
+  if (Choice_compare(&asn_DEF_S1AP_S1AP_PDU, &s1ap1->pdu, &s1ap2->pdu) != 0) {
+    return 0;
+  }
+
+#else
   asn_comp_rval_t *rv = NULL;
+
   if (s1ap1->pdu.present != s1ap2->pdu.present)  {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_PRESENT; return rv;}
+
   switch (s1ap1->pdu.present) {
-    case  S1AP_PDU_PR_NOTHING:
+    case  S1AP_S1AP_PDU_PR_NOTHING:
       break;
-    case  S1AP_PDU_PR_initiatingMessage:
+
+    case  S1AP_S1AP_PDU_PR_initiatingMessage:
       if (s1ap1->pdu.choice.initiatingMessage.procedureCode != s1ap2->pdu.choice.initiatingMessage.procedureCode)
-        {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE; return rv;}
+      {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE; return rv;}
+
       if (s1ap1->pdu.choice.initiatingMessage.criticality != s1ap2->pdu.choice.initiatingMessage.criticality)
-        {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY; return rv;}
+      {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY; return rv;}
+
       break;
-    case  S1AP_PDU_PR_successfulOutcome:
+
+    case  S1AP_S1AP_PDU_PR_successfulOutcome:
       if (s1ap1->pdu.choice.successfulOutcome.procedureCode != s1ap2->pdu.choice.successfulOutcome.procedureCode)
-        {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE; return rv;}
+      {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE; return rv;}
+
       if (s1ap1->pdu.choice.successfulOutcome.criticality != s1ap2->pdu.choice.successfulOutcome.criticality)
-        {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY; return rv;}
+      {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY; return rv;}
+
       break;
-    case  S1AP_PDU_PR_unsuccessfulOutcome:
+
+    case  S1AP_S1AP_PDU_PR_unsuccessfulOutcome:
       if (s1ap1->pdu.choice.unsuccessfulOutcome.procedureCode != s1ap2->pdu.choice.unsuccessfulOutcome.procedureCode)
-        {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE; return rv;}
+      {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE; return rv;}
+
       if (s1ap1->pdu.choice.unsuccessfulOutcome.criticality != s1ap2->pdu.choice.unsuccessfulOutcome.criticality)
-        {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY; return rv;}
+      {rv  = calloc(1, sizeof(asn_comp_rval_t)); rv->err_code = ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY; return rv;}
+
       break;
+
     default:
       AssertFatal(0, "Unknown pdu.present %d", s1ap1->pdu.present);
   }
 
   if (s1ap1->binary_stream_allocated_size == s1ap2->binary_stream_allocated_size) {
-    if (memcmp((void*)s1ap1->binary_stream, (void*)s1ap2->binary_stream, s1ap1->binary_stream_allocated_size) ==  0) return NULL;
+    if (memcmp((void *)s1ap1->binary_stream, (void *)s1ap2->binary_stream, s1ap1->binary_stream_allocated_size) ==  0) return NULL;
   }
+
   // if no matching, may be the scenario need minor corrections (same enb_ue_s1ap_id but need to update mme_ue_s1ap_id)
   return et_s1ap_ies_is_matching(s1ap1->pdu.present, &s1ap1->message, &s1ap2->message, constraints);
+#endif
 }
 
 //------------------------------------------------------------------------------
-et_packet_t* et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t * const s1ap_data_ind)
+et_packet_t *et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t *const s1ap_data_ind)
 {
-  et_packet_t     * packet    = NULL;
+  et_packet_t      *packet    = NULL;
   AssertFatal (NULL != s1ap_data_ind, "Bad parameter sctp_data_ind\n");
   packet = calloc(1, sizeof(*packet));
   packet->action                                        = ET_PACKET_ACTION_S1C_NULL;
@@ -577,7 +599,7 @@ et_packet_t* et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t * const
   //packet->ip_hdr;
   // keep in mind: allocated buffer: sctp_datahdr.payload.binary_stream
   packet->sctp_hdr.chunk_type = SCTP_CID_DATA;
-  memcpy((void*)&packet->sctp_hdr.u.data_hdr, (void*)&s1ap_data_ind->sctp_datahdr, sizeof(packet->sctp_hdr));
+  memcpy((void *)&packet->sctp_hdr.u.data_hdr, (void *)&s1ap_data_ind->sctp_datahdr, sizeof(packet->sctp_hdr));
   //packet->next = NULL;
   packet->status = ET_PACKET_STATUS_RECEIVED;
   //packet->timer_id = 0;
@@ -588,16 +610,15 @@ et_packet_t* et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t * const
 
 //------------------------------------------------------------------------------
 // return 0 if packet was waited
-int et_scenario_set_packet_received(et_packet_t * const packet)
+int et_scenario_set_packet_received(et_packet_t *const packet)
 {
-  et_packet_t * p = NULL;
+  et_packet_t *p = NULL;
   int           rc = 0;
-
   packet->status = ET_PACKET_STATUS_RECEIVED;
   S1AP_DEBUG("Packet received:          num %u  | original frame number %u \n", packet->packet_number, packet->original_frame_number);
   S1AP_DEBUG("Last Packet received:     num %u  | original frame number %u \n", g_scenario->last_rx_packet->packet_number, g_scenario->last_rx_packet->original_frame_number);
-
   p = g_scenario->last_rx_packet;
+
   while (NULL != p) {
     if (ET_PACKET_ACTION_S1C_RECEIVE == p->action) {
       if ((ET_PACKET_STATUS_RECEIVED == p->status) || (ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT == p->status)) {
@@ -610,6 +631,7 @@ int et_scenario_set_packet_received(et_packet_t * const packet)
         break;
       }
     }
+
     p = p->next;
   }
 
@@ -619,11 +641,12 @@ int et_scenario_set_packet_received(et_packet_t * const packet)
     g_scenario->timer_count--;
     return rc;
   }
+
   return 1;
 }
 
 //------------------------------------------------------------------------------
-int et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t * const s1ap_data_ind)
+int et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t *const s1ap_data_ind)
 {
   et_packet_t      *packet       = NULL;
   et_packet_t      *rx_packet    = NULL;
@@ -631,37 +654,44 @@ int et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t * const s1ap_data_ind)
   asn_comp_rval_t  *comp_results = NULL;
   asn_comp_rval_t  *comp_results2 = NULL;
   unsigned char     error_code   = 0;
-
   AssertFatal (NULL != s1ap_data_ind, "Bad parameter sctp_data_ind\n");
   rx_packet = et_build_packet_from_s1ap_data_ind(s1ap_data_ind);
 
   if (NULL == g_scenario->last_rx_packet) {
     packet = g_scenario->list_packet;
+
     while (NULL != packet) {
       if (packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
         if ((ET_PACKET_STATUS_RECEIVED == packet->status) || (ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT == packet->status)) {
           g_scenario->last_rx_packet = packet;
+
           if  (ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT != packet->status) {
             g_scenario->time_last_rx_packet.tv_sec  = packet->timestamp_packet.tv_sec;
             g_scenario->time_last_rx_packet.tv_usec = packet->timestamp_packet.tv_usec;
           }
+
           S1AP_DEBUG("Set Last Packet received: num %u  | original frame number %u \n", g_scenario->last_rx_packet->packet_number, g_scenario->last_rx_packet->original_frame_number);
           S1AP_DEBUG("Set time_last_rx_packet %ld.%06d\n", g_scenario->time_last_rx_packet.tv_sec, g_scenario->time_last_rx_packet.tv_usec);
         } else {
           break;
         }
       }
+
       packet = packet->next;
     }
+
     packet = g_scenario->list_packet;
   } else {
     packet = g_scenario->last_rx_packet->next;
   }
+
   // not_found threshold may sure depend on number of mme, may be not sure on number of UE
   while ((NULL != packet) && (not_found < 9)) {
     S1AP_DEBUG("%s() Considering packet num %d original frame number %u\n", __FUNCTION__, packet->packet_number, packet->original_frame_number);
+
     if (packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
       comp_results = et_sctp_is_matching(&packet->sctp_hdr, &rx_packet->sctp_hdr, g_constraints);
+
       if (NULL == comp_results) {
         S1AP_DEBUG("Compare RX packet with packet: num %u  | original frame number %u \n", packet->packet_number, packet->original_frame_number);
         packet->timestamp_packet.tv_sec = rx_packet->timestamp_packet.tv_sec;
@@ -669,10 +699,12 @@ int et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t * const s1ap_data_ind)
         return et_scenario_set_packet_received(packet);
       } else {
         S1AP_DEBUG("Compare RX packet with packet: num %u  | original frame number %u failed\n",
-          packet->packet_number, packet->original_frame_number);
+                   packet->packet_number, packet->original_frame_number);
+
         while (comp_results) {
           S1AP_DEBUG("Result err code %s(%u) ASN1 struct name %s\n",
-              et_error_match2str(comp_results->err_code), comp_results->err_code, comp_results->name);
+                     et_error_match2str(comp_results->err_code), comp_results->err_code, comp_results->name);
+
           // (each asn1 rc <= 166 (enum e_S1ap_ProtocolIE_ID, in generated file S1ap_ProtocolIE_ID.h))
           if (comp_results->err_code == COMPARE_ERR_CODE_NO_MATCH) {
             //TODO MME_UE_S1AP_ID, etc.
@@ -696,40 +728,40 @@ int et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t * const s1ap_data_ind)
               AssertFatal(0,"Some work needed there");
             }
           }
+
           comp_results2 = comp_results;
           comp_results = comp_results2->next;
           et_free_pointer(comp_results2);
         }
       }
     }
+
     not_found += 1;
     packet = packet->next;
   }
+
   et_display_packet_sctp(&rx_packet->sctp_hdr);
   AssertFatal(0, "Rx packet not found in scenario (see dump above)");
   return -1;
 }
 
 //------------------------------------------------------------------------------
-void et_s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t * const sctp_data_ind)
+void et_s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *const sctp_data_ind)
 {
   int            result = 0;
   et_event_t     event;
-
   DevAssert(sctp_data_ind != NULL);
-
-  memset((void*)&event, 0, sizeof(event));
-
+  memset((void *)&event, 0, sizeof(event));
   event.code = ET_EVENT_RX_S1AP;
   event.u.s1ap_data_ind.sctp_datahdr.tsn                       = 0;
   event.u.s1ap_data_ind.sctp_datahdr.stream                    = sctp_data_ind->stream;
   event.u.s1ap_data_ind.sctp_datahdr.ssn                       = 0;
   event.u.s1ap_data_ind.sctp_datahdr.ppid                      = S1AP_SCTP_PPID;
   event.u.s1ap_data_ind.sctp_datahdr.assoc_id                  = sctp_data_ind->assoc_id;
-
   event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream_pos = 0;
   event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream_allocated_size = sctp_data_ind->buffer_length;
   event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream = NULL;
+
   if ((sctp_data_ind->buffer_length > 0) && (NULL != sctp_data_ind->buffer)) {
     event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream   = calloc(1, sctp_data_ind->buffer_length);
     memcpy(event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream,
@@ -737,72 +769,54 @@ void et_s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t * const sctp_data_ind)
            sctp_data_ind->buffer_length);
 
     if (et_s1ap_decode_pdu(
-           &event.u.s1ap_data_ind.sctp_datahdr.payload.pdu,
-           &event.u.s1ap_data_ind.sctp_datahdr.payload.message,
-           event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream,
-           event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream_allocated_size) < 0) {
+          &event.u.s1ap_data_ind.sctp_datahdr.payload.pdu,
+          &event.u.s1ap_data_ind.sctp_datahdr.payload.message,
+          event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream,
+          event.u.s1ap_data_ind.sctp_datahdr.payload.binary_stream_allocated_size) < 0) {
       AssertFatal (0, "ERROR Cannot decode RX S1AP message!\n");
     }
-
   }
 
   result = itti_free(TASK_UNKNOWN, sctp_data_ind->buffer);
   AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
-
   et_scenario_fsm_notify_event(event);
-
-  memset((void*)&event, 0, sizeof(event));
+  memset((void *)&event, 0, sizeof(event));
   event.code = ET_EVENT_TICK;
   et_scenario_fsm_notify_event(event);
-
 }
 //------------------------------------------------------------------------------
 void et_s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
-                                  net_ip_address_t    *mme_ip_address,
-                                  net_ip_address_t    *local_ip_addr,
-                                  uint16_t             in_streams,
-                                  uint16_t             out_streams)
+                              net_ip_address_t    *mme_ip_address,
+                              net_ip_address_t    *local_ip_addr,
+                              uint16_t             in_streams,
+                              uint16_t             out_streams)
 {
   MessageDef                 *message_p                   = NULL;
   sctp_new_association_req_t *sctp_new_association_req_p  = NULL;
   s1ap_eNB_mme_data_t        *s1ap_mme_data_p             = NULL;
-
   DevAssert(instance_p != NULL);
   DevAssert(mme_ip_address != NULL);
-
   message_p = itti_alloc_new_message(TASK_S1AP, SCTP_NEW_ASSOCIATION_REQ);
-
   sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req;
-
   sctp_new_association_req_p->port = S1AP_PORT_NUMBER;
   sctp_new_association_req_p->ppid = S1AP_SCTP_PPID;
-
   sctp_new_association_req_p->in_streams  = in_streams;
   sctp_new_association_req_p->out_streams = out_streams;
-
   memcpy(&sctp_new_association_req_p->remote_address,
          mme_ip_address,
          sizeof(*mme_ip_address));
-
   memcpy(&sctp_new_association_req_p->local_address,
          local_ip_addr,
          sizeof(*local_ip_addr));
-
   /* Create new MME descriptor */
   s1ap_mme_data_p = calloc(1, sizeof(*s1ap_mme_data_p));
   DevAssert(s1ap_mme_data_p != NULL);
-
   s1ap_mme_data_p->cnx_id                = et_s1ap_eNB_fetch_add_global_cnx_id();
   sctp_new_association_req_p->ulp_cnx_id = s1ap_mme_data_p->cnx_id;
-
   s1ap_mme_data_p->assoc_id          = -1;
   s1ap_mme_data_p->s1ap_eNB_instance = instance_p;
-
-  memcpy((void*)&s1ap_mme_data_p->mme_net_ip_address, mme_ip_address, sizeof(*mme_ip_address));
-
-
+  memcpy((void *)&s1ap_mme_data_p->mme_net_ip_address, mme_ip_address, sizeof(*mme_ip_address));
   STAILQ_INIT(&s1ap_mme_data_p->served_gummei);
-
   /* Insert the new descriptor in list of known MME
    * but not yet associated.
    */
@@ -810,33 +824,33 @@ void et_s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
   s1ap_mme_data_p->state = S1AP_ENB_STATE_WAITING;
   instance_p->s1ap_mme_nb ++;
   instance_p->s1ap_mme_pending_nb ++;
-
   itti_send_msg_to_task(TASK_SCTP, instance_p->instance, message_p);
 }
 //------------------------------------------------------------------------------
 void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
-                                        struct s1ap_eNB_instance_s * const s1ap_eNB_instance,
-                                        s1ap_eNB_mme_data_t        * const mme_desc_p)
+                                        struct s1ap_eNB_instance_s *const s1ap_eNB_instance,
+                                        s1ap_eNB_mme_data_t         *const mme_desc_p)
 {
   et_packet_t     *packet = NULL;
   int              ret;
   unsigned int     old_enb_port = 0;
   unsigned int     old_mme_port = 0;
-
   S1AP_DEBUG("%s for SCTP association (%u)\n",__FUNCTION__,assoc_id);
-
   packet = g_scenario->list_packet;
+
   while (NULL != packet) {
     switch (packet->sctp_hdr.chunk_type) {
-
       case SCTP_CID_DATA :
         S1AP_DEBUG("%s for SCTP association (%u) SCTP_CID_DATA\n",__FUNCTION__,assoc_id);
+
         if ((ET_PACKET_STATUS_NONE == packet->status) || (ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING == packet->status)) {
           if (0 < old_mme_port) {
             if (packet->action == ET_PACKET_ACTION_S1C_SEND) {
               ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &mme_desc_p->mme_net_ip_address);
+
               if (0 == ret) {
                 ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &s1ap_eNB_instance->s1c_net_ip_address);
+
                 if (0 == ret) {
                   // same IP src, same IP dst
                   if ((packet->sctp_hdr.dst_port == old_mme_port) && (packet->sctp_hdr.src_port == old_enb_port)) {
@@ -848,8 +862,10 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
               }
             } else if (packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
               ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &mme_desc_p->mme_net_ip_address);
+
               if (0 == ret) {
                 ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &s1ap_eNB_instance->s1c_net_ip_address);
+
                 if (0 == ret) {
                   // same IP src, same IP dst
                   if ((packet->sctp_hdr.src_port == old_mme_port) && (packet->sctp_hdr.dst_port == old_enb_port)) {
@@ -862,15 +878,18 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
             }
           }
         }
+
         break;
 
-        // Strong assumption
-        // in replayed scenario, the order of SCTP INIT packets is supposed to be the same as in the catched scenario
+      // Strong assumption
+      // in replayed scenario, the order of SCTP INIT packets is supposed to be the same as in the catched scenario
       case SCTP_CID_INIT:
         S1AP_DEBUG("%s for SCTP association (%u) SCTP_CID_INIT\n",__FUNCTION__,assoc_id);
         ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &mme_desc_p->mme_net_ip_address);
+
         if (0 == ret) {
           ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &s1ap_eNB_instance->s1c_net_ip_address);
+
           if (0 == ret) {
             if (0 == old_enb_port) {
               if (ET_PACKET_STATUS_NONE == packet->status) {
@@ -881,13 +900,16 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
             }
           }
         }
+
         break;
 
       case SCTP_CID_INIT_ACK:
         S1AP_DEBUG("%s for SCTP association (%u) SCTP_CID_INIT_ACK\n",__FUNCTION__,assoc_id);
         ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &mme_desc_p->mme_net_ip_address);
+
         if (0 == ret) {
           ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &s1ap_eNB_instance->s1c_net_ip_address);
+
           if (0 == ret) {
             if (old_enb_port == packet->sctp_hdr.dst_port) {
               if (ET_PACKET_STATUS_NONE == packet->status) {
@@ -898,6 +920,7 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
             }
           }
         }
+
         break;
 
       case SCTP_CID_HEARTBEAT:
@@ -920,6 +943,7 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
         AssertFatal(0, "Unknown chunk_type %d packet num %d", packet->sctp_hdr.chunk_type, packet->packet_number);
         ;
     }
+
     packet = packet->next;
   }
 }
@@ -941,7 +965,6 @@ void et_s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_s
       /* If there are no more associated MME, inform eNB app */
       if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb == 0) {
         MessageDef                 *message_p;
-
         message_p = itti_alloc_new_message(TASK_S1AP, S1AP_DEREGISTERED_ENB_IND);
         S1AP_DEREGISTERED_ENB_IND(message_p).nb_mme = 0;
         itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
@@ -959,14 +982,12 @@ void et_s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_s
     }
 
     et_s1ap_update_assoc_id_of_packets(mme_desc_p->assoc_id,
-        mme_desc_p->s1ap_eNB_instance,
-        mme_desc_p);
-
+                                       mme_desc_p->s1ap_eNB_instance,
+                                       mme_desc_p);
 
     /* If there are no more pending messages, inform eNB app */
     if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb == 0) {
       MessageDef                 *message_p;
-
       message_p = itti_alloc_new_message(TASK_S1AP, S1AP_REGISTER_ENB_CNF);
       S1AP_REGISTER_ENB_CNF(message_p).nb_mme = mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb;
       itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
@@ -978,9 +999,7 @@ void et_s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_
 {
   s1ap_eNB_instance_t *new_instance;
   uint8_t index;
-
   DevAssert(s1ap_register_eNB != NULL);
-
   /* Look if the provided instance already exists */
   new_instance = et_s1ap_eNB_get_instance(instance);
 
@@ -992,14 +1011,12 @@ void et_s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_
     DevCheck(new_instance->mcc == s1ap_register_eNB->mcc, new_instance->mcc, s1ap_register_eNB->mcc, 0);
     DevCheck(new_instance->mnc == s1ap_register_eNB->mnc, new_instance->mnc, s1ap_register_eNB->mnc, 0);
     DevCheck(new_instance->mnc_digit_length == s1ap_register_eNB->mnc_digit_length, new_instance->mnc_digit_length, s1ap_register_eNB->mnc_digit_length, 0);
-    DevCheck(memcmp((void*)&new_instance->s1c_net_ip_address, (void*)&s1ap_register_eNB->enb_ip_address, sizeof(new_instance->s1c_net_ip_address)) == 0, 0,0,0);
+    DevCheck(memcmp((void *)&new_instance->s1c_net_ip_address, (void *)&s1ap_register_eNB->enb_ip_address, sizeof(new_instance->s1c_net_ip_address)) == 0, 0,0,0);
   } else {
     new_instance = calloc(1, sizeof(s1ap_eNB_instance_t));
     DevAssert(new_instance != NULL);
-
     RB_INIT(&new_instance->s1ap_ue_head);
     RB_INIT(&new_instance->s1ap_mme_head);
-
     /* Copy usefull parameters */
     new_instance->instance         = instance;
     new_instance->eNB_name         = s1ap_register_eNB->eNB_name;
@@ -1009,11 +1026,9 @@ void et_s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_
     new_instance->mcc              = s1ap_register_eNB->mcc;
     new_instance->mnc              = s1ap_register_eNB->mnc;
     new_instance->mnc_digit_length = s1ap_register_eNB->mnc_digit_length;
-    memcpy((void*)&new_instance->s1c_net_ip_address, (void*)&s1ap_register_eNB->enb_ip_address, sizeof(new_instance->s1c_net_ip_address));
-
+    memcpy((void *)&new_instance->s1c_net_ip_address, (void *)&s1ap_register_eNB->enb_ip_address, sizeof(new_instance->s1c_net_ip_address));
     /* Add the new instance to the list of eNB (meaningfull in virtual mode) */
     et_s1ap_eNB_insert_new_instance(new_instance);
-
     S1AP_DEBUG("Registered new eNB[%d] and %s eNB id %u\n",
                instance,
                s1ap_register_eNB->cell_type == CELL_MACRO_ENB ? "macro" : "home",
@@ -1026,10 +1041,10 @@ void et_s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_
   /* Trying to connect to provided list of MME ip address */
   for (index = 0; index < s1ap_register_eNB->nb_mme; index++) {
     et_s1ap_eNB_register_mme(new_instance,
-                      &s1ap_register_eNB->mme_ip_address[index],
-                          &s1ap_register_eNB->enb_ip_address,
-                          s1ap_register_eNB->sctp_in_streams,
-                          s1ap_register_eNB->sctp_out_streams);
+                             &s1ap_register_eNB->mme_ip_address[index],
+                             &s1ap_register_eNB->enb_ip_address,
+                             s1ap_register_eNB->sctp_in_streams,
+                             s1ap_register_eNB->sctp_out_streams);
   }
 }
 
@@ -1038,14 +1053,11 @@ void et_s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_asso
 {
   s1ap_eNB_instance_t *instance_p      = NULL;
   s1ap_eNB_mme_data_t *s1ap_mme_data_p = NULL;
-
   DevAssert(sctp_new_association_resp != NULL);
-
   instance_p = et_s1ap_eNB_get_instance(instance);
   DevAssert(instance_p != NULL);
-
   s1ap_mme_data_p = et_s1ap_eNB_get_MME(instance_p, -1,
-                                     sctp_new_association_resp->ulp_cnx_id);
+                                        sctp_new_association_resp->ulp_cnx_id);
   DevAssert(s1ap_mme_data_p != NULL);
 
   if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) {
@@ -1053,9 +1065,7 @@ void et_s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_asso
               sctp_new_association_resp->sctp_state,
               instance,
               sctp_new_association_resp->ulp_cnx_id);
-
     et_s1ap_handle_s1_setup_message(s1ap_mme_data_p, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN);
-
     return;
   }
 
@@ -1067,7 +1077,6 @@ void et_s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_asso
   s1ap_mme_data_p->assoc_id    = sctp_new_association_resp->assoc_id;
   s1ap_mme_data_p->in_streams  = sctp_new_association_resp->in_streams;
   s1ap_mme_data_p->out_streams = sctp_new_association_resp->out_streams;
-
   et_s1ap_handle_s1_setup_message(s1ap_mme_data_p, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN);
 }
 
@@ -1076,11 +1085,8 @@ void *et_s1ap_eNB_task(void *arg)
 {
   MessageDef *received_msg = NULL;
   int         result;
-
   S1AP_DEBUG("Starting S1AP layer\n");
-
   et_s1ap_eNB_prepare_internal_data();
-
   itti_mark_task_ready(TASK_S1AP);
   MSC_START_USE();
 
@@ -1088,77 +1094,78 @@ void *et_s1ap_eNB_task(void *arg)
     itti_receive_msg(TASK_S1AP, &received_msg);
 
     switch (ITTI_MSG_ID(received_msg)) {
-    case TERMINATE_MESSAGE:
-      S1AP_WARN("*** Exiting S1AP thread\n");
-      itti_exit_task();
+      case TERMINATE_MESSAGE:
+        S1AP_WARN("*** Exiting S1AP thread\n");
+        itti_exit_task();
+        break;
+
+      case S1AP_REGISTER_ENB_REQ: {
+        /* Register a new eNB.
+         * in Virtual mode eNBs will be distinguished using the mod_id/
+         * Each eNB has to send an S1AP_REGISTER_ENB message with its
+         * own parameters.
+         */
+        et_s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                        &S1AP_REGISTER_ENB_REQ(received_msg));
+      }
       break;
 
-    case S1AP_REGISTER_ENB_REQ: {
-      /* Register a new eNB.
-       * in Virtual mode eNBs will be distinguished using the mod_id/
-       * Each eNB has to send an S1AP_REGISTER_ENB message with its
-       * own parameters.
-       */
-      et_s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                   &S1AP_REGISTER_ENB_REQ(received_msg));
-    }
-    break;
+      case SCTP_NEW_ASSOCIATION_RESP: {
+        et_s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+            &received_msg->ittiMsg.sctp_new_association_resp);
+      }
+      break;
 
-    case SCTP_NEW_ASSOCIATION_RESP: {
-      et_s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                            &received_msg->ittiMsg.sctp_new_association_resp);
-    }
-    break;
+      case SCTP_DATA_IND: {
+        et_s1ap_eNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
+      }
+      break;
 
-    case SCTP_DATA_IND: {
-      et_s1ap_eNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
-    }
-    break;
-
-    case TIMER_HAS_EXPIRED:
-      LOG_I(S1AP, " Received TIMER_HAS_EXPIRED: timer_id %d\n", TIMER_HAS_EXPIRED(received_msg).timer_id);
-      {
-        et_packet_t * packet = (et_packet_t*)TIMER_HAS_EXPIRED (received_msg).arg;
-        et_event_t    event;
-        g_scenario->timer_count--;
-        if (NULL != packet) {
-          if (packet->status == ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING) {
-            memset((void*)&event, 0, sizeof(event));
-            event.code = ET_EVENT_RX_PACKET_TIME_OUT;
-            event.u.rx_packet_time_out = packet;
-            et_scenario_fsm_notify_event(event);
-          } else if (packet->status == ET_PACKET_STATUS_SCHEDULED_FOR_SENDING) {
-            memset((void*)&event, 0, sizeof(event));
-            event.code = ET_EVENT_TX_TIMED_PACKET;
-            event.u.tx_timed_packet = packet;
-            et_scenario_fsm_notify_event(event);
-
-            et_event_t continue_event;
-            continue_event.code = ET_EVENT_TICK;
-            et_scenario_fsm_notify_event(continue_event);
-          } else if ((packet->status != ET_PACKET_STATUS_SENT) && ((packet->status != ET_PACKET_STATUS_RECEIVED))) {
-            AssertFatal (0, "Bad status %d of packet timed out!\n", packet->status);
+      case TIMER_HAS_EXPIRED:
+        LOG_I(S1AP, " Received TIMER_HAS_EXPIRED: timer_id %d\n", TIMER_HAS_EXPIRED(received_msg).timer_id);
+        {
+          et_packet_t *packet = (et_packet_t *)TIMER_HAS_EXPIRED (received_msg).arg;
+          et_event_t    event;
+          g_scenario->timer_count--;
+
+          if (NULL != packet) {
+            if (packet->status == ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING) {
+              memset((void *)&event, 0, sizeof(event));
+              event.code = ET_EVENT_RX_PACKET_TIME_OUT;
+              event.u.rx_packet_time_out = packet;
+              et_scenario_fsm_notify_event(event);
+            } else if (packet->status == ET_PACKET_STATUS_SCHEDULED_FOR_SENDING) {
+              memset((void *)&event, 0, sizeof(event));
+              event.code = ET_EVENT_TX_TIMED_PACKET;
+              event.u.tx_timed_packet = packet;
+              et_scenario_fsm_notify_event(event);
+              et_event_t continue_event;
+              continue_event.code = ET_EVENT_TICK;
+              et_scenario_fsm_notify_event(continue_event);
+            } else if ((packet->status != ET_PACKET_STATUS_SENT) && ((packet->status != ET_PACKET_STATUS_RECEIVED))) {
+              AssertFatal (0, "Bad status %d of packet timed out!\n", packet->status);
+            }
+          } else {
+            LOG_W(S1AP, " Received TIMER_HAS_EXPIRED: timer_id %d, no packet attached to timer\n", TIMER_HAS_EXPIRED(received_msg).timer_id);
           }
-        } else {
-          LOG_W(S1AP, " Received TIMER_HAS_EXPIRED: timer_id %d, no packet attached to timer\n", TIMER_HAS_EXPIRED(received_msg).timer_id);
         }
-      }
-      if (TIMER_HAS_EXPIRED (received_msg).timer_id == g_scenario->enb_register_retry_timer_id) {
-        /* Restart the registration process */
-        g_scenario->registered_enb = 0;
-        et_eNB_app_register (g_scenario->enb_properties);
-      }
-      break;
 
-    default:
-      S1AP_ERROR("Received unhandled message: %d:%s\n",
-                 ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
-      break;
+        if (TIMER_HAS_EXPIRED (received_msg).timer_id == g_scenario->enb_register_retry_timer_id) {
+          /* Restart the registration process */
+          g_scenario->registered_enb = 0;
+          et_eNB_app_register (g_scenario->enb_properties);
+        }
+
+        break;
+
+      default:
+        S1AP_ERROR("Received unhandled message: %d:%s\n",
+                   ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
+        break;
     }
 
     result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg);
     AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
-
     received_msg = NULL;
   }
 
diff --git a/openair3/TEST/EPC_TEST/play_scenario_s1ap_compare_ie.c b/openair3/TEST/EPC_TEST/play_scenario_s1ap_compare_ie.c
index 08f79ef206dc245cc9ad20cbd2c4da6456d0f0cd..59cb1cdac9cfbd42e65a82cce291ebcda3b8beb2 100644
--- a/openair3/TEST/EPC_TEST/play_scenario_s1ap_compare_ie.c
+++ b/openair3/TEST/EPC_TEST/play_scenario_s1ap_compare_ie.c
@@ -56,402 +56,11 @@ extern et_scenario_t  *g_scenario;
 extern uint32_t        g_constraints;
 //------------------------------------------------------------------------------
 
-asn_comp_rval_t * et_s1ap_ies_is_matching(const S1AP_PDU_PR present, s1ap_message * const m1, s1ap_message * const m2, const uint32_t constraints)
-{
-  asn_comp_rval_t *ret = NULL;
-  AssertFatal(m1 != NULL, "bad parameter m1");
-  AssertFatal(m2 != NULL, "bad parameter m2");
-  AssertFatal((present == S1AP_PDU_PR_initiatingMessage) ||
-              (present == S1AP_PDU_PR_successfulOutcome) ||
-              (present == S1AP_PDU_PR_unsuccessfulOutcome) , "Bad parameter S1AP_PDU_PR present ");
-  AssertFatal( m1->procedureCode == m2->procedureCode, "Bad parameters: no matching procedure codes");
-
-
-  // some cases can never occur since uplink only.
-  switch (m1->procedureCode) {
-    case  S1ap_ProcedureCode_id_HandoverPreparation:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_handoverrequiredies(
-                &m1->msg.s1ap_HandoverRequiredIEs,
-                &m2->msg.s1ap_HandoverRequiredIEs);
-      } else {
-        ret = s1ap_compare_s1ap_handovercommandies(
-                &m1->msg.s1ap_HandoverCommandIEs,
-                &m2->msg.s1ap_HandoverCommandIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_HandoverResourceAllocation:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_handoverrequesties(
-                &m1->msg.s1ap_HandoverRequestIEs,
-                &m2->msg.s1ap_HandoverRequestIEs);
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
-        ret = s1ap_compare_s1ap_handoverrequestacknowledgeies(
-                &m1->msg.s1ap_HandoverRequestAcknowledgeIEs,
-                &m2->msg.s1ap_HandoverRequestAcknowledgeIEs);
-      } else if (present == S1AP_PDU_PR_unsuccessfulOutcome) {
-        ret = s1ap_compare_s1ap_handoverfailureies(
-                &m1->msg.s1ap_HandoverFailureIEs,
-                &m2->msg.s1ap_HandoverFailureIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_HandoverNotification:
-        ret = s1ap_compare_s1ap_handovernotifyies(
-                &m1->msg.s1ap_HandoverNotifyIEs,
-                &m2->msg.s1ap_HandoverNotifyIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_PathSwitchRequest:
-      ret = s1ap_compare_s1ap_pathswitchrequesties(
-              &m1->msg.s1ap_PathSwitchRequestIEs,
-              &m2->msg.s1ap_PathSwitchRequestIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_HandoverCancel:
-      ret = s1ap_compare_s1ap_handovercancelies(
-              &m1->msg.s1ap_HandoverCancelIEs,
-              &m2->msg.s1ap_HandoverCancelIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_E_RABSetup:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_e_rabsetuprequesties(
-                &m1->msg.s1ap_E_RABSetupRequestIEs,
-                &m2->msg.s1ap_E_RABSetupRequestIEs);
-      } else  {
-        ret = s1ap_compare_s1ap_e_rabsetupresponseies(
-                &m1->msg.s1ap_E_RABSetupResponseIEs,
-                &m2->msg.s1ap_E_RABSetupResponseIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_E_RABModify:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_e_rabmodifyrequesties(
-                &m1->msg.s1ap_E_RABModifyRequestIEs,
-                &m2->msg.s1ap_E_RABModifyRequestIEs);
-      } else  {
-        ret = s1ap_compare_s1ap_e_rabmodifyresponseies(
-                &m1->msg.s1ap_E_RABModifyResponseIEs,
-                &m2->msg.s1ap_E_RABModifyResponseIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_E_RABRelease:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_e_rabreleasecommandies(
-                &m1->msg.s1ap_E_RABReleaseCommandIEs,
-                &m2->msg.s1ap_E_RABReleaseCommandIEs);
-      } else  {
-        ret = s1ap_compare_s1ap_e_rabreleaseresponseies(
-                &m1->msg.s1ap_E_RABReleaseResponseIEs,
-                &m2->msg.s1ap_E_RABReleaseResponseIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_E_RABReleaseIndication:
-      ret = s1ap_compare_s1ap_e_rabreleaseindicationies(
-              &m1->msg.s1ap_E_RABReleaseIndicationIEs,
-              &m2->msg.s1ap_E_RABReleaseIndicationIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_InitialContextSetup:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_initialcontextsetuprequesties(
-                &m1->msg.s1ap_InitialContextSetupRequestIEs,
-                &m2->msg.s1ap_InitialContextSetupRequestIEs);
-      } else  {
-        ret = s1ap_compare_s1ap_initialcontextsetupresponseies(
-                &m1->msg.s1ap_InitialContextSetupResponseIEs,
-                &m2->msg.s1ap_InitialContextSetupResponseIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_Paging:
-      ret = s1ap_compare_s1ap_pagingies(
-              &m1->msg.s1ap_PagingIEs,
-              &m2->msg.s1ap_PagingIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_downlinkNASTransport:
-      ret = s1ap_compare_s1ap_downlinknastransporties(
-              &m1->msg.s1ap_DownlinkNASTransportIEs,
-              &m2->msg.s1ap_DownlinkNASTransportIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_initialUEMessage:
-      ret = s1ap_compare_s1ap_initialuemessageies(
-              &m1->msg.s1ap_InitialUEMessageIEs,
-              &m2->msg.s1ap_InitialUEMessageIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_uplinkNASTransport:
-      ret = s1ap_compare_s1ap_uplinknastransporties(
-              &m1->msg.s1ap_UplinkNASTransportIEs,
-              &m2->msg.s1ap_UplinkNASTransportIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_Reset:
-      ret = s1ap_compare_s1ap_reseties(
-              &m1->msg.s1ap_ResetIEs,
-              &m2->msg.s1ap_ResetIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_ErrorIndication:
-      ret = s1ap_compare_s1ap_errorindicationies(
-              &m1->msg.s1ap_ErrorIndicationIEs,
-              &m2->msg.s1ap_ErrorIndicationIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_NASNonDeliveryIndication:
-      ret = s1ap_compare_s1ap_nasnondeliveryindication_ies(
-              &m1->msg.s1ap_NASNonDeliveryIndication_IEs,
-              &m2->msg.s1ap_NASNonDeliveryIndication_IEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_S1Setup:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_s1setuprequesties(
-                &m1->msg.s1ap_S1SetupRequestIEs,
-                &m2->msg.s1ap_S1SetupRequestIEs);
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
-        ret = s1ap_compare_s1ap_s1setupresponseies(
-                &m1->msg.s1ap_S1SetupResponseIEs,
-                &m2->msg.s1ap_S1SetupResponseIEs);
-      } else if (present == S1AP_PDU_PR_unsuccessfulOutcome) {
-        ret = s1ap_compare_s1ap_s1setupfailureies(
-                &m1->msg.s1ap_S1SetupFailureIEs,
-                &m2->msg.s1ap_S1SetupFailureIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_UEContextReleaseRequest:
-      ret = s1ap_compare_s1ap_uecontextreleaserequesties(
-                &m1->msg.s1ap_UEContextReleaseRequestIEs,
-                &m2->msg.s1ap_UEContextReleaseRequestIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_DownlinkS1cdma2000tunneling:
-      ret = s1ap_compare_s1ap_downlinks1cdma2000tunnelingies(
-                &m1->msg.s1ap_DownlinkS1cdma2000tunnelingIEs,
-                &m2->msg.s1ap_DownlinkS1cdma2000tunnelingIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_UplinkS1cdma2000tunneling:
-      ret = s1ap_compare_s1ap_uplinks1cdma2000tunnelingies(
-                &m1->msg.s1ap_UplinkS1cdma2000tunnelingIEs,
-                &m2->msg.s1ap_UplinkS1cdma2000tunnelingIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_UEContextModification:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_uecontextmodificationrequesties(
-                &m1->msg.s1ap_UEContextModificationRequestIEs,
-                &m2->msg.s1ap_UEContextModificationRequestIEs);
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
-        ret = s1ap_compare_s1ap_uecontextmodificationresponseies(
-                &m1->msg.s1ap_UEContextModificationResponseIEs,
-                &m2->msg.s1ap_UEContextModificationResponseIEs);
-      } else if (present == S1AP_PDU_PR_unsuccessfulOutcome) {
-        ret = s1ap_compare_s1ap_uecontextmodificationfailureies(
-                &m1->msg.s1ap_UEContextModificationFailureIEs,
-                &m2->msg.s1ap_UEContextModificationFailureIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_UECapabilityInfoIndication:
-      ret = s1ap_compare_s1ap_uecapabilityinfoindicationies(
-                &m1->msg.s1ap_UECapabilityInfoIndicationIEs,
-                &m2->msg.s1ap_UECapabilityInfoIndicationIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_UEContextRelease:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_uecontextreleasecommandies(
-                &m1->msg.s1ap_UEContextReleaseCommandIEs,
-                &m2->msg.s1ap_UEContextReleaseCommandIEs);
-      } else  {
-        ret = s1ap_compare_s1ap_uecontextreleasecompleteies(
-                &m1->msg.s1ap_UEContextReleaseCompleteIEs,
-                &m2->msg.s1ap_UEContextReleaseCompleteIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_eNBStatusTransfer:
-      ret = s1ap_compare_s1ap_enbstatustransferies(
-                &m1->msg.s1ap_ENBStatusTransferIEs,
-                &m2->msg.s1ap_ENBStatusTransferIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_MMEStatusTransfer:
-      ret = s1ap_compare_s1ap_mmestatustransferies(
-                &m1->msg.s1ap_MMEStatusTransferIEs,
-                &m2->msg.s1ap_MMEStatusTransferIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_DeactivateTrace:
-      ret = s1ap_compare_s1ap_deactivatetraceies(
-                &m1->msg.s1ap_DeactivateTraceIEs,
-                &m2->msg.s1ap_DeactivateTraceIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_TraceStart:
-      ret = s1ap_compare_s1ap_tracestarties(
-                &m1->msg.s1ap_TraceStartIEs,
-                &m2->msg.s1ap_TraceStartIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_TraceFailureIndication:
-      ret = s1ap_compare_s1ap_tracefailureindicationies(
-                &m1->msg.s1ap_TraceFailureIndicationIEs,
-                &m2->msg.s1ap_TraceFailureIndicationIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_ENBConfigurationUpdate:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_enbconfigurationupdateies(
-                &m1->msg.s1ap_ENBConfigurationUpdateIEs,
-                &m2->msg.s1ap_ENBConfigurationUpdateIEs);
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
-        ret = s1ap_compare_s1ap_enbconfigurationupdateacknowledgeies(
-                &m1->msg.s1ap_ENBConfigurationUpdateAcknowledgeIEs,
-                &m2->msg.s1ap_ENBConfigurationUpdateAcknowledgeIEs);
-      } else {
-        ret = s1ap_compare_s1ap_enbconfigurationupdatefailureies(
-                &m1->msg.s1ap_ENBConfigurationUpdateFailureIEs,
-                &m2->msg.s1ap_ENBConfigurationUpdateFailureIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_MMEConfigurationUpdate:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_mmeconfigurationupdateies(
-                &m1->msg.s1ap_MMEConfigurationUpdateIEs,
-                &m2->msg.s1ap_MMEConfigurationUpdateIEs);
-      } else if (present == S1AP_PDU_PR_successfulOutcome) {
-        ret = s1ap_compare_s1ap_mmeconfigurationupdateacknowledgeies(
-                &m1->msg.s1ap_MMEConfigurationUpdateAcknowledgeIEs,
-                &m2->msg.s1ap_MMEConfigurationUpdateAcknowledgeIEs);
-      } else {
-        ret = s1ap_compare_s1ap_mmeconfigurationupdatefailureies(
-                &m1->msg.s1ap_MMEConfigurationUpdateFailureIEs,
-                &m2->msg.s1ap_MMEConfigurationUpdateFailureIEs);
-      }
-      break;
+//asn_comp_rval_t * et_s1ap_ies_is_matching(const S1AP_PDU_PR present, s1ap_message * const m1, s1ap_message * const m2, const uint32_t constraints)
+//{
+//}
 
-    case  S1ap_ProcedureCode_id_LocationReportingControl:
-      ret = s1ap_compare_s1ap_locationreportingcontrolies(
-                &m1->msg.s1ap_LocationReportingControlIEs,
-                &m2->msg.s1ap_LocationReportingControlIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_LocationReportingFailureIndication:
-      ret = s1ap_compare_s1ap_locationreportingfailureindicationies(
-                &m1->msg.s1ap_LocationReportingFailureIndicationIEs,
-                &m2->msg.s1ap_LocationReportingFailureIndicationIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_LocationReport:
-      ret = s1ap_compare_s1ap_locationreporties(
-                &m1->msg.s1ap_LocationReportIEs,
-                &m2->msg.s1ap_LocationReportIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_OverloadStart:
-      ret = s1ap_compare_s1ap_overloadstarties(
-                &m1->msg.s1ap_OverloadStartIEs,
-                &m2->msg.s1ap_OverloadStartIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_OverloadStop:
-      ret = s1ap_compare_s1ap_overloadstopies(
-                &m1->msg.s1ap_OverloadStopIEs,
-                &m2->msg.s1ap_OverloadStopIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_WriteReplaceWarning:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_writereplacewarningrequesties(
-                &m1->msg.s1ap_WriteReplaceWarningRequestIEs,
-                &m2->msg.s1ap_WriteReplaceWarningRequestIEs);
-      } else  {
-        ret = s1ap_compare_s1ap_writereplacewarningresponseies(
-                &m1->msg.s1ap_WriteReplaceWarningResponseIEs,
-                &m2->msg.s1ap_WriteReplaceWarningResponseIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_eNBDirectInformationTransfer:
-      ret = s1ap_compare_s1ap_enbdirectinformationtransferies(
-                &m1->msg.s1ap_ENBDirectInformationTransferIEs,
-                &m2->msg.s1ap_ENBDirectInformationTransferIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_MMEDirectInformationTransfer:
-
-      ret = s1ap_compare_s1ap_mmedirectinformationtransferies(
-                &m1->msg.s1ap_MMEDirectInformationTransferIEs,
-                &m2->msg.s1ap_MMEDirectInformationTransferIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_PrivateMessage:
-    case  S1ap_ProcedureCode_id_eNBConfigurationTransfer:
-    case  S1ap_ProcedureCode_id_MMEConfigurationTransfer:
-      AssertFatal(0, "TODO");
-      break;
-
-    case  S1ap_ProcedureCode_id_CellTrafficTrace:
-      ret = s1ap_compare_s1ap_celltraffictraceies(
-                &m1->msg.s1ap_CellTrafficTraceIEs,
-                &m2->msg.s1ap_CellTrafficTraceIEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_Kill:
-      if (present == S1AP_PDU_PR_initiatingMessage) {
-        ret = s1ap_compare_s1ap_killrequesties(
-                &m1->msg.s1ap_KillRequestIEs,
-                &m2->msg.s1ap_KillRequestIEs);
-      } else  {
-        ret = s1ap_compare_s1ap_killresponseies(
-                &m1->msg.s1ap_KillResponseIEs,
-                &m2->msg.s1ap_KillResponseIEs);
-      }
-      break;
-
-    case  S1ap_ProcedureCode_id_downlinkUEAssociatedLPPaTransport:
-      ret = s1ap_compare_s1ap_downlinkueassociatedlppatransport_ies(
-                &m1->msg.s1ap_DownlinkUEAssociatedLPPaTransport_IEs,
-                &m2->msg.s1ap_DownlinkUEAssociatedLPPaTransport_IEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_uplinkUEAssociatedLPPaTransport:
-      ret = s1ap_compare_s1ap_uplinkueassociatedlppatransport_ies(
-                &m1->msg.s1ap_UplinkUEAssociatedLPPaTransport_IEs,
-                &m2->msg.s1ap_UplinkUEAssociatedLPPaTransport_IEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_downlinkNonUEAssociatedLPPaTransport:
-      ret = s1ap_compare_s1ap_downlinknonueassociatedlppatransport_ies(
-                &m1->msg.s1ap_DownlinkNonUEAssociatedLPPaTransport_IEs,
-                &m2->msg.s1ap_DownlinkNonUEAssociatedLPPaTransport_IEs);
-      break;
-
-    case  S1ap_ProcedureCode_id_uplinkNonUEAssociatedLPPaTransport:
-      ret = s1ap_compare_s1ap_uplinknonueassociatedlppatransport_ies(
-                &m1->msg.s1ap_UplinkNonUEAssociatedLPPaTransport_IEs,
-                &m2->msg.s1ap_UplinkNonUEAssociatedLPPaTransport_IEs);
-      break;
-
-    default:
-      AssertFatal(0, "Unknown procedure code %ld", m1->procedureCode);
-  }
-  return ret;
-}
-
-
-void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, const S1ap_MME_UE_S1AP_ID_t new_id)
+void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t *const s1ap, xmlNode *node, const S1AP_MME_UE_S1AP_ID_t new_id)
 {
   xmlNode       *cur_node = NULL;
   xmlAttrPtr     attr     = NULL;
@@ -464,24 +73,30 @@ void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, con
   // modify
   for (cur_node = (xmlNode *)node; cur_node; cur_node = cur_node->next) {
     go_deeper_in_tree = 1;
+
     if ((!xmlStrcmp(cur_node->name, (const xmlChar *)"field"))) {
       // do not get hidden fields
       xml_char = xmlGetProp((xmlNode *)cur_node, (const xmlChar *)"hide");
+
       if (NULL != xml_char) {
         if ((!xmlStrcmp(xml_char, (const xmlChar *)"yes"))) {
           go_deeper_in_tree = 0;
         }
+
         xmlFree(xml_char);
       }
+
       if (0 < go_deeper_in_tree) {
         // first get size
         xml_char = xmlGetProp((xmlNode *)cur_node, (const xmlChar *)"pos");
+
         if (NULL != xml_char) {
           pos = strtoul((const char *)xml_char, NULL, 0);
           pos -= s1ap->xml_stream_pos_offset;
           AssertFatal(pos >= 0, "Bad pos %d xml_stream_pos_offset %d", pos, s1ap->xml_stream_pos_offset);
           xmlFree(xml_char);
           xml_char = xmlGetProp((xmlNode *)cur_node, (const xmlChar *)"size");
+
           if (NULL != xml_char) {
             const xmlChar value_d[32];
             const xmlChar value_h[20];
@@ -491,7 +106,6 @@ void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, con
             unsigned long int uli = 0;
             char          hex[3]  = {0,0,0};
             char         *end_ptr = NULL;
-
             size = strtoul((const char *)xml_char, NULL, 0);
             xmlFree(xml_char);
             // second: try to set value (always hex)
@@ -501,12 +115,12 @@ void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, con
             AssertFatal((ret > 0) && (ret < 20), "Could not convert int to hex str");
             ret = snprintf((char *)showname, 64, "MME-UE-S1AP-ID: %d", new_id);
             AssertFatal((ret > 0) && (ret < 64), "Could not convert int to dec str");
-
             attr = xmlSetProp((xmlNode *)cur_node, (const xmlChar *)"value", value_h);
             attr = xmlSetProp((xmlNode *)cur_node, (const xmlChar *)"show", value_d);
             attr = xmlSetProp((xmlNode *)cur_node, (const xmlChar *)"showname", showname);
             //TODO update s1ap->binary_stream @pos with new_id_hex, size
             AssertFatal((pos+size) < s1ap->binary_stream_allocated_size, "Rewrite of mme_ue_s1ap_id out of bounds of binary_stream");
+
             //avoid endianess issues
             do {
               hex[0] = value_h[pos2++];
@@ -517,6 +131,7 @@ void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, con
               AssertFatal((uli != ULONG_MAX) && (end_ptr != NULL) && (*end_ptr == '\0'), "Conversion of hexstring %s failed returned %ld errno %d", hex, uli, errno);
               s1ap->binary_stream[pos++] = (unsigned char)uli;
             } while (pos2 < (2*5));
+
             // update ASN1
             et_decode_s1ap(s1ap);
             //S1AP_INFO("Updated ASN1 for %s\n", showname);
@@ -524,6 +139,7 @@ void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, con
         }
       }
     }
+
     if (0 < go_deeper_in_tree) {
       update_xpath_node_mme_ue_s1ap_id(s1ap, cur_node->children, new_id);
     }
@@ -538,12 +154,11 @@ void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, con
  * Prints the @nodes content to @output.
  * From http://www.xmlsoft.org/examples/#xpath2.c
  */
-void update_xpath_nodes_mme_ue_s1ap_id(et_s1ap_t * const s1ap_payload, xmlNodeSetPtr nodes, const S1ap_MME_UE_S1AP_ID_t new_id)
+void update_xpath_nodes_mme_ue_s1ap_id(et_s1ap_t *const s1ap_payload, xmlNodeSetPtr nodes, const S1AP_MME_UE_S1AP_ID_t new_id)
 {
   int           size = 0;
   int           i    = 0;
   xmlNode      *s1ap_node = NULL;
-
   size = (nodes) ? nodes->nodeNr : 0;
   //S1AP_DEBUG("%s() num nodes %u\n", __FUNCTION__, size);
 
@@ -559,6 +174,7 @@ void update_xpath_nodes_mme_ue_s1ap_id(et_s1ap_t * const s1ap_payload, xmlNodeSe
     s1ap_node = nodes->nodeTab[i];
     AssertFatal(NULL != s1ap_node, "One element of resultset of XPATH expression is NULL\n");
     update_xpath_node_mme_ue_s1ap_id(s1ap_payload, s1ap_node, new_id);
+
     /*
      * All the elements returned by an XPath query are pointers to
      * elements from the tree *except* namespace nodes where the XPath
@@ -581,28 +197,24 @@ void update_xpath_nodes_mme_ue_s1ap_id(et_s1ap_t * const s1ap_payload, xmlNodeSe
   }
 }
 //------------------------------------------------------------------------------
-int et_s1ap_update_mme_ue_s1ap_id(et_packet_t * const packet, const S1ap_MME_UE_S1AP_ID_t old_id, const S1ap_MME_UE_S1AP_ID_t new_id)
+int et_s1ap_update_mme_ue_s1ap_id(et_packet_t *const packet, const S1AP_MME_UE_S1AP_ID_t old_id, const S1AP_MME_UE_S1AP_ID_t new_id)
 {
-
-
   xmlChar              xpath_expression[ET_XPATH_EXPRESSION_MAX_LENGTH];
   int                  ret       = 0;
   xmlDocPtr            doc       = NULL;
   xmlXPathContextPtr   xpath_ctx = NULL;
   xmlXPathObjectPtr    xpath_obj = NULL;
-
   //S1AP_DEBUG("%s() packet num %u original frame number %u, mme_ue_s1ap_id %u -> %u\n", __FUNCTION__, packet->packet_number, packet->original_frame_number, old_id, new_id);
-
   ret = snprintf(xpath_expression, ET_XPATH_EXPRESSION_MAX_LENGTH, "//field[@name=\"s1ap.MME_UE_S1AP_ID\"][@show=\"%u\"]", old_id);
   AssertFatal((ret > 0) && (ret < ET_XPATH_EXPRESSION_MAX_LENGTH), "Could not build XPATH expression err=%d", ret);
-
   doc = packet->sctp_hdr.u.data_hdr.payload.doc;
   // Create xpath evaluation context
   xpath_ctx = xmlXPathNewContext(doc);
+
   if(xpath_ctx == NULL) {
-      fprintf(stderr,"Error: unable to create new XPath context\n");
-      xmlFreeDoc(doc);
-      return(-1);
+    fprintf(stderr,"Error: unable to create new XPath context\n");
+    xmlFreeDoc(doc);
+    return(-1);
   }
 
   // Evaluate xpath expression
@@ -610,17 +222,16 @@ int et_s1ap_update_mme_ue_s1ap_id(et_packet_t * const packet, const S1ap_MME_UE_
   xmlXPathFreeContext(xpath_ctx);
   AssertFatal(xpath_obj != NULL, "Unable to evaluate XPATH expression \"%s\"\n", xpath_expression);
 
-  if(xmlXPathNodeSetIsEmpty(xpath_obj->nodesetval)){
+  if(xmlXPathNodeSetIsEmpty(xpath_obj->nodesetval)) {
     xmlXPathFreeObject(xpath_obj);
     S1AP_DEBUG("%s() No match \"%s\"packet num %u original frame number %u, mme_ue_s1ap_id %u -> %u\n",
-        __FUNCTION__, xpath_expression, packet->packet_number, packet->original_frame_number, old_id, new_id);
+               __FUNCTION__, xpath_expression, packet->packet_number, packet->original_frame_number, old_id, new_id);
     return -1;
   }
+
   // update selected nodes
   update_xpath_nodes_mme_ue_s1ap_id(&packet->sctp_hdr.u.data_hdr.payload, xpath_obj->nodesetval, new_id);
-
   // Cleanup of XPath data
   xmlXPathFreeObject(xpath_obj);
-
   return 0;
 }
diff --git a/openair3/TEST/EPC_TEST/play_scenario_sctp.c b/openair3/TEST/EPC_TEST/play_scenario_sctp.c
index 8a9bc491c8d443a77ca03c2dbbb8b40f12429336..c126608598bdb62d6aeee08a3d05335941f2c863 100644
--- a/openair3/TEST/EPC_TEST/play_scenario_sctp.c
+++ b/openair3/TEST/EPC_TEST/play_scenario_sctp.c
@@ -36,22 +36,25 @@
 #include "play_scenario.h"
 
 //------------------------------------------------------------------------------
-asn_comp_rval_t * et_sctp_data_is_matching(sctp_datahdr_t * const sctp1, sctp_datahdr_t * const sctp2, const uint32_t constraints)
+asn_comp_rval_t *et_sctp_data_is_matching(sctp_datahdr_t *const sctp1, sctp_datahdr_t *const sctp2, const uint32_t constraints)
 {
   asn_comp_rval_t *rv = NULL;
+
   // no comparison for ports
-  if (sctp1->ppid     != sctp2->ppid) {
+  if (sctp1->ppid != sctp2->ppid) {
     S1AP_WARN("No Matching SCTP PPID %u %u\n", sctp1->ppid, sctp2->ppid);
     rv  = calloc(1, sizeof(asn_comp_rval_t));
     rv->err_code = ET_ERROR_MATCH_PACKET_SCTP_PPID;
     return rv;
   }
+
   if (sctp1->assoc_id != sctp2->assoc_id) {
     S1AP_WARN("No Matching SCTP assoc id %u %u\n", sctp1->assoc_id, sctp2->assoc_id);
     rv  = calloc(1, sizeof(asn_comp_rval_t));
     rv->err_code = ET_ERROR_MATCH_PACKET_SCTP_ASSOC_ID;
     return rv;
   }
+
   if (sctp1->stream != sctp2->stream) {
     if (constraints & ET_BIT_MASK_MATCH_SCTP_STREAM) {
       rv  = calloc(1, sizeof(asn_comp_rval_t));
@@ -61,30 +64,33 @@ asn_comp_rval_t * et_sctp_data_is_matching(sctp_datahdr_t * const sctp1, sctp_da
       S1AP_WARN("No Matching SCTP stream %u %u\n", sctp1->stream, sctp2->stream);
     }
   }
+
   // We do not have SSN from lower layers
-//  if (sctp1->ssn != sctp2->ssn) {
-//    if (constraints & ET_BIT_MASK_MATCH_SCTP_SSN) {
-//      rv  = calloc(1, sizeof(asn_comp_rval_t));
-//      rv->err_code = ET_ERROR_MATCH_PACKET_SCTP_SSN;
-//      return rv;
-//    } else {
-//      S1AP_WARN("No Matching SCTP STREAM SN %u %u\n", sctp1->ssn, sctp2->ssn);
-//    }
-//  }
+  //  if (sctp1->ssn != sctp2->ssn) {
+  //    if (constraints & ET_BIT_MASK_MATCH_SCTP_SSN) {
+  //      rv  = calloc(1, sizeof(asn_comp_rval_t));
+  //      rv->err_code = ET_ERROR_MATCH_PACKET_SCTP_SSN;
+  //      return rv;
+  //    } else {
+  //      S1AP_WARN("No Matching SCTP STREAM SN %u %u\n", sctp1->ssn, sctp2->ssn);
+  //    }
+  //  }
   return et_s1ap_is_matching(&sctp1->payload, &sctp2->payload,  constraints);
 }
 
 //------------------------------------------------------------------------------
-asn_comp_rval_t *  et_sctp_is_matching(et_sctp_hdr_t * const sctp1, et_sctp_hdr_t * const sctp2, const uint32_t constraints)
+asn_comp_rval_t *et_sctp_is_matching(et_sctp_hdr_t *const sctp1, et_sctp_hdr_t *const sctp2, const uint32_t constraints)
 {
   // no comparison for ports
   asn_comp_rval_t *rv = NULL;
-  if (sctp1->chunk_type != sctp2->chunk_type){
+
+  if (sctp1->chunk_type != sctp2->chunk_type) {
     S1AP_WARN("No Matching chunk_type %u %u\n", sctp1->chunk_type, sctp2->chunk_type);
     rv  = calloc(1, sizeof(asn_comp_rval_t));
     rv->err_code = ET_ERROR_MATCH_PACKET_SCTP_CHUNK_TYPE;
     return rv;
   }
+
   switch (sctp1->chunk_type) {
     case SCTP_CID_DATA:
       return et_sctp_data_is_matching(&sctp1->u.data_hdr, &sctp2->u.data_hdr, constraints);
@@ -93,9 +99,11 @@ asn_comp_rval_t *  et_sctp_is_matching(et_sctp_hdr_t * const sctp1, et_sctp_hdr_
     case SCTP_CID_INIT:
       AssertFatal(0, "Not needed now");
       break;
+
     case SCTP_CID_INIT_ACK:
       AssertFatal(0, "Not needed now");
       break;
+
     default:
       AssertFatal(0, "Not needed now cid %d", sctp1->chunk_type);
   }
diff --git a/openair3/TEST/oaisim_mme_client_test.c b/openair3/TEST/oaisim_mme_client_test.c
index 0e89511865c71e89341cc4d27dfe144e2896ac25..8fcda8a5ad01f5539d6511c022425ee5fb59d679 100644
--- a/openair3/TEST/oaisim_mme_client_test.c
+++ b/openair3/TEST/oaisim_mme_client_test.c
@@ -35,7 +35,6 @@
 #include "s1ap_common.h"
 #include "s1ap_eNB.h"
 #include "s1ap_mme.h"
-#include "s1ap_ies_defs.h"
 
 char ip_addr[] = "127.0.0.1";
 
@@ -60,13 +59,10 @@ int s1ap_eNB_generate_initial_ue_message(uint8_t **buffer,
 {
   InitialUEMessageIEs  initialUEmessageIEs;
   InitialUEMessageIEs *initialUEmessageIEs_p = &initialUEmessageIEs;
-
   memset(initialUEmessageIEs_p, 0, sizeof(InitialUEMessageIEs));
-
   initialUEmessageIEs.eNB_UE_S1AP_ID = eNB_UE_S1AP_ID;
   initialUEmessageIEs.nas_pdu.buf = infoNAS;
   initialUEmessageIEs.nas_pdu.size = sizeof(infoNAS);
-
   initialUEmessageIEs.tai.tAC.buf = tac;
   initialUEmessageIEs.tai.tAC.size = 2;
   initialUEmessageIEs.tai.pLMNidentity.buf = identity;
@@ -76,9 +72,7 @@ int s1ap_eNB_generate_initial_ue_message(uint8_t **buffer,
   initialUEmessageIEs.eutran_cgi.cell_ID.buf = id;
   initialUEmessageIEs.eutran_cgi.cell_ID.size = 4;
   initialUEmessageIEs.eutran_cgi.cell_ID.bits_unused = 4;
-
   initialUEmessageIEs.rrC_Establishment_Cause = RRC_Establishment_Cause_mo_Data;
-
   return s1ap_eNB_encode_initial_ue_message(initialUEmessageIEs_p, buffer, length);
 }
 
@@ -95,13 +89,10 @@ int main(int argc, char *argv[])
   asn_enc_rval_t retVal;
   uint8_t *buffer;
   uint32_t len;
-
   SupportedTAs_Item_t ta;
   PLMNidentity_t plmnIdentity;
-
   asn_debug = 0;
   asn1_xer_print = 0;
-
   S1SetupRequestIEs s1SetupRequest;
   memset(&s1SetupRequest, 0, sizeof(S1SetupRequestIEs));
   s1SetupRequest.global_ENB_ID.eNB_ID.present = ENB_ID_PR_macroENB_ID;
@@ -109,32 +100,23 @@ int main(int argc, char *argv[])
   s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.size = 3;
   s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.bits_unused = 4;
   OCTET_STRING_fromBuf(&s1SetupRequest.global_ENB_ID.pLMNidentity, identity, 3);
-
   s1SetupRequest.presenceMask |= S1SETUPREQUESTIES_ENBNAME_PRESENT;
   OCTET_STRING_fromBuf(&s1SetupRequest.eNBname, "ENB 1 eurecom",
                        strlen("ENB 1 eurecom"));
-
   memset(&ta, 0, sizeof(SupportedTAs_Item_t));
   memset(&plmnIdentity, 0, sizeof(PLMNidentity_t));
   OCTET_STRING_fromBuf(&ta.tAC, tac, 2);
   OCTET_STRING_fromBuf(&plmnIdentity, identity, 3);
   ASN_SEQUENCE_ADD(&ta.broadcastPLMNs, &plmnIdentity);
   ASN_SEQUENCE_ADD(&s1SetupRequest.supportedTAs, &ta);
-
   s1SetupRequest.defaultPagingDRX = PagingDRX_v64;
-
   s1ap_eNB_encode_s1setuprequest(&s1SetupRequest, &buffer, &len);
-
   assoc[0] = sctp_connect_to_remote_host(ip_addr, 36412, &recv_callback);
   sctp_send_msg(0, 0, buffer, len);
-
   free(buffer);
-
   //     generateUplinkNASTransport(&buffer, &len);
   //     sctp_send_msg(assoc[0], 0, buffer, len);
   //     s1ap_mme_decode_pdu(buffer, len);
-
   pthread_join(sctp_get_receiver_thread(assoc[0]), NULL);
-
   return(0);
 }
diff --git a/openair3/TEST/oaisim_mme_list_benchmark.c b/openair3/TEST/oaisim_mme_list_benchmark.c
index bfd9274b8a83bf937fa66595af1d194b329c5531..633e83aace9e37786af3b96ad2820ee0ca2868f3 100644
--- a/openair3/TEST/oaisim_mme_list_benchmark.c
+++ b/openair3/TEST/oaisim_mme_list_benchmark.c
@@ -35,7 +35,6 @@
 #include "s1ap_common.h"
 #include "s1ap_eNB.h"
 #include "s1ap_mme.h"
-#include "s1ap_ies_defs.h"
 
 #include "s1ap_eNB_encoder.h"
 #include "s1ap_eNB_decoder.h"
@@ -79,27 +78,22 @@ void s1ap_test_generate_s1_setup_request(uint32_t eNB_id, uint8_t **buffer,
   SupportedTAs_Item_t ta;
   PLMNidentity_t plmnIdentity;
   uint8_t *id_p = (uint8_t *)(&eNB_id + 1);
-
   memset(&s1SetupRequest, 0, sizeof(S1SetupRequestIEs_t));
   s1SetupRequest.global_ENB_ID.eNB_ID.present = ENB_ID_PR_macroENB_ID;
   s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.buf = id_p;
   s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.size = 3;
   s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.bits_unused = 4;
   OCTET_STRING_fromBuf(&s1SetupRequest.global_ENB_ID.pLMNidentity, identity, 3);
-
   s1SetupRequest.presenceMask |= S1SETUPREQUESTIES_ENBNAME_PRESENT;
   OCTET_STRING_fromBuf(&s1SetupRequest.eNBname, "ENB 1 eurecom",
                        strlen("ENB 1 eurecom"));
-
   memset(&ta, 0, sizeof(SupportedTAs_Item_t));
   memset(&plmnIdentity, 0, sizeof(PLMNidentity_t));
   OCTET_STRING_fromBuf(&ta.tAC, tac, 2);
   OCTET_STRING_fromBuf(&plmnIdentity, identity, 3);
   ASN_SEQUENCE_ADD(&ta.broadcastPLMNs, &plmnIdentity);
   ASN_SEQUENCE_ADD(&s1SetupRequest.supportedTAs, &ta);
-
   s1SetupRequest.defaultPagingDRX = PagingDRX_v64;
-
   s1ap_eNB_encode_s1_setup_request(&s1SetupRequest, buffer, length);
 }
 
@@ -109,13 +103,10 @@ int s1ap_test_generate_initial_ue_message(uint32_t eNB_UE_S1AP_ID,
 {
   InitialUEMessageIEs_t  initialUEmessageIEs;
   InitialUEMessageIEs_t *initialUEmessageIEs_p = &initialUEmessageIEs;
-
   memset(initialUEmessageIEs_p, 0, sizeof(InitialUEMessageIEs_t));
-
   initialUEmessageIEs.eNB_UE_S1AP_ID = eNB_UE_S1AP_ID & 0x00ffffff;
   initialUEmessageIEs.nas_pdu.buf = (uint8_t *)infoNAS;
   initialUEmessageIEs.nas_pdu.size = sizeof(infoNAS);
-
   initialUEmessageIEs.tai.tAC.buf = (uint8_t *)tac;
   initialUEmessageIEs.tai.tAC.size = 2;
   initialUEmessageIEs.tai.pLMNidentity.buf = (uint8_t *)identity;
@@ -125,9 +116,7 @@ int s1ap_test_generate_initial_ue_message(uint32_t eNB_UE_S1AP_ID,
   initialUEmessageIEs.eutran_cgi.cell_ID.buf = (uint8_t *)id;
   initialUEmessageIEs.eutran_cgi.cell_ID.size = 4;
   initialUEmessageIEs.eutran_cgi.cell_ID.bits_unused = 4;
-
   initialUEmessageIEs.rrC_Establishment_Cause = RRC_Establishment_Cause_mo_Data;
-
   return s1ap_eNB_encode_initial_ue_message(initialUEmessageIEs_p, buffer, length);
 }
 
@@ -140,26 +129,19 @@ int s1ap_test_generate_initial_setup_resp(uint32_t eNB_UE_S1AP_ID,
 {
   InitialContextSetupResponseIEs_t  initialResponseIEs;
   InitialContextSetupResponseIEs_t *initialResponseIEs_p = &initialResponseIEs;
-
   E_RABSetupItemCtxtSURes_t e_RABSetupItemCtxtSURes;
-
   memset(initialResponseIEs_p, 0, sizeof(InitialContextSetupResponseIEs_t));
   memset(&e_RABSetupItemCtxtSURes, 0, sizeof(E_RABSetupItemCtxtSURes_t));
-
   initialResponseIEs_p->mme_ue_s1ap_id = mme_UE_S1AP_ID;
   initialResponseIEs_p->eNB_UE_S1AP_ID = eNB_UE_S1AP_ID;
-
   e_RABSetupItemCtxtSURes.e_RAB_ID = eRAB_id;
   e_RABSetupItemCtxtSURes.transportLayerAddress.buf = (uint8_t *)&ipv4_local;
   e_RABSetupItemCtxtSURes.transportLayerAddress.size = 4;
-
   e_RABSetupItemCtxtSURes.gTP_TEID.buf = (uint8_t *)&teid;
   e_RABSetupItemCtxtSURes.gTP_TEID.size = 4;
-
   ASN_SEQUENCE_ADD(
     &initialResponseIEs_p->e_RABSetupListCtxtSURes.e_RABSetupItemCtxtSURes,
     &e_RABSetupItemCtxtSURes);
-
   return s1ap_eNB_encode_initial_context_setup_response(initialResponseIEs_p,
          buffer, length);
 }
@@ -169,19 +151,19 @@ int recv_callback(uint32_t  assocId,
                   uint8_t  *buffer,
                   uint32_t  length)
 {
-  s1ap_message message;
+  S1AP_S1AP_PDU_t pdu;
   uint8_t *buffer2;
   uint32_t len;
   int j;
 
-  if (s1ap_eNB_decode_pdu(&message, buffer, length) < 0) {
+  if (s1ap_eNB_decode_pdu(&pdu, buffer, length) < 0) {
     fprintf(stderr, "s1ap_eNB_decode_pdu returned status < 0\n");
     free(buffer);
     return -1;
   }
 
-  if (message.procedureCode == ProcedureCode_id_S1Setup
-      && message.direction == S1AP_PDU_PR_successfulOutcome) {
+  if (pdu.initiatingMessage.procedureCode == S1AP_ProcedureCode_id_S1Setup
+      && pdu.present == S1AP_S1AP_PDU_PR_successfulOutcome) {
     for (j = 0; j < nb_ue; j++) {
       s1ap_test_generate_initial_ue_message(j, &buffer2, &len);
 
@@ -194,8 +176,8 @@ int recv_callback(uint32_t  assocId,
 
       free(buffer2);
     }
-  } else if (message.procedureCode == ProcedureCode_id_InitialContextSetup
-             && message.direction == S1AP_PDU_PR_initiatingMessage) {
+  } else if (pdu.initiatingMessage.procedureCode == S1AP_ProcedureCode_id_InitialContextSetup
+             && pdu.present == S1AP_PDU_PR_initiatingMessage) {
     fprintf(stdout, "Received InitialContextSetup request\n");
     s1ap_test_generate_initial_setup_resp(
       message.msg.initialContextSetupRequestIEs.eNB_UE_S1AP_ID,
@@ -220,7 +202,6 @@ int recv_callback(uint32_t  assocId,
   }
 
   free(buffer);
-
   return 0;
 }
 
@@ -231,9 +212,7 @@ int sctp_connected(void     *args,
 {
   uint8_t *buffer;
   uint32_t len;
-
   fprintf(stdout, "New association %d\n", assocId);
-
   s1ap_test_generate_s1_setup_request(assocId * nb_eNB, &buffer, &len);
 
   if (sctp_send_msg(assocId, 0, buffer, len) < 0) {
@@ -244,7 +223,6 @@ int sctp_connected(void     *args,
   }
 
   free(buffer);
-
   connected_eNB++;
   return 0;
 }
@@ -252,12 +230,9 @@ int sctp_connected(void     *args,
 int main(int argc, char *argv[])
 {
   asn_enc_rval_t retVal;
-
   int i;
-
   SupportedTAs_Item_t ta;
   PLMNidentity_t plmnIdentity;
-
   asn_debug = 0;
   asn1_xer_print = 0;
 
@@ -278,12 +253,9 @@ int main(int argc, char *argv[])
     sleep(1);
   }
 
-
   //     generateUplinkNASTransport(&buffer, &len);
   //     sctp_send_msg(assoc[0], 0, buffer, len);
   //     s1ap_mme_decode_pdu(buffer, len);
-
   sctp_terminate();
-
   return(0);
 }
diff --git a/openair3/TEST/oaisim_mme_s1ap_test.c b/openair3/TEST/oaisim_mme_s1ap_test.c
index 1f7c1d3bbf803f406feb710f4bed60b33e4271ed..aa8f92aee128750cffa67e06f3db364f5e0e2b7f 100644
--- a/openair3/TEST/oaisim_mme_s1ap_test.c
+++ b/openair3/TEST/oaisim_mme_s1ap_test.c
@@ -145,16 +145,16 @@ int main(int argc, char *argv[])
   }
 
   for (i = 0; i < sizeof(s1ap_test) / sizeof(s1ap_test_t); i++) {
-    struct s1ap_message_s message;
+    S1AP_S1AP_PDU_t pdu;
     uint8_t *buffer;
     uint32_t length;
-    memset(&message, 0, sizeof(struct s1ap_message_s));
+    memset(&pdu, 0, sizeof(pdu));
     printf("Trying to decode %s procedure with asn1c decoder\n",
            s1ap_test[i].procedure_name);
 
-    if (s1ap_mme_decode_pdu(&message, s1ap_test[i].buffer,
+    if (s1ap_mme_decode_pdu(&pdu, s1ap_test[i].buffer,
                             s1ap_test[i].buf_len) < 0) {
-      if (s1ap_eNB_decode_pdu(&message, s1ap_test[i].buffer,
+      if (s1ap_eNB_decode_pdu(&pdu, s1ap_test[i].buffer,
                               s1ap_test[i].buf_len) < 0) {
         printf("Failed to decode this message\n");
       } else {
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
     printf("Trying to encode %s procedure with asn1c encoder\n",
            s1ap_test[i].procedure_name);
 
-    if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+    if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
       printf("Failed to encode this message on MME side, trying eNB side\n");
     } else {
       compare_buffer(buffer, length, s1ap_test[i].buffer, s1ap_test[i].buf_len);
diff --git a/openair3/TEST/oaisim_mme_sctp_test.c b/openair3/TEST/oaisim_mme_sctp_test.c
index d810f9ee8f8f19936d14cb58f8c911ead3f5e1ca..b8be3e185cc9aa1a853545728af771901e7c5152 100644
--- a/openair3/TEST/oaisim_mme_sctp_test.c
+++ b/openair3/TEST/oaisim_mme_sctp_test.c
@@ -35,7 +35,6 @@
 #include "s1ap_common.h"
 #include "s1ap_eNB.h"
 #include "s1ap_mme.h"
-#include "s1ap_ies_defs.h"
 
 #include "s1ap_eNB_encoder.h"
 #include "s1ap_eNB_decoder.h"
@@ -45,9 +44,7 @@ int recv_callback(uint32_t  assocId,
                   uint8_t  *buffer,
                   uint32_t  length)
 {
-
   free(buffer);
-
   return 0;
 }
 
@@ -56,14 +53,12 @@ int sctp_connected(void     *args,
                    uint32_t  instreams,
                    uint32_t  outstreams)
 {
-
   return 0;
 }
 
 int main(int argc, char *argv[])
 {
   asn_enc_rval_t retVal;
-
   int i;
 
   for (i = 0; i < nb_eNB; i++) {
@@ -75,6 +70,5 @@ int main(int argc, char *argv[])
   }
 
   sctp_terminate();
-
   return(0);
 }
diff --git a/openair3/TEST/oaisim_mme_test_s1c_s1ap.c b/openair3/TEST/oaisim_mme_test_s1c_s1ap.c
index 993fad2f89df6ab11e49dacfd8f82abcccded082..10d43d595d3107544d046996d774b78f5ffdaae2 100644
--- a/openair3/TEST/oaisim_mme_test_s1c_s1ap.c
+++ b/openair3/TEST/oaisim_mme_test_s1c_s1ap.c
@@ -43,7 +43,6 @@
 #include "intertask_interface.h"
 #include "s1ap_eNB_default_values.h"
 #include "s1ap_common.h"
-#include "s1ap_ies_defs.h"
 #include "s1ap_eNB_defs.h"
 #include "s1ap_eNB_management_procedures.h"
 #include "assertions.h"
@@ -55,11 +54,9 @@
 void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind)
 {
   int result;
-
   DevAssert(sctp_data_ind != NULL);
   mme_test_s1_notify_sctp_data_ind(sctp_data_ind->assoc_id, sctp_data_ind->stream,
-          sctp_data_ind->buffer, sctp_data_ind->buffer_length);
-
+                                   sctp_data_ind->buffer, sctp_data_ind->buffer_length);
   result = itti_free(TASK_UNKNOWN, sctp_data_ind->buffer);
   AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
 }
@@ -70,16 +67,12 @@ void s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uin
 {
   MessageDef      *message_p;
   sctp_data_req_t *sctp_data_req;
-
   message_p = itti_alloc_new_message(TASK_S1AP, SCTP_DATA_REQ);
-
   sctp_data_req = &message_p->ittiMsg.sctp_data_req;
-
   sctp_data_req->assoc_id      = assoc_id;
   sctp_data_req->buffer        = buffer;
   sctp_data_req->buffer_length = buffer_length;
   sctp_data_req->stream        = stream;
-
   itti_send_msg_to_task(TASK_SCTP, instance, message_p);
 }
 
@@ -100,7 +93,6 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut
       /* If there are no more associated MME, inform eNB app */
       if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb == 0) {
         MessageDef                 *message_p;
-
         message_p = itti_alloc_new_message(TASK_S1AP, S1AP_DEREGISTERED_ENB_IND);
         S1AP_DEREGISTERED_ENB_IND(message_p).nb_mme = 0;
         itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
@@ -119,7 +111,6 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut
     /* If there are no more pending messages, inform eNB app */
     if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb == 0) {
       MessageDef                 *message_p;
-
       message_p = itti_alloc_new_message(TASK_S1AP, S1AP_REGISTER_ENB_CNF);
       S1AP_REGISTER_ENB_CNF(message_p).nb_mme = mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb;
       itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
@@ -131,12 +122,9 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
 {
   s1ap_eNB_instance_t *instance_p;
   s1ap_eNB_mme_data_t *s1ap_mme_data_p;
-
   DevAssert(sctp_new_association_resp != NULL);
-
   instance_p = s1ap_eNB_get_instance(instance);
   DevAssert(instance_p != NULL);
-
   s1ap_mme_data_p = s1ap_eNB_get_MME(instance_p, -1,
                                      sctp_new_association_resp->ulp_cnx_id);
   DevAssert(s1ap_mme_data_p != NULL);
@@ -146,9 +134,7 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
               sctp_new_association_resp->sctp_state,
               instance,
               sctp_new_association_resp->ulp_cnx_id);
-
     s1ap_handle_s1_setup_message(s1ap_mme_data_p, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN);
-
     return;
   }
 
@@ -156,49 +142,37 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
   s1ap_mme_data_p->assoc_id    = sctp_new_association_resp->assoc_id;
   s1ap_mme_data_p->in_streams  = sctp_new_association_resp->in_streams;
   s1ap_mme_data_p->out_streams = sctp_new_association_resp->out_streams;
-
   /* Prepare new S1 Setup Request */
   mme_test_s1_start_test(instance_p, s1ap_mme_data_p);
 }
 
 void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
-                                  net_ip_address_t    *mme_ip_address,
-                                  net_ip_address_t    *local_ip_addr)
+                           net_ip_address_t    *mme_ip_address,
+                           net_ip_address_t    *local_ip_addr)
 {
   MessageDef                 *message_p                   = NULL;
   sctp_new_association_req_t *sctp_new_association_req_p  = NULL;
   s1ap_eNB_mme_data_t        *s1ap_mme_data_p             = NULL;
-
   DevAssert(instance_p != NULL);
   DevAssert(mme_ip_address != NULL);
-
   message_p = itti_alloc_new_message(TASK_S1AP, SCTP_NEW_ASSOCIATION_REQ);
-
   sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req;
-
   sctp_new_association_req_p->port = S1AP_PORT_NUMBER;
   sctp_new_association_req_p->ppid = S1AP_SCTP_PPID;
-
   memcpy(&sctp_new_association_req_p->remote_address,
          mme_ip_address,
          sizeof(*mme_ip_address));
-
   memcpy(&sctp_new_association_req_p->local_address,
          local_ip_addr,
          sizeof(*local_ip_addr));
-
   /* Create new MME descriptor */
   s1ap_mme_data_p = calloc(1, sizeof(*s1ap_mme_data_p));
   DevAssert(s1ap_mme_data_p != NULL);
-
   s1ap_mme_data_p->cnx_id                = s1ap_eNB_fetch_add_global_cnx_id();
   sctp_new_association_req_p->ulp_cnx_id = s1ap_mme_data_p->cnx_id;
-
   s1ap_mme_data_p->assoc_id          = -1;
   s1ap_mme_data_p->s1ap_eNB_instance = instance_p;
-
   STAILQ_INIT(&s1ap_mme_data_p->served_gummei);
-
   /* Insert the new descriptor in list of known MME
    * but not yet associated.
    */
@@ -206,7 +180,6 @@ void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
   s1ap_mme_data_p->state = S1AP_ENB_STATE_WAITING;
   instance_p->s1ap_mme_nb ++;
   instance_p->s1ap_mme_pending_nb ++;
-
   itti_send_msg_to_task(TASK_SCTP, instance_p->instance, message_p);
 }
 
@@ -216,9 +189,7 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
 {
   s1ap_eNB_instance_t *new_instance;
   uint8_t index;
-
   DevAssert(s1ap_register_eNB != NULL);
-
   /* Look if the provided instance already exists */
   new_instance = s1ap_eNB_get_instance(instance);
 
@@ -234,10 +205,8 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
   } else {
     new_instance = calloc(1, sizeof(s1ap_eNB_instance_t));
     DevAssert(new_instance != NULL);
-
     RB_INIT(&new_instance->s1ap_ue_head);
     RB_INIT(&new_instance->s1ap_mme_head);
-
     /* Copy usefull parameters */
     new_instance->instance         = instance;
     new_instance->eNB_name         = s1ap_register_eNB->eNB_name;
@@ -248,10 +217,8 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
     new_instance->mnc              = s1ap_register_eNB->mnc;
     new_instance->mnc_digit_length = s1ap_register_eNB->mnc_digit_length;
     new_instance->default_drx      = s1ap_register_eNB->default_drx;
-
     /* Add the new instance to the list of eNB (meaningfull in virtual mode) */
     s1ap_eNB_insert_new_instance(new_instance);
-
     S1AP_DEBUG("Registered new eNB[%d] and %s eNB id %u\n",
                instance,
                s1ap_register_eNB->cell_type == CELL_MACRO_ENB ? "macro" : "home",
@@ -275,54 +242,48 @@ void *s1ap_eNB_task(void *arg)
 {
   MessageDef *received_msg = NULL;
   int         result;
-
   S1AP_DEBUG("Starting S1AP layer\n");
-
   s1ap_eNB_prepare_internal_data();
-
   itti_mark_task_ready(TASK_S1AP);
 
   while (1) {
     itti_receive_msg(TASK_S1AP, &received_msg);
 
     switch (ITTI_MSG_ID(received_msg)) {
-    case TERMINATE_MESSAGE:
-      itti_exit_task();
+      case TERMINATE_MESSAGE:
+        itti_exit_task();
+        break;
+
+      case S1AP_REGISTER_ENB_REQ: {
+        /* Register a new eNB.
+         * in Virtual mode eNBs will be distinguished using the mod_id/
+         * Each eNB has to send an S1AP_REGISTER_ENB message with its
+         * own parameters.
+         */
+        s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                     &S1AP_REGISTER_ENB_REQ(received_msg));
+      }
       break;
 
-    case S1AP_REGISTER_ENB_REQ: {
-      /* Register a new eNB.
-       * in Virtual mode eNBs will be distinguished using the mod_id/
-       * Each eNB has to send an S1AP_REGISTER_ENB message with its
-       * own parameters.
-       */
-      s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                   &S1AP_REGISTER_ENB_REQ(received_msg));
-    }
-    break;
-
-    case SCTP_NEW_ASSOCIATION_RESP: {
-      s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
-                                            &received_msg->ittiMsg.sctp_new_association_resp);
-    }
-    break;
-
-    case SCTP_DATA_IND: {
-      s1ap_eNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
-    }
-    break;
-
-
+      case SCTP_NEW_ASSOCIATION_RESP: {
+        s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                              &received_msg->ittiMsg.sctp_new_association_resp);
+      }
+      break;
 
-    default:
-      S1AP_ERROR("Received unhandled message: %d:%s\n",
-                 ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
+      case SCTP_DATA_IND: {
+        s1ap_eNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
+      }
       break;
+
+      default:
+        S1AP_ERROR("Received unhandled message: %d:%s\n",
+                   ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
+        break;
     }
 
     result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg);
     AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
-
     received_msg = NULL;
   }
 
diff --git a/openair3/TEST/test_s1ap.c b/openair3/TEST/test_s1ap.c
index a366796f77da1e201e73782be16e69da225f19f1..a040822155daadefdd241cc6a117239286068b41 100644
--- a/openair3/TEST/test_s1ap.c
+++ b/openair3/TEST/test_s1ap.c
@@ -153,22 +153,20 @@ static int compare_buffer(uint8_t *buffer, uint32_t length_buffer,
 void doit (void)
 {
   int i;
-
   break_on_error = 1;
 
   //     asn1_xer_print = 1;
   //     asn_debug = 1;
 
   for (i = 0; i < sizeof(s1ap_test) / sizeof(s1ap_test_t); i++) {
-    struct s1ap_message_s message;
+    S1AP_S1AP_PDU_t pdu;
     uint8_t *buffer;
     uint32_t length;
-
-    memset(&message, 0, sizeof(struct s1ap_message_s));
+    memset(&pdu, 0, sizeof(pdu));
 
     if (s1ap_test[i].originating == ENB) {
       /* eNB originated procedure -> USE MME decoder */
-      if (s1ap_mme_decode_pdu(&message, s1ap_test[i].buffer,
+      if (s1ap_mme_decode_pdu(&pdu, s1ap_test[i].buffer,
                               s1ap_test[i].buf_len) < 0) {
         fail("Failed to decode %s\n", s1ap_test[i].procedure_name);
       } else {
@@ -176,7 +174,7 @@ void doit (void)
       }
     } else {
       /* MME originated procedure -> USE eNB decoder */
-      if (s1ap_eNB_decode_pdu(&message, s1ap_test[i].buffer,
+      if (s1ap_eNB_decode_pdu(&pdu, s1ap_test[i].buffer,
                               s1ap_test[i].buf_len) < 0) {
         fail("Failed to decode %s\n", s1ap_test[i].procedure_name);
       } else {
@@ -186,14 +184,14 @@ void doit (void)
 
     if (s1ap_test[i].originating == ENB) {
       /* eNB originated procedure -> USE eNB encoder */
-      if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+      if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
         fail("Failed to decode %s\n", s1ap_test[i].procedure_name);
       } else {
         success("Encoded %s correctly\n", s1ap_test[i].procedure_name);
       }
     } else {
       /* MME originated procedure -> USE mme encoder */
-      if (s1ap_mme_encode_pdu(&message, &buffer, &length) < 0) {
+      if (s1ap_mme_encode_pdu(&pdu, &buffer, &length) < 0) {
         fail("Failed to encode %s\n", s1ap_test[i].procedure_name);
       } else {
         success("Encoded %s correctly\n", s1ap_test[i].procedure_name);
diff --git a/targets/COMMON/openairinterface5g_limits.h b/targets/COMMON/openairinterface5g_limits.h
index 4ce85f4cad6dd6b56f99042bc18619cadf86aec2..dba7b5616e940c4266b570e50946b88d842a08d0 100644
--- a/targets/COMMON/openairinterface5g_limits.h
+++ b/targets/COMMON/openairinterface5g_limits.h
@@ -3,32 +3,74 @@
 
 #if defined(CBMIMO1) || defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
 #        define NUMBER_OF_eNB_MAX 1
+#        define NUMBER_OF_gNB_MAX 1
+
 #        define NUMBER_OF_RU_MAX 2
+#        define NUMBER_OF_NR_RU_MAX 2
+
 #        define NUMBER_OF_UE_MAX 16
+#        define NUMBER_OF_NR_UE_MAX 16
+
 #        define NUMBER_OF_CONNECTED_eNB_MAX 3
+#        define NUMBER_OF_CONNECTED_gNB_MAX 3
+
 #else
 #        define NUMBER_OF_eNB_MAX 7
+#        define NUMBER_OF_gNB_MAX 7
+
 #        define NUMBER_OF_RU_MAX 32
+#        define NUMBER_OF_NR_RU_MAX 32
+
 #        define NUMBER_OF_UE_MAX 20
+#        define NUMBER_OF_NR_UE_MAX 20
+
 #        define NUMBER_OF_CONNECTED_eNB_MAX 3
+#        define NUMBER_OF_CONNECTED_gNB_MAX 3
+
 #        if defined(STANDALONE) && STANDALONE==1
 #                undef  NUMBER_OF_eNB_MAX
+#                undef  NUMBER_OF_gNB_MAX
+
 #                undef  NUMBER_OF_UE_MAX
+#                undef  NUMBER_OF_NR_UE_MAX
+
 #                undef  NUMBER_OF_RU_MAX
+#                undef  NUMBER_OF_NR_RU_MAX
+
 #                define NUMBER_OF_eNB_MAX 3
+#                define NUMBER_OF_gNB_MAX 3
+
 #                define NUMBER_OF_UE_MAX 3
+#                define NUMBER_OF_NR_UE_MAX 3
+
 #                define NUMBER_OF_RU_MAX 3
+#                define NUMBER_OF_NR_RU_MAX 3
 #        endif
 
 #        if defined(LARGE_SCALE) && LARGE_SCALE
 #                undef  NUMBER_OF_eNB_MAX
+#                undef  NUMBER_OF_gNB_MAX
+
 #                undef  NUMBER_OF_UE_MAX
+#                undef  NUMBER_OF_NR_UE_MAX
+
 #                undef  NUMBER_OF_CONNECTED_eNB_MAX
+#                undef  NUMBER_OF_CONNECTED_gNB_MAX
+
 #                undef  NUMBER_OF_RU_MAX
+#                undef  NUMBER_OF_NR_RU_MAX
+
 #                define NUMBER_OF_eNB_MAX 2
+#                define NUMBER_OF_gNB_MAX 2
+
 #                define NUMBER_OF_UE_MAX 120
+#                define NUMBER_OF_NR_UE_MAX 120
+
 #                define NUMBER_OF_RU_MAX 16
+#                define NUMBER_OF_NR_RU_MAX 16
+
 #                define NUMBER_OF_CONNECTED_eNB_MAX 1 // to save some memory
+#                define NUMBER_OF_CONNECTED_gNB_MAX 1
 #        endif
 #endif
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
index cfbfa51cab275669015604756f7e00f9436121e1..7833c02e1f8f0b43c0302aafa2ae898aa5e7895c 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
@@ -2,15 +2,15 @@ Active_eNBs = ( "eNB-Eurecom-LTEBox");
 # Asn1_verbosity, choice in: none, info, annoying
 Asn1_verbosity = "none";
 
-eNBs =
+gNBs =
 (
  {
     ////////// Identification parameters:
-    eNB_ID    =  0xe00;
+    gNB_ID    =  0xe00;
 
     cell_type =  "CELL_MACRO_ENB";
 
-    eNB_name  =  "eNB-Eurecom-LTEBox";
+    gNB_name  =  "eNB-Eurecom-LTEBox";
 
     // Tracking area code, 0x0000 and 0xfffe are reserved values
     tracking_area_code  =  "1";
@@ -25,43 +25,43 @@ eNBs =
 
     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              			      = 7;
-      downlink_frequency      			      = 2685000000L;
-      uplink_frequency_offset 			      = -120000000;
-      Nid_cell					      = 0;
-      N_RB_DL                 			      = 50;
-      Nid_cell_mbsfn          			      = 0;
-      nb_antenna_ports                                = 1;
-      nb_antennas_tx          			      = 1;
-      nb_antennas_rx          			      = 1;
+      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                                         = 7;
+      downlink_frequency                                 = 2685000000L;
+      uplink_frequency_offset                            = -120000000;
+      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                                            = 125;
-      pbch_repetition                                 = "FALSE";
-      prach_root              			      = 0;
-      prach_config_index      			      = 0;
-      prach_high_speed        			      = "DISABLE";
-      prach_zero_correlation  			      = 1;
-      prach_freq_offset       			      = 2;
-      pucch_delta_shift       			      = 1;
-      pucch_nRB_CQI           			      = 0;
-      pucch_nCS_AN            			      = 0;
-      pucch_n1_AN             			      = 32;
-      pdsch_referenceSignalPower 			      = -27;
-      pdsch_p_b                  			      = 0;
-      pusch_n_SB                 			      = 1;
-      pusch_enable64QAM          			      = "DISABLE";
+      pbch_repetition                                    = "FALSE";
+      prach_root                                         = 0;
+      prach_config_index                                 = 0;
+      prach_high_speed                                   = "DISABLE";
+      prach_zero_correlation                             = 1;
+      prach_freq_offset                                  = 2;
+      pucch_delta_shift                                  = 1;
+      pucch_nRB_CQI                                      = 0;
+      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_groupHoppingEnabled                          = "ENABLE";
+      pusch_groupAssignment                              = 0;
+      pusch_sequenceHoppingEnabled                       = "DISABLE";
       pusch_nDMRS1                                       = 1;
       phich_duration                                     = "NORMAL";
       phich_resource                                     = "ONESIXTH";
@@ -79,7 +79,7 @@ eNBs =
       pucch_deltaF_Format1b                              = "deltaF3";
       pucch_deltaF_Format2                               = "deltaF0";
       pucch_deltaF_Format2a                              = "deltaF0";
-      pucch_deltaF_Format2b		    	      = "deltaF0";
+      pucch_deltaF_Format2b                              = "deltaF0";
 
       rach_numberOfRA_Preambles                          = 64;
       rach_preamblesGroupAConfig                         = "DISABLE";
@@ -97,14 +97,14 @@ eNBs =
 
       pcch_default_PagingCycle                           = 128;
       pcch_nB                                            = "oneT";
-      bcch_modificationPeriodCoeff			      = 2;
-      ue_TimersAndConstants_t300			      = 1000;
-      ue_TimersAndConstants_t301			      = 1000;
-      ue_TimersAndConstants_t310			      = 1000;
-      ue_TimersAndConstants_t311			      = 10000;
-      ue_TimersAndConstants_n310			      = 20;
-      ue_TimersAndConstants_n311			      = 1;
-      ue_TransmissionMode                                    = 1;
+      bcch_modificationPeriodCoeff                       = 2;
+      ue_TimersAndConstants_t300                         = 1000;
+      ue_TimersAndConstants_t301                         = 1000;
+      ue_TimersAndConstants_t310                         = 1000;
+      ue_TimersAndConstants_t311                         = 10000;
+      ue_TimersAndConstants_n310                         = 20;
+      ue_TimersAndConstants_n311                         = 1;
+      ue_TransmissionMode                                = 1;
       }
     );
 
@@ -218,3 +218,237 @@ NETWORK_CONTROLLER :
        rrc_log_verbosity                     ="medium";
     };
 
+
+
+
+
+Active_gNBs = ( "gNB_Eurecom_5GNRBox");
+# Asn1_verbosity, choice in: none, info, annoying
+Asn1_verbosity = "none";
+
+gNBs =
+(
+ {
+    ////////// Identification parameters:
+    gNB_ID    =  0xe00;
+
+    cell_type =  "CELL_MACRO_GNB";
+
+    gNB_name  =  "gNB_Eurecom_LTEBox";
+
+    // Tracking area code, 0x0000 and 0xfffe are reserved values
+    tracking_area_code  =  "1";
+
+    mobile_country_code =  "208";
+
+    mobile_network_code =  "93";
+
+    tr_s_preference     = "local_mac"
+
+    ////////// Physical parameters:
+
+    component_carriers = (
+      {
+      node_function                                                 = "3GPP_gNODEB";
+      node_timing                                                   = "synch_to_ext_device";
+      node_synch_ref                                                = 0;
+      frame_type					                                          = "FDD";
+      DL_prefix_type             			                              = "NORMAL";
+      UL_prefix_type                                                = "NORMAL";
+      eutra_band              			                                = 7;
+      downlink_frequency      			                                = 2685000000L;
+      uplink_frequency_offset 			                                = -120000000;
+      Nid_cell					                                            = 0;
+      N_RB_DL                 			                                = 50;
+      nb_antenna_ports                                              = 1;
+      nb_antennas_tx          			                                = 1;
+      nb_antennas_rx          			                                = 1;
+      tx_gain                                                       = 90;
+      rx_gain                                                       = 125;
+      MIB_subCarrierSpacingCommon                                   = 0;
+      MIB_ssb_SubcarrierOffset                                      = 0;
+      MIB_dmrs_TypeA_Position                                       = 0;
+      pdcch_ConfigSIB1                                              = 0;
+      SIB1_frequencyOffsetSSB                                       = 0; 
+      SIB1_ssb_PeriodicityServingCell                               = 0;
+      SIB1_ss_PBCH_BlockPower                                       = 0;      
+      absoluteFrequencySSB                                          = 0;
+      ssb_SubcarrierOffset                                          = 0;
+      DL_FreqBandIndicatorNR                                        = 0;
+      DL_absoluteFrequencyPointA                                    = 0;
+      DL_offsetToCarrier                                            = 0;
+      DL_SCS_SubcarrierSpacing                                      = 0;
+      DL_SCS_SpecificCarrier_k0                                     = 0;
+      DL_carrierBandwidth                                           = 0;
+      DL_locationAndBandwidth                                       = 0;
+      DL_BWP_SubcarrierSpacing                                      = 0;
+      DL_BWP_prefix_type                                            = "NORMAL";
+      UL_FreqBandIndicatorNR                                        = 0;
+      UL_absoluteFrequencyPointA                                    = 0;
+      UL_additionalSpectrumEmission                                 = 0;
+      UL_p_Max                                                      = 0;
+      UL_frequencyShift7p5khz                                       = 0;
+      UL_offsetToCarrier                                            = 0;
+      UL_SCS_SubcarrierSpacing                                      = 0;
+      UL_SCS_SpecificCarrier_k0                                     = 0;
+      UL_carrierBandwidth                                           = 0;
+      UL_locationAndBandwidth                                       = 0;
+      UL_BWP_SubcarrierSpacing                                      = 0;
+      UL_BWP_prefix_type                                            = 0;
+      ServingCellConfigCommon__ssb_PositionsInBurst_PR              = 0;
+      ServingCellConfigCommon_ssb_periodicityServingCell            = 0;
+      ServingCellConfigCommon_dmrs_TypeA_Position                   = 0;
+      NIA_SubcarrierSpacing                                         = 0; 
+      ServingCellConfigCommon_ss_PBCH_BlockPower                    = 0;
+      referenceSubcarrierSpacing                                    = 0;
+      dl_UL_TransmissionPeriodicity                                 = 0;
+      nrofDownlinkSlots                                             = 0;
+      nrofDownlinkSymbols                                           = 0;
+      nrofUplinkSlots                                               = 0;
+      nrofUplinkSymbols                                             = 0;
+      rach_totalNumberOfRA_Preambles                                = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 0;
+      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 0;
+      rach_groupBconfigured                                         = NULL;
+      rach_ra_Msg3SizeGroupA                                        = 0;
+      rach_messagePowerOffsetGroupB                                 = 0;
+      rach_numberOfRA_PreamblesGroupA                               = 0;
+      rach_ra_ContentionResolutionTimer                             = 0;
+      rsrp_ThresholdSSB                                             = 0;
+      rsrp_ThresholdSSB_SUL                                         = 0;
+      prach_RootSequenceIndex_choice                                = 0;
+      prach_RootSequenceIndex_l839                                  = 0;
+      prach_RootSequenceIndex_l139                                  = 0;
+      prach_msg1_SubcarrierSpacing                                  = 0;
+      restrictedSetConfig                                           = 0;
+      msg3_transformPrecoding                                       = 0;
+      prach_ConfigurationIndex                                      = 0;
+      prach_msg1_FDM                                                = 0;
+      prach_msg1_FrequencyStart                                     = 0;
+      zeroCorrelationZoneConfig                                     = 0;
+      preambleReceivedTargetPower                                   = 0;
+      preambleTransMax                                              = 0;
+      powerRampingStep                                              = 0;
+      ra_ResponseWindow                                             = 0;
+      groupHoppingEnabledTransformPrecoding                         = NULL;
+      msg3_DeltaPreamble                                            = 0;
+      p0_NominalWithGrant                                           = 0;
+      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
+      PUSCH_TimeDomainResourceAllocation_mappingType                = 0;
+      pucch_GroupHopping                                            = 0;
+      p0_nominal                                                    = 0;
+      PDSCH_TimeDomainResourceAllocation_k0                         = 0;
+      PDSCH_TimeDomainResourceAllocation_mappingType                = 0;
+      rateMatchPatternId                                            = 0;
+      RateMatchPattern_patternType                                  = 0;
+      symbolsInResourceBlock                                        = 0;
+      periodicityAndPattern                                         = 0;
+      RateMatchPattern_controlResourceSet                           = 0;
+      RateMatchPattern_subcarrierSpacing                            = 0;
+      RateMatchPattern_mode                                         = 0;
+      searchSpaceSIB1                                               = 0;
+      searchSpaceOtherSystemInformation                             = 0;
+      pagingSearchSpace                                             = 0;
+      ra_SearchSpace                                                = 0;
+      rach_ra_ControlResourceSet                                    = 0;
+      PDCCH_common_controlResourceSetId                             = 0;
+      PDCCH_common_ControlResourceSet_duration                      = 0;
+      PDCCH_cce_REG_MappingType                                     = 0;
+      PDCCH_reg_BundleSize                                          = 0;
+      PDCCH_interleaverSize                                         = 0;
+      PDCCH_shiftIndex                                              = 0;  
+      PDCCH_precoderGranularity                                     = 0;
+      PDCCH_TCI_StateId                                             = 0;
+      tci_PresentInDCI                                              = NULL;
+      SearchSpaceId                                                 = 0;
+      commonSearchSpaces_controlResourceSetId                       = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl1            = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl2            = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl4            = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl5            = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl8            = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl10           = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl16           = 0;
+      SearchSpace_monitoringSlotPeriodicityAndOffset_sl20           = 0;
+      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
+      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
+      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
+      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
+      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
+      SearchSpace_searchSpaceType                                   = 0;
+      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 0;
+      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 0;
+      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 0;
+      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 0;
+      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 0; 
+      Common_dci_Format2_3_monitoringPeriodicity                    = 0;
+      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 0;
+      ue_Specific__dci_Formats                                      = 0;
+      RateMatchPatternLTE_CRS_carrierFreqDL                         = 0;
+      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 0;
+      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 0;
+      RateMatchPatternLTE_CRS_v_Shift                               = 0;
+      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 0;
+      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
+      RateMatchPatternLTE_CRS_subframeAllocation_choice             = 0;
+      }
+    );
+
+
+    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       = "192.168.12.26";
+                              ipv6       = "192:168:30::17";
+                              active     = "yes";
+                              preference = "ipv4";
+                            }
+                          );
+
+    NETWORK_INTERFACES :
+    {
+
+        ENB_INTERFACE_NAME_FOR_S1_MME            = "eth0";
+        ENB_IPV4_ADDRESS_FOR_S1_MME              = "192.168.12.19/24";
+        ENB_INTERFACE_NAME_FOR_S1U               = "eth0";
+        ENB_IPV4_ADDRESS_FOR_S1U                 = "192.168.12.19/24";
+        ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
+    };
+  }
+);
diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c
index b2ace74474b91ffaf53ed931b74fa158d4eddc46..1eb4ba78f1c4d47c8240045bdbd8ed09d4b6de12 100644
--- a/targets/RT/USER/lte-ue.c
+++ b/targets/RT/USER/lte-ue.c
@@ -210,7 +210,12 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
   l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
 	     0,// cba_group_active
 	     0); // HO flag
-  
+
+#ifdef NR 
+//  nr_l2_init_ue();
+//  nr_l3_init_ue();
+#endif
+
   for (inst=0;inst<nb_inst;inst++) {
 
     LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]);