From ff688f163bfd73c3987991bf026449c8803afc7c Mon Sep 17 00:00:00 2001 From: Robert Schmidt <robert.schmidt@eurecom.fr> Date: Wed, 4 Jul 2018 15:20:16 +0200 Subject: [PATCH] NNSF my MME code: respect selected PLMN ID --- openair3/S1AP/s1ap_eNB_nas_procedures.c | 1 + openair3/S1AP/s1ap_eNB_nnsf.c | 36 ++++++++++++++----------- openair3/S1AP/s1ap_eNB_nnsf.h | 1 + 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c index c87f1106e0..91d3da4745 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c @@ -89,6 +89,7 @@ int s1ap_eNB_handle_nas_first_req( mme_desc_p = s1ap_eNB_nnsf_select_mme_by_mme_code( instance_p, s1ap_nas_first_req_p->establishment_cause, + s1ap_nas_first_req_p->selected_plmn_identity, s1ap_nas_first_req_p->ue_identity.s_tmsi.mme_code); } } diff --git a/openair3/S1AP/s1ap_eNB_nnsf.c b/openair3/S1AP/s1ap_eNB_nnsf.c index 8b7d65cb01..a3fa634db1 100644 --- a/openair3/S1AP/s1ap_eNB_nnsf.c +++ b/openair3/S1AP/s1ap_eNB_nnsf.c @@ -92,11 +92,10 @@ s1ap_eNB_nnsf_select_mme(s1ap_eNB_instance_t *instance_p, struct s1ap_eNB_mme_data_s * s1ap_eNB_nnsf_select_mme_by_mme_code(s1ap_eNB_instance_t *instance_p, rrc_establishment_cause_t cause, + int selected_plmn_identity, uint8_t mme_code) { struct s1ap_eNB_mme_data_s *mme_data_p = NULL; - struct s1ap_eNB_mme_data_s *mme_highest_capacity_p = NULL; - uint8_t current_capacity = 0; RB_FOREACH(mme_data_p, s1ap_mme_map, &instance_p->s1ap_mme_head) { struct served_gummei_s *gummei_p = NULL; @@ -135,30 +134,37 @@ s1ap_eNB_nnsf_select_mme_by_mme_code(s1ap_eNB_instance_t *instance_p, } } - if (current_capacity < mme_data_p->relative_mme_capacity) { - /* We find a better MME, keep a reference to it */ - current_capacity = mme_data_p->relative_mme_capacity; - mme_highest_capacity_p = mme_data_p; - } - /* Looking for MME code matching the one provided by NAS */ STAILQ_FOREACH(gummei_p, &mme_data_p->served_gummei, next) { struct mme_code_s *mme_code_p = NULL; + struct plmn_identity_s *served_plmn_p = NULL; + STAILQ_FOREACH(served_plmn_p, &gummei_p->served_plmns, next) { + if ((served_plmn_p->mcc == instance_p->mcc[selected_plmn_identity]) && + (served_plmn_p->mnc == instance_p->mnc[selected_plmn_identity])) { + break; + } + } STAILQ_FOREACH(mme_code_p, &gummei_p->mme_codes, next) { if (mme_code_p->mme_code == mme_code) { - return mme_data_p; + break; } } + + /* The MME matches the parameters provided by the NAS layer -> + * the MME is knwown and the association is ready. + * Return the reference to the MME to use it for this UE. + */ + if (mme_code_p && served_plmn_p) { + return mme_data_p; + } } } - /* At this point no MME matches the provided GUMMEI. Select the one with the - * highest relative capacity. - * In case the list of known MME is empty, simply return NULL, that way the RRC - * layer should know about it and reject RRC connectivity. - */ - return mme_highest_capacity_p; + /* At this point no MME matches the selected PLMN and MME code. In this case, + * return NULL. That way the RRC layer should know about it and reject RRC + * connectivity. */ + return NULL; } struct s1ap_eNB_mme_data_s * diff --git a/openair3/S1AP/s1ap_eNB_nnsf.h b/openair3/S1AP/s1ap_eNB_nnsf.h index 78405f34d1..5a3d44416f 100644 --- a/openair3/S1AP/s1ap_eNB_nnsf.h +++ b/openair3/S1AP/s1ap_eNB_nnsf.h @@ -29,6 +29,7 @@ s1ap_eNB_nnsf_select_mme(s1ap_eNB_instance_t *instance_p, struct s1ap_eNB_mme_data_s* s1ap_eNB_nnsf_select_mme_by_mme_code(s1ap_eNB_instance_t *instance_p, rrc_establishment_cause_t cause, + int selected_plmn_identity, uint8_t mme_code); struct s1ap_eNB_mme_data_s* -- GitLab