From 28f6e507f74d3fb069441e05da523378dee0f6ed Mon Sep 17 00:00:00 2001
From: Sakthivel Velumani <velumani@eurecom.fr>
Date: Mon, 5 Sep 2022 15:02:02 -0400
Subject: [PATCH] Header cleaups and unitary simulators build fixes

---
 CMakeLists.txt                                | 14 ++-
 openair1/SIMULATION/NR_PHY/dlschsim.c         |  3 +-
 openair1/SIMULATION/NR_PHY/dlsim.c            |  4 +-
 .../SIMULATION/NR_PHY/nr_dummy_functions.c    | 63 ++++++++++++-
 openair1/SIMULATION/NR_PHY/nr_gtp_stub.c      | 89 -------------------
 openair1/SIMULATION/NR_PHY/pbchsim.c          | 19 ++++
 openair1/SIMULATION/NR_PHY/prachsim.c         | 16 ++--
 openair1/SIMULATION/NR_PHY/pucchsim.c         |  1 +
 openair1/SIMULATION/NR_PHY/ulschsim.c         |  1 +
 openair1/SIMULATION/NR_PHY/ulsim.c            | 13 +--
 openair2/COMMON/e1ap_messages_types.h         |  1 +
 openair2/E1AP/CMakeLists.txt                  |  5 +-
 openair2/E1AP/e1ap.c                          |  6 ++
 openair2/E1AP/e1ap.h                          |  7 +-
 openair2/E1AP/e1ap_api.c                      |  8 +-
 openair2/E1AP/e1ap_api.h                      |  5 +-
 openair2/E1AP/e1ap_asnc.h                     | 65 ++++++++++++++
 openair2/E1AP/e1ap_common.c                   |  5 +-
 openair2/E1AP/e1ap_common.h                   | 38 +-------
 openair2/LAYER2/NR_MAC_gNB/main.c             |  2 +-
 openair2/RRC/NR/cucp_cuup_direct.c            |  4 +-
 openair2/RRC/NR/cucp_cuup_e1ap.c              |  2 +-
 openair2/RRC/NR/rrc_gNB.c                     |  2 -
 openair2/RRC/NR/rrc_gNB_NGAP.c                |  4 +-
 24 files changed, 198 insertions(+), 179 deletions(-)
 delete mode 100644 openair1/SIMULATION/NR_PHY/nr_gtp_stub.c
 create mode 100644 openair2/E1AP/e1ap_asnc.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e8642f5fafa..741c8667f66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1829,7 +1829,6 @@ set(NR_RLC_SRC
 
 set(NR_PDCP_SRC
   ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
-  ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_e1_api.c
   ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_ue_manager.c
   ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_entity.c
   ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_sdu.c
@@ -1900,8 +1899,6 @@ set(L2_NR_SRC
   ${NR_RRC_DIR}/L2_nr_interface.c
   ${NR_RRC_DIR}/mac_rrc_dl_direct.c
   ${NR_RRC_DIR}/mac_rrc_dl_f1ap.c
-  ${NR_RRC_DIR}/cucp_cuup_direct.c
-  ${NR_RRC_DIR}/cucp_cuup_e1ap.c
   ${NR_RRC_DIR}/nr_rrc_config.c
   ${NR_RRC_DIR}/rrc_gNB_nsa.c
   ${NR_RRC_DIR}/rrc_gNB_internode.c
@@ -2068,6 +2065,15 @@ add_library(L2_NR
   ${GNB_APP_SRC}
   )
 
+add_library(E1_IF
+  ${NR_RRC_DIR}/cucp_cuup_direct.c
+  ${NR_RRC_DIR}/cucp_cuup_e1ap.c
+  )
+
+add_library(E1_PDCP_IF
+  ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_e1_api.c
+  )
+
 target_link_libraries(L2_NR PRIVATE E1AP)
 
 add_library(L2_LTE_NR
@@ -2792,7 +2798,7 @@ target_link_libraries (nr-softmodem
   -Wl,--start-group
   UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECU_CN SECU_OSA
   ITTI ${FLPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB
-  NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR E1AP L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
+  NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR E1_IF L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
   X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB}
   -Wl,--end-group z dl)
 
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index 86f3c2d4ea4..f32759c4bb2 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -80,13 +80,14 @@ nfapi_mode_t nfapi_getmode(void) {
 }
 void nfapi_setmode(nfapi_mode_t nfapi_mode) { nfapi_mod=nfapi_mode; }
 
-
 nrUE_params_t nrUE_params={0};
 
 nrUE_params_t *get_nrUE_params(void) {
   return &nrUE_params;
 }
 
+NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {return(NULL);}
+
 int main(int argc, char **argv)
 {
   char c;
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index db1176831cc..73b5bdc9c1d 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -102,9 +102,6 @@ nfapi_ue_release_request_body_t release_rntis;
 instance_t DUuniqInstance=0;
 instance_t CUuniqInstance=0;
 
-
-// dummy functions
-
 int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
                               const int CC_id,
                               const uint8_t gNB_index,
@@ -675,6 +672,7 @@ int main(int argc, char **argv)
   /* initialize the sin table */
   InitSinLUT();
 
+  get_softmodem_params()->usim_test = 1;
   get_softmodem_params()->phy_test = 1;
   get_softmodem_params()->do_ra = 0;
   set_softmodem_optmask(SOFTMODEM_DLSIM_BIT);
diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
index a89e52e7a6d..e24f78b62ab 100644
--- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
+++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
@@ -16,7 +16,68 @@ int oai_nfapi_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { return(0);  }
 int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind) { return(0);  }
 
 int32_t get_uldl_offset(int nr_bandP)                                       { return(0);  }
-NR_IF_Module_t *NR_IF_Module_init(int Mod_id)                               {return(NULL);}
 
 int dummy_nr_ue_dl_indication(nr_downlink_indication_t *dl_info)            { return(0);  }
 int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info)              { return(0);  }
+void cucp_cuup_message_transfer_e1ap_init(gNB_RRC_INST *rrc) {}
+void cucp_cuup_message_transfer_direct_init(gNB_RRC_INST *rrc) {}
+teid_t newGtpuCreateTunnel(instance_t instance,
+                           ue_id_t ue_id,
+                           int incoming_bearer_id,
+                           int outgoing_bearer_id,
+                           teid_t outgoing_teid,
+                           int qfi,
+                           transport_layer_addr_t remoteAddr,
+                           int port,
+                           gtpCallback callBack,
+                           gtpCallbackSDAP callBackSDAP) {
+  return 0;
+}
+
+int newGtpuDeleteAllTunnels(instance_t instance, ue_id_t ue_id) {
+  return 0;
+}
+
+instance_t gtpv1Init(openAddr_t context) {return 0;}
+
+void GtpuUpdateTunnelOutgoingPair(instance_t instance,
+                                  ue_id_t ue_id,
+                                  ebi_t bearer_id,
+                                  teid_t newOutgoingTeid,
+                                  transport_layer_addr_t newRemoteAddr) {}
+
+int
+gtpv1u_create_ngu_tunnel(
+  const instance_t instanceP,
+  const gtpv1u_gnb_create_tunnel_req_t *  const create_tunnel_req_pP,
+        gtpv1u_gnb_create_tunnel_resp_t * const create_tunnel_resp_pP){
+  return 0;
+}
+
+int
+gtpv1u_update_ngu_tunnel(
+  const instance_t                              instanceP,
+  const gtpv1u_gnb_create_tunnel_req_t *const  create_tunnel_req_pP,
+  const ue_id_t                                 ue_id 
+){
+  return 0;
+}
+
+int gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
+  return 0;
+}
+
+int gtpv1u_delete_ngu_tunnel( const instance_t instance,
+			      gtpv1u_gnb_delete_tunnel_req_t *req) {
+  return 0;
+}
+
+int
+gtpv1u_create_s1u_tunnel(
+  const instance_t                              instanceP,
+  const gtpv1u_enb_create_tunnel_req_t *const  create_tunnel_req_pP,
+  gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP
+) {
+  return 0;
+}
+
diff --git a/openair1/SIMULATION/NR_PHY/nr_gtp_stub.c b/openair1/SIMULATION/NR_PHY/nr_gtp_stub.c
deleted file mode 100644
index 7a97987ad99..00000000000
--- a/openair1/SIMULATION/NR_PHY/nr_gtp_stub.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-  int gtpv1u_create_s1u_tunnel(const instance_t instance, const gtpv1u_enb_create_tunnel_req_t  *create_tunnel_req,
-                               gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp){
-    return 0;
-  }
-  int gtpv1u_update_s1u_tunnel(const instance_t instanceP,
-                               const gtpv1u_enb_create_tunnel_req_t   *create_tunnel_req_pP,
-                               const rnti_t prior_rnti
-                               ){
-    return 0;
-  }
-  
-  int gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP){
-    return 0;
-  }
-
-  int gtpv1u_create_x2u_tunnel(const instance_t instanceP,
-                               const gtpv1u_enb_create_x2u_tunnel_req_t   *const create_tunnel_req_pP,
-                               gtpv1u_enb_create_x2u_tunnel_resp_t *const create_tunnel_resp_pP){
-    return 0;
-  }
-
-  int gtpv1u_delete_x2u_tunnel( const instance_t instanceP,
-                                const gtpv1u_enb_delete_tunnel_req_t *const req_pP){
-    return 0;
-  }
-  int
-  gtpv1u_create_ngu_tunnel(
-                           const instance_t instanceP,
-                           const gtpv1u_gnb_create_tunnel_req_t   *const create_tunnel_req_pP,
-                           gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp_pP){
-    return 0;
-  }
-  
-  int gtpv1u_delete_ngu_tunnel( const instance_t instance,
-                                gtpv1u_gnb_delete_tunnel_req_t *req) {
-    return 0;
-  }
-  
-  int gtpv1u_update_ngu_tunnel( const instance_t                              instanceP,
-                                const gtpv1u_gnb_create_tunnel_req_t *const  create_tunnel_req_pP,
-                                const ue_id_t                                  prior_rnti
-                                ) {
-    return 0;
-  }
-
-  // New API
-  teid_t newGtpuCreateTunnel(instance_t instance, ue_id_t ue_id, int incoming_bearer_id, int outgoing_rb_id, teid_t teid,
-                              int outgoing_qfi, transport_layer_addr_t remoteAddr, int port, gtpCallback callBack,
-                             gtpCallbackSDAP callBackSDAP) {
-    return 0;
-  }
-  void GtpuUpdateTunnelOutgoingTeid(instance_t instance, ue_id_t ue_id, ebi_t bearer_id, teid_t newOutgoingTeid) {
-  }
-  
-  int newGtpuDeleteAllTunnels(instance_t instance, ue_id_t ue_id) { return 0;
-  }
-  int newGtpuDeleteTunnels(instance_t instance, ue_id_t ue_id, int nbTunnels, pdusessionid_t *pdusession_id) {
-    return 0;
-  }
-  
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index feb5507ba45..620e1abb934 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -83,6 +83,25 @@ nrUE_params_t *get_nrUE_params(void) {
   return &nrUE_params;
 }
 
+NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {return(NULL);}
+
+void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind,
+                           fapi_nr_dci_indication_t *dci_ind,
+                           fapi_nr_rx_indication_t *rx_ind,
+                           UE_nr_rxtx_proc_t *proc,
+                           PHY_VARS_NR_UE *ue,
+                           uint8_t gNB_id,
+                           void *phy_data) {}
+void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind,
+                           uint8_t pdu_type,
+                           uint8_t gNB_id,
+                           PHY_VARS_NR_UE *ue,
+                           NR_UE_DLSCH_t *dlsch0,
+                           NR_UE_DLSCH_t *dlsch1,
+                           uint16_t n_pdus,
+                           UE_nr_rxtx_proc_t *proc,
+                           void *typeSpecific ) {}
+
 void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
 
 int nr_ue_pdcch_procedures(uint8_t gNB_id,
diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c
index cf75d963cfd..69396a9e856 100644
--- a/openair1/SIMULATION/NR_PHY/prachsim.c
+++ b/openair1/SIMULATION/NR_PHY/prachsim.c
@@ -55,12 +55,15 @@
 //#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
 #include <openair3/ocp-gtpu/gtp_itf.h>
 #include "executables/nr-uesoftmodem.h"
-
+#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
 #define NR_PRACH_DEBUG 1
 #define PRACH_WRITE_OUTPUT_DEBUG 1
 
 LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC;
 rlc_info_t Rlc_info_um,Rlc_info_am_config;
+THREAD_STRUCT thread_struct;
+char *parallel_config = NULL;
+char *worker_config = NULL;
 
 char *uecap_file;
 PHY_VARS_gNB *gNB;
@@ -81,19 +84,12 @@ uint32_t N_RB_DL = 106;
 /* temporary dummy implem of get_softmodem_optmask, till basic simulators implemented as device */
 uint64_t get_softmodem_optmask(void) {return 0;}
 softmodem_params_t *get_softmodem_params(void) {return 0;}
-int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0);  }
-int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req){ return(0);  }
-int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req){ return(0);  }
-int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req){ return(0);  }
-int oai_nfapi_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_srs_indication(nfapi_nr_srs_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind) { return(0);  }
 //Fixme: Uniq dirty DU instance, by global var, datamodel need better management
 instance_t DUuniqInstance=0;
 instance_t CUuniqInstance=0;
 
+NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {return(NULL);}
+
 void
 rrc_data_ind(
   const protocol_ctxt_t *const ctxt_pP,
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index 6375eb47e1f..8d80b9e2f13 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -73,6 +73,7 @@ nfapi_mode_t nfapi_getmode(void) {
 }
 void nfapi_setmode(nfapi_mode_t nfapi_mode) { nfapi_mod=nfapi_mode; }
 
+NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {return(NULL);}
 
 nrUE_params_t nrUE_params={0};
 
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index da154ad3ec6..9883bb55284 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -79,6 +79,7 @@ nfapi_mode_t nfapi_getmode(void) {
 }
 void nfapi_setmode(nfapi_mode_t nfapi_mode) { nfapi_mod=nfapi_mode; }
 
+NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {return(NULL);}
 
 int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
   ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req);
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 1583a2515e2..ba5ea6d204d 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -68,6 +68,7 @@
 #include "PHY/NR_REFSIG/ul_ref_seq_nr.h"
 #include <openair3/ocp-gtpu/gtp_itf.h>
 #include "executables/nr-uesoftmodem.h"
+#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
 //#define DEBUG_ULSIM
 
 const char *__asan_default_options()
@@ -186,18 +187,6 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t     module_idP,
 
 nr_bler_struct nr_bler_data[NR_NUM_MCS];
 
