From 7a22573f3e7e16960e3310609dea2783ddf404a2 Mon Sep 17 00:00:00 2001
From: laurent <laurent Thomas>
Date: Fri, 29 Jul 2022 13:03:31 +0200
Subject: [PATCH] fix compile issues, simplify gtp send function

---
 openair1/SIMULATION/NR_PHY/dlschsim.c         |   5 +
 openair1/SIMULATION/NR_PHY/dlsim.c            |  65 +-----
 .../SIMULATION/NR_PHY/nr_dummy_functions.c    |  21 --
 openair1/SIMULATION/NR_PHY/nr_unitary_defs.h  |   1 -
 openair1/SIMULATION/NR_PHY/pbchsim.c          |   6 +-
 openair1/SIMULATION/NR_PHY/prachsim.c         |  51 ----
 openair1/SIMULATION/NR_PHY/pucchsim.c         |   6 +
 openair1/SIMULATION/NR_PHY/ulschsim.c         |   7 +
 openair1/SIMULATION/NR_PHY/ulsim.c            |  51 ----
 openair2/COMMON/e1ap_messages_types.h         |   3 -
 openair2/E1AP/e1ap_common.h                   |   2 +-
 openair3/ocp-gtpu/gtp_itf.h                   | 221 +++++++++---------
 12 files changed, 135 insertions(+), 304 deletions(-)

diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index f429409d5ab..86f3c2d4ea4 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -74,6 +74,11 @@ uint16_t n_rnti = 0x1234;
 openair0_config_t openair0_cfg[MAX_CARDS];
 
 void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
+nfapi_mode_t nfapi_mod;
+nfapi_mode_t nfapi_getmode(void) {
+  return nfapi_mod;
+}
+void nfapi_setmode(nfapi_mode_t nfapi_mode) { nfapi_mod=nfapi_mode; }
 
 
 nrUE_params_t nrUE_params={0};
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 4836a570f39..db1176831cc 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -61,7 +61,7 @@
 #include "openair1/SIMULATION/RF/rf.h"
 #include "openair1/SIMULATION/TOOLS/sim.h"
 #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
-//#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
+#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
 #include "PHY/NR_REFSIG/ptrs_nr.h"
 #include "NR_RRCReconfiguration.h"
 #define inMicroS(a) (((double)(a))/(get_cpu_freq_GHz()*1000.0))
@@ -101,25 +101,9 @@ nfapi_ue_release_request_body_t release_rntis;
 //Fixme: Uniq dirty DU instance, by global var, datamodel need better management
 instance_t DUuniqInstance=0;
 instance_t CUuniqInstance=0;
-teid_t newGtpuCreateTunnel(instance_t instance,
-                           rnti_t rnti,
-                           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, rnti_t rnti) {
-  return 0;
-}
 
 // dummy functions
-int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info)              { return(0);  }
 
 int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
                               const int CC_id,
@@ -159,15 +143,6 @@ rrc_data_ind(
 {
 }
 
-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;
-}
-
 int
 rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   const protocol_ctxt_t *const ctxt_pP,
@@ -177,32 +152,6 @@ rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   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_update_ngu_tunnel(
-  const instance_t                              instanceP,
-  const gtpv1u_gnb_create_tunnel_req_t *const  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_delete_ngu_tunnel( const instance_t instance,
-			      gtpv1u_gnb_delete_tunnel_req_t *req) {
-  return 0;
-}
-
 int
 nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   const protocol_ctxt_t *const ctxt_pP,
@@ -254,18 +203,6 @@ void processSlotTX(void *arg) {}
 
 nr_bler_struct nr_bler_data[NR_NUM_MCS];
 
-//nFAPI P7 dummy functions to avoid linking errors 
-
-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);  }
-
 // needed for some functions
 openair0_config_t openair0_cfg[MAX_CARDS];
 void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSize, uint8_t *mcsIndex,int8_t *ptrs_arg);
diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
index 75e3d998ff9..a89e52e7a6d 100644
--- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
+++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
@@ -17,27 +17,6 @@ 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);}
-nfapi_mode_t nfapi_mod;
-nfapi_mode_t nfapi_getmode(void) {
-  return nfapi_mod;
-}
-void nfapi_setmode(nfapi_mode_t nfapi_mode) {}
 
 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 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 ) {}
diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
index d3af2acd77f..c556f663619 100644
--- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
+++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
@@ -63,7 +63,6 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R
 void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap);
 void prepare_scc(NR_ServingCellConfigCommon_t *scc);
 void prepare_scd(NR_ServingCellConfig_t *scd);
-ngap_gNB_config_t ngap_config;
 uint32_t ngap_generate_gNB_id(void) {return 0;}
 void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) { return;}
 void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { return;}
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index 8c7bce71f6c..feb5507ba45 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -59,7 +59,6 @@ RAN_CONTEXT_t RC;
 int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 double cpuf;
-//uint8_t nfapi_mode = 0;
 uint16_t NB_UE_INST = 1;
 
 // needed for some functions
@@ -67,6 +66,11 @@ openair0_config_t openair0_cfg[MAX_CARDS];
 
 uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1};
 
+nfapi_mode_t nfapi_mod;
+nfapi_mode_t nfapi_getmode(void) {
+  return nfapi_mod;
+}
+
 uint64_t get_softmodem_optmask(void) {return 0;}
 static softmodem_params_t softmodem_params;
 softmodem_params_t *get_softmodem_params(void) {
diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c
index 3622ba49ba5..cf75d963cfd 100644
--- a/openair1/SIMULATION/NR_PHY/prachsim.c
+++ b/openair1/SIMULATION/NR_PHY/prachsim.c
@@ -93,22 +93,6 @@ 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;
-teid_t newGtpuCreateTunnel(instance_t instance,
-                           rnti_t rnti,
-                           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, rnti_t rnti) {
-  return 0;
-}
 
 void
 rrc_data_ind(
@@ -120,15 +104,6 @@ rrc_data_ind(
 {
 }
 
-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;
-}
-
 int
 rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   const protocol_ctxt_t *const ctxt_pP,
@@ -138,32 +113,6 @@ rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   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_update_ngu_tunnel(
-  const instance_t                              instanceP,
-  const gtpv1u_gnb_create_tunnel_req_t *const  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_delete_ngu_tunnel( const instance_t instance,
-			      gtpv1u_gnb_delete_tunnel_req_t *req) {
-  return 0;
-}
-
 int
 nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   const protocol_ctxt_t *const ctxt_pP,
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index cabe87ef016..6375eb47e1f 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -67,6 +67,12 @@ const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1};
 PHY_VARS_NR_UE * PHY_vars_UE_g[1][1]={{NULL}};
 
 void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
+nfapi_mode_t nfapi_mod;
+nfapi_mode_t nfapi_getmode(void) {
+  return nfapi_mod;
+}
+void nfapi_setmode(nfapi_mode_t nfapi_mode) { nfapi_mod=nfapi_mode; }
+
 
 nrUE_params_t nrUE_params={0};
 
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index 6ef8bff116b..da154ad3ec6 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -73,6 +73,13 @@ PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
 uint16_t n_rnti = 0x1234;
 openair0_config_t openair0_cfg[MAX_CARDS];
 
+nfapi_mode_t nfapi_mod;
+nfapi_mode_t nfapi_getmode(void) {
+  return nfapi_mod;
+}
+void nfapi_setmode(nfapi_mode_t nfapi_mode) { nfapi_mod=nfapi_mode; }
+
+
 int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
   ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req);
   NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq;
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 43ac3fc145f..1583a2515e2 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -97,22 +97,6 @@ nfapi_ue_release_request_body_t release_rntis;
 //Fixme: Uniq dirty DU instance, by global var, datamodel need better management
 instance_t DUuniqInstance=0;
 instance_t CUuniqInstance=0;
-teid_t newGtpuCreateTunnel(instance_t instance,
-                           rnti_t rnti,
-                           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, rnti_t rnti) {
-  return 0;
-}
 
 extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration
 
@@ -149,25 +133,6 @@ rrc_data_ind(
 {
 }
 
-
-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;
-}
-
-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
 rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   const protocol_ctxt_t *const ctxt_pP,
@@ -177,22 +142,6 @@ rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   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_update_ngu_tunnel(
-  const instance_t                              instanceP,
-  const gtpv1u_gnb_create_tunnel_req_t *const  create_tunnel_req_pP,
-  const rnti_t                                  prior_rnti
-){
-  return 0;
-}
 
 int
 nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
diff --git a/openair2/COMMON/e1ap_messages_types.h b/openair2/COMMON/e1ap_messages_types.h
index 84d99e87a11..9656b0fe2b0 100644
--- a/openair2/COMMON/e1ap_messages_types.h
+++ b/openair2/COMMON/e1ap_messages_types.h
@@ -41,9 +41,6 @@
 #define E1AP_BEARER_CONTEXT_SETUP_REQ(mSGpTR)      (mSGpTR)->ittiMsg.e1ap_bearer_setup_req
 #define E1AP_BEARER_CONTEXT_SETUP_RESP(mSGpTR)     (mSGpTR)->ittiMsg.e1ap_bearer_setup_resp
 
-#define E1AP_PORT_NUMBER 25
-#define E1AP_SCTP_PPID 64
-
 typedef f1ap_net_ip_address_t e1ap_net_ip_address_t;
 
 typedef struct PLMN_ID_s {
diff --git a/openair2/E1AP/e1ap_common.h b/openair2/E1AP/e1ap_common.h
index b820c1f3c4e..90d41e26992 100644
--- a/openair2/E1AP/e1ap_common.h
+++ b/openair2/E1AP/e1ap_common.h
@@ -23,7 +23,7 @@
 
 #ifndef E1AP_COMMON_H_
 #define E1AP_COMMON_H_
- 
+#include "openair2/E1AP/e1ap_default_values.h"
 #include "openair2/COMMON/e1ap_messages_types.h"
 int e1ap_decode_pdu(E1AP_E1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t length);
 
diff --git a/openair3/ocp-gtpu/gtp_itf.h b/openair3/ocp-gtpu/gtp_itf.h
index 17ded407a91..3e06ef0786b 100644
--- a/openair3/ocp-gtpu/gtp_itf.h
+++ b/openair3/ocp-gtpu/gtp_itf.h
@@ -8,58 +8,57 @@
 extern "C" {
 #endif
 
-typedef bool (*gtpCallback)(protocol_ctxt_t  *ctxt_pP,
-                            const srb_flag_t     srb_flagP,
-                            const rb_id_t        rb_idP,
-                            const mui_t          muiP,
-                            const confirm_t      confirmP,
-                            const sdu_size_t     sdu_buffer_sizeP,
-                            unsigned char *const sdu_buffer_pP,
-                            const pdcp_transmission_mode_t modeP,
-                            const uint32_t *sourceL2Id,
-                            const uint32_t *destinationL2Id);
-
-typedef bool (*gtpCallbackSDAP)(protocol_ctxt_t  *ctxt_pP,
-                                const ue_id_t        ue_id,
-                                const srb_flag_t     srb_flagP,
-                                const rb_id_t        rb_idP,
-                                const mui_t          muiP,
-                                const confirm_t      confirmP,
-                                const sdu_size_t     sdu_buffer_sizeP,
-                                unsigned char *const sdu_buffer_pP,
-                                const pdcp_transmission_mode_t modeP,
-                                const uint32_t *sourceL2Id,
-                                const uint32_t *destinationL2Id,
-                                const uint8_t   qfi,
-                                const bool      rqi,
-                                const int       pdusession_id);
-
-typedef struct openAddr_s {
-  char originHost[HOST_NAME_MAX];
-  char originService[HOST_NAME_MAX];
-  char destinationHost[HOST_NAME_MAX];
-  char destinationService[HOST_NAME_MAX];
-  instance_t originInstance;
-} openAddr_t;
-
-typedef struct extensionHeader_s{
-  uint8_t buffer[500];
-  uint8_t length;
-}extensionHeader_t;
-
-// the init function create a gtp instance and return the gtp instance id
-// the parameter originInstance will be sent back in each message from gtp to the creator
-void gtpv1uReceiver(int h);
-void gtpv1uProcessTimeout(int handle,void *arg);
-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);
-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
-                            );
-int gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP);
-  
-int gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP);
+  typedef bool (*gtpCallback)(protocol_ctxt_t  *ctxt_pP,
+                              const srb_flag_t     srb_flagP,
+                              const rb_id_t        rb_idP,
+                              const mui_t          muiP,
+                              const confirm_t      confirmP,
+                              const sdu_size_t     sdu_buffer_sizeP,
+                              unsigned char *const sdu_buffer_pP,
+                              const pdcp_transmission_mode_t modeP,
+                              const uint32_t *sourceL2Id,
+                              const uint32_t *destinationL2Id);
+
+  typedef bool (*gtpCallbackSDAP)(protocol_ctxt_t  *ctxt_pP,
+                                  const ue_id_t        ue_id,
+                                  const srb_flag_t     srb_flagP,
+                                  const rb_id_t        rb_idP,
+                                  const mui_t          muiP,
+                                  const confirm_t      confirmP,
+                                  const sdu_size_t     sdu_buffer_sizeP,
+                                  unsigned char *const sdu_buffer_pP,
+                                  const pdcp_transmission_mode_t modeP,
+                                  const uint32_t *sourceL2Id,
+                                  const uint32_t *destinationL2Id,
+                                  const uint8_t   qfi,
+                                  const bool      rqi,
+                                  const int       pdusession_id);
+
+  typedef struct openAddr_s {
+    char originHost[HOST_NAME_MAX];
+    char originService[HOST_NAME_MAX];
+    char destinationHost[HOST_NAME_MAX];
+    char destinationService[HOST_NAME_MAX];
+    instance_t originInstance;
+  } openAddr_t;
+
+  typedef struct extensionHeader_s{
+    uint8_t buffer[500];
+    uint8_t length;
+  }extensionHeader_t;
+
+  // the init function create a gtp instance and return the gtp instance id
+  // the parameter originInstance will be sent back in each message from gtp to the creator
+  void gtpv1uReceiver(int h);
+  void gtpv1uProcessTimeout(int handle,void *arg);
+  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);
+  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
+                               );
+
+  int gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP);
 
   int gtpv1u_create_x2u_tunnel(const instance_t instanceP,
                                const gtpv1u_enb_create_x2u_tunnel_req_t   *const create_tunnel_req_pP,
@@ -77,73 +76,73 @@ int gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete
                                 gtpv1u_gnb_delete_tunnel_req_t *req);
   
   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
