Files
openairinterface5g/openair3/NAS/TOOLS/conf_user_plmn.c
T
Robert Schmidt 8107939f08 Change OAI license to CSSL v1.0 (and others)
- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
  scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly

For automated changes based on OAI PL v1.1:

    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
    perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml

The rest (cmake, files with missing license, cmake) manually.
2026-03-27 16:36:37 +01:00

86 lines
2.5 KiB
C

/*
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
*/
#include <stdlib.h>
#include <string.h>
#include "conf_user_plmn.h"
bool parse_user_plmns_conf(config_setting_t *ue_setting, int user_id,
user_plmns_t *user_plmns, const char **h,
const networks_t networks) {
int nb_errors = 0;
const char *hplmn;
if ( config_setting_lookup_string(ue_setting, HPLMN, h) != 1 ) {
printf("Check HPLMN section for UE%d. Exiting\n", user_id);
return false;
}
hplmn = *h;
if (get_plmn_index(hplmn, networks) == -1) {
printf("HPLMN for UE%d is not defined in PLMN section. Exiting\n",
user_id);
return false;
}
if ( parse_Xplmn(ue_setting, UCPLMN, user_id, &user_plmns->users_controlled, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, OPLMN, user_id, &user_plmns->operators, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, OCPLMN, user_id, &user_plmns->operators_controlled, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, FPLMN, user_id, &user_plmns->forbiddens, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, EHPLMN, user_id, &user_plmns->equivalents_home, networks) == false )
nb_errors++;
if ( nb_errors > 0 )
return false;
return true;
}
bool parse_Xplmn(config_setting_t *ue_setting, const char *section,
int user_id, plmns_list *plmns, const networks_t networks) {
int rc;
int item_count;
config_setting_t *setting;
setting = config_setting_get_member(ue_setting, section);
if (setting == NULL) {
printf("Check %s section for UE%d. Exiting\n", section, user_id);
return false;
}
item_count = config_setting_length(setting);
int *datas = malloc(item_count * sizeof(int));
for (int i = 0; i < item_count; i++) {
const char *mccmnc = config_setting_get_string_elem(setting, i);
if (mccmnc == NULL) {
printf("Check %s section for UE%d. Exiting\n", section, user_id);
free(datas);
return false;
}
rc = get_plmn_index(mccmnc, networks);
if (rc == -1) {
printf("The PLMN %s is not defined in PLMN section. Exiting...\n",
mccmnc);
free(datas);
return false;
}
datas[i] = rc;
}
plmns->size = item_count;
plmns->items = datas;
return true;
}
void user_plmns_free(user_plmns_t *user_plmns) {
free(user_plmns->users_controlled.items);
free(user_plmns->operators.items);
free(user_plmns->operators_controlled.items);
free(user_plmns->forbiddens.items);
free(user_plmns->equivalents_home.items);
memset(user_plmns, 0, sizeof(user_plmns_t));
}