-//nFAPI P7 dummy functions
-
-int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0);  }
-int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req){ return(0);  }
-int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req){ return(0);  }
-int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req){ return(0);  }
-int oai_nfapi_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_srs_indication(nfapi_nr_srs_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { return(0);  }
-int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind) { return(0);  }
-
 int nr_derive_key(int alg_type, uint8_t alg_id,
                const uint8_t key[32], uint8_t **out)
 {
diff --git a/openair2/COMMON/e1ap_messages_types.h b/openair2/COMMON/e1ap_messages_types.h
index 19009ee427b..f4d8e88a34e 100644
--- a/openair2/COMMON/e1ap_messages_types.h
+++ b/openair2/COMMON/e1ap_messages_types.h
@@ -24,6 +24,7 @@
 #ifndef E1AP_MESSAGES_TYPES_H
 #define E1AP_MESSAGES_TYPES_H
 
+#include "f1ap_messages_types.h"
 #include "ngap_messages_types.h"
 
 #define E1AP_MAX_NUM_TRANSAC_IDS 4
diff --git a/openair2/E1AP/CMakeLists.txt b/openair2/E1AP/CMakeLists.txt
index 3726f0bbd64..c3bac728426 100644
--- a/openair2/E1AP/CMakeLists.txt
+++ b/openair2/E1AP/CMakeLists.txt
@@ -2,6 +2,7 @@ add_subdirectory(MESSAGES)
 
 add_library(E1AP e1ap.c e1ap_common.c e1ap_api.c)
 target_link_libraries(E1AP
-                        PUBLIC ASN1_E1AP_LIB
-                        PRIVATE UTIL)
+                      PUBLIC ASN1_E1AP_LIB
+                      PRIVATE UTIL
+                      PRIVATE E1_PDCP_IF)
 target_include_directories(E1AP PUBLIC ${CMAKE_CURRENT_DIR})
