diff --git a/CMakeLists.txt b/CMakeLists.txt index d0b9f17a02..0f2e8931a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1308,6 +1308,8 @@ set (GNB_APP_SRC ${OPENAIR2_DIR}/GNB_APP/gnb_app.c ${OPENAIR2_DIR}/E1AP/e1ap_setup.c ${OPENAIR2_DIR}/GNB_APP/gnb_config.c + ${OPENAIR2_DIR}/GNB_APP/gnb_config_common.c + ${OPENAIR2_DIR}/GNB_APP/gnb_config_ng.c ) set (MCE_APP_SRC diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index 98546413a0..9597f61430 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -53,6 +53,7 @@ #include "openair2/E1AP/e1ap.h" #include "gnb_config.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "openair2/GNB_APP/gnb_config_ng.h" extern RAN_CONTEXT_t RC; /*------------------------------------------------------------------------------*/ diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 667ab25093..d6d370fe70 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -79,7 +79,7 @@ #include "uper_encoder.h" #include "utils.h" #include "x2ap_messages_types.h" - +#include "gnb_config_common.h" static int DEFBANDS[] = {7}; static int DEFENBS[] = {0}; @@ -96,45 +96,6 @@ static int DEFRUTPCORES[] = {-1,-1,-1,-1}; (element)->choice.setup = CALLOC(1, sizeof(*((element)->choice.setup))); \ } while (0) -static uint16_t set_snssai_config(nssai_t *nssai, const int max_num_ssi, uint8_t k, uint8_t l) -{ - char snssaistr[MAX_OPTNAME_SIZE * 2 + 8]; - snprintf(snssaistr, sizeof(snssaistr), "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, k, GNB_CONFIG_STRING_PLMN_LIST, l); - GET_PARAMS_LIST(SNSSAIParamList, - SNSSAIParams, - GNBSNSSAIPARAMS_DESC, - GNB_CONFIG_STRING_SNSSAI_LIST, - snssaistr, - SNSSAIPARAMS_CHECK); - uint16_t num_ssi = SNSSAIParamList.numelt; - AssertFatal(num_ssi < max_num_ssi, "S-NSSAI size %d exceeds the max array size %d", num_ssi, max_num_ssi); - for (int s = 0; s < num_ssi; ++s) { - nssai[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 - nssai[s].sd = *SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr; - AssertFatal(nssai[s].sd <= 0xffffff, "SD cannot be bigger than 0xffffff, but is %d\n", nssai[s].sd); - } - return num_ssi; -} - -static uint8_t set_plmn_config(plmn_id_t *p, uint8_t idx) -{ - char gnbpath[MAX_OPTNAME_SIZE * 2 + 8]; - snprintf(gnbpath, sizeof(gnbpath), "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, idx); - GET_PARAMS_LIST(PLMNParamList, PLMNParams, GNBPLMNPARAMS_DESC, GNB_CONFIG_STRING_PLMN_LIST, gnbpath, PLMNPARAMS_CHECK); - uint8_t num_plmn = PLMNParamList.numelt; - AssertFatal(num_plmn >= 1 && num_plmn <= 6, "The number of PLMN IDs must be in [1,6], but is %d\n", num_plmn); - for (int l = 0; l < num_plmn; ++l) { - plmn_id_t *plmn = &p[l]; - plmn->mcc = *PLMNParamList.paramarray[l][GNB_MOBILE_COUNTRY_CODE_IDX].uptr; - plmn->mnc = *PLMNParamList.paramarray[l][GNB_MOBILE_NETWORK_CODE_IDX].uptr; - plmn->mnc_digit_length = *PLMNParamList.paramarray[l][GNB_MNC_DIGIT_LENGTH].u8ptr; - AssertFatal((plmn->mnc_digit_length == 2) || (plmn->mnc_digit_length == 3), "BAD MNC DIGIT LENGTH %d", plmn->mnc_digit_length); - } - return num_plmn; -} - /** * Allocate memory and initialize ServingCellConfigCommon struct members */ @@ -2131,130 +2092,6 @@ gNB_RRC_INST *RCconfig_NRRRC() return rrc; } -int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) -{ - int j,k = 0; - int gnb_id; - - char* gnb_ipv4_address_for_NGU = NULL; - uint32_t gnb_port_for_NGU = 0; - char* gnb_ipv4_address_for_S1U = NULL; - uint32_t gnb_port_for_S1U = 0; - - GET_PARAMS(GNBSParams, GNBSPARAMS_DESC, NULL); - AssertFatal (i0) { - // Output a list of all gNBs. - GET_PARAMS_LIST(GNBParamList, GNBParams, GNBPARAMS_DESC, GNB_CONFIG_STRING_GNB_LIST, NULL); - if (GNBParamList.numelt > 0) { - for (k = 0; k < GNBParamList.numelt; k++) { - if (GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr == NULL) { - // Calculate a default gNB ID - if (IS_SA_MODE(get_softmodem_params())) { - uint32_t hash; - - hash = ngap_generate_gNB_id (); - gnb_id = k + (hash & 0xFFFFFF8); - } else { - gnb_id = k; - } - } else { - gnb_id = *(GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr); - } - - - // search if in active list - for (j=0; j < GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; j++) { - if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[j], *(GNBParamList.paramarray[k][GNB_GNB_NAME_IDX].strptr)) == 0) { - - char aprefix[MAX_OPTNAME_SIZE*2 + 8]; - NGAP_REGISTER_GNB_REQ (msg_p).gNB_id = gnb_id; - - if (strcmp(*(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr), "CELL_MACRO_GNB") == 0) { - NGAP_REGISTER_GNB_REQ (msg_p).cell_type = CELL_MACRO_GNB; - } else if (strcmp(*(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr), "CELL_HOME_GNB") == 0) { - NGAP_REGISTER_GNB_REQ (msg_p).cell_type = CELL_HOME_ENB; - } else { - AssertFatal (0, - "Failed to parse gNB configuration file %s, gnb %u unknown value \"%s\" for cell_type choice: CELL_MACRO_GNB or CELL_HOME_GNB !\n", - RC.config_file_name, i, *(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr)); - } - - NGAP_REGISTER_GNB_REQ (msg_p).gNB_name = strdup(*(GNBParamList.paramarray[k][GNB_GNB_NAME_IDX].strptr)); - NGAP_REGISTER_GNB_REQ (msg_p).tac = *GNBParamList.paramarray[k][GNB_TRACKING_AREA_CODE_IDX].uptr; - AssertFatal(!GNBParamList.paramarray[k][GNB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr - && !GNBParamList.paramarray[k][GNB_MOBILE_NETWORK_CODE_IDX_OLD].strptr, - "It seems that you use an old configuration file. Please change the existing\n" - " tracking_area_code = \"1\";\n" - " mobile_country_code = \"208\";\n" - " mobile_network_code = \"93\";\n" - "to\n" - " tracking_area_code = 1; // no string!!\n" - " plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n"); - // PLMN - plmn_id_t p[PLMN_LIST_MAX_SIZE] = {0}; - NGAP_REGISTER_GNB_REQ(msg_p).num_plmn = set_plmn_config(p, 0); - for (int l = 0; l < NGAP_REGISTER_GNB_REQ(msg_p).num_plmn; ++l) { - NGAP_REGISTER_GNB_REQ(msg_p).plmn[l].plmn = p[l]; - // SNSSAI - NGAP_REGISTER_GNB_REQ(msg_p).plmn[l].num_nssai = set_snssai_config(NGAP_REGISTER_GNB_REQ(msg_p).plmn[l].s_nssai, 8, k, l); - } - NGAP_REGISTER_GNB_REQ(msg_p).default_drx = 0; - // NG - snprintf(aprefix, sizeof(aprefix), "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, k); - GET_PARAMS_LIST(NGParamList, NGParams, GNBNGPARAMS_DESC, GNB_CONFIG_STRING_AMF_IP_ADDRESS, aprefix); - NGAP_REGISTER_GNB_REQ (msg_p).nb_amf = 0; - - for (int l = 0; l < NGParamList.numelt; l++) { - NGAP_REGISTER_GNB_REQ (msg_p).nb_amf += 1; - strcpy(NGAP_REGISTER_GNB_REQ (msg_p).amf_ip_address[l].ipv4_address,*(NGParamList.paramarray[l][GNB_AMF_IPV4_ADDRESS_IDX].strptr)); - NGAP_REGISTER_GNB_REQ (msg_p).amf_ip_address[j].ipv4 = 1; - NGAP_REGISTER_GNB_REQ (msg_p).amf_ip_address[j].ipv6 = 0; - /* if no broadcasst_plmn array is defined, fill default values */ - if (NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_num[l] == 0) { - NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_num[l] = NGAP_REGISTER_GNB_REQ(msg_p).num_plmn; - for (int el = 0; el < NGAP_REGISTER_GNB_REQ(msg_p).num_plmn; ++el) - NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_index[l][el] = el; - } - } - - // SCTP SETTING - NGAP_REGISTER_GNB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; - NGAP_REGISTER_GNB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; - if (IS_SA_MODE(get_softmodem_params())) { - snprintf(aprefix, sizeof(aprefix), "%s.[%d].%s", GNB_CONFIG_STRING_GNB_LIST, k, GNB_CONFIG_STRING_SCTP_CONFIG); - GET_PARAMS(SCTPParams, GNBSCTPPARAMS_DESC, aprefix); - NGAP_REGISTER_GNB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); - NGAP_REGISTER_GNB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[GNB_SCTP_OUTSTREAMS_IDX].uptr); - } - - // NETWORK_INTERFACES - snprintf(aprefix, sizeof(aprefix), "%s.[%d].%s", GNB_CONFIG_STRING_GNB_LIST, k, GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); - GET_PARAMS(NETParams, GNBNETPARAMS_DESC, aprefix); - if (NETParams[GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX].strptr != NULL) { - char *cidr = *(NETParams[GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX].strptr); - char *save = NULL; - char *address = strtok_r(cidr, "/", &save); - strcpy(NGAP_REGISTER_GNB_REQ (msg_p).gnb_ip_address.ipv4_address, address); - LOG_I(GNB_APP, "Parsed IPv4 address for NG AMF: %s\n", address); - } - - NGAP_REGISTER_GNB_REQ (msg_p).gnb_ip_address.ipv6 = 0; - NGAP_REGISTER_GNB_REQ (msg_p).gnb_ip_address.ipv4 = 1; - - break; - } - } - } - } - } - return 0; -} - static pthread_mutex_t rc_mutex = PTHREAD_MUTEX_INITIALIZER; static bool rc_done = false; diff --git a/openair2/GNB_APP/gnb_config.h b/openair2/GNB_APP/gnb_config.h index c33c6964dc..1f48358e67 100644 --- a/openair2/GNB_APP/gnb_config.h +++ b/openair2/GNB_APP/gnb_config.h @@ -44,7 +44,6 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg); void NRRCConfig(void); gNB_RRC_INST *RCconfig_NRRRC(); -int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i); int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i); void wait_f1_setup_response(void); f1ap_tdd_info_t read_tdd_config(const NR_ServingCellConfigCommon_t *scc); diff --git a/openair2/GNB_APP/gnb_config_common.c b/openair2/GNB_APP/gnb_config_common.c new file mode 100644 index 0000000000..ac5e840851 --- /dev/null +++ b/openair2/GNB_APP/gnb_config_common.c @@ -0,0 +1,66 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "openair2/GNB_APP/gnb_config_common.h" +#include "common/config/config_paramdesc.h" +#include "common/config/config_userapi.h" +#include "RRC_nr_paramsvalues.h" +#include "gnb_paramdef.h" +#include "sctp_default_values.h" + +uint16_t set_snssai_config(nssai_t *nssai, const int max_num_ssi, uint8_t k, uint8_t l) +{ + char snssaistr[MAX_OPTNAME_SIZE * 2 + 8]; + snprintf(snssaistr, sizeof(snssaistr), "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, k, GNB_CONFIG_STRING_PLMN_LIST, l); + GET_PARAMS_LIST(SNSSAIParamList, + SNSSAIParams, + GNBSNSSAIPARAMS_DESC, + GNB_CONFIG_STRING_SNSSAI_LIST, + snssaistr, + SNSSAIPARAMS_CHECK); + uint16_t num_ssi = SNSSAIParamList.numelt; + AssertFatal(num_ssi < max_num_ssi, "S-NSSAI size %d exceeds the max array size %d", num_ssi, max_num_ssi); + for (int s = 0; s < num_ssi; ++s) { + nssai[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 + nssai[s].sd = *SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr; + AssertFatal(nssai[s].sd <= 0xffffff, "SD cannot be bigger than 0xffffff, but is %d\n", nssai[s].sd); + } + return num_ssi; +} + +uint8_t set_plmn_config(plmn_id_t *p, uint8_t idx) +{ + char gnbpath[MAX_OPTNAME_SIZE * 2 + 8]; + snprintf(gnbpath, sizeof(gnbpath), "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, idx); + GET_PARAMS_LIST(PLMNParamList, PLMNParams, GNBPLMNPARAMS_DESC, GNB_CONFIG_STRING_PLMN_LIST, gnbpath, PLMNPARAMS_CHECK); + uint8_t num_plmn = PLMNParamList.numelt; + AssertFatal(num_plmn >= 1 && num_plmn <= 6, "The number of PLMN IDs must be in [1,6], but is %d\n", num_plmn); + for (int l = 0; l < num_plmn; ++l) { + plmn_id_t *plmn = &p[l]; + plmn->mcc = *PLMNParamList.paramarray[l][GNB_MOBILE_COUNTRY_CODE_IDX].uptr; + plmn->mnc = *PLMNParamList.paramarray[l][GNB_MOBILE_NETWORK_CODE_IDX].uptr; + plmn->mnc_digit_length = *PLMNParamList.paramarray[l][GNB_MNC_DIGIT_LENGTH].u8ptr; + AssertFatal((plmn->mnc_digit_length == 2) || (plmn->mnc_digit_length == 3), "BAD MNC DIGIT LENGTH %d", plmn->mnc_digit_length); + } + return num_plmn; +} diff --git a/openair2/GNB_APP/gnb_config_common.h b/openair2/GNB_APP/gnb_config_common.h new file mode 100644 index 0000000000..8317709a78 --- /dev/null +++ b/openair2/GNB_APP/gnb_config_common.h @@ -0,0 +1,26 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include +#include "common/5g_platform_types.h" + +uint16_t set_snssai_config(nssai_t *nssai, const int max_num_ssi, uint8_t k, uint8_t l); +uint8_t set_plmn_config(plmn_id_t *p, uint8_t idx); diff --git a/openair2/GNB_APP/gnb_config_ng.c b/openair2/GNB_APP/gnb_config_ng.c new file mode 100644 index 0000000000..632c670def --- /dev/null +++ b/openair2/GNB_APP/gnb_config_ng.c @@ -0,0 +1,162 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "gnb_config_ng.h" +#include +#include "assertions.h" +#include "common/ran_context.h" +#include "openair2/GNB_APP/gnb_config_common.h" +#include "common/config/config_paramdesc.h" +#include "sctp_default_values.h" +#include "gnb_paramdef.h" + +int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) +{ + int j, k = 0; + int gnb_id; + + char *gnb_ipv4_address_for_NGU = NULL; + uint32_t gnb_port_for_NGU = 0; + char *gnb_ipv4_address_for_S1U = NULL; + uint32_t gnb_port_for_S1U = 0; + + GET_PARAMS(GNBSParams, GNBSPARAMS_DESC, NULL); + AssertFatal(i < GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt, + "Failed to parse config file %s, %uth attribute %s \n", + RC.config_file_name, + i, + GNB_CONFIG_STRING_ACTIVE_GNBS); + + if (GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt > 0) { + // Output a list of all gNBs. + GET_PARAMS_LIST(GNBParamList, GNBParams, GNBPARAMS_DESC, GNB_CONFIG_STRING_GNB_LIST, NULL); + if (GNBParamList.numelt > 0) { + for (k = 0; k < GNBParamList.numelt; k++) { + if (GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr == NULL) { + // Calculate a default gNB ID + if (IS_SA_MODE(get_softmodem_params())) { + uint32_t hash; + + hash = ngap_generate_gNB_id(); + gnb_id = k + (hash & 0xFFFFFF8); + } else { + gnb_id = k; + } + } else { + gnb_id = *(GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr); + } + + // search if in active list + for (j = 0; j < GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; j++) { + if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[j], *(GNBParamList.paramarray[k][GNB_GNB_NAME_IDX].strptr)) == 0) { + char aprefix[MAX_OPTNAME_SIZE * 2 + 8]; + NGAP_REGISTER_GNB_REQ(msg_p).gNB_id = gnb_id; + + if (strcmp(*(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr), "CELL_MACRO_GNB") == 0) { + NGAP_REGISTER_GNB_REQ(msg_p).cell_type = CELL_MACRO_GNB; + } else if (strcmp(*(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr), "CELL_HOME_GNB") == 0) { + NGAP_REGISTER_GNB_REQ(msg_p).cell_type = CELL_HOME_ENB; + } else { + AssertFatal(0, + "Failed to parse gNB configuration file %s, gnb %u unknown value \"%s\" for cell_type choice: " + "CELL_MACRO_GNB or CELL_HOME_GNB !\n", + RC.config_file_name, + i, + *(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr)); + } + + NGAP_REGISTER_GNB_REQ(msg_p).gNB_name = strdup(*(GNBParamList.paramarray[k][GNB_GNB_NAME_IDX].strptr)); + NGAP_REGISTER_GNB_REQ(msg_p).tac = *GNBParamList.paramarray[k][GNB_TRACKING_AREA_CODE_IDX].uptr; + AssertFatal(!GNBParamList.paramarray[k][GNB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr + && !GNBParamList.paramarray[k][GNB_MOBILE_NETWORK_CODE_IDX_OLD].strptr, + "It seems that you use an old configuration file. Please change the existing\n" + " tracking_area_code = \"1\";\n" + " mobile_country_code = \"208\";\n" + " mobile_network_code = \"93\";\n" + "to\n" + " tracking_area_code = 1; // no string!!\n" + " plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n"); + // PLMN + plmn_id_t p[PLMN_LIST_MAX_SIZE] = {0}; + NGAP_REGISTER_GNB_REQ(msg_p).num_plmn = set_plmn_config(p, 0); + for (int l = 0; l < NGAP_REGISTER_GNB_REQ(msg_p).num_plmn; ++l) { + NGAP_REGISTER_GNB_REQ(msg_p).plmn[l].plmn = p[l]; + // SNSSAI + NGAP_REGISTER_GNB_REQ(msg_p).plmn[l].num_nssai = + set_snssai_config(NGAP_REGISTER_GNB_REQ(msg_p).plmn[l].s_nssai, 8, k, l); + } + NGAP_REGISTER_GNB_REQ(msg_p).default_drx = 0; + // NG + snprintf(aprefix, sizeof(aprefix), "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, k); + GET_PARAMS_LIST(NGParamList, NGParams, GNBNGPARAMS_DESC, GNB_CONFIG_STRING_AMF_IP_ADDRESS, aprefix); + NGAP_REGISTER_GNB_REQ(msg_p).nb_amf = 0; + + for (int l = 0; l < NGParamList.numelt; l++) { + NGAP_REGISTER_GNB_REQ(msg_p).nb_amf += 1; + strcpy(NGAP_REGISTER_GNB_REQ(msg_p).amf_ip_address[l].ipv4_address, + *(NGParamList.paramarray[l][GNB_AMF_IPV4_ADDRESS_IDX].strptr)); + NGAP_REGISTER_GNB_REQ(msg_p).amf_ip_address[l].ipv4 = 1; + NGAP_REGISTER_GNB_REQ(msg_p).amf_ip_address[l].ipv6 = 0; + /* if no broadcasst_plmn array is defined, fill default values */ + if (NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_num[l] == 0) { + NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_num[l] = NGAP_REGISTER_GNB_REQ(msg_p).num_plmn; + for (int el = 0; el < NGAP_REGISTER_GNB_REQ(msg_p).num_plmn; ++el) + NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_index[l][el] = el; + } + } + + // SCTP SETTING + NGAP_REGISTER_GNB_REQ(msg_p).sctp_out_streams = SCTP_OUT_STREAMS; + NGAP_REGISTER_GNB_REQ(msg_p).sctp_in_streams = SCTP_IN_STREAMS; + if (IS_SA_MODE(get_softmodem_params())) { + snprintf(aprefix, sizeof(aprefix), "%s.[%d].%s", GNB_CONFIG_STRING_GNB_LIST, k, GNB_CONFIG_STRING_SCTP_CONFIG); + GET_PARAMS(SCTPParams, GNBSCTPPARAMS_DESC, aprefix); + NGAP_REGISTER_GNB_REQ(msg_p).sctp_in_streams = (uint16_t) * (SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); + NGAP_REGISTER_GNB_REQ(msg_p).sctp_out_streams = (uint16_t) * (SCTPParams[GNB_SCTP_OUTSTREAMS_IDX].uptr); + } + + // NETWORK_INTERFACES + snprintf(aprefix, + sizeof(aprefix), + "%s.[%d].%s", + GNB_CONFIG_STRING_GNB_LIST, + k, + GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); + GET_PARAMS(NETParams, GNBNETPARAMS_DESC, aprefix); + if (NETParams[GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX].strptr != NULL) { + char *cidr = *(NETParams[GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX].strptr); + char *save = NULL; + char *address = strtok_r(cidr, "/", &save); + strcpy(NGAP_REGISTER_GNB_REQ(msg_p).gnb_ip_address.ipv4_address, address); + LOG_I(GNB_APP, "Parsed IPv4 address for NG AMF: %s\n", address); + } + + NGAP_REGISTER_GNB_REQ(msg_p).gnb_ip_address.ipv6 = 0; + NGAP_REGISTER_GNB_REQ(msg_p).gnb_ip_address.ipv4 = 1; + + break; + } + } + } + } + } + return 0; +} diff --git a/openair2/GNB_APP/gnb_config_ng.h b/openair2/GNB_APP/gnb_config_ng.h new file mode 100644 index 0000000000..792f55e940 --- /dev/null +++ b/openair2/GNB_APP/gnb_config_ng.h @@ -0,0 +1,29 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef NGAP_GNB_CONFIG_H_ +#define NGAP_GNB_CONFIG_H_ +#include +#include "intertask_interface.h" + +int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i); + +#endif /* NGAP_GNB_CONFIG_H_ */