-                               );
+                                const gtpv1u_gnb_create_tunnel_req_t *const  create_tunnel_req_pP,
+                                const ue_id_t                                  prior_rnti
+                                );
 
-// 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);
-void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer_id, teid_t newOutgoingTeid);
-int newGtpuDeleteAllTunnels(instance_t instance, ue_id_t ue_id);
-int newGtpuDeleteTunnels(instance_t instance, ue_id_t ue_id, int nbTunnels, pdusessionid_t *pdusession_id);
-instance_t gtpv1Init(openAddr_t context);
-void *gtpv1uTask(void *args);
+  // 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);
+  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);
+  int newGtpuDeleteTunnels(instance_t instance, ue_id_t ue_id, int nbTunnels, pdusessionid_t *pdusession_id);
+  instance_t gtpv1Init(openAddr_t context);
+  void *gtpv1uTask(void *args);
 
   // Legacy to fix
   typedef struct gtpv1u_data_s {
     /* RB tree of UEs */
     hash_table_t         *ue_mapping;
   } gtpv1u_data_t;
-  #define GTPV1U_BEARER_OFFSET 3
+#define GTPV1U_BEARER_OFFSET 3
 #define GTPV1U_MAX_BEARERS_ID     (max_val_LTE_DRB_Identity - GTPV1U_BEARER_OFFSET)
