From 84579c5dc0fbe144775e52bfcd3584d0a527ca55 Mon Sep 17 00:00:00 2001 From: zhenghuangkun Date: Tue, 29 Sep 2020 02:56:21 +0000 Subject: [PATCH] Modify MME_MODE_ENABLED to AMF_MODE_ENABLED Modify kenb to kgnb Modify some warnings --- executables/nr-ru.c | 2 +- executables/nr-softmodem.c | 4 +- openair1/SIMULATION/NR_PHY/nr_unitary_defs.h | 4 +- openair2/GNB_APP/gnb_app.c | 2 +- openair2/GNB_APP/gnb_config.c | 16 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 3 +- openair2/RRC/NR/nr_rrc_defs.h | 8 +- openair2/RRC/NR/rrc_gNB.c | 8 +- openair2/RRC/NR/rrc_gNB_NGAP.c | 10 +- openair2/RRC/NR/rrc_gNB_NGAP.h | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 195 ++++++++++ openair2/RRC/NR_UE/rrc_defs.h | 3 + openair3/NGAP/ngap_gNB.c | 1 + openair3/NGAP/ngap_gNB.h | 10 + openair3/NGAP/ngap_gNB_handlers.c | 224 +---------- openair3/NGAP/ngap_gNB_nas_procedures.c | 383 +------------------ openair3/NGAP/ngap_gNB_overload.c | 33 +- openair3/NGAP/ngap_gNB_trace.c | 33 +- targets/COMMON/create_nr_tasks.c | 4 +- 19 files changed, 247 insertions(+), 698 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index e85db116c9..a0f5710128 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1796,7 +1796,7 @@ void init_RU_proc(RU_t *ru) { pthread_cond_init( &proc->cond_asynch_rxtx, NULL); pthread_cond_init( &proc->cond_synch,NULL); pthread_cond_init( &proc->cond_gNBs, NULL); - //threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "thread_FH", -1, OAI_PRIORITY_RT_MAX ); + threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "thread_FH", -1, OAI_PRIORITY_RT_MAX ); if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) threadCreate( &proc->pthread_FH1, ru_thread_tx, (void *)ru, "thread_FH1", -1, OAI_PRIORITY_RT ); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 554bb0440e..30fe023544 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -401,7 +401,7 @@ int create_gNB_tasks(uint32_t gnb_nb) { } } - if (EPC_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0)) { + if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0)) { if (gnb_nb > 0) { /* if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) { @@ -824,7 +824,7 @@ int main( int argc, char **argv ) } openair0_cfg[0].threequarter_fs = threequarter_fs; - EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; //!get_softmodem_params()->phy_test; + AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1; //!get_softmodem_params()->phy_test; if (get_softmodem_params()->do_ra) AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index 7a465e0ea3..a7150fb2f9 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -235,8 +235,8 @@ void fill_scc(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_RB_DL void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap); void prepare_scc(NR_ServingCellConfigCommon_t *scc); -s1ap_eNB_config_t s1ap_config; -uint32_t s1ap_generate_eNB_id(void) {return 0;} +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/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index ab2fea0144..e4d3e53549 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -173,7 +173,7 @@ void *gNB_app_task(void *args_p) __attribute__((unused)) uint32_t x2_register_gnb_pending = gNB_app_register_x2 (gnb_id_start, gnb_id_end); } - if (EPC_MODE_ENABLED) { + if (AMF_MODE_ENABLED) { /* Try to register each gNB */ //registered_gnb = 0; __attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end);//, gnb_properties_p); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 17fdb31dfb..737ad044e9 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -342,7 +342,7 @@ void RCconfig_nr_flexran() /* gNB ID from configuration, as read in by RCconfig_RRC() */ if (!GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr) { // Calculate a default gNB ID - if (EPC_MODE_ENABLED) + if (AMF_MODE_ENABLED) gnb_id = i + (ngap_generate_gNB_id () & 0xFFFFFF8); else gnb_id = i; @@ -536,7 +536,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { AssertFatal (imodule_id); /******************** Radio Bearer Config ********************/ + ie = calloc(1, sizeof(NR_RRCReconfiguration_IEs_t)); ie->radioBearerConfig = calloc(1, sizeof(NR_RadioBearerConfig_t)); /* Configure SRB2 */ diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 92c82ecc2c..cceb294dd6 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -290,9 +290,9 @@ typedef struct gNB_RRC_UE_s { ImsiMobileIdentity_t imsi; #if defined(ENABLE_SECURITY) - /* KeNB as derived from KASME received from EPC */ - uint8_t kenb[32]; - int8_t kenb_ncc; + /* KgNB as derived from KASME received from EPC */ + uint8_t kgnb[32]; + int8_t kgnb_ncc; uint8_t nh[32]; int8_t nh_ncc; #endif @@ -322,7 +322,7 @@ typedef struct gNB_RRC_UE_s { uint64_t amf_ue_ngap_id:40; nr_rrc_guami_t ue_guami; - security_capabilities_t security_capabilities; + ngap_security_capabilities_t security_capabilities; /* Total number of e_rab already setup in the list */ uint8_t setup_e_rabs; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 4b4f6158ae..771e797fa7 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -542,18 +542,18 @@ rrc_gNB_process_RRCReconfigurationComplete( return; } - /* Derive the keys from kenb */ + /* Derive the keys from kgnb */ if (DRB_configList != NULL) { derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm, - ue_context_pP->ue_context.kenb, + ue_context_pP->ue_context.kgnb, &kUPenc); } derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm, - ue_context_pP->ue_context.kenb, + ue_context_pP->ue_context.kgnb, &kRRCenc); derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, - ue_context_pP->ue_context.kenb, + ue_context_pP->ue_context.kgnb, &kRRCint); /* Refresh SRBs/DRBs */ diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index da10657552..9d81462d40 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -370,7 +370,7 @@ int rrc_gNB_process_security( const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, - security_capabilities_t *security_capabilities_pP + ngap_security_capabilities_t *security_capabilities_pP ) { boolean_t changed = FALSE; NR_CipheringAlgorithm_t cipheringAlgorithm; @@ -381,19 +381,19 @@ rrc_gNB_process_security( LOG_D(NR_RRC, "[eNB %d] NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n", ctxt_pP->module_id, - ue_context_pP->ue_context.security_capabilities.encryption_algorithms, + ue_context_pP->ue_context.security_capabilities.nRencryption_algorithms, (unsigned long)ue_context_pP->ue_context.ciphering_algorithm, - ue_context_pP->ue_context.security_capabilities.integrity_algorithms, + ue_context_pP->ue_context.security_capabilities.nRintegrity_algorithms, ue_context_pP->ue_context.integrity_algorithm); /* Select relevant algorithms */ - cipheringAlgorithm = rrc_gNB_select_ciphering (ue_context_pP->ue_context.security_capabilities.encryption_algorithms); + cipheringAlgorithm = rrc_gNB_select_ciphering (ue_context_pP->ue_context.security_capabilities.nRencryption_algorithms); if (ue_context_pP->ue_context.ciphering_algorithm != cipheringAlgorithm) { ue_context_pP->ue_context.ciphering_algorithm = cipheringAlgorithm; changed = TRUE; } - integrityProtAlgorithm = rrc_gNB_select_integrity (ue_context_pP->ue_context.security_capabilities.integrity_algorithms); + integrityProtAlgorithm = rrc_gNB_select_integrity (ue_context_pP->ue_context.security_capabilities.nRintegrity_algorithms); if (ue_context_pP->ue_context.integrity_algorithm != integrityProtAlgorithm) { ue_context_pP->ue_context.integrity_algorithm = integrityProtAlgorithm; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index 8da2f06c57..5fb1a9f0d9 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -74,7 +74,7 @@ int rrc_gNB_process_security( const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, - security_capabilities_t *security_capabilities_pP + ngap_security_capabilities_t *security_capabilities_pP ); #endif diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 03e5b6b4f2..09217b0500 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -507,3 +507,198 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message( return 0; } + + +//----------------------------------------------------------------------------- +void +nr_rrc_ue_process_securityModeCommand( + const protocol_ctxt_t *const ctxt_pP, + NR_SecurityModeCommand_t *const securityModeCommand, + const uint8_t gNB_index +) +//----------------------------------------------------------------------------- +{ + asn_enc_rval_t enc_rval; + NR_UL_DCCH_Message_t ul_dcch_msg; + uint8_t buffer[200]; + int i, securityMode; + LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (eNB %d)\n", + ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index); + + switch (securityModeCommand->criticalExtensions.choice->securityModeCommand->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm) { + case NR_CipheringAlgorithm_nea0: + LOG_I(RRC,"[UE %d] Security algorithm is set to nea0\n", + ctxt_pP->module_id); + securityMode= NR_CipheringAlgorithm_nea0; + break; + + case NR_CipheringAlgorithm_nea1: + LOG_I(RRC,"[UE %d] Security algorithm is set to nea1\n",ctxt_pP->module_id); + securityMode= NR_CipheringAlgorithm_nea1; + break; + + case NR_CipheringAlgorithm_nea2: + LOG_I(RRC,"[UE %d] Security algorithm is set to nea2\n", + ctxt_pP->module_id); + securityMode = NR_CipheringAlgorithm_nea2; + break; + + default: + LOG_I(RRC,"[UE %d] Security algorithm is set to none\n",ctxt_pP->module_id); + securityMode = NR_CipheringAlgorithm_spare1; + break; + } + + switch (securityModeCommand->criticalExtensions.choice->securityModeCommand.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm) { + case NR_IntegrityProtAlgorithm_nia1: + LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to nia1\n",ctxt_pP->module_id); + securityMode |= 1 << 5; + break; + + case NR_IntegrityProtAlgorithm_nia2: + LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to nia2\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); + NR_UE_rrc_inst->cipheringAlgorithm = + securityModeCommand->criticalExtensions.choice->securityModeCommand.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm; + NR_UE_rrc_inst->integrityProtAlgorithm = + securityModeCommand->criticalExtensions.choice->securityModeCommand.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm; +memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); + //memset((void *)&SecurityModeCommand,0,sizeof(SecurityModeCommand_t)); + ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; + + if (securityMode >= NO_SECURITY_MODE) { + LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode complete case \n"); + ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_securityModeComplete; + } else { + LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode failure case \n"); + ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure; + } + + uint8_t *kRRCenc = NULL; + uint8_t *kUPenc = NULL; + uint8_t *kRRCint = NULL; + 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); + + 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 KgNB=" + "%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", + NR_UE_rrc_inst->kgnb[0], NR_UE_rrc_inst->kgnb[1], NR_UE_rrc_inst->kgnb[2], NR_UE_rrc_inst->kgnb[3], + NR_UE_rrc_inst->kgnb[4], NR_UE_rrc_inst->kgnb[5], NR_UE_rrc_inst->kgnb[6], NR_UE_rrc_inst->kgnb[7], + NR_UE_rrc_inst->kgnb[8], NR_UE_rrc_inst->kgnb[9], NR_UE_rrc_inst->kgnb[10], NR_UE_rrc_inst->kgnb[11], + NR_UE_rrc_inst->kgnb[12], NR_UE_rrc_inst->kgnb[13], NR_UE_rrc_inst->kgnb[14], NR_UE_rrc_inst->kgnb[15], + NR_UE_rrc_inst->kgnb[16], NR_UE_rrc_inst->kgnb[17], NR_UE_rrc_inst->kgnb[18], NR_UE_rrc_inst->kgnb[19], + NR_UE_rrc_inst->kgnb[20], NR_UE_rrc_inst->kgnb[21], NR_UE_rrc_inst->kgnb[22], NR_UE_rrc_inst->kgnb[23], + NR_UE_rrc_inst->kgnb[24], NR_UE_rrc_inst->kgnb[25], NR_UE_rrc_inst->kgnb[26], NR_UE_rrc_inst->kgnb[27], + NR_UE_rrc_inst->kgnb[28], NR_UE_rrc_inst->kgnb[29], NR_UE_rrc_inst->kgnb[30], NR_UE_rrc_inst->kgnb[31]); + derive_key_rrc_enc(NR_UE_rrc_inst->cipheringAlgorithm,NR_UE_rrc_inst->kgnb, &kRRCenc); + derive_key_rrc_int(NR_UE_rrc_inst->integrityProtAlgorithm,NR_UE_rrc_inst->kgnb, &kRRCint); + derive_key_up_enc(NR_UE_rrc_inst->cipheringAlgorithm,NR_UE_rrc_inst->kgnb, &kUPenc); + + if (securityMode != 0xff) { + pdcp_config_set_security(ctxt_pP, pdcp_p, 0, 0, + NR_UE_rrc_inst->cipheringAlgorithm + | (NR_UE_rrc_inst->integrityProtAlgorithm << 4), + kRRCenc, kRRCint, kUPenc); + } else { + LOG_I(RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", + securityMode); + } + } else { + LOG_I(RRC, "Could not get PDCP instance where key=0x%ld\n", key); + } + + if (securityModeCommand->criticalExtensions.present == NR_SecurityModeComplete__criticalExtensions_PR_securityModeComplete) { + + ul_dcch_msg.message.choice->c1->choice.securityModeComplete.rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; + ul_dcch_msg.message.choice->c1->choice.securityModeComplete.criticalExtensions.present = NR_SecurityModeComplete__criticalExtensions_PR_securityModeComplete; + ul_dcch_msg.message.choice->c1->choice.securityModeComplete.criticalExtensions.choice.securityModeComplete->nonCriticalExtension =NULL; + LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d), rrc_TransactionIdentifier: %ld\n", + ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index, securityModeCommand->rrc_TransactionIdentifier); + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_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); + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); + } + + 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); + } else LOG_W(RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n", + securityModeCommand->criticalExtensions.present); +} + +//----------------------------------------------------------------------------- +void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ) { + uint8_t i=0,rv[6]; + + if(UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_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++) { +#ifdef SMBV + // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed + rv[i]=i; +#else + rv[i]=taus()&0xff; +#endif + LOG_T(RRC,"%x.",rv[i]); + } + + LOG_T(RRC,"\n"); + UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size = + do_RRCSetupRequest( + ctxt_pP->module_id, + (uint8_t *)UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, + rv); + LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (bytes %d, eNB %d)\n", + ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index); + + for (i=0; imodule_id].Srb0[gNB_index].Tx_buffer.payload_size; i++) { + LOG_T(RRC,"%x.",UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload[i]); + } + + 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; */ + } +} diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 6481fb0cea..e01d7ffc39 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -70,6 +70,9 @@ typedef struct NR_UE_RRC_INST_s { NR_RadioBearerConfig_t *radio_bearer_config; NR_MIB_t *mib; + + /* KeNB as computed from parameters within USIM card */ + uint8_t kgnb[32]; // lists // CellGroupConfig.rlc-BearerToAddModList diff --git a/openair3/NGAP/ngap_gNB.c b/openair3/NGAP/ngap_gNB.c index b2f597b582..70446eea5f 100644 --- a/openair3/NGAP/ngap_gNB.c +++ b/openair3/NGAP/ngap_gNB.c @@ -65,6 +65,7 @@ #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 2aa0080cd1..e011af0cf5 100644 --- a/openair3/NGAP/ngap_gNB.h +++ b/openair3/NGAP/ngap_gNB.h @@ -39,6 +39,16 @@ #ifndef NGAP_GNB_H_ #define NGAP_GNB_H_ +typedef struct ngap_gNB_config_s { + // MME related params + unsigned char amf_enabled; ///< AMF enabled ? +} ngap_gNB_config_t; + +extern ngap_gNB_config_t ngap_config; + +#define AMF_MODE_ENABLED ngap_config.amf_enabled + + void *ngap_gNB_process_itti_msg(void*); void ngap_gNB_init(void); void *ngap_gNB_task(void *arg); diff --git a/openair3/NGAP/ngap_gNB_handlers.c b/openair3/NGAP/ngap_gNB_handlers.c index 408957d899..b35741151f 100644 --- a/openair3/NGAP/ngap_gNB_handlers.c +++ b/openair3/NGAP/ngap_gNB_handlers.c @@ -1859,165 +1859,7 @@ static int ngap_gNB_handle_ng_path_switch_request_ack(uint32_t assoc_id, uint32_t stream, NGAP_NGAP_PDU_t *pdu) { -#if 0 - ngap_gNB_amf_data_t *amf_desc_p = NULL; - ngap_gNB_ue_context_t *ue_desc_p = NULL; - MessageDef *message_p = NULL; - NGAP_PathSwitchRequestAcknowledge_t *pathSwitchRequestAcknowledge; - NGAP_PathSwitchRequestAcknowledgeIEs_t *ie; - NGAP_PDUSESSIONToBeSwitchedULItemIEs_t *ngap_PDUSESSIONToBeSwitchedULItemIEs; - NGAP_PDUSESSIONToBeSwitchedULItem_t *ngap_PDUSESSIONToBeSwitchedULItem; - NGAP_PDUSESSIONItemIEs_t *e_RABItemIEs; - NGAP_PDUSESSIONItem_t *e_RABItem; - DevAssert(pdu != NULL); - pathSwitchRequestAcknowledge = &pdu->choice.successfulOutcome->value.choice.PathSwitchRequestAcknowledge; - - /* Path Switch request == UE-related procedure -> stream !=0 */ - if (stream == 0) { - NGAP_ERROR("[SCTP %d] Received s1 path switch request ack on stream (%d)\n", - assoc_id, stream); - //return -1; - } - - if ((amf_desc_p = ngap_gNB_get_AMF(NULL, assoc_id, 0)) == NULL) { - NGAP_ERROR("[SCTP %d] Received S1 path switch request ack for non existing " - "AMF context\n", assoc_id); - return -1; - } - - // send a message to RRC - message_p = itti_alloc_new_message(TASK_NGAP, NGAP_PATH_SWITCH_REQ_ACK); - /* mandatory */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID, true); - if (ie == NULL) { - NGAP_ERROR("[SCTP %d] Received path switch request ack for non " - "ie context is NULL\n", assoc_id); - return -1; - } - - NGAP_PATH_SWITCH_REQ_ACK(message_p).gNB_ue_ngap_id = ie->value.choice.GNB_UE_NGAP_ID; - - if ((ue_desc_p = ngap_gNB_get_ue_context(amf_desc_p->ngap_gNB_instance, - ie->value.choice.GNB_UE_NGAP_ID)) == NULL) { - NGAP_ERROR("[SCTP %d] Received path switch request ack for non " - "existing UE context 0x%06lx\n", assoc_id, - ie->value.choice.GNB_UE_NGAP_ID); - itti_free(ITTI_MSG_ORIGIN_ID(message_p), message_p); - return -1; - } - - NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_initial_id = ue_desc_p->ue_initial_id; - /* mandatory */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_AMF_UE_NGAP_ID, true); - - if (ie == NULL) { - NGAP_ERROR("[SCTP %d] Received path switch request ack for non " - "ie context is NULL\n", assoc_id); - return -1; - } - - NGAP_PATH_SWITCH_REQ_ACK(message_p).amf_ue_ngap_id = ie->value.choice.AMF_UE_NGAP_ID; - - if ( ue_desc_p->amf_ue_ngap_id != ie->value.choice.AMF_UE_NGAP_ID) { - NGAP_WARN("UE context amf_ue_ngap_id is different form that of the message (%d != %ld)", - ue_desc_p->amf_ue_ngap_id, ie->value.choice.AMF_UE_NGAP_ID); - } - - /* mandatory */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_SecurityContext, true); - - if (ie == NULL) { - NGAP_ERROR("[SCTP %d] Received path switch request ack for non " - "ie context is NULL\n", assoc_id); - return -1; - } - - NGAP_PATH_SWITCH_REQ_ACK(message_p).next_hop_chain_count = - ie->value.choice.SecurityContext.nextHopChainingCount; - memcpy(&NGAP_PATH_SWITCH_REQ_ACK(message_p).next_security_key, - ie->value.choice.SecurityContext.nextHopParameter.buf, - ie->value.choice.SecurityContext.nextHopParameter.size); - /* optional */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_uEaggregateMaximumBitrate, false); - - if (ie) { - OCTET_STRING_TO_INT32 ( - &ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateUL, - NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_ul - ); - OCTET_STRING_TO_INT32 ( - &ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateDL, - NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_dl - ); - } else { - NGAP_WARN("UEAggregateMaximumBitrate not supported\n"); - NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_ul = 0; - NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_dl = 0; - } - - /* optional */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_PDUSESSIONToBeSwitchedULList, false); - - if (ie) { - NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobeswitched = ie->value.choice.PDUSESSIONToBeSwitchedULList.list.count; - - for (int i = 0; i < ie->value.choice.PDUSESSIONToBeSwitchedULList.list.count; i++) { - ngap_PDUSESSIONToBeSwitchedULItemIEs = (NGAP_PDUSESSIONToBeSwitchedULItemIEs_t *)ie->value.choice.PDUSESSIONToBeSwitchedULList.list.array[i]; - ngap_PDUSESSIONToBeSwitchedULItem = &ngap_PDUSESSIONToBeSwitchedULItemIEs->value.choice.PDUSESSIONToBeSwitchedULItem; - NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].pdusession_id = ngap_PDUSESSIONToBeSwitchedULItem->e_RAB_ID; - memcpy(NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].sgw_addr.buffer, - ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.buf, ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.size); - NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].sgw_addr.length = - ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.size * 8 - ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.bits_unused; - OCTET_STRING_TO_INT32(&ngap_PDUSESSIONToBeSwitchedULItem->gTP_TEID, - NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].gtp_teid); - } - } else { - NGAP_WARN("PDUSESSIONToBeSwitchedULList not supported\n"); - NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobeswitched = 0; - } - - /* optional */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_PDUSESSIONToBeReleasedList, false); - - if (ie) { - NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobereleased = ie->value.choice.PDUSESSIONList.list.count; - - for (int i = 0; i < ie->value.choice.PDUSESSIONList.list.count; i++) { - e_RABItemIEs = (NGAP_PDUSESSIONItemIEs_t *)ie->value.choice.PDUSESSIONList.list.array[i]; - e_RABItem = &e_RABItemIEs->value.choice.PDUSESSIONItem; - NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobereleased[i].pdusession_id = e_RABItem->e_RAB_ID; - } - } else { - NGAP_WARN("PDUSESSIONToBeReleasedList not supported\n"); - NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobereleased = 0; - } - - /* optional */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_CriticalityDiagnostics, false); - - if(!ie) { - NGAP_WARN("Critical Diagnostic not supported\n"); - } - - /* optional */ - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, - NGAP_ProtocolIE_ID_id_AMF_UE_NGAP_ID_2, false); - - if(!ie) { - NGAP_WARN("AMF_UE_NGAP_ID_2 flag not supported\n"); - } - - // TODO continue - itti_send_msg_to_task(TASK_RRC_GNB, ue_desc_p->gNB_instance->instance, message_p); -#endif + // TODO return 0; } @@ -2025,68 +1867,8 @@ static int ngap_gNB_handle_ng_path_switch_request_failure(uint32_t assoc_id, uint32_t stream, NGAP_NGAP_PDU_t *pdu) { -#if 0 - ngap_gNB_amf_data_t *amf_desc_p = NULL; - NGAP_PathSwitchRequestFailure_t *pathSwitchRequestFailure; - NGAP_PathSwitchRequestFailureIEs_t *ie; - DevAssert(pdu != NULL); - pathSwitchRequestFailure = &pdu->choice.unsuccessfulOutcome->value.choice.PathSwitchRequestFailure; - if (stream != 0) { - NGAP_ERROR("[SCTP %d] Received s1 path switch request failure on stream != 0 (%d)\n", - assoc_id, stream); - return -1; - } - - if ((amf_desc_p = ngap_gNB_get_AMF(NULL, assoc_id, 0)) == NULL) { - NGAP_ERROR("[SCTP %d] Received S1 path switch request failure for non existing " - "AMF context\n", assoc_id); - return -1; - } - - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestFailureIEs_t, ie, pathSwitchRequestFailure, - NGAP_ProtocolIE_ID_id_Cause, true); - - if (ie == NULL) { - NGAP_ERROR("[SCTP %d] Received S1 path switch request failure for non existing " - "ie context is NULL\n", assoc_id); - return -1; - } - - switch(ie->value.choice.Cause.present) { - case NGAP_Cause_PR_NOTHING: - NGAP_WARN("Received S1 Error indication cause NOTHING\n"); - break; - - case NGAP_Cause_PR_radioNetwork: - NGAP_WARN("Radio Network Layer Cause Failure\n"); - break; - - case NGAP_Cause_PR_transport: - NGAP_WARN("Transport Layer Cause Failure\n"); - break; - - case NGAP_Cause_PR_nas: - NGAP_WARN("NAS Cause Failure\n"); - break; - - case NGAP_Cause_PR_misc: - NGAP_WARN("Miscelaneous Cause Failure\n"); - break; - - default: - NGAP_WARN("Received an unknown S1 Error indication cause\n"); - break; - } - - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestFailureIEs_t, ie, pathSwitchRequestFailure, - NGAP_ProtocolIE_ID_id_CriticalityDiagnostics, false); - - if(!ie) { - NGAP_WARN("Critical Diagnostic not supported\n"); - } -#endif - // TODO continue + // TODO return 0; } @@ -2095,7 +1877,7 @@ int ngap_gNB_handle_ng_ENDC_pdusession_modification_confirm(uint32_t uint32_t stream, NGAP_NGAP_PDU_t *pdu){ - LOG_W(NGAP, "Implementation of NGAP E-RAB Modification confirm handler is pending...\n"); + LOG_W(NGAP, "Implementation of NGAP Pdusession Modification confirm handler is pending...\n"); return 0; } diff --git a/openair3/NGAP/ngap_gNB_nas_procedures.c b/openair3/NGAP/ngap_gNB_nas_procedures.c index ef8472dcc0..d49f6951ac 100644 --- a/openair3/NGAP/ngap_gNB_nas_procedures.c +++ b/openair3/NGAP/ngap_gNB_nas_procedures.c @@ -1439,237 +1439,7 @@ int ngap_gNB_path_switch_req(instance_t instance, ngap_path_switch_req_t *path_switch_req_p) //------------------------------------------------------------------------------ { -#if 0 - ngap_gNB_instance_t *ngap_gNB_instance_p = NULL; - struct ngap_gNB_ue_context_s *ue_context_p = NULL; - struct ngap_gNB_amf_data_s *amf_desc_p = NULL; - - NGAP_NGAP_PDU_t pdu; - NGAP_PathSwitchRequest_t *out; - NGAP_PathSwitchRequestIEs_t *ie; - - NGAP_PDUSESSIONToBeSwitchedDLItemIEs_t *e_RABToBeSwitchedDLItemIEs; - NGAP_PDUSESSIONToBeSwitchedDLItem_t *e_RABToBeSwitchedDLItem; - - uint8_t *buffer = NULL; - uint32_t length; - int ret = 0;//-1; - - /* Retrieve the NGAP gNB instance associated with Mod_id */ - ngap_gNB_instance_p = ngap_gNB_get_instance(instance); - - DevAssert(path_switch_req_p != NULL); - DevAssert(ngap_gNB_instance_p != NULL); - - //if ((ue_context_p = ngap_gNB_get_ue_context(ngap_gNB_instance_p, - // path_switch_req_p->gNB_ue_ngap_id)) == NULL) { - /* The context for this gNB ue ngap id doesn't exist in the map of gNB UEs */ - //NGAP_WARN("Failed to find ue context associated with gNB ue ngap id: 0x%06x\n", - // path_switch_req_p->gNB_ue_ngap_id); - //return -1; - //} - - /* Uplink NAS transport can occur either during an ngap connected state - * or during initial attach (for example: NAS authentication). - */ - //if (!(ue_context_p->ue_state == NGAP_UE_CONNECTED || - // ue_context_p->ue_state == NGAP_UE_WAITING_CSR)) { - //NGAP_WARN("You are attempting to send NAS data over non-connected " - // "gNB ue ngap id: %06x, current state: %d\n", - // path_switch_req_p->gNB_ue_ngap_id, ue_context_p->ue_state); - //return -1; - //} - - /* Select the AMF corresponding to the provided GUAMI. */ - amf_desc_p = ngap_gNB_nnsf_select_amf_by_guami_no_cause(ngap_gNB_instance_p, path_switch_req_p->ue_guami); - - if (amf_desc_p == NULL) { - /* - * In case gNB has no AMF associated, the gNB should inform RRC and discard - * this request. - */ - - NGAP_WARN("No AMF is associated to the gNB\n"); - // TODO: Inform RRC - return -1; - } - - /* The gNB should allocate a unique gNB UE NGAP ID for this UE. The value - * will be used for the duration of the connectivity. - */ - ue_context_p = ngap_gNB_allocate_new_UE_context(); - DevAssert(ue_context_p != NULL); - - /* Keep a reference to the selected AMF */ - ue_context_p->amf_ref = amf_desc_p; - ue_context_p->ue_initial_id = path_switch_req_p->ue_initial_id; - ue_context_p->gNB_instance = ngap_gNB_instance_p; - - do { - struct ngap_gNB_ue_context_s *collision_p; - - /* Peek a random value for the gNB_ue_ngap_id */ - ue_context_p->gNB_ue_ngap_id = (random() + random()) & 0x00ffffff; - - if ((collision_p = RB_INSERT(ngap_ue_map, &ngap_gNB_instance_p->ngap_ue_head, ue_context_p)) - == NULL) { - NGAP_DEBUG("Found usable gNB_ue_ngap_id: 0x%06x %u(10)\n", - ue_context_p->gNB_ue_ngap_id, - ue_context_p->gNB_ue_ngap_id); - /* Break the loop as the id is not already used by another UE */ - break; - } - } while(1); - - ue_context_p->amf_ue_ngap_id = path_switch_req_p->amf_ue_ngap_id; - - /* Prepare the NGAP message to encode */ - memset(&pdu, 0, sizeof(pdu)); - pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_PathSwitchRequest; - pdu.choice.initiatingMessage->criticality = NGAP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_PathSwitchRequest; - out = &pdu.choice.initiatingMessage->value.choice.PathSwitchRequest; - - /* mandatory */ - ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID; - ie->criticality = NGAP_Criticality_reject; - ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_GNB_UE_NGAP_ID; - ie->value.choice.GNB_UE_NGAP_ID = ue_context_p->gNB_ue_ngap_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - /* mandatory */ - if (path_switch_req_p->nb_of_pdusessions > 0) { - ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeSwitchedDLList; - ie->criticality = NGAP_Criticality_reject; - ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_PDUSESSIONToBeSwitchedDLList; - - for (int i = 0; i < path_switch_req_p->nb_of_pdusessions; i++) { - e_RABToBeSwitchedDLItemIEs = (NGAP_PDUSESSIONToBeSwitchedDLItemIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONToBeSwitchedDLItemIEs_t)); - e_RABToBeSwitchedDLItemIEs->id = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeSwitchedDLItem; - e_RABToBeSwitchedDLItemIEs->criticality = NGAP_Criticality_reject; - e_RABToBeSwitchedDLItemIEs->value.present = NGAP_PDUSESSIONToBeSwitchedDLItemIEs__value_PR_PDUSESSIONToBeSwitchedDLItem; - - e_RABToBeSwitchedDLItem = &e_RABToBeSwitchedDLItemIEs->value.choice.PDUSESSIONToBeSwitchedDLItem; - e_RABToBeSwitchedDLItem->e_RAB_ID = path_switch_req_p->pdusessions_tobeswitched[i].pdusession_id; - INT32_TO_OCTET_STRING(path_switch_req_p->pdusessions_tobeswitched[i].gtp_teid, &e_RABToBeSwitchedDLItem->gTP_TEID); - - e_RABToBeSwitchedDLItem->transportLayerAddress.size = path_switch_req_p->pdusessions_tobeswitched[i].gNB_addr.length; - e_RABToBeSwitchedDLItem->transportLayerAddress.bits_unused = 0; - - e_RABToBeSwitchedDLItem->transportLayerAddress.buf = calloc(1,e_RABToBeSwitchedDLItem->transportLayerAddress.size); - - memcpy (e_RABToBeSwitchedDLItem->transportLayerAddress.buf, - path_switch_req_p->pdusessions_tobeswitched[i].gNB_addr.buffer, - path_switch_req_p->pdusessions_tobeswitched[i].gNB_addr.length); - - NGAP_DEBUG("path_switch_req: pdusession ID %ld, teid %u, enb_addr %d.%d.%d.%d, SIZE %zu\n", - e_RABToBeSwitchedDLItem->e_RAB_ID, - path_switch_req_p->pdusessions_tobeswitched[i].gtp_teid, - e_RABToBeSwitchedDLItem->transportLayerAddress.buf[0], - e_RABToBeSwitchedDLItem->transportLayerAddress.buf[1], - e_RABToBeSwitchedDLItem->transportLayerAddress.buf[2], - e_RABToBeSwitchedDLItem->transportLayerAddress.buf[3], - e_RABToBeSwitchedDLItem->transportLayerAddress.size); - - ASN_SEQUENCE_ADD(&ie->value.choice.PDUSESSIONToBeSwitchedDLList.list, e_RABToBeSwitchedDLItemIEs); - } - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - } - - /* mandatory */ - ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_SourceAMF_UE_NGAP_ID; - ie->criticality = NGAP_Criticality_reject; - ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_AMF_UE_NGAP_ID; - ie->value.choice.AMF_UE_NGAP_ID = path_switch_req_p->amf_ue_ngap_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - /* mandatory */ - ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_EUTRAN_CGI; - ie->criticality = NGAP_Criticality_ignore; - ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_EUTRAN_CGI; - MACRO_GNB_ID_TO_CELL_IDENTITY(ngap_gNB_instance_p->gNB_id, - 0, - &ie->value.choice.EUTRAN_CGI.cell_ID); - MCC_MNC_TO_TBCD(ngap_gNB_instance_p->mcc[0], - ngap_gNB_instance_p->mnc[0], - ngap_gNB_instance_p->mnc_digit_length[0], - &ie->value.choice.EUTRAN_CGI.pLMNidentity); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - /* mandatory */ - ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_TAI; - ie->criticality = NGAP_Criticality_ignore; - ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_TAI; - /* Assuming TAI is the TAI from the cell */ - INT16_TO_OCTET_STRING(ngap_gNB_instance_p->tac, &ie->value.choice.TAI.tAC); - MCC_MNC_TO_PLMNID(ngap_gNB_instance_p->mcc[0], - ngap_gNB_instance_p->mnc[0], - ngap_gNB_instance_p->mnc_digit_length[0], - &ie->value.choice.TAI.pLMNidentity); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - /* mandatory */ - ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_UESecurityCapabilities; - ie->criticality = NGAP_Criticality_ignore; - ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_UESecurityCapabilities; - ENCRALG_TO_BIT_STRING(path_switch_req_p->security_capabilities.encryption_algorithms, - &ie->value.choice.UESecurityCapabilities.encryptionAlgorithms); - INTPROTALG_TO_BIT_STRING(path_switch_req_p->security_capabilities.integrity_algorithms, - &ie->value.choice.UESecurityCapabilities.integrityProtectionAlgorithms); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - if (ngap_gNB_encode_pdu(&pdu, &buffer, &length) < 0) { - NGAP_ERROR("Failed to encode Path Switch Req \n"); - /* Encode procedure has failed... */ - return -1; - } - - /* Update the current NGAP UE state */ - ue_context_p->ue_state = NGAP_UE_WAITING_CSR; - - /* Assign a stream for this UE : - * From 3GPP 36.412 7)Transport layers: - * Within the SCTP association established between one AMF and gNB pair: - * - a single pair of stream identifiers shall be reserved for the sole use - * of NGAP elementary procedures that utilize non UE-associated signalling. - * - At least one pair of stream identifiers shall be reserved for the sole use - * of NGAP elementary procedures that utilize UE-associated signallings. - * However a few pairs (i.e. more than one) should be reserved. - * - A single UE-associated signalling shall use one SCTP stream and - * the stream should not be changed during the communication of the - * UE-associated signalling. - */ - amf_desc_p->nextstream = (amf_desc_p->nextstream + 1) % amf_desc_p->out_streams; - - if ((amf_desc_p->nextstream == 0) && (amf_desc_p->out_streams > 1)) { - amf_desc_p->nextstream += 1; - } - - ue_context_p->tx_stream = amf_desc_p->nextstream; - - MSC_LOG_TX_MESSAGE( - MSC_NGAP_GNB, - MSC_NGAP_AMF, - (const char *)buffer, - length, - MSC_AS_TIME_FMT" E_RAN Setup successfulOutcome gNB_ue_ngap_id %u amf_ue_ngap_id %u", - 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->gNB_ue_ngap_id, - path_switch_req_p->amf_ue_ngap_id); - - /* UE associated signalling -> use the allocated stream */ - ngap_gNB_itti_send_sctp_data_req(ngap_gNB_instance_p->instance, - amf_desc_p->assoc_id, buffer, - length, ue_context_p->tx_stream); -#endif + //TODO return 0; } @@ -1679,156 +1449,7 @@ int ngap_gNB_generate_PDUSESSION_Modification_Indication( ngap_pdusession_modification_ind_t *pdusession_modification_ind) //----------------------------------------------------------------------------- { -#if 0 - struct ngap_gNB_ue_context_s *ue_context_p = NULL; - NGAP_NGAP_PDU_t pdu; - NGAP_PDUSESSIONModificationIndication_t *out = NULL; - NGAP_PDUSESSIONModificationIndicationIEs_t *ie = NULL; - NGAP_PDUSESSIONToBeModifiedItemBearerModInd_t *PDUSESSION_ToBeModifiedItem_BearerModInd = NULL; - NGAP_PDUSESSIONToBeModifiedItemBearerModIndIEs_t *PDUSESSION_ToBeModifiedItem_BearerModInd_IEs = NULL; - - //NGAP_PDUSESSIONNotToBeModifiedItemBearerModInd_t *PDUSESSION_NotToBeModifiedItem_BearerModInd = NULL; - //NGAP_PDUSESSIONNotToBeModifiedItemBearerModIndIEs_t *PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs = NULL; - - - ngap_gNB_instance_t *ngap_gNB_instance_p = NULL; - ngap_gNB_instance_p = ngap_gNB_get_instance(instance); - uint8_t *buffer = NULL; - uint32_t len = 0; - int ret = 0; - DevAssert(ngap_gNB_instance_p != NULL); - DevAssert(pdusession_modification_ind != NULL); - - int num_pdusessions_tobemodified = pdusession_modification_ind->nb_of_pdusessions_tobemodified; - //int num_pdusessions_nottobemodified = pdusession_modification_ind->nb_of_pdusessions_nottobemodified; - - //uint32_t CSG_id = 0; - //uint32_t pseudo_gtp_teid = 10; - - if ((ue_context_p = ngap_gNB_get_ue_context(ngap_gNB_instance_p, - pdusession_modification_ind->gNB_ue_ngap_id)) == NULL) { - // The context for this gNB ue ngap id doesn't exist in the map of gNB UEs - NGAP_WARN("Failed to find ue context associated with gNB ue ngap id: 0x%06x\n", - pdusession_modification_ind->gNB_ue_ngap_id); - return -1; - } - - // Prepare the NGAP message to encode - memset(&pdu, 0, sizeof(pdu)); - pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_PDUSESSIONModificationIndication; - pdu.choice.initiatingMessage->criticality = NGAP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_PDUSESSIONModificationIndication; - out = &pdu.choice.initiatingMessage->value.choice.PDUSESSIONModificationIndication; - /* mandatory */ - ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_AMF_UE_NGAP_ID; - ie->criticality = NGAP_Criticality_reject; - ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_AMF_UE_NGAP_ID; - ie->value.choice.AMF_UE_NGAP_ID = pdusession_modification_ind->amf_ue_ngap_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID; - ie->criticality = NGAP_Criticality_reject; - ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_GNB_UE_NGAP_ID; - ie->value.choice.GNB_UE_NGAP_ID = pdusession_modification_ind->gNB_ue_ngap_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - //E-RABs to be modified list - ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeModifiedListBearerModInd; - ie->criticality = NGAP_Criticality_reject; - ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_PDUSESSIONToBeModifiedListBearerModInd; - - //The following two for-loops here will probably need to change. We should do a different type of search - for(int i=0; iid = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeModifiedItemBearerModInd; - PDUSESSION_ToBeModifiedItem_BearerModInd_IEs->criticality = NGAP_Criticality_reject; - PDUSESSION_ToBeModifiedItem_BearerModInd_IEs->value.present = NGAP_PDUSESSIONToBeModifiedItemBearerModIndIEs__value_PR_PDUSESSIONToBeModifiedItemBearerModInd; - PDUSESSION_ToBeModifiedItem_BearerModInd = &PDUSESSION_ToBeModifiedItem_BearerModInd_IEs->value.choice.PDUSESSIONToBeModifiedItemBearerModInd; - - { - PDUSESSION_ToBeModifiedItem_BearerModInd->e_RAB_ID = pdusession_modification_ind->pdusessions_tobemodified[i].pdusession_id; - - PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.size = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length/8; - PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.bits_unused = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length%8; - PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.buf = calloc(1, PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.size); - memcpy (PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.buf, pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.buffer, - PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.size); - - INT32_TO_OCTET_STRING(pdusession_modification_ind->pdusessions_tobemodified[i].gtp_teid, &PDUSESSION_ToBeModifiedItem_BearerModInd->dL_GTP_TEID); - - } - ASN_SEQUENCE_ADD(&ie->value.choice.PDUSESSIONToBeModifiedListBearerModInd.list, PDUSESSION_ToBeModifiedItem_BearerModInd_IEs); - } - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - //E-RABs NOT to be modified list - /*ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_PDUSESSIONNotToBeModifiedListBearerModInd; - ie->criticality = NGAP_Criticality_reject; - //if(num_pdusessions_nottobemodified > 0) { - ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_PDUSESSIONNotToBeModifiedListBearerModInd; - - for(int i=0; iid = NGAP_ProtocolIE_ID_id_PDUSESSIONNotToBeModifiedItemBearerModInd; - PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs->criticality = NGAP_Criticality_reject; - PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs->value.present = NGAP_PDUSESSIONNotToBeModifiedItemBearerModIndIEs__value_PR_PDUSESSIONNotToBeModifiedItemBearerModInd; - PDUSESSION_NotToBeModifiedItem_BearerModInd = &PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs->value.choice.PDUSESSIONNotToBeModifiedItemBearerModInd; - - { - PDUSESSION_NotToBeModifiedItem_BearerModInd->e_RAB_ID = 10; //pdusession_modification_ind->pdusessions_tobemodified[i].pdusession_id; - - PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.size = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length/8; - PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.bits_unused = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length%8; - PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.buf = - calloc(1, PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.size); - memcpy (PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.buf, pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.buffer, - PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.size); - - //INT32_TO_OCTET_STRING(pdusession_modification_ind->pdusessions_tobemodified[i].gtp_teid, &PDUSESSION_NotToBeModifiedItem_BearerModInd->dL_GTP_TEID); - INT32_TO_OCTET_STRING(pseudo_gtp_teid, &PDUSESSION_NotToBeModifiedItem_BearerModInd->dL_GTP_TEID); - - } - ASN_SEQUENCE_ADD(&ie->value.choice.PDUSESSIONNotToBeModifiedListBearerModInd.list, PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs); - } - // } - //else{ -// ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_PDUSESSIONNotToBeModifiedListBearerModInd; -// ie->value.choice.PDUSESSIONNotToBeModifiedListBearerModInd.list.size = 0; -// } / - - - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);*/ - - /*ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t)); - ie->id = NGAP_ProtocolIE_ID_id_CSGMembershipInfo; - ie->criticality = NGAP_Criticality_reject; - ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_CSGMembershipInfo; - ie->value.choice.CSGMembershipInfo.cSGMembershipStatus = NGAP_CSGMembershipStatus_member; - INT32_TO_BIT_STRING(CSG_id, &ie->value.choice.CSGMembershipInfo.cSG_Id); - ie->value.choice.CSGMembershipInfo.cSG_Id.bits_unused=5; - ie->value.choice.CSGMembershipInfo.cellAccessMode = NGAP_CellAccessMode_hybrid; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);*/ - - if (ngap_gNB_encode_pdu(&pdu, &buffer, &len) < 0) { - NGAP_ERROR("Failed to encode S1 E-RAB modification indication \n"); - return -1; - } - - // Non UE-Associated signalling -> stream = 0 - NGAP_INFO("Size of encoded message: %d \n", len); - ngap_gNB_itti_send_sctp_data_req(ngap_gNB_instance_p->instance, - ue_context_p->amf_ref->assoc_id, buffer, - len, ue_context_p->tx_stream); - -//ngap_gNB_itti_send_sctp_data_req(ngap_gNB_instance_p->instance, ue_context_p->amf_ref->assoc_id, buffer, len, 0); -#endif + //TODO return 0; } diff --git a/openair3/NGAP/ngap_gNB_overload.c b/openair3/NGAP/ngap_gNB_overload.c index 669478bccb..318a2124bd 100644 --- a/openair3/NGAP/ngap_gNB_overload.c +++ b/openair3/NGAP/ngap_gNB_overload.c @@ -49,38 +49,7 @@ int ngap_gNB_handle_overload_start(uint32_t assoc_id, uint32_t stream, NGAP_NGAP_PDU_t *pdu) { -#if 0 - ngap_gNB_amf_data_t *amf_desc_p; - NGAP_OverloadStart_t *container; - NGAP_OverloadStartIEs_t *ie; - - DevAssert(pdu != NULL); - - container = &pdu->choice.initiatingMessage.value.choice.OverloadStart; - - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_OverloadStartIEs_t, ie, container, - NGAP_ProtocolIE_ID_id_OverloadResponse, true); - if (ie != NULL) { - DevCheck(ie->value.choice.OverloadResponse.present == - NGAP_OverloadResponse_PR_overloadAction, - NGAP_OverloadResponse_PR_overloadAction, 0, 0); - } - /* Non UE-associated signalling -> stream 0 */ - DevCheck(stream == 0, stream, 0, 0); - - if ((amf_desc_p = ngap_gNB_get_AMF(NULL, assoc_id, 0)) == NULL) { - /* No AMF context associated */ - return -1; - } - - /* Mark the AMF as overloaded and set the overload state according to - * the value received. - */ - amf_desc_p->state = NGAP_GNB_OVERLOAD; - amf_desc_p->overload_state = - ie->value.choice.OverloadResponse.choice.overloadAction; - -#endif + //TODO return 0; } diff --git a/openair3/NGAP/ngap_gNB_trace.c b/openair3/NGAP/ngap_gNB_trace.c index b070c5d050..f3e216988c 100644 --- a/openair3/NGAP/ngap_gNB_trace.c +++ b/openair3/NGAP/ngap_gNB_trace.c @@ -50,38 +50,7 @@ int ngap_gNB_handle_trace_start(uint32_t assoc_id, uint32_t stream, NGAP_NGAP_PDU_t *pdu) { -#if 0 - NGAP_TraceStart_t *container; - NGAP_TraceStartIEs_t *ie; - struct ngap_gNB_ue_context_s *ue_desc_p = NULL; - struct ngap_gNB_amf_data_s *amf_ref_p; - - DevAssert(pdu != NULL); - - container = &pdu->choice.initiatingMessage.value.choice.TraceStart; - - NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_TraceStartIEs_t, ie, container, - NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID, TRUE); - amf_ref_p = ngap_gNB_get_AMF(NULL, assoc_id, 0); - DevAssert(amf_ref_p != NULL); - if (ie != NULL) { - ue_desc_p = ngap_gNB_get_ue_context(amf_ref_p->ngap_gNB_instance, - ie->value.choice.GNB_UE_NGAP_ID); - } - if (ue_desc_p == NULL) { - /* Could not find context associated with this gNB_ue_ngap_id -> generate - * trace failure indication. - */ - NGAP_E_UTRAN_Trace_ID_t trace_id; - NGAP_Cause_t cause; - memset(&trace_id, 0, sizeof(NGAP_E_UTRAN_Trace_ID_t)); - memset(&cause, 0, sizeof(NGAP_Cause_t)); - cause.present = NGAP_Cause_PR_radioNetwork; - cause.choice.radioNetwork = NGAP_CauseRadioNetwork_unknown_pair_ue_ngap_id; - ngap_gNB_generate_trace_failure(NULL, &trace_id, &cause); - } - -#endif + //TODO return 0; } diff --git a/targets/COMMON/create_nr_tasks.c b/targets/COMMON/create_nr_tasks.c index 13f72b3876..94fc6140f6 100644 --- a/targets/COMMON/create_nr_tasks.c +++ b/targets/COMMON/create_nr_tasks.c @@ -26,7 +26,7 @@ # ifdef OPENAIR2 #include "sctp_eNB_task.h" -#include "s1ap_eNB.h" +#include "ngap_gNB.h" #include "nas_ue_task.h" #include "udp_eNB_task.h" #include "gtpv1u_eNB_task.h" @@ -59,7 +59,7 @@ int create_gNB_tasks(uint32_t gnb_nb) } - if (EPC_MODE_ENABLED) { + if (AMF_MODE_ENABLED) { if (gnb_nb > 0) { /*if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) { LOG_E(SCTP, "Create task for SCTP failed\n");