open5gs/tests/unit/proto-message-test.c
Sukchan Lee 782a97efe9 Fix DNN Operator-Identifier format and refactor OI parsing for HR roaming interop
Align full-DNN construction with 3GPP TS 23.003 §9.1.2 by switching the
Operator Identifier format from "5gc.mncXXX.mccYYY.3gppnetwork.org" to
"mncXXX.mccYYY.gprs". Introduce new helper utilities to extract and build
OI (Operator Identifier) from both PLMN-ID and FQDN, and replace the
legacy `ogs_home_network_domain_from_fqdn()` usage in AMF/SMF/PCF paths.

This resolves DNN misalignment in vSMF–hSMF PDU Session Create that
caused interop issues with external 5G core vendors during HR roaming.

Includes updates across AMF/SMF/PCF, unit tests, and supporting helpers.

Issues: #4096
2025-12-06 22:23:34 +09:00

86 lines
2.9 KiB
C

/*
* Copyright (C) 2023 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ogs-sbi.h"
#include "core/abts.h"
static void proto_message_test1(abts_case *tc, void *data)
{
char *fqdn = NULL;
ogs_plmn_id_t plmn_id1, plmn_id2;
ogs_plmn_id_build(&plmn_id1, 456, 123, 3);
fqdn = ogs_home_network_domain_from_plmn_id(&plmn_id1);
ABTS_STR_EQUAL(tc, "5gc.mnc123.mcc456.3gppnetwork.org", fqdn);
ABTS_INT_EQUAL(tc, 456, ogs_plmn_id_mcc_from_fqdn(fqdn));
ABTS_INT_EQUAL(tc, 123, ogs_plmn_id_mnc_from_fqdn(fqdn));
ogs_free(fqdn);
ogs_plmn_id_build(&plmn_id1, 1, 1, 2);
fqdn = ogs_home_network_domain_from_plmn_id(&plmn_id1);
ABTS_STR_EQUAL(tc, "5gc.mnc001.mcc001.3gppnetwork.org", fqdn);
ABTS_INT_EQUAL(tc, 1, ogs_plmn_id_mcc_from_fqdn(fqdn));
ABTS_INT_EQUAL(tc, 1, ogs_plmn_id_mnc_from_fqdn(fqdn));
ogs_free(fqdn);
ogs_plmn_id_build(&plmn_id1, 310, 14, 3);
fqdn = ogs_home_network_domain_from_plmn_id(&plmn_id1);
ABTS_STR_EQUAL(tc, "5gc.mnc014.mcc310.3gppnetwork.org", fqdn);
ABTS_INT_EQUAL(tc, 310, ogs_plmn_id_mcc_from_fqdn(fqdn));
ABTS_INT_EQUAL(tc, 14, ogs_plmn_id_mnc_from_fqdn(fqdn));
ogs_free(fqdn);
}
static void proto_message_test2(abts_case *tc, void *data)
{
char *dnn_oi = NULL;
char *full_dnn = NULL;
char dnn_ni[OGS_MAX_DNN_LEN+1];
ogs_plmn_id_t plmn_id1, plmn_id2;
ogs_plmn_id_build(&plmn_id1, 456, 123, 3);
dnn_oi = ogs_dnn_oi_from_plmn_id(&plmn_id1);
ABTS_STR_EQUAL(tc,
"mnc123.mcc456.gprs", dnn_oi);
full_dnn = ogs_msprintf("internet.realm.%s", dnn_oi);
ABTS_STR_EQUAL(tc,
"internet.realm.mnc123.mcc456.gprs", full_dnn);
ABTS_STR_EQUAL(tc,
dnn_oi, ogs_dnn_oi_from_fqdn(full_dnn));
ogs_cpystrn(dnn_ni, full_dnn,
ogs_min(OGS_MAX_DNN_LEN,
ogs_dnn_oi_from_fqdn(full_dnn) - full_dnn));
ABTS_STR_EQUAL(tc, "internet.realm", dnn_ni);
ABTS_INT_EQUAL(tc, 456, ogs_plmn_id_mcc_from_fqdn(full_dnn));
ABTS_INT_EQUAL(tc, 123, ogs_plmn_id_mnc_from_fqdn(full_dnn));
ogs_free(dnn_oi);
ogs_free(full_dnn);
}
abts_suite *test_proto_message(abts_suite *suite)
{
suite = ADD_SUITE(suite)
abts_run_test(suite, proto_message_test1, NULL);
abts_run_test(suite, proto_message_test2, NULL);
return suite;
}