diff --git a/common/utils/ocp_itti/all_msg.h b/common/utils/ocp_itti/all_msg.h index a2add514e1..11d1abc7d8 100644 --- a/common/utils/ocp_itti/all_msg.h +++ b/common/utils/ocp_itti/all_msg.h @@ -16,3 +16,4 @@ #include "openair2/COMMON/gtpv1_u_messages_def.h" #include "openair2/COMMON/flexran_messages_def.h" #include "openair2/COMMON/f1ap_messages_def.h" +#include "openair2/COMMON/ngap_messages_def.h" diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 3b3b3fc118..91cf2ce267 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -230,6 +230,7 @@ typedef struct IttiMsgText_s { #include #include #include +#include #include #include #include diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index ef6d469a91..17ebefa71b 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -83,6 +83,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "executables/thread-common.h" #include "NB_IoT_interface.h" #include "x2ap_eNB.h" +#include "ngap_gNB.h" pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; @@ -408,10 +409,12 @@ int create_gNB_tasks(uint32_t gnb_nb) { return -1; } */ + /* if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) { LOG_E(S1AP, "Create task for NGAP failed\n"); return -1; } + */ if(!emulate_rf){ diff --git a/openair2/COMMON/ngap_messages_types.h b/openair2/COMMON/ngap_messages_types.h index 1e067ba4ef..ff836d06bf 100644 --- a/openair2/COMMON/ngap_messages_types.h +++ b/openair2/COMMON/ngap_messages_types.h @@ -74,83 +74,78 @@ #define NGAP_MAX_NB_AMF_IP_ADDRESS 10 #define NGAP_IMSI_LENGTH 16 -#define QOSFLOW_MAX_VALUE 64; +#define QOSFLOW_MAX_VALUE 64 /* Security key length used within gNB * Even if only 16 bytes will be effectively used, * the key length is 32 bytes (256 bits) */ #define SECURITY_KEY_LENGTH 32 -typedef enum cell_type_e { - CELL_MACRO_ENB, - CELL_HOME_ENB, - CELL_MACRO_GNB -} cell_type_t; -typedef enum paging_drx_e { - PAGING_DRX_32 = 0x0, - PAGING_DRX_64 = 0x1, - PAGING_DRX_128 = 0x2, - PAGING_DRX_256 = 0x3 -} paging_drx_t; +typedef enum ngap_paging_drx_e { + NGAP_PAGING_DRX_32 = 0x0, + NGAP_PAGING_DRX_64 = 0x1, + NGAP_PAGING_DRX_128 = 0x2, + NGAP_PAGING_DRX_256 = 0x3 +} ngap_paging_drx_t; /* Lower value codepoint * indicates higher priority. */ -typedef enum paging_priority_s { - PAGING_PRIO_LEVEL1 = 0, - PAGING_PRIO_LEVEL2 = 1, - PAGING_PRIO_LEVEL3 = 2, - PAGING_PRIO_LEVEL4 = 3, - PAGING_PRIO_LEVEL5 = 4, - PAGING_PRIO_LEVEL6 = 5, - PAGING_PRIO_LEVEL7 = 6, - PAGING_PRIO_LEVEL8 = 7 -} paging_priority_t; +typedef enum ngap_paging_priority_s { + NGAP_PAGING_PRIO_LEVEL1 = 0, + NGAP_PAGING_PRIO_LEVEL2 = 1, + NGAP_PAGING_PRIO_LEVEL3 = 2, + NGAP_PAGING_PRIO_LEVEL4 = 3, + NGAP_PAGING_PRIO_LEVEL5 = 4, + NGAP_PAGING_PRIO_LEVEL6 = 5, + NGAP_PAGING_PRIO_LEVEL7 = 6, + NGAP_PAGING_PRIO_LEVEL8 = 7 +} ngap_paging_priority_t; -typedef enum cn_domain_s { - CN_DOMAIN_PS = 1, - CN_DOMAIN_CS = 2 -} cn_domain_t; +typedef enum ngap_cn_domain_s { + NGAP_CN_DOMAIN_PS = 1, + NGAP_CN_DOMAIN_CS = 2 +} ngap_cn_domain_t; -typedef struct net_ip_address_s { +typedef struct ngap_net_ip_address_s { unsigned ipv4:1; unsigned ipv6:1; char ipv4_address[16]; char ipv6_address[46]; -} net_ip_address_t; +} ngap_net_ip_address_t; typedef uint64_t bitrate_t; -typedef struct ambr_s { +typedef struct ngap_ambr_s { bitrate_t br_ul; bitrate_t br_dl; -} ambr_t; +} ngap_ambr_t; -typedef enum priority_level_s { - PRIORITY_LEVEL_SPARE = 0, - PRIORITY_LEVEL_HIGHEST = 1, - PRIORITY_LEVEL_LOWEST = 14, - PRIORITY_LEVEL_NO_PRIORITY = 15 -} priority_level_t; +typedef enum ngap_priority_level_s { + NGAP_PRIORITY_LEVEL_SPARE = 0, + NGAP_PRIORITY_LEVEL_HIGHEST = 1, + NGAP_PRIORITY_LEVEL_LOWEST = 14, + NGAP_PRIORITY_LEVEL_NO_PRIORITY = 15 +} ngap_priority_level_t; -typedef enum pre_emp_capability_e { - PRE_EMPTION_CAPABILITY_ENABLED = 0, - PRE_EMPTION_CAPABILITY_DISABLED = 1, - PRE_EMPTION_CAPABILITY_MAX, -} pre_emp_capability_t; +typedef enum ngap_pre_emp_capability_e { + NGAP_PRE_EMPTION_CAPABILITY_ENABLED = 0, + NGAP_PRE_EMPTION_CAPABILITY_DISABLED = 1, + NGAP_PRE_EMPTION_CAPABILITY_MAX, +} ngap_pre_emp_capability_t; -typedef enum pre_emp_vulnerability_e { - PRE_EMPTION_VULNERABILITY_ENABLED = 0, - PRE_EMPTION_VULNERABILITY_DISABLED = 1, - PRE_EMPTION_VULNERABILITY_MAX, -} pre_emp_vulnerability_t; +typedef enum ngap_pre_emp_vulnerability_e { + NGAP_PRE_EMPTION_VULNERABILITY_ENABLED = 0, + NGAP_PRE_EMPTION_VULNERABILITY_DISABLED = 1, + NGAP_PRE_EMPTION_VULNERABILITY_MAX, +} ngap_pre_emp_vulnerability_t; -typedef struct allocation_retention_priority_s { - priority_level_t priority_level; - pre_emp_capability_t pre_emp_capability; - pre_emp_vulnerability_t pre_emp_vulnerability; -} allocation_retention_priority_t; +typedef struct ngap_allocation_retention_priority_s { + ngap_priority_level_t priority_level; + ngap_pre_emp_capability_t pre_emp_capability; + ngap_pre_emp_vulnerability_t pre_emp_vulnerability; +} ngap_allocation_retention_priority_t; typedef struct nr_security_capabilities_s { uint16_t nRencryption_algorithms; @@ -164,17 +159,17 @@ typedef struct nr_security_capabilities_s { * concerns AC11..AC15, ‘mt Estands for ‘Mobile Terminating Eand ‘mo Efor * 'Mobile Originating'. Defined in TS 36.331. */ -typedef enum rrc_establishment_cause_e { - RRC_CAUSE_EMERGENCY = 0x0, - RRC_CAUSE_HIGH_PRIO_ACCESS = 0x1, - RRC_CAUSE_MT_ACCESS = 0x2, - RRC_CAUSE_MO_SIGNALLING = 0x3, - RRC_CAUSE_MO_DATA = 0x4, +typedef enum ngap_rrc_establishment_cause_e { + NGAP_RRC_CAUSE_EMERGENCY = 0x0, + NGAP_RRC_CAUSE_HIGH_PRIO_ACCESS = 0x1, + NGAP_RRC_CAUSE_MT_ACCESS = 0x2, + NGAP_RRC_CAUSE_MO_SIGNALLING = 0x3, + NGAP_RRC_CAUSE_MO_DATA = 0x4, #if defined(UPDATE_RELEASE_10) - RRC_CAUSE_DELAY_TOLERANT_ACCESS = 0x5, + NGAP_RRC_CAUSE_DELAY_TOLERANT_ACCESS = 0x5, #endif - RRC_CAUSE_LAST -} rrc_establishment_cause_t; + NGAP_RRC_CAUSE_LAST +} ngap_rrc_establishment_cause_t; typedef struct ngap_guami_s { uint16_t mcc; @@ -197,43 +192,43 @@ typedef struct ngap_imsi_s { uint8_t length; } ngap_imsi_t; -typedef struct s_tmsi_s { +typedef struct ngap_s_tmsi_s { uint8_t amf_code; uint32_t m_tmsi; -} s_tmsi_t; +} ngap_s_tmsi_t; -typedef enum ue_paging_identity_presenceMask_e { - UE_PAGING_IDENTITY_NONE = 0, - UE_PAGING_IDENTITY_imsi = (1 << 1), - UE_PAGING_IDENTITY_s_tmsi = (1 << 2), -} ue_paging_identity_presenceMask_t; +typedef enum ngap_ue_paging_identity_presenceMask_e { + NGAP_UE_PAGING_IDENTITY_NONE = 0, + NGAP_UE_PAGING_IDENTITY_imsi = (1 << 1), + NGAP_UE_PAGING_IDENTITY_s_tmsi = (1 << 2), +} ngap_ue_paging_identity_presenceMask_t; -typedef struct ue_paging_identity_s { - ue_paging_identity_presenceMask_t presenceMask; +typedef struct ngap_ue_paging_identity_s { + ngap_ue_paging_identity_presenceMask_t presenceMask; union { ngap_imsi_t imsi; - s_tmsi_t s_tmsi; + ngap_s_tmsi_t s_tmsi; } choice; -} ue_paging_identity_t; +} ngap_ue_paging_identity_t; -typedef enum ue_identities_presenceMask_e { - UE_IDENTITIES_NONE = 0, - UE_IDENTITIES_s_tmsi = 1 << 1, - UE_IDENTITIES_guami = 1 << 2, -} ue_identities_presenceMask_t; +typedef enum ngap_ue_identities_presenceMask_e { + NGAP_UE_IDENTITIES_NONE = 0, + NGAP_UE_IDENTITIES_s_tmsi = 1 << 1, + NGAP_UE_IDENTITIES_guami = 1 << 2, +} ngap_ue_identities_presenceMask_t; -typedef struct nrue_identity_s { - ue_identities_presenceMask_t presenceMask; - s_tmsi_t s_tmsi; +typedef struct ngap_nrue_identity_s { + ngap_ue_identities_presenceMask_t presenceMask; + ngap_s_tmsi_t s_tmsi; ngap_guami_t guami; } nrue_identity_t; -typedef struct nas_pdu_s { +typedef struct ngap_nas_pdu_s { /* Octet string data */ uint8_t *buffer; /* Length of the octet string */ uint32_t length; -} nas_pdu_t, ue_radio_cap_t; +} ngap_nas_pdu_t, ngap_ue_radio_cap_t; typedef enum pdu_session_type_e { PDUSessionType_ipv4 = 0, @@ -243,7 +238,7 @@ typedef enum pdu_session_type_e { PDUSessionType_unstructured = 4 }pdu_session_type_t; -typedef struct transport_layer_addr_s { +typedef struct ngap_transport_layer_addr_s { /* Length of the transport layer address buffer in bits. NGAP layer received a * bit string<1..160> containing one of the following addresses: ipv4, * ipv6, or ipv4 and ipv6. The layer doesn't interpret the buffer but @@ -252,7 +247,7 @@ typedef struct transport_layer_addr_s { uint8_t pdu_session_type; uint8_t length; uint8_t buffer[20]; // in network byte order -} transport_layer_addr_t; +} ngap_transport_layer_addr_t; #define TRANSPORT_LAYER_ADDR_COPY(dEST,sOURCE) \ do { \ @@ -275,9 +270,9 @@ typedef struct pdusession_s { /* Quality of service for this pdusession */ pdusession_level_qos_parameter_t qos[QOSFLOW_MAX_VALUE]; /* The NAS PDU should be forwarded by the RRC layer to the NAS layer */ - nas_pdu_t nas_pdu; + ngap_nas_pdu_t nas_pdu; /* The transport layer address for the IP packets */ - transport_layer_addr_t upf_addr; + ngap_transport_layer_addr_t upf_addr; /* S-GW Tunnel endpoint identifier */ uint32_t gtp_teid; } pdusession_t; @@ -339,7 +334,7 @@ typedef struct pdusession_modify_s { uint8_t pdusession_id; } pdusession_modify_t; -typedef enum S1ap_Cause_e { +typedef enum ngap_Cause_e { NGAP_CAUSE_NOTHING, /* No components present */ NGAP_CAUSE_RADIO_NETWORK, NGAP_CAUSE_TRANSPORT, @@ -400,7 +395,7 @@ typedef struct ngap_register_gnb_req_s { uint8_t num_plmn; /* Default Paging DRX of the gNB as defined in TS 36.304 */ - paging_drx_t default_drx; + ngap_paging_drx_t default_drx; /* The gNB IP address to bind */ net_ip_address_t gnb_ip_address; @@ -446,7 +441,7 @@ typedef struct ngap_nas_first_req_s { int selected_plmn_identity; /* Establishment cause as sent by UE */ - rrc_establishment_cause_t establishment_cause; + ngap_rrc_establishment_cause_t establishment_cause; /* NAS PDU */ nas_pdu_t nas_pdu; @@ -508,7 +503,7 @@ typedef struct ngap_ue_ctxt_modification_req_s { uint8_t security_key[SECURITY_KEY_LENGTH]; /* UE aggregate maximum bitrate */ - ambr_t ue_ambr; + ngap_ambr_t ue_ambr; /* NR Security capabilities */ nr_security_capabilities_t security_capabilities; @@ -569,11 +564,11 @@ typedef struct ngap_initial_context_setup_req_s { pdusession_t pdusession_param[NGAP_MAX_PDUSESSION]; } ngap_initial_context_setup_req_t; -typedef struct tai_plmn_identity_s { +typedef struct ngap_tai_plmn_identity_s { uint16_t mcc; uint16_t mnc; uint8_t mnc_digit_length; -} plmn_identity_t; +} ngap_plmn_identity_t; typedef struct ngap_paging_ind_s { /* UE identity index value. @@ -582,13 +577,13 @@ typedef struct ngap_paging_ind_s { unsigned ue_index_value:10; /* UE paging identity */ - ue_paging_identity_t ue_paging_identity; + ngap_ue_paging_identity_t ue_paging_identity; /* Indicates origin of paging */ - cn_domain_t cn_domain; + ngap_cn_domain_t cn_domain; /* PLMN_identity in TAI of Paging*/ - plmn_identity_t plmn_identity[256]; + ngap_plmn_identity_t plmn_identity[256]; /* TAC in TAIList of Paging*/ int16_t tac[256]; @@ -597,9 +592,9 @@ typedef struct ngap_paging_ind_s { int16_t tai_size; /* Optional fields */ - paging_drx_t paging_drx; + ngap_paging_drx_t paging_drx; - paging_priority_t paging_priority; + ngap_paging_priority_t paging_priority; } ngap_paging_ind_t; typedef struct ngap_pdusession_setup_req_s { diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index 8bb585f3ee..ab2fea0144 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -39,7 +39,7 @@ #include "x2ap_eNB.h" #include "intertask_interface.h" -#include "s1ap_eNB.h" +#include "ngap_gNB.h" #include "sctp_eNB_task.h" #include "gtpv1u_eNB_task.h" #include "PHY/INIT/phy_init.h" @@ -83,14 +83,14 @@ static uint32_t gNB_app_register(uint32_t gnb_id_start, uint32_t gnb_id_end)//, ngap_register_gnb_req_t *ngap_register_gNB; //Type Temporarily reuse // note: there is an implicit relationship between the data structure and the message name - *msg_p = itti_alloc_new_message (TASK_GNB_APP, NGAP_REGISTER_GNB_REQ); //Message Temporarily reuse + msg_p = itti_alloc_new_message (TASK_GNB_APP, NGAP_REGISTER_GNB_REQ); //Message Temporarily reuse RCconfig_NR_NG(msg_p, gnb_id); if (gnb_id == 0) RCconfig_nr_gtpu(); ngap_register_gNB = &NGAP_REGISTER_GNB_REQ(msg_p); //Message Temporarily reuse - LOG_I(GNB_APP,"default drx %d\n",ngap_register_gNB->default_drx);*/ + LOG_I(GNB_APP,"default drx %d\n",ngap_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)); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 4d9b76301a..237594ae26 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -37,6 +37,7 @@ #include "UTIL/OTG/otg.h" #include "UTIL/OTG/otg_externs.h" #include "intertask_interface.h" +#include "s1ap_eNB.h" #include "ngap_gNB.h" #include "sctp_eNB_task.h" #include "sctp_default_values.h" @@ -342,7 +343,7 @@ void RCconfig_nr_flexran() if (!GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr) { // Calculate a default gNB ID if (EPC_MODE_ENABLED) - gnb_id = i + (ngap_generate_gNB_id () & 0xFFFF8); + gnb_id = i + (s1ap_generate_eNB_id () & 0xFFFF8); else gnb_id = i; } else { @@ -569,7 +570,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { // Calculate a default gNB ID if (EPC_MODE_ENABLED) { uint32_t hash; - hash = ngap_generate_gNB_id (); + hash = s1ap_generate_eNB_id (); gnb_id = i + (hash & 0xFFFF8); } else { gnb_id = i; @@ -786,7 +787,7 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { if (EPC_MODE_ENABLED) { uint32_t hash; - hash = ngap_generate_gNB_id (); + hash = s1ap_generate_eNB_id (); gnb_id = k + (hash & 0xFFFF8); } else { gnb_id = k; @@ -1035,7 +1036,7 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { // Calculate a default eNB ID if (EPC_MODE_ENABLED) { uint32_t hash; - hash = ngap_generate_gNB_id (); + hash = s1ap_generate_eNB_id (); gnb_id = k + (hash & 0xFFFF8); } else { gnb_id = k; diff --git a/openair2/GNB_APP/gnb_config.h b/openair2/GNB_APP/gnb_config.h index b2e03deeb0..0d965171ef 100644 --- a/openair2/GNB_APP/gnb_config.h +++ b/openair2/GNB_APP/gnb_config.h @@ -39,6 +39,7 @@ #include "platform_constants.h" #include "PHY/defs_eNB.h" #include "s1ap_messages_types.h" +#include "ngap_messages_types.h" #ifdef CMAKER #include "rrc_messages_types.h" diff --git a/openair3/COMMON/messages_types.h b/openair3/COMMON/messages_types.h index f91881bf11..f8fd464288 100644 --- a/openair3/COMMON/messages_types.h +++ b/openair3/COMMON/messages_types.h @@ -39,6 +39,7 @@ #include "udp_messages_types.h" #include "mme_app_messages_types.h" #include "m2ap_messages_types.h" +#include "ngap_messages_types.h" #endif /* MESSAGES_TYPES_H_ */ diff --git a/openair3/NGAP/ngap_gNB.c b/openair3/NGAP/ngap_gNB.c index aa4b7713f9..cd6857824b 100644 --- a/openair3/NGAP/ngap_gNB.c +++ b/openair3/NGAP/ngap_gNB.c @@ -64,7 +64,6 @@ #include "oaisim_amf_test_s1c.h" #endif -ngap_gNB_config_t ngap_config; static int ngap_gNB_generate_ng_setup_request( ngap_gNB_instance_t *instance_p, ngap_gNB_amf_data_t *ngap_amf_data_p); diff --git a/openair3/NGAP/ngap_gNB.h b/openair3/NGAP/ngap_gNB.h index 79ee2e0eee..5750dfccef 100644 --- a/openair3/NGAP/ngap_gNB.h +++ b/openair3/NGAP/ngap_gNB.h @@ -30,15 +30,6 @@ #ifndef NGAP_GNB_H_ #define NGAP_GNB_H_ -typedef struct ngap_gNB_config_s { - // AMF related params - unsigned char amf_enabled; ///< AMF enabled ? -} ngap_gNB_config_t; - -extern ngap_gNB_config_t ngap_config; - -#define EPC_MODE_ENABLED ngap_config.amf_enabled - void *ngap_gNB_process_itti_msg(void*); void ngap_gNB_init(void); void *ngap_gNB_task(void *arg);