diff --git a/openair2/COMMON/e1ap_messages_types.h b/openair2/COMMON/e1ap_messages_types.h index f98058b85c..c50efd337f 100644 --- a/openair2/COMMON/e1ap_messages_types.h +++ b/openair2/COMMON/e1ap_messages_types.h @@ -59,10 +59,7 @@ typedef struct PLMN_ID_s { int mnc_digit_length; } PLMN_ID_t; -typedef struct e1ap_nssai_t { - uint8_t sst; - uint32_t sd; // optional: "No SD" is 0xffffff, see 23.003 Sec 28.4.2 -} e1ap_nssai_t; +typedef nssai_t e1ap_nssai_t; typedef struct e1ap_net_config_t { net_ip_address_t CUUP_e1_ip_address; diff --git a/openair2/COMMON/ngap_messages_types.h b/openair2/COMMON/ngap_messages_types.h index a03a9d88b6..24eebbd3aa 100644 --- a/openair2/COMMON/ngap_messages_types.h +++ b/openair2/COMMON/ngap_messages_types.h @@ -194,6 +194,11 @@ typedef enum ngap_rrc_establishment_cause_e { NGAP_RRC_CAUSE_LAST } ngap_rrc_establishment_cause_t; +typedef struct nssai_s { + uint8_t sst; + uint32_t sd; +} nssai_t; + typedef struct pdusession_level_qos_parameter_s { uint8_t qfi; uint64_t fiveQI; @@ -210,12 +215,6 @@ typedef struct ngap_guami_s { uint8_t amf_pointer; } ngap_guami_t; -typedef struct ngap_allowed_NSSAI_s{ - uint8_t sST; - uint8_t sD_flag; - uint8_t sD[3]; -}ngap_allowed_NSSAI_t; - typedef struct fiveg_s_tmsi_s { uint16_t amf_set_id; uint8_t amf_pointer; @@ -282,6 +281,7 @@ typedef struct pdusession_s { transport_layer_addr_t gNB_addr_N3; uint32_t UPF_teid_N3; transport_layer_addr_t UPF_addr_N3; + nssai_t nssai; } pdusession_t; typedef enum pdusession_qosflow_mapping_ind_e{ @@ -452,8 +452,8 @@ typedef struct ngap_register_gnb_req_s { uint8_t mnc_digit_length[PLMN_LIST_MAX_SIZE]; uint8_t num_plmn; - uint16_t num_nssai[PLMN_LIST_MAX_SIZE]; - ngap_allowed_NSSAI_t s_nssai[PLMN_LIST_MAX_SIZE][8]; + uint16_t num_nssai[PLMN_LIST_MAX_SIZE]; + nssai_t s_nssai[PLMN_LIST_MAX_SIZE][8]; /* Default Paging DRX of the gNB as defined in TS 38.304 */ ngap_paging_drx_t default_drx; @@ -601,7 +601,7 @@ typedef struct ngap_initial_context_setup_req_s { /* allowed nssai */ uint8_t nb_allowed_nssais; - ngap_allowed_NSSAI_t allowed_nssai[8]; + nssai_t allowed_nssai[8]; /* Security algorithms */ ngap_security_capabilities_t security_capabilities; @@ -662,7 +662,7 @@ typedef struct ngap_pdusession_setup_req_s { /* S-NSSAI */ // Fixme: illogical, nssai is part of each pdu session - ngap_allowed_NSSAI_t allowed_nssai[8]; + nssai_t allowed_nssai[8]; /* Number of pdusession to be setup in the list */ uint8_t nb_pdusessions_tosetup; diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 2368e5ab6b..79ba5f9163 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1761,16 +1761,11 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { NGAP_REGISTER_GNB_REQ (msg_p).num_nssai[l] = SNSSAIParamList.numelt; for (int s = 0; s < SNSSAIParamList.numelt; ++s) { - - NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sST = *SNSSAIParamList.paramarray[s][GNB_SLICE_SERVICE_TYPE_IDX].uptr; - NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD_flag = 0; - if(SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr != 0 // SD is optional - && *SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr != 0xffffff) { // 0xffffff is "no SD", see 23.003 Sec 28.4.2 - NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD_flag = 1; - NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD[0] = (*SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr & 0xFF0000) >> 16; - NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD[1] = (*SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr & 0x00FF00) >> 8; - NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD[2] = (*SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr & 0x0000FF); - } + NGAP_REGISTER_GNB_REQ(msg_p).s_nssai[l][s].sst = *SNSSAIParamList.paramarray[s][GNB_SLICE_SERVICE_TYPE_IDX].uptr; + // SD is optional + // 0xffffff is "no SD", see 23.003 Sec 28.4.2 + NGAP_REGISTER_GNB_REQ(msg_p).s_nssai[l][s].sd = + (*SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr & 0xffffff); } } sprintf(aprefix,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k); diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 49d3ccad99..d60586e2c9 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -766,11 +766,12 @@ void rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(MessageDef *msg_p, instance_t ins for (int i = 0; i < msg->nb_pdusessions_tosetup; i++) { rrc_pdu_session_param_t *pduSession = find_pduSession(UE, msg->pdusession_setup_params[i].pdusession_id, true); pdusession_t *session = &pduSession->param; - LOG_I(NR_RRC, "Adding pdusession %d, total nb of sessions %d\n", session->pdusession_id, UE->nb_of_pdusessions); session->pdusession_id = msg->pdusession_setup_params[i].pdusession_id; + LOG_I(NR_RRC, "Adding pdusession %d, total nb of sessions %d\n", session->pdusession_id, UE->nb_of_pdusessions); session->pdu_session_type = msg->pdusession_setup_params[i].pdu_session_type; session->nas_pdu = msg->pdusession_setup_params[i].nas_pdu; session->pdusessionTransfer = msg->pdusession_setup_params[i].pdusessionTransfer; + session->nssai = msg->pdusession_setup_params[i].nssai; decodePDUSessionResourceSetup(session); bearer_req.gNB_cu_cp_ue_id = msg->gNB_ue_ngap_id; bearer_req.cipheringAlgorithm = UE->ciphering_algorithm; @@ -781,11 +782,9 @@ void rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(MessageDef *msg_p, instance_t ins pdu_session_to_setup_t *pdu = bearer_req.pduSession + bearer_req.numPDUSessions; bearer_req.numPDUSessions++; pdu->sessionId = session->pdusession_id; - ngap_allowed_NSSAI_t *nssai = &msg->allowed_nssai[i]; - pdu->nssai.sst = nssai->sST; - pdu->nssai.sd = 0xffffff; - if (nssai->sD_flag) - pdu->nssai.sd = nssai->sD[0] << 16 | nssai->sD[1] << 8 | nssai->sD[2]; + nssai_t *nssai = &msg->allowed_nssai[i]; + pdu->nssai.sst = nssai->sst; + pdu->nssai.sd = nssai->sd; if (cuup_nssai.sst == 0) cuup_nssai = pdu->nssai; /* for CU-UP selection below */ pdu->integrityProtectionIndication = rrc->security.do_drb_integrity ? E1AP_IntegrityProtectionIndication_required : E1AP_IntegrityProtectionIndication_not_needed; diff --git a/openair3/NGAP/ngap_gNB.c b/openair3/NGAP/ngap_gNB.c index 09dc9321a1..be6fbc28bd 100644 --- a/openair3/NGAP/ngap_gNB.c +++ b/openair3/NGAP/ngap_gNB.c @@ -453,17 +453,17 @@ static int ngap_gNB_generate_ng_setup_request( for(int si = 0; si < instance_p->num_nssai[i]; si++) { ssi = (NGAP_SliceSupportItem_t *)calloc(1, sizeof(NGAP_SliceSupportItem_t)); - INT8_TO_OCTET_STRING(instance_p->s_nssai[i][si].sST, &ssi->s_NSSAI.sST); + INT8_TO_OCTET_STRING(instance_p->s_nssai[i][si].sst, &ssi->s_NSSAI.sST); - if (instance_p->s_nssai[i][si].sD_flag) { + const uint32_t sd = instance_p->s_nssai[i][si].sd; + if (sd != 0xffffff) { ssi->s_NSSAI.sD = calloc(1, sizeof(NGAP_SD_t)); ssi->s_NSSAI.sD->buf = calloc(3, sizeof(uint8_t)); ssi->s_NSSAI.sD->size = 3; - ssi->s_NSSAI.sD->buf[0] = instance_p->s_nssai[i][si].sD[0]; - ssi->s_NSSAI.sD->buf[1] = instance_p->s_nssai[i][si].sD[1]; - ssi->s_NSSAI.sD->buf[2] = instance_p->s_nssai[i][si].sD[2]; + ssi->s_NSSAI.sD->buf[0] = (sd & 0xff0000) >> 16; + ssi->s_NSSAI.sD->buf[1] = (sd & 0x00ff00) >> 8; + ssi->s_NSSAI.sD->buf[2] = (sd & 0x0000ff); } - asn1cSeqAdd(&plmn->tAISliceSupportList.list, ssi); } diff --git a/openair3/NGAP/ngap_gNB_defs.h b/openair3/NGAP/ngap_gNB_defs.h index c93d448723..4a6e0d7c5b 100644 --- a/openair3/NGAP/ngap_gNB_defs.h +++ b/openair3/NGAP/ngap_gNB_defs.h @@ -215,12 +215,6 @@ typedef struct ngap_gNB_amf_data_s { struct ngap_gNB_instance_s *ngap_gNB_instance; } ngap_gNB_amf_data_t; -typedef struct ngap_gNB_NSSAI_s{ - uint8_t sST; - uint8_t sD_flag; - uint8_t sD[3]; -}ngap_gNB_NSSAI_t; - typedef struct ngap_gNB_instance_s { /* Next ngap gNB association. * Only used for virtual mode. @@ -265,8 +259,8 @@ typedef struct ngap_gNB_instance_s { uint8_t num_plmn; uint16_t num_nssai[PLMN_LIST_MAX_SIZE]; - ngap_gNB_NSSAI_t s_nssai[PLMN_LIST_MAX_SIZE][8]; - + nssai_t s_nssai[PLMN_LIST_MAX_SIZE][8]; + /* Default Paging DRX of the gNB as defined in TS 38.304 */ ngap_paging_drx_t default_drx; } ngap_gNB_instance_t; diff --git a/openair3/NGAP/ngap_gNB_handlers.c b/openair3/NGAP/ngap_gNB_handlers.c index 1835b51cb6..0fb9fd0dbc 100644 --- a/openair3/NGAP/ngap_gNB_handlers.c +++ b/openair3/NGAP/ngap_gNB_handlers.c @@ -780,12 +780,13 @@ static int ngap_gNB_handle_initial_context_request(sctp_assoc_t assoc_id, uint32 for(i = 0; i < ie->value.choice.AllowedNSSAI.list.count; i++) { allow_nssai_item_p = ie->value.choice.AllowedNSSAI.list.array[i]; - - OCTET_STRING_TO_INT8(&allow_nssai_item_p->s_NSSAI.sST, msg->allowed_nssai[i].sST); + + OCTET_STRING_TO_INT8(&allow_nssai_item_p->s_NSSAI.sST, msg->allowed_nssai[i].sst); if(allow_nssai_item_p->s_NSSAI.sD != NULL) { - msg->allowed_nssai[i].sD_flag = 1; - memcpy(msg->allowed_nssai[i].sD, allow_nssai_item_p->s_NSSAI.sD, sizeof(msg->allowed_nssai[i].sD)); + memcpy(&msg->allowed_nssai[i].sd, allow_nssai_item_p->s_NSSAI.sD, 3); + } else { + msg->allowed_nssai[i].sd = 0xffffff; } } @@ -961,12 +962,14 @@ static int ngap_gNB_handle_pdusession_setup_request(sctp_assoc_t assoc_id, uint3 msg->pdusession_setup_params[i].pdusession_id = item_p->pDUSessionID; // S-NSSAI - OCTET_STRING_TO_INT8(&item_p->s_NSSAI.sST, msg->allowed_nssai[i].sST); + OCTET_STRING_TO_INT8(&item_p->s_NSSAI.sST, msg->pdusession_setup_params[i].nssai.sst); if (item_p->s_NSSAI.sD != NULL) { - msg->allowed_nssai[i].sD_flag = 1; - msg->allowed_nssai[i].sD[0] = item_p->s_NSSAI.sD->buf[0]; - msg->allowed_nssai[i].sD[1] = item_p->s_NSSAI.sD->buf[1]; - msg->allowed_nssai[i].sD[2] = item_p->s_NSSAI.sD->buf[2]; + uint8_t *sd_p = (uint8_t *)&msg->pdusession_setup_params[i].nssai.sd; + sd_p[0] = item_p->s_NSSAI.sD->buf[0]; + sd_p[1] = item_p->s_NSSAI.sD->buf[1]; + sd_p[2] = item_p->s_NSSAI.sD->buf[2]; + } else { + msg->pdusession_setup_params[i].nssai.sd = 0xffffff; } allocCopy(&msg->pdusession_setup_params[i].nas_pdu, *item_p->pDUSessionNAS_PDU);