From 5295c108adc2fc5ae97ee5007760334ef7a6297b Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 2 Sep 2022 23:04:57 +0900 Subject: [PATCH] Added Service-based NF discovery == Known limitation == Placing npcf-smpolicycontrol and pcf-policyauthorization in different NFs is not supported. Both npcf-smpolicycontrol and pcf-policyauthorization should be placed in the same NF. --- configs/open5gs/pcf.yaml.in | 5 ++ lib/sbi/context.c | 89 +++++++++++++++++++++++------------ lib/sbi/context.h | 39 ++++++---------- lib/sbi/nf-sm.c | 7 --- lib/sbi/nnrf-build.c | 13 ++---- lib/sbi/nnrf-build.h | 2 +- lib/sbi/path.c | 93 +++++++++++++++++++++++++++---------- lib/sbi/path.h | 5 +- src/amf/context.c | 9 +++- src/amf/gmm-handler.c | 30 ++++-------- src/amf/nnrf-handler.c | 46 +++++++++++++++++- src/amf/nsmf-build.c | 5 +- src/amf/sbi-path.c | 67 ++------------------------ src/amf/sbi-path.h | 5 +- src/ausf/nnrf-handler.c | 17 ++++++- src/ausf/sbi-path.c | 17 ++----- src/ausf/sbi-path.h | 5 +- src/bsf/nnrf-handler.c | 17 ++++++- src/bsf/sbi-path.c | 17 ++----- src/bsf/sbi-path.h | 5 +- src/mme/mme-fd-path.c | 34 +++++++------- src/nrf/sbi-path.c | 13 ------ src/nssf/sbi-path.c | 1 + src/pcf/nbsf-build.c | 8 ++-- src/pcf/nnrf-handler.c | 54 ++++++++++++++++++++- src/pcf/nudr-handler.c | 29 ++++++++++-- src/pcf/sbi-path.c | 56 ++++++++-------------- src/pcf/sbi-path.h | 8 ++-- src/scp/nnrf-handler.c | 17 ++++++- src/scp/sbi-path.c | 28 ++--------- src/scp/sbi-path.h | 5 +- src/smf/nnrf-handler.c | 17 ++++++- src/smf/sbi-path.c | 17 ++----- src/smf/sbi-path.h | 5 +- src/udm/nnrf-handler.c | 17 ++++++- src/udm/sbi-path.c | 17 ++----- src/udm/sbi-path.h | 5 +- src/udr/sbi-path.c | 1 + tests/af/af-sm.c | 2 +- tests/af/event.c | 4 +- tests/af/event.h | 6 +-- tests/af/local.c | 4 +- tests/af/nnrf-handler.c | 17 ++++++- tests/af/sbi-path.c | 17 ++----- tests/af/sbi-path.h | 5 +- 45 files changed, 474 insertions(+), 406 deletions(-) diff --git a/configs/open5gs/pcf.yaml.in b/configs/open5gs/pcf.yaml.in index 31dc5e26f..5b1a1a9a8 100644 --- a/configs/open5gs/pcf.yaml.in +++ b/configs/open5gs/pcf.yaml.in @@ -98,6 +98,11 @@ logger: # - npcf-smpolicycontrol # - npcf-policyauthorization # +# == NOTE == +# Placing npcf-smpolicycontrol and pcf-policyauthorization +# in different NFs is not supported. Both npcf-smpolicycontrol +# and pcf-policyauthorization should be placed in the same NF. +# # # # o (Default) If you do not set Query Parameter as shown below, diff --git a/lib/sbi/context.c b/lib/sbi/context.c index 268f68ccc..7b50466a8 100644 --- a/lib/sbi/context.c +++ b/lib/sbi/context.c @@ -908,6 +908,52 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find(char *id) return nf_instance; } +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_discovery_param( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(target_nf_type); + + ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { + if (ogs_sbi_discovery_param_is_matched( + nf_instance, target_nf_type, discovery_option) == false) + continue; + + return nf_instance; + } + + return NULL; +} + +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_service_type( + ogs_sbi_service_type_e service_type) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_discovery_option_t *discovery_option = NULL; + + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + char *service_name = NULL; + + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); + service_name = (char *)ogs_sbi_service_type_to_name(service_type); + ogs_assert(service_name); + + discovery_option = ogs_sbi_discovery_option_new(); + ogs_assert(discovery_option); + ogs_sbi_discovery_option_add_service_names(discovery_option, service_name); + + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + + ogs_sbi_discovery_option_free(discovery_option); + + return nf_instance; +} + bool ogs_sbi_nf_instance_maximum_number_is_reached() { return nf_instance_pool.avail <= 0; @@ -1082,10 +1128,10 @@ ogs_sbi_nf_service_t *ogs_sbi_nf_service_find_by_name( ogs_list_for_each(&nf_instance->nf_service_list, nf_service) { ogs_assert(nf_service->name); if (strcmp(nf_service->name, name) == 0) - break; + return nf_service; } - return nf_service; + return NULL; } ogs_sbi_nf_info_t *ogs_sbi_nf_info_add( @@ -1460,29 +1506,6 @@ bool ogs_sbi_discovery_param_is_matched( return true; } -void ogs_sbi_select_nf( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - ogs_sbi_discovery_option_t *discovery_option) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(sbi_object); - ogs_assert(service_type); - target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); - ogs_assert(target_nf_type); - - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (ogs_sbi_discovery_param_is_matched( - nf_instance, target_nf_type, discovery_option) == false) - continue; - - OGS_SBI_SETUP_NF_INSTANCE(sbi_object, service_type, nf_instance); - break; - } -} - void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance) { ogs_sbi_client_t *client = NULL; @@ -1537,8 +1560,16 @@ void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object) ogs_error("SBI running [%d]", ogs_list_count(&sbi_object->xact_list)); for (i = 0; i < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE; i++) { - if (OGS_SBI_NF_INSTANCE(sbi_object, i)) - ogs_sbi_nf_instance_remove(OGS_SBI_NF_INSTANCE(sbi_object, i)); + ogs_sbi_nf_instance_t *nf_instance = + sbi_object->service_type_array[i].nf_instance; + if (nf_instance) + ogs_sbi_nf_instance_remove(nf_instance); + } + for (i = 0; i < OGS_SBI_MAX_NUM_OF_NF_TYPE; i++) { + ogs_sbi_nf_instance_t *nf_instance = + sbi_object->nf_type_array[i].nf_instance; + if (nf_instance) + ogs_sbi_nf_instance_remove(nf_instance); } } @@ -1639,8 +1670,8 @@ void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact) ogs_assert(xact->t_response); ogs_timer_delete(xact->t_response); - ogs_assert(xact->request); - ogs_sbi_request_free(xact->request); + if (xact->request) + ogs_sbi_request_free(xact->request); ogs_list_remove(&sbi_object->xact_list, xact); ogs_pool_free(&xact_pool, xact); diff --git a/lib/sbi/context.h b/lib/sbi/context.h index 92f4ba9cf..52d3f8e3d 100644 --- a/lib/sbi/context.h +++ b/lib/sbi/context.h @@ -128,10 +128,6 @@ typedef struct ogs_sbi_nf_instance_s { unsigned int reference_count; /* reference count for memory free */ } ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_nf_instance_array_s { - ogs_sbi_nf_instance_t *nf_instance; -} ogs_sbi_nf_instance_array_t[OGS_SBI_MAX_NUM_OF_SERVICE_TYPE]; - typedef enum { OGS_SBI_OBJ_BASE = 0, @@ -146,7 +142,10 @@ typedef struct ogs_sbi_object_s { ogs_sbi_obj_type_e type; - ogs_sbi_nf_instance_array_t nf_instance_array; + struct { + ogs_sbi_nf_instance_t *nf_instance; + } nf_type_array[OGS_SBI_MAX_NUM_OF_NF_TYPE], + service_type_array[OGS_SBI_MAX_NUM_OF_SERVICE_TYPE]; ogs_list_t xact_list; @@ -291,6 +290,11 @@ void ogs_sbi_nf_instance_clear(ogs_sbi_nf_instance_t *nf_instance); void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance); void ogs_sbi_nf_instance_remove_all(void); ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find(char *id); +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_discovery_param( + OpenAPI_nf_type_e nf_type, + ogs_sbi_discovery_option_t *discovery_option); +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_service_type( + ogs_sbi_service_type_e service_type); bool ogs_sbi_nf_instance_maximum_number_is_reached(void); ogs_sbi_nf_service_t *ogs_sbi_nf_service_add( @@ -328,25 +332,17 @@ void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance); OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void); -#define OGS_SBI_NF_INSTANCE(__sBIObject, __sERVICEType) \ - (((__sBIObject)->nf_instance_array)[__sERVICEType].nf_instance) - -#define OGS_SBI_SETUP_NF_INSTANCE(__sBIObject, __sERVICEType, __nFInstance) \ +#define OGS_SBI_SETUP_NF_INSTANCE(__cTX, __nFInstance) \ do { \ - ogs_assert((__sBIObject)); \ - ogs_assert((__sERVICEType)); \ - ogs_assert((__nFInstance)); \ + ogs_assert(__nFInstance); \ \ - if (OGS_SBI_NF_INSTANCE((__sBIObject), (__sERVICEType))) { \ - ogs_warn("UE %s-EndPoint updated [%s]", \ - ogs_sbi_service_type_to_name((__sERVICEType)), \ - (__nFInstance)->id); \ - ogs_sbi_nf_instance_remove( \ - OGS_SBI_NF_INSTANCE((__sBIObject), (__sERVICEType))); \ + if ((__cTX).nf_instance) { \ + ogs_warn("NF Instance updated [%s]", (__nFInstance)->id); \ + ogs_sbi_nf_instance_remove((__cTX).nf_instance); \ } \ \ OGS_OBJECT_REF(__nFInstance); \ - OGS_SBI_NF_INSTANCE((__sBIObject), (__sERVICEType)) = (__nFInstance); \ + ((__cTX).nf_instance) = (__nFInstance); \ } while(0) bool ogs_sbi_discovery_param_is_matched( @@ -358,11 +354,6 @@ bool ogs_sbi_discovery_option_is_matched( ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_discovery_option_t *discovery_option); -void ogs_sbi_select_nf( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - ogs_sbi_discovery_option_t *discovery_option); - void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object); ogs_sbi_xact_t *ogs_sbi_xact_add( diff --git a/lib/sbi/nf-sm.c b/lib/sbi/nf-sm.c index 8f552598d..79b999b73 100644 --- a/lib/sbi/nf-sm.c +++ b/lib/sbi/nf-sm.c @@ -25,13 +25,6 @@ void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) ogs_assert(nf_instance); - if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { - } else if (NF_INSTANCE_ID_IS_OTHERS(nf_instance->id)) { - } else { - ogs_fatal("FSM is available in NRF or OTHERS"); - ogs_assert_if_reached(); - } - memset(&e, 0, sizeof(e)); e.sbi.data = nf_instance; diff --git a/lib/sbi/nnrf-build.c b/lib/sbi/nnrf-build.c index e77fc0a2b..380c5f9fe 100644 --- a/lib/sbi/nnrf-build.c +++ b/lib/sbi/nnrf-build.c @@ -93,9 +93,9 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile( NFProfile = ogs_calloc(1, sizeof(*NFProfile)); ogs_expect_or_return_val(NFProfile, NULL); - NFProfile->nf_instance_id = nf_instance->id; - NFProfile->nf_type = nf_instance->nf_type; - NFProfile->nf_status = nf_instance->nf_status; + NFProfile->nf_instance_id = nf_instance->id; + NFProfile->nf_type = nf_instance->nf_type; + NFProfile->nf_status = nf_instance->nf_status; ogs_trace("[%s] ogs_nnrf_nfm_build_nf_profile()", nf_instance->id); @@ -806,7 +806,7 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe( ogs_expect_or_return_val( SubscriptionData->nf_status_notification_uri, NULL); - SubscriptionData->req_nf_type = subscription->req_nf_type; + SubscriptionData->req_nf_type = subscription->req_nf_type; SubscriptionData->req_nf_instance_id = subscription->req_nf_instance_id; OGS_SBI_FEATURES_SET(subscription->requester_features, @@ -874,17 +874,14 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_profile_retrieve(char *nf_instance_id) } ogs_sbi_request_t *ogs_nnrf_disc_build_discover( - ogs_sbi_service_type_e service_type, + OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option) { ogs_sbi_message_t message; ogs_sbi_request_t *request = NULL; - OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - ogs_assert(service_type); - target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); ogs_assert(ogs_sbi_self()->nf_instance); diff --git a/lib/sbi/nnrf-build.h b/lib/sbi/nnrf-build.h index afd8a7079..770af4d39 100644 --- a/lib/sbi/nnrf-build.h +++ b/lib/sbi/nnrf-build.h @@ -41,7 +41,7 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_unsubscribe( ogs_sbi_request_t *ogs_nnrf_nfm_build_profile_retrieve(char *nf_instance_id); ogs_sbi_request_t *ogs_nnrf_disc_build_discover( - ogs_sbi_service_type_e service_type, + OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option); #ifdef __cplusplus diff --git a/lib/sbi/path.c b/lib/sbi/path.c index 2f09ec528..4d92d7992 100644 --- a/lib/sbi/path.c +++ b/lib/sbi/path.c @@ -76,6 +76,60 @@ bool ogs_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, return true; } +bool ogs_sbi_discover_only( + ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_sbi_object_t *sbi_object = NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; + ogs_sbi_discovery_option_t *discovery_option = NULL; + + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + + sbi_object = xact->sbi_object; + ogs_assert(sbi_object); + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); + ogs_assert(client_cb); + + discovery_option = xact->discovery_option; + + /* NRF NF-Instance */ + nf_instance = sbi_object->nf_type_array[OpenAPI_nf_type_NRF].nf_instance; + if (!nf_instance) { + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + OpenAPI_nf_type_NRF, NULL); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->nf_type_array[OpenAPI_nf_type_NRF], nf_instance); + } + + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + ogs_sbi_request_t *request = NULL; + + ogs_warn("Try to discover [%s]", + ogs_sbi_service_type_to_name(service_type)); + + request = ogs_nnrf_disc_build_discover( + target_nf_type, discovery_option); + ogs_expect_or_return_val(request, false); + + client = nf_instance->client; + ogs_assert(client); + + return ogs_sbi_client_send_request(client, client_cb, request, xact); + } + + ogs_error("Cannot discover [%s]", + ogs_sbi_service_type_to_name(service_type)); + + return false; +} + bool ogs_sbi_discover_and_send( ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb) { @@ -85,45 +139,33 @@ bool ogs_sbi_discover_and_send( ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + sbi_object = xact->sbi_object; ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); ogs_assert(client_cb); discovery_option = xact->discovery_option; /* Target NF-Instance */ - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); + nf_instance = sbi_object->service_type_array[service_type].nf_instance; if (!nf_instance) { - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); } if (nf_instance) { return ogs_sbi_send_request(nf_instance, client_cb, xact); } - /* NRF NF-Instance */ - nf_instance = OGS_SBI_NF_INSTANCE( - sbi_object, OGS_SBI_SERVICE_TYPE_NNRF_DISC); - if (!nf_instance) { - ogs_sbi_select_nf(sbi_object, OGS_SBI_SERVICE_TYPE_NNRF_DISC, NULL); - nf_instance = OGS_SBI_NF_INSTANCE( - sbi_object, OGS_SBI_SERVICE_TYPE_NNRF_DISC); - } - - if (nf_instance) { - ogs_warn("Try to discover [%s]", - ogs_sbi_service_type_to_name(service_type)); - return ogs_nnrf_disc_send_nf_discover( - nf_instance, service_type, discovery_option, xact); - } - - ogs_error("Cannot discover [%s]", - ogs_sbi_service_type_to_name(service_type)); - - return false; + return ogs_sbi_discover_only(xact, client_cb); } bool ogs_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance) @@ -236,7 +278,7 @@ bool ogs_nnrf_nfm_send_nf_status_unsubscribe( bool ogs_nnrf_disc_send_nf_discover( ogs_sbi_nf_instance_t *nf_instance, - ogs_sbi_service_type_e service_type, + OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option, void *data) { @@ -244,8 +286,9 @@ bool ogs_nnrf_disc_send_nf_discover( ogs_sbi_request_t *request = NULL; ogs_assert(nf_instance); + ogs_assert(target_nf_type); - request = ogs_nnrf_disc_build_discover(service_type, discovery_option); + request = ogs_nnrf_disc_build_discover(target_nf_type, discovery_option); ogs_expect_or_return_val(request, false); client = nf_instance->client; diff --git a/lib/sbi/path.h b/lib/sbi/path.h index bdf7f77bb..ec65a486c 100644 --- a/lib/sbi/path.h +++ b/lib/sbi/path.h @@ -28,6 +28,8 @@ extern "C" { bool ogs_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_client_cb_f client_cb, ogs_sbi_xact_t *xact); +bool ogs_sbi_discover_only( + ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb); bool ogs_sbi_discover_and_send( ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb); @@ -45,10 +47,11 @@ bool ogs_nnrf_nfm_send_nf_status_unsubscribe( bool ogs_nnrf_disc_send_nf_discover( ogs_sbi_nf_instance_t *nf_instance, - ogs_sbi_service_type_e service_type, + OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option, void *data); + #define ogs_sbi_send_http_status_no_content(__sTREAM) \ ogs_sbi_send_response(__sTREAM, OGS_SBI_HTTP_STATUS_NO_CONTENT) bool ogs_sbi_send_response(ogs_sbi_stream_t *stream, int status); diff --git a/src/amf/context.c b/src/amf/context.c index 1f47f0b1c..3b82f7f88 100644 --- a/src/amf/context.c +++ b/src/amf/context.c @@ -1799,7 +1799,11 @@ void amf_sbi_select_nf( switch(sbi_object->type) { case OGS_SBI_OBJ_UE_TYPE: - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); break; case OGS_SBI_OBJ_SESS_TYPE: sess = (amf_sess_t *)sbi_object; @@ -1818,7 +1822,8 @@ void amf_sbi_select_nf( continue; } - OGS_SBI_SETUP_NF_INSTANCE(sbi_object, service_type, nf_instance); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); break; } break; diff --git a/src/amf/gmm-handler.c b/src/amf/gmm-handler.c index 977461b3c..1665801d3 100644 --- a/src/amf/gmm-handler.c +++ b/src/amf/gmm-handler.c @@ -1064,30 +1064,20 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_discovery_option_t *discovery_option = NULL; + ogs_sbi_service_type_e service_type = + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION; - discovery_option = ogs_sbi_discovery_option_new(); - ogs_assert(discovery_option); - ogs_sbi_discovery_option_add_service_names( - discovery_option, - (char *)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); - - nf_instance = OGS_SBI_NF_INSTANCE( - &sess->sbi, - OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION); + nf_instance = sess->sbi. + service_type_array[service_type].nf_instance; if (!nf_instance) { - amf_sbi_select_nf( - &sess->sbi, - OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, - discovery_option); - nf_instance = OGS_SBI_NF_INSTANCE( - &sess->sbi, - OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION); + nf_instance = + ogs_sbi_nf_instance_find_by_service_type(service_type); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sess->sbi.service_type_array[service_type], + nf_instance); } - if (discovery_option) - ogs_sbi_discovery_option_free(discovery_option); - if (nf_instance) { ogs_assert(true == amf_sess_sbi_discover_and_send( diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c index addbe7b4d..27971dbb3 100644 --- a/src/amf/nnrf-handler.c +++ b/src/amf/nnrf-handler.c @@ -25,6 +25,7 @@ void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; @@ -50,5 +51,48 @@ void amf_nnrf_handle_nf_discover( amf_sbi_select_nf(sbi_object, service_type, discovery_option); - ogs_expect(true == amf_sbi_send_request(sbi_object, service_type, xact)); + nf_instance = sbi_object->service_type_array[service_type].nf_instance; + if (!nf_instance) { + amf_ue_t *amf_ue = NULL; + amf_sess_t *sess = NULL; + + ogs_assert(sbi_object->type > OGS_SBI_OBJ_BASE && + sbi_object->type < OGS_SBI_OBJ_TOP); + switch(sbi_object->type) { + case OGS_SBI_OBJ_UE_TYPE: + amf_ue = (amf_ue_t *)sbi_object; + ogs_assert(amf_ue); + ogs_error("[%s] (NF discover) No [%s]", amf_ue->suci, + ogs_sbi_service_type_to_name(service_type)); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi(amf_ue, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); + break; + case OGS_SBI_OBJ_SESS_TYPE: + sess = (amf_sess_t *)sbi_object; + ogs_assert(sess); + ogs_error("[%d:%d] (NF discover) No [%s]", sess->psi, sess->pti, + ogs_sbi_service_type_to_name(service_type)); + if (sess->payload_container_type) { + ogs_assert(OGS_OK == + nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, + AMF_NAS_BACKOFF_TIME)); + } else { + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_transport, + NGAP_CauseTransport_transport_resource_unavailable)); + } + break; + default: + ogs_fatal("(NF discover) Not implemented [%s:%d]", + ogs_sbi_service_type_to_name(service_type), sbi_object->type); + ogs_assert_if_reached(); + } + + return; + } + + ogs_expect(true == amf_sbi_send_request(nf_instance, xact)); } diff --git a/src/amf/nsmf-build.c b/src/amf/nsmf-build.c index 60062ffa3..7753a142c 100644 --- a/src/amf/nsmf-build.c +++ b/src/amf/nsmf-build.c @@ -120,9 +120,8 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_create_sm_context( SmContextCreateData.ue_time_zone = ogs_sbi_timezone_string(ogs_timezone()); ogs_expect_or_return_val(SmContextCreateData.ue_time_zone, NULL); - pcf_nf_instance = OGS_SBI_NF_INSTANCE( - &amf_ue->sbi, - OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL); + pcf_nf_instance = amf_ue->sbi.service_type_array[ + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL].nf_instance; ogs_expect_or_return_val(pcf_nf_instance, NULL); SmContextCreateData.pcf_id = pcf_nf_instance->id; diff --git a/src/amf/sbi-path.c b/src/amf/sbi-path.c index d00372e03..1fc2ad15d 100644 --- a/src/amf/sbi-path.c +++ b/src/amf/sbi-path.c @@ -93,6 +93,7 @@ int amf_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AMF); @@ -108,17 +109,6 @@ int amf_sbi_open(void) ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); } - /* Initialize SCP NF Instance */ - nf_instance = ogs_sbi_self()->scp_instance; - if (nf_instance) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to SCP */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - } - /* Initialize NRF NF Instance */ nf_instance = ogs_sbi_self()->nrf_instance; if (nf_instance) { @@ -146,60 +136,11 @@ void amf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool amf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool amf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - ogs_assert(sbi_object); + ogs_assert(nf_instance); ogs_assert(data); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - amf_ue_t *amf_ue = NULL; - amf_sess_t *sess = NULL; - - ogs_assert(sbi_object->type > OGS_SBI_OBJ_BASE && - sbi_object->type < OGS_SBI_OBJ_TOP); - switch(sbi_object->type) { - case OGS_SBI_OBJ_UE_TYPE: - amf_ue = (amf_ue_t *)sbi_object; - ogs_assert(amf_ue); - ogs_error("[%s] (NF discover) No [%s]", amf_ue->suci, - ogs_sbi_service_type_to_name(service_type)); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi(amf_ue, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); - break; - case OGS_SBI_OBJ_SESS_TYPE: - sess = (amf_sess_t *)sbi_object; - ogs_assert(sess); - ogs_error("[%d:%d] (NF discover) No [%s]", sess->psi, sess->pti, - ogs_sbi_service_type_to_name(service_type)); - if (sess->payload_container_type) { - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); - } else { - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_transport, - NGAP_CauseTransport_transport_resource_unavailable)); - } - break; - default: - ogs_fatal("(NF discover) Not implemented [%s:%d]", - ogs_sbi_service_type_to_name(service_type), sbi_object->type); - ogs_assert_if_reached(); - } - - return false; - } - return ogs_sbi_send_request(nf_instance, client_cb, data); } @@ -349,7 +290,7 @@ static int client_discover_cb( amf_sbi_select_nf(&sess->sbi, service_type, discovery_option); - if (!OGS_SBI_NF_INSTANCE(&sess->sbi, service_type)) { + if (!sess->sbi.service_type_array[service_type].nf_instance) { ogs_error("[%s:%d] (NF discover) No [%s]", amf_ue->supi, sess->psi, ogs_sbi_service_type_to_name(service_type)); diff --git a/src/amf/sbi-path.h b/src/amf/sbi-path.h index d60b003a8..ba01a3136 100644 --- a/src/amf/sbi-path.h +++ b/src/amf/sbi-path.h @@ -34,10 +34,7 @@ extern "C" { int amf_sbi_open(void); void amf_sbi_close(void); -bool amf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool amf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool amf_ue_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, diff --git a/src/ausf/nnrf-handler.c b/src/ausf/nnrf-handler.c index 09e67ecf6..4e3324341 100644 --- a/src/ausf/nnrf-handler.c +++ b/src/ausf/nnrf-handler.c @@ -23,10 +23,12 @@ void ausf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; ogs_assert(recvmsg); @@ -35,6 +37,8 @@ void ausf_nnrf_handle_nf_discover( ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -46,7 +50,16 @@ void ausf_nnrf_handle_nf_discover( ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + ogs_sbi_service_type_to_name(service_type)); + return; + } - ogs_expect(true == ausf_sbi_send_request(sbi_object, service_type, xact)); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); + + ogs_expect(true == ausf_sbi_send_request(nf_instance, xact)); } diff --git a/src/ausf/sbi-path.c b/src/ausf/sbi-path.c index 949d90e67..6bc2db463 100644 --- a/src/ausf/sbi-path.c +++ b/src/ausf/sbi-path.c @@ -86,6 +86,7 @@ int ausf_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AUSF); @@ -128,21 +129,9 @@ void ausf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool ausf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool ausf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - ogs_sbi_service_type_to_name(service_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } diff --git a/src/ausf/sbi-path.h b/src/ausf/sbi-path.h index ca526603c..c2c257f41 100644 --- a/src/ausf/sbi-path.h +++ b/src/ausf/sbi-path.h @@ -29,10 +29,7 @@ extern "C" { int ausf_sbi_open(void); void ausf_sbi_close(void); -bool ausf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool ausf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool ausf_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, diff --git a/src/bsf/nnrf-handler.c b/src/bsf/nnrf-handler.c index b7e018d4e..260f08efc 100644 --- a/src/bsf/nnrf-handler.c +++ b/src/bsf/nnrf-handler.c @@ -23,10 +23,12 @@ void bsf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; ogs_assert(recvmsg); @@ -35,6 +37,8 @@ void bsf_nnrf_handle_nf_discover( ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -46,7 +50,16 @@ void bsf_nnrf_handle_nf_discover( ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + ogs_sbi_service_type_to_name(service_type)); + return; + } - ogs_expect(true == bsf_sbi_send_request(sbi_object, service_type, xact)); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); + + ogs_expect(true == bsf_sbi_send_request(nf_instance, xact)); } diff --git a/src/bsf/sbi-path.c b/src/bsf/sbi-path.c index f8e411ea7..1679441e4 100644 --- a/src/bsf/sbi-path.c +++ b/src/bsf/sbi-path.c @@ -86,6 +86,7 @@ int bsf_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_BSF); @@ -128,21 +129,9 @@ void bsf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool bsf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool bsf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - ogs_sbi_service_type_to_name(service_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } diff --git a/src/bsf/sbi-path.h b/src/bsf/sbi-path.h index 51a73060c..4bffe075d 100644 --- a/src/bsf/sbi-path.h +++ b/src/bsf/sbi-path.h @@ -29,10 +29,7 @@ extern "C" { int bsf_sbi_open(void); void bsf_sbi_close(void); -bool bsf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool bsf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool bsf_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, diff --git a/src/mme/mme-fd-path.c b/src/mme/mme-fd-path.c index b5874459c..a9f39fa41 100644 --- a/src/mme/mme-fd-path.c +++ b/src/mme/mme-fd-path.c @@ -799,7 +799,7 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg) ogs_assert(ret == 0); mme_ue->network_access_mode = hdr->avp_value->i32; } else { - mme_ue->network_access_mode = 0; + mme_ue->network_access_mode = 0; ogs_warn("no subscribed Network-Access-Mode, defaulting to PACKET_AND_CIRCUIT (0)"); } @@ -1785,48 +1785,48 @@ int mme_fd_init(void) mme_self()->diam_conf_path, mme_self()->diam_config); ogs_assert(ret == 0); - /* Install objects definitions for this application */ - ret = ogs_diam_s6a_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_s6a_init(); ogs_assert(ret == OGS_OK); /* Create handler for sessions */ - ret = fd_sess_handler_create(&mme_s6a_reg, &state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&mme_s6a_reg, &state_cleanup, NULL, NULL); ogs_assert(ret == 0); - /* Specific handler for Cancel-Location-Request */ - data.command = ogs_diam_s6a_cmd_clr; - ret = fd_disp_register(mme_ogs_diam_s6a_clr_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for Cancel-Location-Request */ + data.command = ogs_diam_s6a_cmd_clr; + ret = fd_disp_register(mme_ogs_diam_s6a_clr_cb, DISP_HOW_CC, &data, NULL, &hdl_s6a_clr); ogs_assert(ret == 0); - /* Specific handler for Insert-Subscriber-Data-Request */ - data.command = ogs_diam_s6a_cmd_idr; - ret = fd_disp_register(mme_ogs_diam_s6a_idr_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for Insert-Subscriber-Data-Request */ + data.command = ogs_diam_s6a_cmd_idr; + ret = fd_disp_register(mme_ogs_diam_s6a_idr_cb, DISP_HOW_CC, &data, NULL, &hdl_s6a_idr); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_s6a_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_s6a_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); ret = ogs_diam_start(); ogs_assert(ret == 0); - - return 0; + + return 0; } void mme_fd_final(void) { int ret; - ret = fd_sess_handler_destroy(&mme_s6a_reg, NULL); + ret = fd_sess_handler_destroy(&mme_s6a_reg, NULL); ogs_assert(ret == OGS_OK); if (hdl_s6a_clr) - (void) fd_disp_unregister(&hdl_s6a_clr, NULL); + (void) fd_disp_unregister(&hdl_s6a_clr, NULL); if (hdl_s6a_idr) - (void) fd_disp_unregister(&hdl_s6a_idr, NULL); + (void) fd_disp_unregister(&hdl_s6a_idr, NULL); ogs_diam_final(); } diff --git a/src/nrf/sbi-path.c b/src/nrf/sbi-path.c index 5d0bc7a00..712fcb472 100644 --- a/src/nrf/sbi-path.c +++ b/src/nrf/sbi-path.c @@ -80,19 +80,6 @@ static int client_notify_cb( int nrf_sbi_open(void) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - /* Initialize SCP NF Instance */ - nf_instance = ogs_sbi_self()->scp_instance; - if (nf_instance) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to SCP */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_notify_cb; - } - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; diff --git a/src/nssf/sbi-path.c b/src/nssf/sbi-path.c index 591e5a813..3cf175756 100644 --- a/src/nssf/sbi-path.c +++ b/src/nssf/sbi-path.c @@ -82,6 +82,7 @@ int nssf_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_NSSF); diff --git a/src/pcf/nbsf-build.c b/src/pcf/nbsf-build.c index 05755e84c..5366e981a 100644 --- a/src/pcf/nbsf-build.c +++ b/src/pcf/nbsf-build.c @@ -41,6 +41,9 @@ ogs_sbi_request_t *pcf_nbsf_management_build_register( pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); + nf_instance = data; + ogs_assert(nf_instance); + memset(&message, 0, sizeof(message)); message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT; @@ -59,9 +62,8 @@ ogs_sbi_request_t *pcf_nbsf_management_build_register( ogs_expect_or_return_val(sess->dnn, NULL); PcfBinding.dnn = sess->dnn; - nf_instance = ogs_sbi_self()->nf_instance; - ogs_expect_or_return_val(nf_instance, NULL); - nf_service = ogs_list_first(&nf_instance->nf_service_list); + nf_service = ogs_sbi_nf_service_find_by_name( + nf_instance, (char *)OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION); ogs_expect_or_return_val(nf_service, NULL); if (nf_service->fqdn) diff --git a/src/pcf/nnrf-handler.c b/src/pcf/nnrf-handler.c index d06183452..18af3bf5c 100644 --- a/src/pcf/nnrf-handler.c +++ b/src/pcf/nnrf-handler.c @@ -23,10 +23,16 @@ void pcf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + ogs_sbi_stream_t *stream = NULL; + pcf_ue_t *pcf_ue = NULL; + pcf_sess_t *sess = NULL; + + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; ogs_assert(recvmsg); @@ -35,8 +41,11 @@ void pcf_nnrf_handle_nf_discover( ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); discovery_option = xact->discovery_option; + stream = xact->assoc_stream; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -44,9 +53,50 @@ void pcf_nnrf_handle_nf_discover( return; } + if (sbi_object->type == OGS_SBI_OBJ_UE_TYPE) { + pcf_ue = (pcf_ue_t *)sbi_object; + ogs_assert(pcf_ue); + } else if (sbi_object->type == OGS_SBI_OBJ_SESS_TYPE) { + sess = (pcf_sess_t *)sbi_object; + ogs_assert(sess); + pcf_ue = sess->pcf_ue; + ogs_assert(pcf_ue); + } else { + ogs_fatal("(NF discover) Not implemented [%s:%d]", + ogs_sbi_service_type_to_name(service_type), sbi_object->type); + ogs_assert_if_reached(); + } + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("[%s:%d] (NF discover) No [%s]", + pcf_ue ? pcf_ue->supi : "Unknown", + sess ? sess->psi : 0, + ogs_sbi_service_type_to_name(service_type)); + return; + } - ogs_expect(true == pcf_sbi_send_request(sbi_object, service_type, xact)); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); + + switch (service_type) { + case OGS_SBI_SERVICE_TYPE_NPCF_POLICYAUTHORIZATION: + ogs_sbi_xact_remove(xact); + + ogs_assert(sess); + ogs_assert(stream); + ogs_assert(true == + pcf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL, + pcf_nbsf_management_build_register, + sess, stream, nf_instance)); + break; + default: + ogs_assert(xact->request); + ogs_expect(true == pcf_sbi_send_request(nf_instance, xact)); + break; + } } diff --git a/src/pcf/nudr-handler.c b/src/pcf/nudr-handler.c index c0b6abdff..e50d61bbe 100644 --- a/src/pcf/nudr-handler.c +++ b/src/pcf/nudr-handler.c @@ -186,6 +186,9 @@ bool pcf_nudr_dr_handle_query_sm_data( SWITCH(recvmsg->h.resource.component[3]) CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; + if (!recvmsg->SmPolicyData) { strerror = ogs_msprintf("[%s:%d] No SmPolicyData", pcf_ue->supi, sess->psi); @@ -193,10 +196,28 @@ bool pcf_nudr_dr_handle_query_sm_data( goto cleanup; } - ogs_assert(true == - pcf_sess_sbi_discover_and_send( - OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL, - pcf_nbsf_management_build_register, sess, stream, NULL)); + service_type = OGS_SBI_SERVICE_TYPE_NPCF_POLICYAUTHORIZATION; + + nf_instance = sess->sbi.service_type_array[service_type].nf_instance; + if (!nf_instance) { + nf_instance = + ogs_sbi_nf_instance_find_by_service_type(service_type); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sess->sbi.service_type_array[service_type], + nf_instance); + } + + if (nf_instance) { + ogs_assert(true == + pcf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL, + pcf_nbsf_management_build_register, + sess, stream, nf_instance)); + } else { + ogs_expect(true == + pcf_sess_sbi_discover_only(sess, stream, service_type)); + } return true; diff --git a/src/pcf/sbi-path.c b/src/pcf/sbi-path.c index 230e875cf..92ce928d8 100644 --- a/src/pcf/sbi-path.c +++ b/src/pcf/sbi-path.c @@ -87,6 +87,7 @@ int pcf_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_PCF); @@ -156,43 +157,9 @@ void pcf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool pcf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool pcf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - pcf_ue_t *pcf_ue = NULL; - pcf_sess_t *sess = NULL; - - ogs_assert(sbi_object->type > OGS_SBI_OBJ_BASE && - sbi_object->type < OGS_SBI_OBJ_TOP); - switch(sbi_object->type) { - case OGS_SBI_OBJ_UE_TYPE: - pcf_ue = (pcf_ue_t *)sbi_object; - ogs_assert(pcf_ue); - ogs_error("[%s] (NF discover) No [%s]", pcf_ue->supi, - ogs_sbi_service_type_to_name(service_type)); - break; - case OGS_SBI_OBJ_SESS_TYPE: - sess = (pcf_sess_t *)sbi_object; - ogs_assert(sess); - ogs_error("[%d] (NF discover) No [%s]", sess->psi, - ogs_sbi_service_type_to_name(service_type)); - break; - default: - ogs_fatal("(NF discover) Not implemented [%s:%d]", - ogs_sbi_service_type_to_name(service_type), sbi_object->type); - ogs_assert_if_reached(); - } - - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } @@ -247,6 +214,23 @@ bool pcf_ue_sbi_discover_and_send( return true; } +bool pcf_sess_sbi_discover_only( + pcf_sess_t *sess, ogs_sbi_stream_t *stream, + ogs_sbi_service_type_e service_type) +{ + ogs_sbi_xact_t *xact = NULL; + + ogs_assert(sess); + ogs_assert(service_type); + + xact = ogs_sbi_xact_add(&sess->sbi, service_type, NULL, NULL, NULL, NULL); + ogs_expect_or_return_val(xact, false); + + xact->assoc_stream = stream; + + return ogs_sbi_discover_only(xact, client_cb); +} + bool pcf_sess_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, diff --git a/src/pcf/sbi-path.h b/src/pcf/sbi-path.h index 74caac230..c44bdf456 100644 --- a/src/pcf/sbi-path.h +++ b/src/pcf/sbi-path.h @@ -33,10 +33,7 @@ extern "C" { int pcf_sbi_open(void); void pcf_sbi_close(void); -bool pcf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool pcf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool pcf_ue_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, @@ -47,6 +44,9 @@ bool pcf_sess_sbi_discover_and_send( ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data), pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data); +bool pcf_sess_sbi_discover_only( + pcf_sess_t *sess, ogs_sbi_stream_t *stream, + ogs_sbi_service_type_e service_type); bool pcf_sbi_send_am_policy_control_notify(pcf_ue_t *pcf_ue); bool pcf_sbi_send_smpolicycontrol_update_notify( diff --git a/src/scp/nnrf-handler.c b/src/scp/nnrf-handler.c index 854153aa6..5e7c6bc59 100644 --- a/src/scp/nnrf-handler.c +++ b/src/scp/nnrf-handler.c @@ -23,10 +23,12 @@ void scp_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; ogs_assert(recvmsg); @@ -35,6 +37,8 @@ void scp_nnrf_handle_nf_discover( ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -46,7 +50,16 @@ void scp_nnrf_handle_nf_discover( ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + ogs_sbi_service_type_to_name(service_type)); + return; + } - scp_sbi_send_request(sbi_object, service_type, xact); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); + + ogs_expect(true == scp_sbi_send_request(nf_instance, xact)); } diff --git a/src/scp/sbi-path.c b/src/scp/sbi-path.c index c6cdc33db..ef7195eee 100644 --- a/src/scp/sbi-path.c +++ b/src/scp/sbi-path.c @@ -43,21 +43,11 @@ int scp_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_SCP); - /* Initialize SCP NF Instance */ - nf_instance = ogs_sbi_self()->scp_instance; - if (nf_instance) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to SCP */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - } - /* Initialize NRF NF Instance */ nf_instance = ogs_sbi_self()->nrf_instance; if (nf_instance) { @@ -364,21 +354,9 @@ static int client_cb(int status, ogs_sbi_response_t *response, void *data) return OGS_OK; } -bool scp_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool scp_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - ogs_sbi_service_type_to_name(service_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } diff --git a/src/scp/sbi-path.h b/src/scp/sbi-path.h index 7db260ba9..388979876 100644 --- a/src/scp/sbi-path.h +++ b/src/scp/sbi-path.h @@ -29,10 +29,7 @@ extern "C" { int scp_sbi_open(void); void scp_sbi_close(void); -bool scp_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool scp_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool scp_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, diff --git a/src/smf/nnrf-handler.c b/src/smf/nnrf-handler.c index 8f5c3f61f..e47fe2d17 100644 --- a/src/smf/nnrf-handler.c +++ b/src/smf/nnrf-handler.c @@ -23,10 +23,12 @@ void smf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; ogs_assert(recvmsg); @@ -35,6 +37,8 @@ void smf_nnrf_handle_nf_discover( ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -46,7 +50,16 @@ void smf_nnrf_handle_nf_discover( ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + ogs_sbi_service_type_to_name(service_type)); + return; + } - ogs_expect(true == smf_sbi_send_request(sbi_object, service_type, xact)); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); + + ogs_expect(true == smf_sbi_send_request(nf_instance, xact)); } diff --git a/src/smf/sbi-path.c b/src/smf/sbi-path.c index 8f806d4f1..fc36d0dcc 100644 --- a/src/smf/sbi-path.c +++ b/src/smf/sbi-path.c @@ -91,6 +91,7 @@ int smf_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_SMF); @@ -133,21 +134,9 @@ void smf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool smf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool smf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - ogs_sbi_service_type_to_name(service_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } diff --git a/src/smf/sbi-path.h b/src/smf/sbi-path.h index 61942871f..89c2337a6 100644 --- a/src/smf/sbi-path.h +++ b/src/smf/sbi-path.h @@ -33,10 +33,7 @@ extern "C" { int smf_sbi_open(void); void smf_sbi_close(void); -bool smf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool smf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool smf_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, diff --git a/src/udm/nnrf-handler.c b/src/udm/nnrf-handler.c index 53ed07df3..be1ae9242 100644 --- a/src/udm/nnrf-handler.c +++ b/src/udm/nnrf-handler.c @@ -23,10 +23,12 @@ void udm_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; ogs_assert(recvmsg); @@ -35,6 +37,8 @@ void udm_nnrf_handle_nf_discover( ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -46,7 +50,16 @@ void udm_nnrf_handle_nf_discover( ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + ogs_sbi_service_type_to_name(service_type)); + return; + } - ogs_expect(true == udm_sbi_send_request(sbi_object, service_type, xact)); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); + + ogs_expect(true == udm_sbi_send_request(nf_instance, xact)); } diff --git a/src/udm/sbi-path.c b/src/udm/sbi-path.c index d01f05423..22086178e 100644 --- a/src/udm/sbi-path.c +++ b/src/udm/sbi-path.c @@ -86,6 +86,7 @@ int udm_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_UDM); @@ -149,21 +150,9 @@ void udm_sbi_close(void) ogs_sbi_server_stop_all(); } -bool udm_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool udm_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - ogs_sbi_service_type_to_name(service_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } diff --git a/src/udm/sbi-path.h b/src/udm/sbi-path.h index 50f6ef425..b92b339d0 100644 --- a/src/udm/sbi-path.h +++ b/src/udm/sbi-path.h @@ -29,10 +29,7 @@ extern "C" { int udm_sbi_open(void); void udm_sbi_close(void); -bool udm_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool udm_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool udm_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, diff --git a/src/udr/sbi-path.c b/src/udr/sbi-path.c index 3de425113..c0a9f230f 100644 --- a/src/udr/sbi-path.c +++ b/src/udr/sbi-path.c @@ -82,6 +82,7 @@ int udr_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_UDR); diff --git a/tests/af/af-sm.c b/tests/af/af-sm.c index bb50cee73..c1b935540 100644 --- a/tests/af/af-sm.c +++ b/tests/af/af-sm.c @@ -450,7 +450,7 @@ void af_state_operational(ogs_fsm_t *s, af_event_t *e) } break; - case AF_EVT_SBI_LOCAL: + case AF_EVENT_SBI_LOCAL: ogs_assert(e); switch(e->local_id) { diff --git a/tests/af/event.c b/tests/af/event.c index 4274047f4..7365d96cb 100644 --- a/tests/af/event.c +++ b/tests/af/event.c @@ -50,8 +50,8 @@ const char *af_event_get_name(af_event_t *e) case OGS_EVENT_SBI_TIMER: return OGS_EVENT_NAME_SBI_TIMER; - case AF_EVT_SBI_LOCAL: - return "AF_EVT_SBI_LOCAL"; + case AF_EVENT_SBI_LOCAL: + return "AF_EVENT_SBI_LOCAL"; default: break; diff --git a/tests/af/event.h b/tests/af/event.h index e392b11e2..fd54c66e7 100644 --- a/tests/af/event.h +++ b/tests/af/event.h @@ -29,11 +29,11 @@ extern "C" { typedef struct af_sess_s af_sess_t; typedef enum { - AF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, + AF_EVENT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, - AF_EVT_SBI_LOCAL, + AF_EVENT_SBI_LOCAL, - AF_EVT_TOP, + MAX_NUM_OF_AF_EVENT, } af_event_e; diff --git a/tests/af/local.c b/tests/af/local.c index 23eae4c01..32ffbddce 100644 --- a/tests/af/local.c +++ b/tests/af/local.c @@ -39,7 +39,7 @@ void af_local_discover_and_send( int rv; af_event_t *e = NULL; - e = af_event_new(AF_EVT_SBI_LOCAL); + e = af_event_new(AF_EVENT_SBI_LOCAL); ogs_assert(e); e->local_id = AF_LOCAL_DISCOVER_AND_SEND; @@ -66,7 +66,7 @@ void af_local_send_to_pcf( int rv; af_event_t *e = NULL; - e = af_event_new(AF_EVT_SBI_LOCAL); + e = af_event_new(AF_EVENT_SBI_LOCAL); ogs_assert(e); e->local_id = AF_LOCAL_SEND_TO_PCF; diff --git a/tests/af/nnrf-handler.c b/tests/af/nnrf-handler.c index 6c0c1b211..6d4b79ab3 100644 --- a/tests/af/nnrf-handler.c +++ b/tests/af/nnrf-handler.c @@ -23,10 +23,12 @@ void af_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; ogs_assert(recvmsg); @@ -35,6 +37,8 @@ void af_nnrf_handle_nf_discover( ogs_assert(sbi_object); service_type = xact->service_type; ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -46,7 +50,16 @@ void af_nnrf_handle_nf_discover( ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_sbi_select_nf(sbi_object, service_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + ogs_sbi_service_type_to_name(service_type)); + return; + } - ogs_expect(true == af_sbi_send_request(sbi_object, service_type, xact)); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_array[service_type], nf_instance); + + ogs_expect(true == af_sbi_send_request(nf_instance, xact)); } diff --git a/tests/af/sbi-path.c b/tests/af/sbi-path.c index c548bd1d6..d22c6a7ef 100644 --- a/tests/af/sbi-path.c +++ b/tests/af/sbi-path.c @@ -85,6 +85,7 @@ int af_sbi_open(void) /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AF); @@ -116,21 +117,9 @@ void af_sbi_close(void) ogs_sbi_server_stop_all(); } -bool af_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data) +bool af_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(service_type); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - ogs_sbi_service_type_to_name(service_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } diff --git a/tests/af/sbi-path.h b/tests/af/sbi-path.h index ac85a008a..96bc52fd4 100644 --- a/tests/af/sbi-path.h +++ b/tests/af/sbi-path.h @@ -30,10 +30,7 @@ extern "C" { int af_sbi_open(void); void af_sbi_close(void); -bool af_sbi_send_request( - ogs_sbi_object_t *sbi_object, - ogs_sbi_service_type_e service_type, - void *data); +bool af_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); void af_sbi_discover_and_send( ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option,