diff --git a/openair2/E1AP/e1ap.c b/openair2/E1AP/e1ap.c
index a753e122728..9a7acf6de32 100644
--- a/openair2/E1AP/e1ap.c
+++ b/openair2/E1AP/e1ap.c
@@ -26,6 +26,12 @@
 #include "e1ap_api.h"
 #include "gnb_config.h"
 #include "openair2/SDAP/nr_sdap/nr_sdap_entity.h"
+#include "openair3/UTILS/conversions.h"
+#include "openair2/RRC/NR/MESSAGES/asn1_msg.h"
+#include "openairinterface5g_limits.h"
+#include "common/utils/LOG/log.h"
+#include "openair2/F1AP/f1ap_common.h"
+#include "e1ap_default_values.h"
 
 #define E1AP_NUM_MSG_HANDLERS 14
 typedef int (*e1ap_message_processing_t)(
diff --git a/openair2/E1AP/e1ap.h b/openair2/E1AP/e1ap.h
index 00d08babf74..f290f5805f7 100644
--- a/openair2/E1AP/e1ap.h
+++ b/openair2/E1AP/e1ap.h
@@ -24,13 +24,8 @@
 #ifndef __E1AP_H_
 #define __E1AP_H_
 
-#include <common/utils/LOG/log.h>
-#include "openairinterface5g_limits.h"
-#include <openair2/RRC/NR/MESSAGES/asn1_msg.h>
 #include "openair2/COMMON/e1ap_messages_types.h"
-#include "openair3/UTILS/conversions.h"
-#include "openair2/F1AP/f1ap_common.h"
-#include "openair2/E1AP/e1ap_common.h"
+#include "e1ap_asnc.h"
 
 #endif
 
diff --git a/openair2/E1AP/e1ap_api.c b/openair2/E1AP/e1ap_api.c
index ec60e0c9504..97fb4587482 100644
--- a/openair2/E1AP/e1ap_api.c
+++ b/openair2/E1AP/e1ap_api.c
@@ -21,18 +21,24 @@
  *      contact@openairinterface.org
  */
 
+#include <arpa/inet.h>
 #include "e1ap_api.h"
 #include "UTIL/OSA/osa_defs.h"
 #include "nr_pdcp/nr_pdcp_entity.h"
 #include "openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h"
 #include "openair2/RRC/NR/cucp_cuup_if.h"
+#include "openair2/RRC/LTE/MESSAGES/asn1_msg.h"
 #include "openair3/ocp-gtpu/gtp_itf.h"
+#include "e1ap_asnc.h"
+#include "e1ap_common.h"
+#include "e1ap.h"
 
+struct NR_DRB_ToAddMod;
 static void fill_DRB_configList_e1(NR_DRB_ToAddModList_t *DRB_configList, pdu_session_to_setup_t *pdu) {
 
   for (int i=0; i < pdu->numDRB2Setup; i++) {
     DRB_nGRAN_to_setup_t *drb = pdu->DRBnGRanList + i;
-    asn1cSequenceAdd(DRB_configList->list, NR_DRB_ToAddMod_t, ie);
+    asn1cSequenceAdd(DRB_configList->list, struct NR_DRB_ToAddMod, ie);
     ie->drb_Identity = drb->id;
     ie->cnAssociation = CALLOC(1, sizeof(*ie->cnAssociation));
     ie->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config;
diff --git a/openair2/E1AP/e1ap_api.h b/openair2/E1AP/e1ap_api.h
index 482cd3dd60c..1f2c439ea28 100644
--- a/openair2/E1AP/e1ap_api.h
+++ b/openair2/E1AP/e1ap_api.h
@@ -24,9 +24,8 @@
 #ifndef E1AP_API_H
 #define E1AP_API_H
 
-#include "e1ap.h"
-#include "e1ap_common.h"
-#include "NR_DRB-ToAddModList.h"
+#include "platform_types.h"
+#include "openair2/COMMON/e1ap_messages_types.h"
 
 void CUUP_process_e1_bearer_context_setup_req(e1ap_bearer_setup_req_t *req, instance_t instance);
 
diff --git a/openair2/E1AP/e1ap_asnc.h b/openair2/E1AP/e1ap_asnc.h
new file mode 100644
index 00000000000..00dbcc13f3e
--- /dev/null
+++ b/openair2/E1AP/e1ap_asnc.h
@@ -0,0 +1,65 @@
+/*
+ * 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
+ *
+ * Author and copyright: Laurent Thomas, open-cells.com
+ *
+ * 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 E1AP_ASNC_H
+#define E1AP_ASNC_H
+
+#include <E1AP_Cause.h>
+#include <E1AP_InitiatingMessage.h>
+#include <E1AP_E1AP-PDU.h>
+#include <E1AP_ProtocolIE-Field.h>
+#include <E1AP_SupportedPLMNs-Item.h>
+#include <E1AP_SuccessfulOutcome.h>
+#include <E1AP_ProtocolIE-Field.h>
+#include <E1AP_UnsuccessfulOutcome.h>
+#include <E1AP_GNB-CU-UP-E1SetupFailure.h>
+#include <E1AP_GNB-CU-UP-ConfigurationUpdate.h>
+#include <E1AP_GNB-CU-UP-TNLA-To-Remove-Item.h>
+#include <E1AP_CP-TNL-Information.h>
+#include <E1AP_UP-Parameters-Item.h>
+#include <E1AP_UP-TNL-Information.h>
+#include <E1AP_PDU-Session-Resource-Setup-Item.h>
+#include <E1AP_DRB-Setup-Item-EUTRAN.h>
+#include <E1AP_DRB-Setup-Item-NG-RAN.h>
+#include <E1AP_QoS-Flow-QoS-Parameter-Item.h>
+#include <E1AP_QoS-Flow-Item.h>
+#include <E1AP_DRB-Failed-List-NG-RAN.h>
+#include <E1AP_DRB-Failed-Item-NG-RAN.h>
+#include <E1AP_BearerContextSetupResponse.h>
+#include <E1AP_BearerContextSetupRequest.h>
+#include <E1AP_DRB-To-Setup-Item-EUTRAN.h>
+#include <E1AP_DRB-To-Setup-Item-NG-RAN.h>
+#include <E1AP_Cell-Group-Information-Item.h>
+#include <E1AP_PDU-Session-Resource-To-Setup-Item.h>
+#include <E1AP_PDU-Session-Resource-To-Modify-List.h>
+#include <E1AP_PDU-Session-Resource-To-Modify-Item.h>
+#include <E1AP_DRB-To-Modify-List-NG-RAN.h>
+#include <E1AP_DRB-To-Modify-Item-NG-RAN.h>
+#include <E1AP_GTPTunnel.h>
+#include <E1AP_Non-Dynamic5QIDescriptor.h>
+#include <E1AP_Dynamic5QIDescriptor.h>
+#include <E1AP_T-ReorderingTimer.h>
+#include <E1AP_SDAP-Configuration.h>
+#include <E1AP_PDCP-Configuration.h>
+
+#endif
diff --git a/openair2/E1AP/e1ap_common.c b/openair2/E1AP/e1ap_common.c
index 60ea22934f7..b765a9dbb43 100644
--- a/openair2/E1AP/e1ap_common.c
+++ b/openair2/E1AP/e1ap_common.c
@@ -23,8 +23,11 @@
 
 #include <time.h>
 #include <stdlib.h>
-#include "e1ap.h"
 #include "e1ap_common.h"
+#include "e1ap_default_values.h"
+#include "e1ap_asnc.h"
+#include "targets/COMMON/openairinterface5g_limits.h"
+#include "common/utils/ocp_itti/intertask_interface.h"
 
 static e1ap_upcp_inst_t *e1ap_cp_inst[NUMBER_OF_gNB_MAX] = {0};
 static e1ap_upcp_inst_t *e1ap_up_inst[NUMBER_OF_gNB_MAX] = {0};
diff --git a/openair2/E1AP/e1ap_common.h b/openair2/E1AP/e1ap_common.h
index 6c57def40f3..a5f9b1e508e 100644
--- a/openair2/E1AP/e1ap_common.h
+++ b/openair2/E1AP/e1ap_common.h
@@ -23,44 +23,8 @@
 
 #ifndef E1AP_COMMON_H_
 #define E1AP_COMMON_H_
-#include "openair2/E1AP/e1ap_default_values.h"
 #include "openair2/COMMON/e1ap_messages_types.h"
-
-#include <E1AP_Cause.h>
-#include <E1AP_InitiatingMessage.h>
-#include <E1AP_E1AP-PDU.h>
-#include <E1AP_ProtocolIE-Field.h>
-#include <E1AP_SupportedPLMNs-Item.h>
-#include <E1AP_SuccessfulOutcome.h>
-#include <E1AP_ProtocolIE-Field.h>
-#include <E1AP_UnsuccessfulOutcome.h>
-#include <E1AP_GNB-CU-UP-E1SetupFailure.h>
-#include <E1AP_GNB-CU-UP-ConfigurationUpdate.h>
-#include <E1AP_GNB-CU-UP-TNLA-To-Remove-Item.h>
-#include <E1AP_CP-TNL-Information.h>
-#include <E1AP_UP-Parameters-Item.h>
-#include <E1AP_UP-TNL-Information.h>
-#include <E1AP_PDU-Session-Resource-Setup-Item.h>
-#include <E1AP_DRB-Setup-Item-EUTRAN.h>
-#include <E1AP_DRB-Setup-Item-NG-RAN.h>
-#include <E1AP_QoS-Flow-QoS-Parameter-Item.h>
-#include <E1AP_QoS-Flow-Item.h>
-#include <E1AP_DRB-Failed-List-NG-RAN.h>
-#include <E1AP_DRB-Failed-Item-NG-RAN.h>
-#include <E1AP_BearerContextSetupResponse.h>
-#include <E1AP_BearerContextSetupRequest.h>
-#include <E1AP_DRB-To-Setup-Item-EUTRAN.h>
-#include <E1AP_DRB-To-Setup-Item-NG-RAN.h>
-#include <E1AP_Cell-Group-Information-Item.h>
-#include <E1AP_PDU-Session-Resource-To-Setup-Item.h>
-#include <E1AP_PDU-Session-Resource-To-Modify-List.h>
-#include <E1AP_PDU-Session-Resource-To-Modify-Item.h>
-#include <E1AP_DRB-To-Modify-List-NG-RAN.h>
-#include <E1AP_DRB-To-Modify-Item-NG-RAN.h>
-#include <E1AP_GTPTunnel.h>
-#include <E1AP_Non-Dynamic5QIDescriptor.h>
-#include <E1AP_Dynamic5QIDescriptor.h>
-#include <E1AP_T-ReorderingTimer.h>
+#include "e1ap_asnc.h"
 
 extern int asn1_xer_print;
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index b272561a2d1..71cbd828ef2 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -245,7 +245,7 @@ void mac_top_init_gNB(ngran_node_t node_type)
     AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n");
 
     // These should be out of here later
-    pdcp_layer_init();
+    if (get_softmodem_params()->usim_test == 0 ) pdcp_layer_init();
 
     if(IS_SOFTMODEM_NOS1 && get_softmodem_params()->phy_test)
       nr_DRB_preconfiguration(0x1234);
diff --git a/openair2/RRC/NR/cucp_cuup_direct.c b/openair2/RRC/NR/cucp_cuup_direct.c
index 1aa48b10e0e..ac3bd35e1c4 100644
--- a/openair2/RRC/NR/cucp_cuup_direct.c
+++ b/openair2/RRC/NR/cucp_cuup_direct.c
@@ -28,15 +28,15 @@
 #include "softmodem-common.h"
 #include "nr_rrc_proto.h"
 #include "nr_rrc_extern.h"
-#include "openair2/E1AP/e1ap_common.h"
+#include "openair2/COMMON/e1ap_messages_types.h"
 #include "UTIL/OSA/osa_defs.h"
 #include "nr_pdcp/nr_pdcp_entity.h"
 #include "openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h"
 #include <openair2/RRC/NR/rrc_gNB_UE_context.h>
 #include "openair3/ocp-gtpu/gtp_itf.h"
-#include "openair2/F1AP/f1ap_common.h"
 #include "rrc_gNB_GTPV1U.h"
 #include "common/ran_context.h"
+#include "openair2/F1AP/f1ap_common.h"
 
 extern RAN_CONTEXT_t RC;
 
diff --git a/openair2/RRC/NR/cucp_cuup_e1ap.c b/openair2/RRC/NR/cucp_cuup_e1ap.c
index 2b90af4880f..7322714718d 100644
--- a/openair2/RRC/NR/cucp_cuup_e1ap.c
+++ b/openair2/RRC/NR/cucp_cuup_e1ap.c
@@ -28,7 +28,7 @@
 #include "nr_rrc_proto.h"
 #include "nr_rrc_extern.h"
 #include "cucp_cuup_if.h"
-#include "openair2/E1AP/e1ap_common.h"
+#include "openair2/COMMON/e1ap_messages_types.h"
 #include "UTIL/OSA/osa_defs.h"
 #include <openair2/RRC/NR/rrc_gNB_UE_context.h>
 #include "common/ran_context.h"
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
index 382692b6f62..1dc05a6a453 100755
--- a/openair2/RRC/NR/rrc_gNB.c
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -100,9 +100,7 @@
 #include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
 #include "openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h"
 #include "openair2/F1AP/f1ap_common.h"
-#include "openair2/E1AP/e1ap_common.h"
 #include "openair2/SDAP/nr_sdap/nr_sdap_entity.h"
-#include "openair2/E1AP/e1ap_api.h"
 #include "cucp_cuup_if.h"
 
 #include "BIT_STRING.h"
diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c
index f44abd6ae5d..08ec38b9942 100644
--- a/openair2/RRC/NR/rrc_gNB_NGAP.c
+++ b/openair2/RRC/NR/rrc_gNB_NGAP.c
@@ -57,9 +57,7 @@
 #include "NGAP_Cause.h"
 #include "NGAP_CauseRadioNetwork.h"
 #include "f1ap_messages_types.h"
-#include "E1AP_SDAP-Configuration.h"
-#include "E1AP_PDCP-Configuration.h"
-#include "openair2/E1AP/e1ap.h"
+#include "openair2/E1AP/e1ap_asnc.h"
 
 extern RAN_CONTEXT_t RC;
 
-- 
GitLab