-typedef enum {
-  BEARER_DOWN = 0,
-  BEARER_IN_CONFIG,
-  BEARER_UP,
-  BEARER_DL_HANDOVER,
-  BEARER_UL_HANDOVER,
-  BEARER_MAX,
-} bearer_state_t;
-
-typedef struct fixMe_gtpv1u_bearer_s {
-  /* TEID used in dl and ul */
-  teid_t          teid_eNB;                ///< eNB TEID
-  uintptr_t       teid_eNB_stack_session;  ///< eNB TEID
-  teid_t          teid_sgw;                ///< Remote TEID
-  in_addr_t       sgw_ip_addr;
-  struct in6_addr sgw_ip6_addr;
-  teid_t          teid_teNB;
-  in_addr_t       tenb_ip_addr;       ///< target eNB ipv4
-  struct in6_addr tenb_ip6_addr;        ///< target eNB ipv6
-  tcp_udp_port_t  port;
-  //NwGtpv1uStackSessionHandleT stack_session;
-  bearer_state_t state;
-} fixMe_gtpv1u_bearer_t;
-
-typedef struct gtpv1u_ue_data_s {
-  /* UE identifier for oaisim stack */
-  rnti_t   ue_id;
-
-  /* Unique identifier used between PDCP and GTP-U to distinguish UEs */
-  uint32_t instance_id;
-  int      num_bearers;
-  /* Bearer related data.
-   * Note that the first LCID available for data is 3 and we fixed the maximum
-   * number of e-rab per UE to be (32 [id range]), max RB is 11. The real rb id will 3 + rab_id (3..32).
-   */
-  fixMe_gtpv1u_bearer_t bearers[GTPV1U_MAX_BEARERS_ID];
-
-  //RB_ENTRY(gtpv1u_ue_data_s) gtpv1u_ue_node;
-} gtpv1u_ue_data_t;
+  typedef enum {
+    BEARER_DOWN = 0,
+    BEARER_IN_CONFIG,
+    BEARER_UP,
+    BEARER_DL_HANDOVER,
+    BEARER_UL_HANDOVER,
+    BEARER_MAX,
+  } bearer_state_t;
+
+  typedef struct fixMe_gtpv1u_bearer_s {
+    /* TEID used in dl and ul */
+    teid_t          teid_eNB;                ///< eNB TEID
+    uintptr_t       teid_eNB_stack_session;  ///< eNB TEID
+    teid_t          teid_sgw;                ///< Remote TEID
+    in_addr_t       sgw_ip_addr;
+    struct in6_addr sgw_ip6_addr;
+    teid_t          teid_teNB;
+    in_addr_t       tenb_ip_addr;       ///< target eNB ipv4
+    struct in6_addr tenb_ip6_addr;        ///< target eNB ipv6
+    tcp_udp_port_t  port;
+    //NwGtpv1uStackSessionHandleT stack_session;
+    bearer_state_t state;
+  } fixMe_gtpv1u_bearer_t;
+
+  typedef struct gtpv1u_ue_data_s {
+    /* UE identifier for oaisim stack */
+    rnti_t   ue_id;
+
+    /* Unique identifier used between PDCP and GTP-U to distinguish UEs */
+    uint32_t instance_id;
+    int      num_bearers;
+    /* Bearer related data.
+     * Note that the first LCID available for data is 3 and we fixed the maximum
+     * number of e-rab per UE to be (32 [id range]), max RB is 11. The real rb id will 3 + rab_id (3..32).
+     */
+    fixMe_gtpv1u_bearer_t bearers[GTPV1U_MAX_BEARERS_ID];
+
+    //RB_ENTRY(gtpv1u_ue_data_s) gtpv1u_ue_node;
+  } gtpv1u_ue_data_t;
   
 #ifdef __cplusplus
 }
-- 
GitLab