diff --git a/lib/proto/types.h b/lib/proto/types.h index 78fb5485c..b057591c0 100644 --- a/lib/proto/types.h +++ b/lib/proto/types.h @@ -81,7 +81,7 @@ extern "C" { #define OGS_MAX_PCO_LEN 251 #define OGS_MAX_FQDN_LEN 256 -#define MAX_NUM_OF_SERVED_GUAMI 8 +#define OGS_MAX_NUM_OF_SERVED_GUAMI 8 #define OGS_MAX_NUM_OF_SERVED_TAI 16 #define OGS_MAX_NUM_OF_ALGORITHM 8 diff --git a/lib/sbi/context.c b/lib/sbi/context.c index aa6b58dda..7346a99a6 100644 --- a/lib/sbi/context.c +++ b/lib/sbi/context.c @@ -1189,6 +1189,11 @@ ogs_sbi_nf_info_t *ogs_sbi_nf_info_add( return nf_info; } +static void amf_info_free(ogs_sbi_amf_info_t *amf_info) +{ + /* Nothing */ +} + static void smf_info_free(ogs_sbi_smf_info_t *smf_info) { int i, j; @@ -1214,6 +1219,9 @@ void ogs_sbi_nf_info_remove(ogs_list_t *list, ogs_sbi_nf_info_t *nf_info) ogs_list_remove(list, nf_info); switch(nf_info->nf_type) { + case OpenAPI_nf_type_AMF: + amf_info_free(&nf_info->amf); + break; case OpenAPI_nf_type_SMF: smf_info_free(&nf_info->smf); break; diff --git a/lib/sbi/context.h b/lib/sbi/context.h index c8356a985..ae41a7e6e 100644 --- a/lib/sbi/context.h +++ b/lib/sbi/context.h @@ -260,7 +260,7 @@ typedef struct ogs_sbi_amf_info_s { int amf_region_id; int num_of_guami; - ogs_guami_t guami[MAX_NUM_OF_SERVED_GUAMI]; + ogs_guami_t guami[OGS_MAX_NUM_OF_SERVED_GUAMI]; int num_of_nr_tai; ogs_5gs_tai_t nr_tai[OGS_MAX_NUM_OF_TAI]; diff --git a/lib/sbi/nnrf-build.c b/lib/sbi/nnrf-build.c index 4b16925f0..2e2808b2d 100644 --- a/lib/sbi/nnrf-build.c +++ b/lib/sbi/nnrf-build.c @@ -891,7 +891,17 @@ static void free_amf_info(OpenAPI_amf_info_t *AmfInfo) guamiAmfInfoList = AmfInfo->guami_list; OpenAPI_list_for_each(guamiAmfInfoList, node) { guamiAmfInfoItem = node->data; - ogs_assert(guamiAmfInfoItem); + if (guamiAmfInfoItem) { + if (guamiAmfInfoItem->plmn_id) { + if (guamiAmfInfoItem->plmn_id->mcc) + ogs_free(guamiAmfInfoItem->plmn_id->mcc); + if (guamiAmfInfoItem->plmn_id->mnc) + ogs_free(guamiAmfInfoItem->plmn_id->mnc); + ogs_free(guamiAmfInfoItem->plmn_id); + } + if (guamiAmfInfoItem->amf_id) + ogs_free(guamiAmfInfoItem->amf_id); + } ogs_free(guamiAmfInfoItem); } diff --git a/src/amf/context.c b/src/amf/context.c index 28784b703..a3feead1b 100644 --- a/src/amf/context.c +++ b/src/amf/context.c @@ -180,8 +180,6 @@ int amf_context_parse_config(void) int rv; yaml_document_t *document = NULL; ogs_yaml_iter_t root_iter; - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_nf_info_t *nf_info = NULL; document = ogs_app()->document; ogs_assert(document); @@ -332,7 +330,7 @@ int amf_context_parse_config(void) const char *region = NULL, *set = NULL; const char *pointer = NULL; ogs_assert(self.num_of_served_guami < - MAX_NUM_OF_SERVED_GUAMI); + OGS_MAX_NUM_OF_SERVED_GUAMI); if (ogs_yaml_iter_type(&guami_array) == YAML_MAPPING_NODE) { @@ -833,6 +831,17 @@ int amf_context_parse_config(void) } } + rv = amf_context_validation(); + if (rv != OGS_OK) return rv; + + return OGS_OK; +} + +int amf_context_nf_info(void) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_nf_info_t *nf_info = NULL; + int served_i, next_new_i, info_i; bool next_found; served_i = 0; @@ -916,9 +925,6 @@ int amf_context_parse_config(void) } } while (next_found); - rv = amf_context_validation(); - if (rv != OGS_OK) return rv; - return OGS_OK; } diff --git a/src/amf/context.h b/src/amf/context.h index fda22657a..4a209b4c9 100644 --- a/src/amf/context.h +++ b/src/amf/context.h @@ -48,7 +48,7 @@ typedef uint32_t amf_m_tmsi_t; typedef struct amf_context_s { /* Served GUAMI */ uint8_t num_of_served_guami; - ogs_guami_t served_guami[MAX_NUM_OF_SERVED_GUAMI]; + ogs_guami_t served_guami[OGS_MAX_NUM_OF_SERVED_GUAMI]; /* Served TAI */ uint8_t num_of_served_tai; @@ -611,6 +611,7 @@ void amf_context_final(void); amf_context_t *amf_self(void); int amf_context_parse_config(void); +int amf_context_nf_info(void); amf_gnb_t *amf_gnb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr); void amf_gnb_remove(amf_gnb_t *gnb); diff --git a/src/amf/init.c b/src/amf/init.c index a51c64b41..5b91e40b0 100644 --- a/src/amf/init.c +++ b/src/amf/init.c @@ -43,6 +43,9 @@ int amf_initialize() rv = amf_context_parse_config(); if (rv != OGS_OK) return rv; + rv = amf_context_nf_info(); + if (rv != OGS_OK) return rv; + rv = amf_m_tmsi_pool_generate(); if (rv != OGS_OK) return rv; diff --git a/src/ausf/context.h b/src/ausf/context.h index 5470b9b6b..cb38789c7 100644 --- a/src/ausf/context.h +++ b/src/ausf/context.h @@ -30,8 +30,6 @@ extern "C" { #endif -#define MAX_NUM_OF_SERVED_GUAMI 8 - extern int __ausf_log_domain; #undef OGS_LOG_DOMAIN diff --git a/src/nssf/context.h b/src/nssf/context.h index 192a12223..d29bedc4c 100644 --- a/src/nssf/context.h +++ b/src/nssf/context.h @@ -29,8 +29,6 @@ extern "C" { #endif -#define MAX_NUM_OF_SERVED_GUAMI 8 - extern int __nssf_log_domain; #undef OGS_LOG_DOMAIN diff --git a/src/pcf/context.h b/src/pcf/context.h index bb347d177..50704eece 100644 --- a/src/pcf/context.h +++ b/src/pcf/context.h @@ -31,8 +31,6 @@ extern "C" { #endif -#define MAX_NUM_OF_SERVED_GUAMI 8 - extern int __pcf_log_domain; #undef OGS_LOG_DOMAIN diff --git a/src/udm/context.h b/src/udm/context.h index 0c675a36c..95b27cf50 100644 --- a/src/udm/context.h +++ b/src/udm/context.h @@ -30,8 +30,6 @@ extern "C" { #endif -#define MAX_NUM_OF_SERVED_GUAMI 8 - extern int __udm_log_domain; #undef OGS_LOG_DOMAIN diff --git a/src/udr/context.h b/src/udr/context.h index effddb1c4..b2bb51d66 100644 --- a/src/udr/context.h +++ b/src/udr/context.h @@ -30,8 +30,6 @@ extern "C" { #endif -#define MAX_NUM_OF_SERVED_GUAMI 8 - extern int __udr_log_domain; #undef OGS_LOG_DOMAIN diff --git a/tests/common/context.h b/tests/common/context.h index 5481defd1..7c8a2077a 100644 --- a/tests/common/context.h +++ b/tests/common/context.h @@ -36,8 +36,6 @@ extern "C" { #define TEST_PING_IPV4 "10.45.0.1" #define TEST_PING_IPV6 "2001:db8:cafe::1" -#define MAX_NUM_OF_SERVED_GUAMI 8 - #define TEST_MSISDN "491725670014" #define TEST_ADDITIONAL_MSISDN "491725670015"