diff --git a/.github/workflows/meson-ci.yml b/.github/workflows/meson-ci.yml index a671567c6..053dba738 100644 --- a/.github/workflows/meson-ci.yml +++ b/.github/workflows/meson-ci.yml @@ -6,11 +6,11 @@ jobs: name: Build and Test on MacOS Latest runs-on: macos-latest steps: - - name: Install MongoDB with Package Manager - run: | - brew tap mongodb/brew - brew install mongodb-community - brew services start mongodb-community +# - name: Install MongoDB with Package Manager +# run: | +# brew tap mongodb/brew +# brew install mongodb-community +# brew services start mongodb-community - name: Create the TUN device with the interface name `ogstun`. run: | sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255 @@ -33,6 +33,7 @@ jobs: sudo ifconfig lo0 alias 127.0.0.18 netmask 255.255.255.255 sudo ifconfig lo0 alias 127.0.0.19 netmask 255.255.255.255 sudo ifconfig lo0 alias 127.0.0.20 netmask 255.255.255.255 + sudo ifconfig lo0 alias 127.0.1.10 netmask 255.255.255.255 - name: Install the dependencies for building the source code. run: brew install mongo-c-driver libidn libmicrohttpd nghttp2 bison libusrsctp libtins talloc meson - name: Check out repository code diff --git a/configs/open5gs/amf.yaml.in b/configs/open5gs/amf.yaml.in index c5b8de8d4..4a1ef0a5f 100644 --- a/configs/open5gs/amf.yaml.in +++ b/configs/open5gs/amf.yaml.in @@ -35,7 +35,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: amf.key @@ -85,9 +85,18 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - namf-comm +# # > # -# o NGAP Server(all address avaiable) +# o NGAP Server(all address available) # ngap: # # o NGAP Server(0.0.0.0:38412) @@ -104,7 +113,7 @@ logger: # - addr: 127.0.0.5 # port: 38413 # -# o NGAP Server(address avaiable in `eth0` interface) +# o NGAP Server(address available in `eth0` interface) # ngap: # dev: eth0 # diff --git a/configs/open5gs/ausf.yaml.in b/configs/open5gs/ausf.yaml.in index 66e5c3689..79083742f 100644 --- a/configs/open5gs/ausf.yaml.in +++ b/configs/open5gs/ausf.yaml.in @@ -35,7 +35,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: ausf.key @@ -85,6 +85,15 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nausf-auth +# ausf: sbi: - addr: 127.0.0.11 diff --git a/configs/open5gs/bsf.yaml.in b/configs/open5gs/bsf.yaml.in index ca8260509..1e9ccc3ec 100644 --- a/configs/open5gs/bsf.yaml.in +++ b/configs/open5gs/bsf.yaml.in @@ -37,7 +37,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: bsf.key @@ -87,6 +87,15 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nbsf-management +# bsf: sbi: - addr: 127.0.0.15 diff --git a/configs/open5gs/mme.yaml.in b/configs/open5gs/mme.yaml.in index 12bda8540..720f9762a 100644 --- a/configs/open5gs/mme.yaml.in +++ b/configs/open5gs/mme.yaml.in @@ -26,7 +26,7 @@ logger: # # > # -# o S1AP Server(all address avaiable) +# o S1AP Server(all address available) # s1ap: # # o S1AP Server(0.0.0.0:36412) @@ -43,7 +43,7 @@ logger: # - addr: 127.0.0.2 # port: 36413 # -# o S1AP Server(address avaiable in `eth0` interface) +# o S1AP Server(address available in `eth0` interface) # s1ap: # dev: eth0 # @@ -86,7 +86,7 @@ logger: # # > # -# o GTP-C Server(all address avaiable) +# o GTP-C Server(all address available) # gtpc: # # o GTP-C Server(127.0.0.2:2123, [::1]:2123) diff --git a/configs/open5gs/nrf.yaml.in b/configs/open5gs/nrf.yaml.in index dc3d5daf2..b9b02579f 100644 --- a/configs/open5gs/nrf.yaml.in +++ b/configs/open5gs/nrf.yaml.in @@ -38,7 +38,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # tls: # key: nrf.key @@ -77,6 +77,16 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nnrf-nfm +# - nnrf-disc +# nrf: sbi: addr: diff --git a/configs/open5gs/nssf.yaml.in b/configs/open5gs/nssf.yaml.in index 01c768d36..28adb4c35 100644 --- a/configs/open5gs/nssf.yaml.in +++ b/configs/open5gs/nssf.yaml.in @@ -35,7 +35,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: nssf.key @@ -85,7 +85,7 @@ logger: # l_onoff: true # l_linger: 10 # -# +# # # o One NSI # - NRF[http://::1:7777/nnrf-nfm/v1/nf-instances] @@ -134,6 +134,16 @@ logger: # so_linger: # l_onoff: true # l_linger: 10 +# +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nnssf-nsselection +# nssf: sbi: - addr: 127.0.0.14 diff --git a/configs/open5gs/pcf.yaml.in b/configs/open5gs/pcf.yaml.in index 006699ae0..7d0a7bc55 100644 --- a/configs/open5gs/pcf.yaml.in +++ b/configs/open5gs/pcf.yaml.in @@ -37,7 +37,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: pcf.key @@ -87,6 +87,17 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - npcf-am-policy-control +# - npcf-smpolicycontrol +# - npcf-policyauthorization +# pcf: sbi: - addr: 127.0.0.13 diff --git a/configs/open5gs/scp.yaml.in b/configs/open5gs/scp.yaml.in index 7ca6543a8..371e98ae4 100644 --- a/configs/open5gs/scp.yaml.in +++ b/configs/open5gs/scp.yaml.in @@ -38,7 +38,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: scp.key @@ -103,7 +103,7 @@ logger: # # o delegated: # o auto: (Default) -# Use next-hop SCP if next-hop SCP avaiable. Otherwise NRF is used. +# Use next-hop SCP if next-hop SCP available. Otherwise NRF is used. # => App fails if both next-hop SCP and NRF are unavailable. # o yes: Use next-hop SCP always. # => App fails if no next-hop SCP available. diff --git a/configs/open5gs/smf.yaml.in b/configs/open5gs/smf.yaml.in index b826ff603..74b3f948c 100644 --- a/configs/open5gs/smf.yaml.in +++ b/configs/open5gs/smf.yaml.in @@ -35,7 +35,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: smf.key @@ -85,6 +85,15 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nsmf-pdusession +# # # # o PFCP Server(127.0.0.4:8805, ::1:8805) diff --git a/configs/open5gs/udm.yaml.in b/configs/open5gs/udm.yaml.in index 7fcae87d0..d4f18db3f 100644 --- a/configs/open5gs/udm.yaml.in +++ b/configs/open5gs/udm.yaml.in @@ -35,7 +35,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: udm.key @@ -85,6 +85,17 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nudm-sdm +# - nudm-uecm +# - nudm-ueau +# udm: sbi: - addr: 127.0.0.12 diff --git a/configs/open5gs/udr.yaml.in b/configs/open5gs/udr.yaml.in index 8b8d42d7a..eb072edc7 100644 --- a/configs/open5gs/udr.yaml.in +++ b/configs/open5gs/udr.yaml.in @@ -37,7 +37,7 @@ logger: # - ::0 # port: 7777 # -# o SBI Server(https://:443) +# o SBI Server(https://:443) # sbi: # - tls: # key: udr.key @@ -87,6 +87,15 @@ logger: # l_onoff: true # l_linger: 10 # +# +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nudr-dr +# udr: sbi: - addr: 127.0.0.20 diff --git a/lib/sbi/context.c b/lib/sbi/context.c index a1cd1aeae..5c0c3c779 100644 --- a/lib/sbi/context.c +++ b/lib/sbi/context.c @@ -400,6 +400,27 @@ int ogs_sbi_context_parse_config( ogs_socknode_remove_all(&list); ogs_socknode_remove_all(&list6); } + } else if (!strcmp(local_key, "service_name")) { + ogs_yaml_iter_t service_name_iter; + ogs_yaml_iter_recurse(&local_iter, &service_name_iter); + ogs_assert(ogs_yaml_iter_type( + &service_name_iter) != YAML_MAPPING_NODE); + + do { + const char *v = NULL; + + if (ogs_yaml_iter_type(&service_name_iter) == + YAML_SEQUENCE_NODE) { + if (!ogs_yaml_iter_next(&service_name_iter)) + break; + } + + v = ogs_yaml_iter_value(&service_name_iter); + if (v && strlen(v)) + self.service_name[self.num_of_service_name++] = v; + + } while (ogs_yaml_iter_type( + &service_name_iter) == YAML_SEQUENCE_NODE); } } } else if (nrf && !strcmp(root_key, nrf)) { @@ -706,6 +727,24 @@ int ogs_sbi_context_parse_config( return OGS_OK; } +bool ogs_sbi_nf_service_is_available(const char *name) +{ + int i; + + ogs_assert(name); + + if (self.num_of_service_name == 0) + /* If no service name is configured, all services are available */ + return true; + + for (i = 0; i < self.num_of_service_name; i++) + /* Only services in the configuration are available */ + if (strcmp(self.service_name[i], name) == 0) + return true; + + return false; +} + ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void) { ogs_sbi_nf_instance_t *nf_instance = NULL; @@ -856,7 +895,7 @@ bool ogs_sbi_nf_instance_maximum_number_is_reached() ogs_sbi_nf_service_t *ogs_sbi_nf_service_add( ogs_sbi_nf_instance_t *nf_instance, - char *id, char *name, OpenAPI_uri_scheme_e scheme) + char *id, const char *name, OpenAPI_uri_scheme_e scheme) { ogs_sbi_nf_service_t *nf_service = NULL; @@ -888,7 +927,7 @@ ogs_sbi_nf_service_t *ogs_sbi_nf_service_add( } void ogs_sbi_nf_service_add_version(ogs_sbi_nf_service_t *nf_service, - char *in_uri, char *full, char *expiry) + const char *in_uri, const char *full, const char *expiry) { ogs_assert(nf_service); @@ -1148,7 +1187,7 @@ void ogs_sbi_nf_instance_build_default( } ogs_sbi_nf_service_t *ogs_sbi_nf_service_build_default( - ogs_sbi_nf_instance_t *nf_instance, char *name) + ogs_sbi_nf_instance_t *nf_instance, const char *name) { ogs_sbi_server_t *server = NULL; ogs_sbi_nf_service_t *nf_service = NULL; diff --git a/lib/sbi/context.h b/lib/sbi/context.h index e825ab429..fbe9ee8fb 100644 --- a/lib/sbi/context.h +++ b/lib/sbi/context.h @@ -68,6 +68,8 @@ typedef struct ogs_sbi_context_s { void (*client_wait_expire)(void *data); ogs_fsm_handler_t nf_state_registered; + int num_of_service_name; + const char *service_name[OGS_MAX_NUM_OF_NF_SERVICE]; } ogs_sbi_context_t; typedef struct ogs_sbi_nf_instance_s { @@ -271,6 +273,8 @@ ogs_sbi_context_t *ogs_sbi_self(void); int ogs_sbi_context_parse_config( const char *local, const char *nrf, const char *scp); +bool ogs_sbi_nf_service_is_available(const char *name); + ogs_sbi_nf_instance_t *ogs_sbi_scp_instance(void); ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void); @@ -287,10 +291,12 @@ void ogs_sbi_nf_instance_remove_all(void); ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find(char *id); bool ogs_sbi_nf_instance_maximum_number_is_reached(void); -ogs_sbi_nf_service_t *ogs_sbi_nf_service_add(ogs_sbi_nf_instance_t *nf_instance, - char *id, char *name, OpenAPI_uri_scheme_e scheme); -void ogs_sbi_nf_service_add_version(ogs_sbi_nf_service_t *nf_service, - char *in_uri, char *full, char *expiry); +ogs_sbi_nf_service_t *ogs_sbi_nf_service_add( + ogs_sbi_nf_instance_t *nf_instance, + char *id, const char *name, OpenAPI_uri_scheme_e scheme); +void ogs_sbi_nf_service_add_version( + ogs_sbi_nf_service_t *nf_service, + const char *in_uri, const char *full, const char *expiry); void ogs_sbi_nf_service_add_allowed_nf_type( ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_type_e allowed_nf_type); void ogs_sbi_nf_service_clear(ogs_sbi_nf_service_t *nf_service); @@ -309,7 +315,7 @@ void ogs_sbi_nf_info_remove_all(ogs_list_t *list); void ogs_sbi_nf_instance_build_default( ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e nf_type); ogs_sbi_nf_service_t *ogs_sbi_nf_service_build_default( - ogs_sbi_nf_instance_t *nf_instance, char *name); + ogs_sbi_nf_instance_t *nf_instance, const char *name); ogs_sbi_client_t *ogs_sbi_client_find_by_service_name( ogs_sbi_nf_instance_t *nf_instance, char *name, char *version); diff --git a/lib/sbi/message.h b/lib/sbi/message.h index 55a4bdb87..e9fdec8d2 100644 --- a/lib/sbi/message.h +++ b/lib/sbi/message.h @@ -122,7 +122,6 @@ extern "C" { #define OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION "nsmf-pdusession" #define OGS_SBI_RESOURCE_NAME_SM_CONTEXTS "sm-contexts" -#define OGS_SBI_SERVICE_NAME_NSMF_EVENT_EXPOSURE "nsmf-event-exposure" #define OGS_SBI_RESOURCE_NAME_MODIFY "modify" #define OGS_SBI_RESOURCE_NAME_RELEASE "release" diff --git a/src/amf/context.c b/src/amf/context.c index 60fff81fc..23e08155a 100644 --- a/src/amf/context.c +++ b/src/amf/context.c @@ -821,6 +821,8 @@ int amf_context_parse_config(void) self.amf_name = ogs_yaml_iter_value(&amf_iter); } else if (!strcmp(amf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(amf_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", amf_key); } diff --git a/src/amf/context.h b/src/amf/context.h index 9bf51c38c..bd08d7bdc 100644 --- a/src/amf/context.h +++ b/src/amf/context.h @@ -203,6 +203,7 @@ struct ran_ue_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ amf_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -210,7 +211,6 @@ struct ran_ue_s { OGS_FSM_TRAN(&_nFInstance->sm, amf_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) struct amf_ue_s { diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c index 029b954f1..c1126bca4 100644 --- a/src/amf/nnrf-handler.c +++ b/src/amf/nnrf-handler.c @@ -183,8 +183,6 @@ bool amf_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, amf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -314,8 +312,6 @@ void amf_nnrf_handle_nf_discover_search_result( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, amf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/amf/sbi-path.c b/src/amf/sbi-path.c index 188f80f57..7aaecf575 100644 --- a/src/amf/sbi-path.c +++ b/src/amf/sbi-path.c @@ -91,12 +91,14 @@ int amf_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SMF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NAMF_COMM); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NAMF_COMM)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NAMF_COMM); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + } /* Initialize SCP NF Instance */ nf_instance = ogs_sbi_self()->scp_instance; diff --git a/src/ausf/context.c b/src/ausf/context.c index 6c01afcab..a70ba5bc4 100644 --- a/src/ausf/context.c +++ b/src/ausf/context.c @@ -102,6 +102,8 @@ int ausf_context_parse_config(void) ogs_assert(ausf_key); if (!strcmp(ausf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(ausf_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", ausf_key); } diff --git a/src/ausf/context.h b/src/ausf/context.h index 7f382f195..8f2276738 100644 --- a/src/ausf/context.h +++ b/src/ausf/context.h @@ -70,6 +70,7 @@ struct ausf_ue_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ ausf_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -77,7 +78,6 @@ struct ausf_ue_s { OGS_FSM_TRAN(&_nFInstance->sm, ausf_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) }; diff --git a/src/ausf/nnrf-handler.c b/src/ausf/nnrf-handler.c index 1f44cd34c..3dfacc444 100644 --- a/src/ausf/nnrf-handler.c +++ b/src/ausf/nnrf-handler.c @@ -180,8 +180,6 @@ bool ausf_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, ausf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -292,8 +290,6 @@ void ausf_nnrf_handle_nf_discover( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, ausf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/ausf/sbi-path.c b/src/ausf/sbi-path.c index 2c1dbc77c..a34de4f5e 100644 --- a/src/ausf/sbi-path.c +++ b/src/ausf/sbi-path.c @@ -88,12 +88,14 @@ int ausf_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NAUSF_AUTH); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NAUSF_AUTH)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NAUSF_AUTH); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { diff --git a/src/bsf/context.c b/src/bsf/context.c index 3013ca31f..3d75d356c 100644 --- a/src/bsf/context.c +++ b/src/bsf/context.c @@ -104,6 +104,8 @@ int bsf_context_parse_config(void) ogs_assert(bsf_key); if (!strcmp(bsf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(bsf_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", bsf_key); } diff --git a/src/bsf/context.h b/src/bsf/context.h index 842d47888..976f69f10 100644 --- a/src/bsf/context.h +++ b/src/bsf/context.h @@ -48,6 +48,7 @@ typedef struct bsf_context_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ bsf_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -55,7 +56,6 @@ typedef struct bsf_context_s { OGS_FSM_TRAN(&_nFInstance->sm, bsf_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) typedef struct bsf_sess_s bsf_sess_t; diff --git a/src/bsf/nnrf-handler.c b/src/bsf/nnrf-handler.c index 38eeb2b89..8722ae0f4 100644 --- a/src/bsf/nnrf-handler.c +++ b/src/bsf/nnrf-handler.c @@ -181,8 +181,6 @@ bool bsf_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, bsf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -293,8 +291,6 @@ void bsf_nnrf_handle_nf_discover( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, bsf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/bsf/sbi-path.c b/src/bsf/sbi-path.c index 834a9dbfa..1104265c9 100644 --- a/src/bsf/sbi-path.c +++ b/src/bsf/sbi-path.c @@ -88,12 +88,14 @@ int bsf_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_PCF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { diff --git a/src/nssf/context.c b/src/nssf/context.c index 6b50fb8ad..771c6a2f6 100644 --- a/src/nssf/context.c +++ b/src/nssf/context.c @@ -96,6 +96,8 @@ int nssf_context_parse_config(void) ogs_assert(nssf_key); if (!strcmp(nssf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(nssf_key, "service_name")) { + /* handle config in sbi library */ } else if (!strcmp(nssf_key, "nsi")) { ogs_list_t list, list6; ogs_socknode_t *node = NULL, *node6 = NULL; diff --git a/src/nssf/context.h b/src/nssf/context.h index d20ccaded..274e7bdb4 100644 --- a/src/nssf/context.h +++ b/src/nssf/context.h @@ -47,6 +47,7 @@ typedef struct nssf_context_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ nssf_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -54,7 +55,6 @@ typedef struct nssf_context_s { OGS_FSM_TRAN(&_nFInstance->sm, nssf_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) void nssf_context_init(void); diff --git a/src/nssf/nnrf-handler.c b/src/nssf/nnrf-handler.c index 32ebecdfa..13599489b 100644 --- a/src/nssf/nnrf-handler.c +++ b/src/nssf/nnrf-handler.c @@ -180,8 +180,6 @@ bool nssf_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, nssf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/nssf/sbi-path.c b/src/nssf/sbi-path.c index f38d35b5e..be7ebed42 100644 --- a/src/nssf/sbi-path.c +++ b/src/nssf/sbi-path.c @@ -88,12 +88,15 @@ int nssf_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2, - (char*)OGS_SBI_API_V2_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V2, OGS_SBI_API_V2_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { diff --git a/src/pcf/context.c b/src/pcf/context.c index 2fbb7d15a..dcfa62e49 100644 --- a/src/pcf/context.c +++ b/src/pcf/context.c @@ -117,6 +117,8 @@ int pcf_context_parse_config(void) ogs_assert(pcf_key); if (!strcmp(pcf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(pcf_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", pcf_key); } diff --git a/src/pcf/context.h b/src/pcf/context.h index 860da3291..19321f5b2 100644 --- a/src/pcf/context.h +++ b/src/pcf/context.h @@ -53,6 +53,7 @@ typedef struct pcf_context_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ pcf_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -60,7 +61,6 @@ typedef struct pcf_context_s { OGS_FSM_TRAN(&_nFInstance->sm, pcf_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) struct pcf_ue_s { diff --git a/src/pcf/nnrf-handler.c b/src/pcf/nnrf-handler.c index a45e41852..b137faf3a 100644 --- a/src/pcf/nnrf-handler.c +++ b/src/pcf/nnrf-handler.c @@ -181,8 +181,6 @@ bool pcf_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, pcf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -294,8 +292,6 @@ void pcf_nnrf_handle_nf_discover( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, pcf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/pcf/sbi-path.c b/src/pcf/sbi-path.c index 56c85a1c0..1c5489c5d 100644 --- a/src/pcf/sbi-path.c +++ b/src/pcf/sbi-path.c @@ -91,22 +91,38 @@ int pcf_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF); + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF); + } - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AF); + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF); + } + + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { diff --git a/src/scp/context.c b/src/scp/context.c index f08d2e389..7ff44f55d 100644 --- a/src/scp/context.c +++ b/src/scp/context.c @@ -96,6 +96,8 @@ int scp_context_parse_config(void) ogs_assert(scp_key); if (!strcmp(scp_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(scp_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", scp_key); } diff --git a/src/scp/context.h b/src/scp/context.h index 4474c72d7..ec1bf611a 100644 --- a/src/scp/context.h +++ b/src/scp/context.h @@ -45,6 +45,7 @@ typedef struct scp_context_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ scp_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -52,7 +53,6 @@ typedef struct scp_context_s { OGS_FSM_TRAN(&_nFInstance->sm, scp_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) typedef struct scp_conn_s scp_conn_t; diff --git a/src/scp/nnrf-handler.c b/src/scp/nnrf-handler.c index 714368cf8..f4767899d 100644 --- a/src/scp/nnrf-handler.c +++ b/src/scp/nnrf-handler.c @@ -181,8 +181,6 @@ bool scp_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, scp_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -293,8 +291,6 @@ void scp_nnrf_handle_nf_discover( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, scp_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/smf/context.c b/src/smf/context.c index 6527137d0..5471ab8c2 100644 --- a/src/smf/context.c +++ b/src/smf/context.c @@ -831,6 +831,8 @@ int smf_context_parse_config(void) /* handle config in pfcp library */ } else if (!strcmp(smf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(smf_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", smf_key); } diff --git a/src/smf/context.h b/src/smf/context.h index be7443fc8..bb5b785de 100644 --- a/src/smf/context.h +++ b/src/smf/context.h @@ -132,6 +132,7 @@ typedef struct smf_ue_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ smf_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -139,7 +140,6 @@ typedef struct smf_ue_s { OGS_FSM_TRAN(&_nFInstance->sm, smf_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) #define SMF_SESS_CLEAR(__sESS) \ do { \ diff --git a/src/smf/nnrf-handler.c b/src/smf/nnrf-handler.c index f50bc207a..ffa98322b 100644 --- a/src/smf/nnrf-handler.c +++ b/src/smf/nnrf-handler.c @@ -181,8 +181,6 @@ bool smf_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, smf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -293,8 +291,6 @@ void smf_nnrf_handle_nf_discover( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, smf_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/smf/sbi-path.c b/src/smf/sbi-path.c index f9852466b..935f2251b 100644 --- a/src/smf/sbi-path.c +++ b/src/smf/sbi-path.c @@ -90,12 +90,14 @@ int smf_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { diff --git a/src/udm/context.c b/src/udm/context.c index b35b566e7..675eddd78 100644 --- a/src/udm/context.c +++ b/src/udm/context.c @@ -102,6 +102,8 @@ int udm_context_parse_config(void) ogs_assert(udm_key); if (!strcmp(udm_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(udm_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", udm_key); } diff --git a/src/udm/context.h b/src/udm/context.h index 9ded283ca..f4780e920 100644 --- a/src/udm/context.h +++ b/src/udm/context.h @@ -79,6 +79,7 @@ struct udm_ue_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ udm_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -86,7 +87,6 @@ struct udm_ue_s { OGS_FSM_TRAN(&_nFInstance->sm, udm_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) }; diff --git a/src/udm/nnrf-handler.c b/src/udm/nnrf-handler.c index 59b966c33..8e4a5f9ef 100644 --- a/src/udm/nnrf-handler.c +++ b/src/udm/nnrf-handler.c @@ -181,8 +181,6 @@ bool udm_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, udm_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -293,8 +291,6 @@ void udm_nnrf_handle_nf_discover( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, udm_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/udm/sbi-path.c b/src/udm/sbi-path.c index 1e1c87317..bf5f17a7c 100644 --- a/src/udm/sbi-path.c +++ b/src/udm/sbi-path.c @@ -90,25 +90,33 @@ int udm_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AUSF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDM_UEAU); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AUSF); - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDM_UECM); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDM_SDM); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2, - (char*)OGS_SBI_API_V2_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDM_UEAU)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDM_UEAU); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AUSF); + } + + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDM_UECM)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDM_UECM); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } + + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDM_SDM)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDM_SDM); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V2, OGS_SBI_API_V2_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { diff --git a/src/udr/context.c b/src/udr/context.c index f571c7c1f..9dbc864bb 100644 --- a/src/udr/context.c +++ b/src/udr/context.c @@ -84,6 +84,8 @@ int udr_context_parse_config(void) ogs_assert(udr_key); if (!strcmp(udr_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(udr_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", udr_key); } diff --git a/src/udr/context.h b/src/udr/context.h index e682dca90..a2d6747e0 100644 --- a/src/udr/context.h +++ b/src/udr/context.h @@ -47,6 +47,7 @@ typedef struct udr_context_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ udr_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -54,7 +55,6 @@ typedef struct udr_context_s { OGS_FSM_TRAN(&_nFInstance->sm, udr_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) void udr_context_init(void); diff --git a/src/udr/nnrf-handler.c b/src/udr/nnrf-handler.c index 80398b57b..6874c5ccc 100644 --- a/src/udr/nnrf-handler.c +++ b/src/udr/nnrf-handler.c @@ -181,8 +181,6 @@ bool udr_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, udr_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/src/udr/sbi-path.c b/src/udr/sbi-path.c index 91f6b39f2..a30d9b64c 100644 --- a/src/udr/sbi-path.c +++ b/src/udr/sbi-path.c @@ -89,13 +89,15 @@ int udr_sbi_open(void) ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_UDM); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDR_DR); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_UDM); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDR_DR)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDR_DR); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_UDM); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { diff --git a/tests/af/context.c b/tests/af/context.c index 25c33ddd6..886217f16 100644 --- a/tests/af/context.c +++ b/tests/af/context.c @@ -111,6 +111,8 @@ int af_context_parse_config(void) ogs_assert(af_key); if (!strcmp(af_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(af_key, "service_name")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", af_key); } diff --git a/tests/af/context.h b/tests/af/context.h index 3ac13b893..ee9737549 100644 --- a/tests/af/context.h +++ b/tests/af/context.h @@ -52,6 +52,7 @@ typedef struct af_context_s { if ((_nFInstance)->reference_count == 1) { \ ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ af_nf_fsm_fini((_nFInstance)); \ + ogs_sbi_nf_instance_remove(_nFInstance); \ } else { \ /* There is an assocation with other context */ \ ogs_info("[%s:%d] (%s) NF suspended", \ @@ -59,7 +60,6 @@ typedef struct af_context_s { OGS_FSM_TRAN(&_nFInstance->sm, af_nf_state_de_registered); \ ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ } while(0) typedef struct af_sess_s af_sess_t; diff --git a/tests/af/nnrf-handler.c b/tests/af/nnrf-handler.c index 46f7f9c8d..c08db177e 100644 --- a/tests/af/nnrf-handler.c +++ b/tests/af/nnrf-handler.c @@ -185,8 +185,6 @@ bool af_nnrf_handle_nf_status_notify( ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, af_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); @@ -297,8 +295,6 @@ void af_nnrf_handle_nf_discover( ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); } else { - nf_instance->reference_count++; - OGS_FSM_TRAN(&nf_instance->sm, af_nf_state_registered); ogs_fsm_dispatch(&nf_instance->sm, NULL); diff --git a/tests/af/sbi-path.c b/tests/af/sbi-path.c index 43e354d66..54dd40041 100644 --- a/tests/af/sbi-path.c +++ b/tests/af/sbi-path.c @@ -87,11 +87,14 @@ int af_sbi_open(void) ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AF); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + } /* Initialize NRF NF Instance */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {