diff --git a/configs/sample.yaml.in b/configs/sample.yaml.in index ae4e41b1d..a6dbf3048 100644 --- a/configs/sample.yaml.in +++ b/configs/sample.yaml.in @@ -200,33 +200,33 @@ nrf: # # > # -# o SBI Client(http://127.0.0.10:7777) +# o SBI Client(http://127.0.1.10:7777) # sbi: -# addr: 127.0.0.10 +# addr: 127.0.1.10 # port: 7777 # -# o SBI Client(https://127.0.0.10:443, http://scp.open5gs.org:80) +# o SBI Client(https://127.0.1.10:443, http://scp.open5gs.org:80) # sbi: -# - addr: 127.0.0.10 +# - addr: 127.0.1.10 # tls: # key: scp.key # pem: scp.pem # - name: scp.open5gs.org # -# o SBI Client(http://[fd69:f21d:873c:fa::1]:80) -# If prefer_ipv4 is true, http://127.0.0.10:80 is selected. +# o SBI Client(http://[fd69:f21d:873c:fb::1]:80) +# If prefer_ipv4 is true, http://127.0.1.10:80 is selected. # # sbi: # addr: -# - 127.0.0.10 -# - fd69:f21d:873c:fa::1 +# - 127.0.1.10 +# - fd69:f21d:873c:fb::1 # # o SBI Option (Default) # - tcp_nodelay : true # - so_linger.l_onoff : false # # sbi: -# addr: 127.0.0.10 +# addr: 127.0.1.10 # option: # tcp_nodelay: false # so_linger: diff --git a/lib/app/ogs-context.c b/lib/app/ogs-context.c index 7f031ff61..603655c67 100644 --- a/lib/app/ogs-context.c +++ b/lib/app/ogs-context.c @@ -64,38 +64,27 @@ ogs_app_context_t *ogs_app() static void recalculate_pool_size(void) { + self.pool.packet = self.max.ue * OGS_MAX_NUM_OF_PACKET_BUFFER; + #define MAX_NUM_OF_TUNNEL 3 /* Num of Tunnel per Bearer */ self.pool.sess = self.max.ue * OGS_MAX_NUM_OF_SESS; self.pool.bearer = self.pool.sess * OGS_MAX_NUM_OF_BEARER; self.pool.tunnel = self.pool.bearer * MAX_NUM_OF_TUNNEL; -#define MAX_NUM_OF_TIMER 16 - self.pool.timer = self.max.ue * MAX_NUM_OF_TIMER; -#define MAX_NUM_OF_MESSAGE 16 - self.pool.message = self.max.ue * MAX_NUM_OF_MESSAGE; -#define MAX_NUM_OF_EVENT 16 - self.pool.event = self.max.ue * MAX_NUM_OF_EVENT; +#define OGS_MAX_NUM_OF_NF_SUBSCRIPTION 4 /* Num of Subscription per NF */ + self.pool.nf_service = self.max.gnb * OGS_MAX_NUM_OF_NF_SERVICE; - self.pool.packet = self.max.ue * OGS_MAX_NUM_OF_PACKET_BUFFER; +#define POOL_NUM_PER_UE 16 +#define POOL_NUM_PER_GNB 8 + self.pool.timer = self.max.ue * POOL_NUM_PER_UE; + self.pool.message = self.max.ue * POOL_NUM_PER_UE; + self.pool.event = self.max.ue * POOL_NUM_PER_UE; + self.pool.socket = self.max.ue * POOL_NUM_PER_UE; + self.pool.subscription = self.max.ue * POOL_NUM_PER_UE; + self.pool.xact = self.max.ue * POOL_NUM_PER_UE; self.pool.nf = self.max.gnb; -#define MAX_NUM_OF_SOCKET 8 - self.pool.socket = self.max.ue * MAX_NUM_OF_SOCKET; - -#define MAX_NUM_OF_XACT 8 - self.pool.gtp_xact = self.max.ue * MAX_NUM_OF_XACT; - self.pool.gtp_node = self.max.gtp_peer; - - self.pool.pfcp_xact = self.max.ue * MAX_NUM_OF_XACT; - self.pool.pfcp_node = self.pool.nf; - -#define MAX_NUM_OF_NF_SERVICE 16 /* Num of NF Service per NF Instance */ -#define MAX_NUM_OF_SBI_MESSAGE 4 /* Num of HTTP(s) Request/Response per NF */ -#define MAX_NUM_OF_NF_SUBSCRIPTION 4 /* Num of Subscription per NF */ - self.pool.nf_service = self.pool.nf * MAX_NUM_OF_NF_SERVICE; - self.pool.nf_subscription = self.pool.nf * MAX_NUM_OF_NF_SUBSCRIPTION; - #define MAX_CSMAP_POOL 128 self.pool.csmap = MAX_CSMAP_POOL; /* Num of TAI-LAI Mapping Table */ @@ -192,11 +181,9 @@ static void app_context_prepare(void) #define MAX_NUM_OF_UE 1024 /* Num of UE per AMF/MME */ #define MAX_NUM_OF_GNB 64 /* Num of gNB per AMF/MME */ -#define MAX_NUM_OF_GTP_PEER 64 /* Num of gtp_node per SGW/PGW */ self.max.gnb = MAX_NUM_OF_GNB; self.max.ue = MAX_NUM_OF_UE; - self.max.gtp_peer = MAX_NUM_OF_GTP_PEER; ogs_pkbuf_default_init(&self.pool.defconfig); @@ -444,9 +431,6 @@ int ogs_app_context_parse_config(void) !strcmp(max_key, "enb")) { const char *v = ogs_yaml_iter_value(&max_iter); if (v) self.max.gnb = atoi(v); - } else if (!strcmp(max_key, "gtp_peer")) { - const char *v = ogs_yaml_iter_value(&max_iter); - if (v) self.max.gtp_peer = atoi(v); } else ogs_warn("unknown key `%s`", max_key); } diff --git a/lib/app/ogs-context.h b/lib/app/ogs-context.h index 92cf59b8e..7fa5e820b 100644 --- a/lib/app/ogs-context.h +++ b/lib/app/ogs-context.h @@ -109,27 +109,25 @@ typedef struct ogs_app_context_s { struct { ogs_pkbuf_config_t defconfig; - uint64_t packet; - uint64_t nf; + uint64_t packet; uint64_t sess; uint64_t bearer; uint64_t tunnel; + uint64_t nf_service; - uint64_t nf_subscription; - - uint64_t csmap; + uint64_t timer; uint64_t message; uint64_t event; - uint64_t timer; - uint64_t socket; - uint64_t gtp_xact; - uint64_t gtp_node; - uint64_t pfcp_xact; - uint64_t pfcp_node; + uint64_t subscription; + uint64_t xact; + + uint64_t nf; + + uint64_t csmap; uint64_t impi; uint64_t impu; diff --git a/lib/core/ogs-3gpp-types.h b/lib/core/ogs-3gpp-types.h index 0e372412b..abb3df74b 100644 --- a/lib/core/ogs-3gpp-types.h +++ b/lib/core/ogs-3gpp-types.h @@ -33,6 +33,9 @@ extern "C" { #define OGS_BEARER_PER_UE 8 /* Num of Bearer per UE */ #define OGS_MAX_NUM_OF_PACKET_BUFFER 64 /* Num of PacketBuffer per UE */ +/* Num of NF Service per NF Instance */ +#define OGS_MAX_NUM_OF_NF_SERVICE 16 + /* * The array of TLV messages is limited to 8. * So, Flow(PDI.SDF_Filter) in PDR is limited to 8. diff --git a/lib/gtp/context.c b/lib/gtp/context.c index 506d5e9b0..54eebfb2f 100644 --- a/lib/gtp/context.c +++ b/lib/gtp/context.c @@ -35,7 +35,7 @@ void ogs_gtp_context_init(int num_of_gtpu_resource) ogs_log_install_domain(&__ogs_gtp_domain, "gtp", ogs_core()->log.level); - ogs_pool_init(&pool, ogs_app()->pool.gtp_node); + ogs_pool_init(&pool, ogs_app()->pool.nf); ogs_pool_init(&ogs_gtpu_resource_pool, num_of_gtpu_resource); context_initialized = 1; diff --git a/lib/gtp/xact.c b/lib/gtp/xact.c index 8a85a6fa2..517e0409b 100644 --- a/lib/gtp/xact.c +++ b/lib/gtp/xact.c @@ -48,7 +48,7 @@ int ogs_gtp_xact_init(void) { ogs_assert(ogs_gtp_xact_initialized == 0); - ogs_pool_init(&pool, ogs_app()->pool.gtp_xact); + ogs_pool_init(&pool, ogs_app()->pool.xact); g_xact_id = 0; diff --git a/lib/pfcp/context.c b/lib/pfcp/context.c index 921cbb95f..6784653a5 100644 --- a/lib/pfcp/context.c +++ b/lib/pfcp/context.c @@ -48,7 +48,7 @@ void ogs_pfcp_context_init(void) ogs_log_install_domain(&__ogs_pfcp_domain, "pfcp", ogs_core()->log.level); - ogs_pool_init(&ogs_pfcp_node_pool, ogs_app()->pool.pfcp_node); + ogs_pool_init(&ogs_pfcp_node_pool, ogs_app()->pool.nf); ogs_pool_init(&ogs_pfcp_sess_pool, ogs_app()->pool.sess); diff --git a/lib/pfcp/xact.c b/lib/pfcp/xact.c index b56c2c301..c04631f80 100644 --- a/lib/pfcp/xact.c +++ b/lib/pfcp/xact.c @@ -53,7 +53,7 @@ int ogs_pfcp_xact_init(void) { ogs_assert(ogs_pfcp_xact_initialized == 0); - ogs_pool_init(&pool, ogs_app()->pool.pfcp_xact); + ogs_pool_init(&pool, ogs_app()->pool.xact); g_xact_id = 0; diff --git a/lib/sbi/context.c b/lib/sbi/context.c index 334650f20..a1cd1aeae 100644 --- a/lib/sbi/context.c +++ b/lib/sbi/context.c @@ -50,10 +50,10 @@ void ogs_sbi_context_init(void) ogs_pool_init(&nf_instance_pool, ogs_app()->pool.nf); ogs_pool_init(&nf_service_pool, ogs_app()->pool.nf_service); - ogs_pool_init(&xact_pool, ogs_app()->pool.message); + ogs_pool_init(&xact_pool, ogs_app()->pool.xact); ogs_list_init(&self.subscription_list); - ogs_pool_init(&subscription_pool, ogs_app()->pool.nf_subscription); + ogs_pool_init(&subscription_pool, ogs_app()->pool.subscription); ogs_pool_init(&smf_info_pool, ogs_app()->pool.nf); @@ -1323,41 +1323,48 @@ static void nf_service_associate_client_all(ogs_sbi_nf_instance_t *nf_instance) nf_service_associate_client(nf_service); } -void ogs_sbi_select_nf( - ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e nf_type, void *state) +bool ogs_sbi_discovery_param_is_matched( + ogs_sbi_nf_instance_t *nf_instance, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option) { - ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_state_registered); + ogs_assert(target_nf_type); - ogs_assert(sbi_object); - ogs_assert(nf_type); - ogs_assert(state); + if (!OGS_FSM_CHECK(&nf_instance->sm, + ogs_sbi_self()->nf_state_registered)) return false; - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (OGS_FSM_CHECK(&nf_instance->sm, state) && - nf_instance->nf_type == nf_type) { - OGS_SBI_SETUP_NF(sbi_object, nf_type, nf_instance); - break; - } + if (nf_instance->nf_type != target_nf_type) return false; + + if (discovery_option) { + if (discovery_option->target_nf_instance_id && + strcmp(nf_instance->id, + discovery_option->target_nf_instance_id) != 0) + return false; } + + return true; } -void ogs_sbi_select_nf_by_instanceid( - ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e nf_type, void *state, - char *nf_instance_id) +void ogs_sbi_select_nf( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option) { ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_assert(ogs_sbi_self()->nf_state_registered); ogs_assert(sbi_object); - ogs_assert(nf_type); - ogs_assert(state); + ogs_assert(target_nf_type); ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (OGS_FSM_CHECK(&nf_instance->sm, state) && - (nf_instance->nf_type == nf_type) && - (!(strcmp(nf_instance->id, nf_instance_id)))) { - OGS_SBI_SETUP_NF(sbi_object, nf_type, nf_instance); - break; - } + if (ogs_sbi_discovery_param_is_matched( + nf_instance, target_nf_type, discovery_option) == false) + continue; + + OGS_SBI_SETUP_NF(sbi_object, target_nf_type, nf_instance); + break; } } @@ -1423,21 +1430,25 @@ void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object) } ogs_sbi_xact_t *ogs_sbi_xact_add( - OpenAPI_nf_type_e target_nf_type, ogs_sbi_object_t *sbi_object, - ogs_sbi_build_f build, void *context, void *data, - void (*timer_cb)(void *data)) + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_build_f build, void *context, void *data) { ogs_sbi_xact_t *xact = NULL; + ogs_assert(ogs_sbi_self()->client_wait_expire); ogs_assert(sbi_object); ogs_pool_alloc(&xact_pool, &xact); ogs_expect_or_return_val(xact, NULL); memset(xact, 0, sizeof(ogs_sbi_xact_t)); - xact->target_nf_type = target_nf_type; xact->sbi_object = sbi_object; + xact->target_nf_type = target_nf_type; + xact->discovery_option = discovery_option; + xact->request = (*build)(context, data); if (!xact->request) { ogs_error("SBI build failed"); @@ -1446,7 +1457,7 @@ ogs_sbi_xact_t *ogs_sbi_xact_add( } xact->t_response = ogs_timer_add( - ogs_app()->timer_mgr, timer_cb, xact); + ogs_app()->timer_mgr, ogs_sbi_self()->client_wait_expire, xact); if (!xact->t_response) { ogs_error("ogs_timer_add() failed"); ogs_sbi_request_free(xact->request); @@ -1471,6 +1482,9 @@ void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact) sbi_object = xact->sbi_object; ogs_assert(sbi_object); + if (xact->discovery_option) + ogs_sbi_discovery_option_free(xact->discovery_option); + ogs_assert(xact->t_response); ogs_timer_delete(xact->t_response); diff --git a/lib/sbi/context.h b/lib/sbi/context.h index ccd947fc7..e825ab429 100644 --- a/lib/sbi/context.h +++ b/lib/sbi/context.h @@ -65,6 +65,9 @@ typedef struct ogs_sbi_context_s { const char *content_encoding; + void (*client_wait_expire)(void *data); + ogs_fsm_handler_t nf_state_registered; + } ogs_sbi_context_t; typedef struct ogs_sbi_nf_instance_s { @@ -157,6 +160,7 @@ typedef struct ogs_sbi_xact_s { ogs_lnode_t lnode; OpenAPI_nf_type_e target_nf_type; + ogs_sbi_discovery_option_t *discovery_option; ogs_sbi_request_t *request; ogs_timer_t *t_response; @@ -337,18 +341,23 @@ OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void); (__nFInstance)->reference_count); \ } while(0) +bool ogs_sbi_discovery_param_is_matched( + ogs_sbi_nf_instance_t *nf_instance, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option); + void ogs_sbi_select_nf( - ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e nf_type, void *state); -void ogs_sbi_select_nf_by_instanceid( - ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e nf_type, void *state, - char *nf_instance_id); + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_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( - OpenAPI_nf_type_e target_nf_type, ogs_sbi_object_t *sbi_object, - ogs_sbi_build_f build, void *context, void *data, - void (*timer_cb)(void *data)); + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_build_f build, void *context, void *data); void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact); void ogs_sbi_xact_remove_all(ogs_sbi_object_t *sbi_object); ogs_sbi_xact_t *ogs_sbi_xact_cycle(ogs_sbi_xact_t *xact); diff --git a/lib/sbi/message.c b/lib/sbi/message.c index dadcab7a5..388e1858e 100644 --- a/lib/sbi/message.c +++ b/lib/sbi/message.c @@ -60,6 +60,11 @@ void ogs_sbi_message_free(ogs_sbi_message_t *message) ogs_assert(message); + /* Discovery Option */ + for (i = 0; i < message->param.discovery_option.num_of_service_names; i++) + ogs_free(message->param.discovery_option.service_names[i]); + + /* JSON Data */ if (message->NFProfile) OpenAPI_nf_profile_free(message->NFProfile); if (message->ProblemDetails) @@ -176,6 +181,7 @@ void ogs_sbi_message_free(ogs_sbi_message_t *message) if (message->DeregistrationData) OpenAPI_deregistration_data_free(message->DeregistrationData); + /* HTTP Part */ for (i = 0; i < message->num_of_part; i++) { if (message->part[i].pkbuf) ogs_pkbuf_free(message->part[i].pkbuf); @@ -242,6 +248,7 @@ void ogs_sbi_response_free(ogs_sbi_response_t *response) ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message) { + int i; ogs_sbi_request_t *request = NULL; ogs_assert(message); @@ -255,8 +262,6 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message) request->h.uri = ogs_strdup(message->h.uri); ogs_expect_or_return_val(request->h.uri, NULL); } else { - int i; - ogs_expect_or_return_val(message->h.service.name, NULL); request->h.service.name = ogs_strdup(message->h.service.name); ogs_expect_or_return_val(message->h.api.version, NULL); @@ -270,7 +275,50 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message) message->h.resource.component[i]); } - /* URL Param */ + /* Discovery Parameter */ + if (message->param.target_nf_type) { + char *v = OpenAPI_nf_type_ToString(message->param.target_nf_type); + ogs_expect_or_return_val(v, NULL); + ogs_sbi_header_set(request->http.params, + OGS_SBI_PARAM_TARGET_NF_TYPE, v); + } + if (message->param.requester_nf_type) { + char *v = OpenAPI_nf_type_ToString(message->param.requester_nf_type); + ogs_expect_or_return_val(v, NULL); + ogs_sbi_header_set(request->http.params, + OGS_SBI_PARAM_REQUESTER_NF_TYPE, v); + } + + /* Discovery Option Parameter */ + if (message->param.discovery_option.target_nf_instance_id) { + ogs_sbi_header_set(request->http.params, + OGS_SBI_PARAM_TARGET_NF_INSTANCE_ID, + message->param.discovery_option.target_nf_instance_id); + } + if (message->param.discovery_option.requester_nf_instance_id) { + ogs_sbi_header_set(request->http.params, + OGS_SBI_PARAM_REQUESTER_NF_INSTANCE_ID, + message->param.discovery_option.requester_nf_instance_id); + } + if (message->param.discovery_option.num_of_service_names) { + char *v = NULL; + cJSON *item = NULL; + + item = cJSON_CreateStringArray( + (const char * const*)message->param.discovery_option.service_names, + message->param.discovery_option.num_of_service_names); + ogs_expect_or_return_val(item, NULL); + + v = cJSON_Print(item); + ogs_expect_or_return_val(v, NULL); + cJSON_Delete(item); + + ogs_sbi_header_set( + request->http.params, OGS_SBI_PARAM_SERVICE_NAMES, v); + ogs_free(v); + } + + /* URL Query Paramemter */ if (message->param.nf_id) { ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_NF_ID, message->param.nf_id); @@ -280,18 +328,6 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message) ogs_expect_or_return_val(v, NULL); ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_NF_TYPE, v); } - if (message->param.requester_nf_type) { - char *v = OpenAPI_nf_type_ToString(message->param.requester_nf_type); - ogs_expect_or_return_val(v, NULL); - ogs_sbi_header_set(request->http.params, - OGS_SBI_PARAM_REQUESTER_NF_TYPE, v); - } - if (message->param.target_nf_type) { - char *v = OpenAPI_nf_type_ToString(message->param.target_nf_type); - ogs_expect_or_return_val(v, NULL); - ogs_sbi_header_set(request->http.params, - OGS_SBI_PARAM_TARGET_NF_TYPE, v); - } if (message->param.limit) { char *v = ogs_msprintf("%d", message->param.limit); ogs_expect_or_return_val(v, NULL); @@ -452,12 +488,8 @@ int ogs_sbi_parse_request( for (hi = ogs_hash_first(request->http.params); hi; hi = ogs_hash_next(hi)) { - if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_NF_ID)) { - message->param.nf_id = ogs_hash_this_val(hi); - } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_NF_TYPE)) { - message->param.nf_type = - OpenAPI_nf_type_FromString(ogs_hash_this_val(hi)); - } else if (!strcmp(ogs_hash_this_key(hi), + /* Discovery Parameter */ + if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_TARGET_NF_TYPE)) { message->param.target_nf_type = OpenAPI_nf_type_FromString(ogs_hash_this_val(hi)); @@ -465,6 +497,43 @@ int ogs_sbi_parse_request( OGS_SBI_PARAM_REQUESTER_NF_TYPE)) { message->param.requester_nf_type = OpenAPI_nf_type_FromString(ogs_hash_this_val(hi)); + + /* Discovery Option Parameter */ + } else if (!strcmp(ogs_hash_this_key(hi), + OGS_SBI_PARAM_TARGET_NF_INSTANCE_ID)) { + message->param.discovery_option.target_nf_instance_id = + ogs_hash_this_val(hi); + } else if (!strcmp(ogs_hash_this_key(hi), + OGS_SBI_PARAM_REQUESTER_NF_INSTANCE_ID)) { + message->param.discovery_option.requester_nf_instance_id = + ogs_hash_this_val(hi); + } else if (!strcmp(ogs_hash_this_key(hi), + OGS_SBI_PARAM_SERVICE_NAMES)) { + char *v = NULL; + cJSON *array = NULL, *item = NULL; + + v = ogs_hash_this_val(hi); + if (v) { + array = cJSON_Parse(v); + if (cJSON_IsArray(array)) { + cJSON_ArrayForEach(item, array) { + char *names = cJSON_GetStringValue(item); + if (names) { + message->param.discovery_option.service_names[ + message->param.discovery_option. + num_of_service_names++] = ogs_strdup(names); + } + } + } + cJSON_Delete(array); + } + + /* URL Query Parameter */ + } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_NF_ID)) { + message->param.nf_id = ogs_hash_this_val(hi); + } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_NF_TYPE)) { + message->param.nf_type = + OpenAPI_nf_type_FromString(ogs_hash_this_val(hi)); } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_LIMIT)) { message->param.limit = atoi(ogs_hash_this_val(hi)); } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_DNN)) { @@ -2189,3 +2258,70 @@ static void http_message_free(ogs_sbi_http_message_t *http) ogs_free(http->part[i].content_type); } } + +ogs_sbi_discovery_option_t *ogs_sbi_discovery_option_new(void) +{ + ogs_sbi_discovery_option_t *discovery_option = NULL; + + discovery_option = ogs_calloc(1, sizeof(*discovery_option)); + ogs_assert(discovery_option); + + return discovery_option; +} +void ogs_sbi_discovery_option_free( + ogs_sbi_discovery_option_t *discovery_option) +{ + int i; + + ogs_assert(discovery_option); + + if (discovery_option->target_nf_instance_id) + ogs_free(discovery_option->target_nf_instance_id); + if (discovery_option->requester_nf_instance_id) + ogs_free(discovery_option->requester_nf_instance_id); + + for (i = 0; i < discovery_option->num_of_service_names; i++) + ogs_free(discovery_option->service_names[i]); + + ogs_free(discovery_option); +} + +void ogs_sbi_discovery_option_set_target_nf_instance_id( + ogs_sbi_discovery_option_t *discovery_option, + char *target_nf_instance_id) +{ + ogs_assert(discovery_option); + ogs_assert(target_nf_instance_id); + + ogs_assert(!discovery_option->target_nf_instance_id); + discovery_option->target_nf_instance_id = ogs_strdup(target_nf_instance_id); + ogs_assert(discovery_option->target_nf_instance_id); +} +void ogs_sbi_discovery_option_set_requester_nf_instance_id( + ogs_sbi_discovery_option_t *discovery_option, + char *requester_nf_instance_id) +{ + ogs_assert(discovery_option); + ogs_assert(requester_nf_instance_id); + + ogs_assert(!discovery_option->requester_nf_instance_id); + discovery_option->requester_nf_instance_id = + ogs_strdup(requester_nf_instance_id); + ogs_assert(discovery_option->requester_nf_instance_id); +} +void ogs_sbi_discovery_option_add_service_names( + ogs_sbi_discovery_option_t *discovery_option, + char *service_name) +{ + ogs_assert(discovery_option); + ogs_assert(service_name); + + ogs_assert(discovery_option->num_of_service_names < + OGS_MAX_NUM_OF_NF_SERVICE); + + discovery_option->service_names[discovery_option->num_of_service_names] = + ogs_strdup(service_name); + ogs_assert(discovery_option->service_names + [discovery_option->num_of_service_names]); + discovery_option->num_of_service_names++; +} diff --git a/lib/sbi/message.h b/lib/sbi/message.h index d64aa44ec..3a657d3d5 100644 --- a/lib/sbi/message.h +++ b/lib/sbi/message.h @@ -247,20 +247,6 @@ extern "C" { #define OGS_SBI_NBSF_MANAGEMENT_ES3XX 4 #define OGS_SBI_NBSF_MANAGEMENT_EXTENDED_SAME_PCF 5 -#define OGS_SBI_PARAM_NF_ID "nf-id" -#define OGS_SBI_PARAM_NF_TYPE "nf-type" -#define OGS_SBI_PARAM_TARGET_NF_TYPE "target-nf-type" -#define OGS_SBI_PARAM_REQUESTER_NF_TYPE "requester-nf-type" -#define OGS_SBI_PARAM_LIMIT "limit" -#define OGS_SBI_PARAM_DNN "dnn" -#define OGS_SBI_PARAM_PLMN_ID "plmn-id" -#define OGS_SBI_PARAM_SINGLE_NSSAI "single-nssai" -#define OGS_SBI_PARAM_SNSSAI "snssai" -#define OGS_SBI_PARAM_SLICE_INFO_REQUEST_FOR_PDU_SESSION \ - "slice-info-request-for-pdu-session" -#define OGS_SBI_PARAM_IPV4ADDR "ipv4Addr" -#define OGS_SBI_PARAM_IPV6PREFIX "ipv6Prefix" - #define OGS_SBI_ACCEPT "Accept" #define OGS_SBI_ACCEPT_ENCODING "Accept-Encoding" #define OGS_SBI_CONTENT_TYPE "Content-Type" @@ -274,20 +260,61 @@ extern "C" { #define OGS_SBI_APPLICATION_5GNAS_TYPE "vnd.3gpp.5gnas" #define OGS_SBI_APPLICATION_NGAP_TYPE "vnd.3gpp.ngap" -#define OGS_SBI_CUSTOM_3GPP_COMMON "3gpp-Sbi-" -#define OGS_SBI_CUSTOM_MESSAGE_PRIORITY "3gpp-Sbi-Message-Priority" -#define OGS_SBI_CUSTOM_CALLBACK "3gpp-Sbi-Callback" -#define OGS_SBI_CUSTOM_TARGET_APIROOT "3gpp-Sbi-Target-apiRoot" -#define OGS_SBI_CUSTOM_ROUTING_BINDING "3gpp-Sbi-Routing-Binding" -#define OGS_SBI_CUSTOM_BINDING "3gpp-Sbi-Binding" -#define OGS_SBI_CUSTOM_DISCOVERY_COMMON "3gpp-Sbi-Discovery-" -#define OGS_SBI_CUSTOM_PRODUCER_ID "3gpp-Sbi-Producer-Id" -#define OGS_SBI_CUSTOM_OCI "3gpp-Sbi-Oci" -#define OGS_SBI_CUSTOM_CLIENT_CREDENTIALS "3gpp-Sbi-Client-Credentials" -#define OGS_SBI_CUSTOM_NRF_URI "3gpp-Sbi-Nrf-Uri" -#define OGS_SBI_CUSTOM_TARGET_NF_ID "3gpp-Sbi-Target-Nf-Id" -#define OGS_SBI_CUSTOM_ACCESS_SCOPE "3gpp-Sbi-Access-Scope" -#define OGS_SBI_CUSTOM_ACCESS_TOKEN "3gpp-Sbi-Access-Token" +#define OGS_SBI_CUSTOM_3GPP_COMMON "3gpp-Sbi-" +#define OGS_SBI_CUSTOM_MESSAGE_PRIORITY \ + OGS_SBI_CUSTOM_3GPP_COMMON "Message-Priority" +#define OGS_SBI_CUSTOM_CALLBACK \ + OGS_SBI_CUSTOM_3GPP_COMMON "Callback" +#define OGS_SBI_CUSTOM_TARGET_APIROOT \ + OGS_SBI_CUSTOM_3GPP_COMMON "Target-apiRoot" +#define OGS_SBI_CUSTOM_ROUTING_BINDING \ + OGS_SBI_CUSTOM_3GPP_COMMON "Routing-Binding" +#define OGS_SBI_CUSTOM_BINDING \ + OGS_SBI_CUSTOM_3GPP_COMMON "Binding" +#define OGS_SBI_CUSTOM_DISCOVERY_COMMON \ + OGS_SBI_CUSTOM_3GPP_COMMON "Discovery-" +#define OGS_SBI_CUSTOM_DISCOVERY_TARGET_NF_TYPE \ + OGS_SBI_CUSTOM_DISCOVERY_COMMON OGS_SBI_PARAM_TARGET_NF_TYPE +#define OGS_SBI_CUSTOM_DISCOVERY_REQUESTER_NF_TYPE \ + OGS_SBI_CUSTOM_DISCOVERY_COMMON OGS_SBI_PARAM_REQUESTER_NF_TYPE +#define OGS_SBI_CUSTOM_DISCOVERY_TARGET_NF_INSTANCE_ID \ + OGS_SBI_CUSTOM_DISCOVERY_COMMON OGS_SBI_PARAM_TARGET_NF_INSTANCE_ID +#define OGS_SBI_CUSTOM_DISCOVERY_REQUESTER_NF_INSTANCE_ID \ + OGS_SBI_CUSTOM_DISCOVERY_COMMON OGS_SBI_PARAM_REQUESTER_NF_INSTANCE_ID +#define OGS_SBI_CUSTOM_DISCOVERY_SERVICE_NAMES \ + OGS_SBI_CUSTOM_DISCOVERY_COMMON OGS_SBI_PARAM_SERVICE_NAMES +#define OGS_SBI_CUSTOM_PRODUCER_ID \ + OGS_SBI_CUSTOM_3GPP_COMMON "Producer-Id" +#define OGS_SBI_CUSTOM_OCI \ + OGS_SBI_CUSTOM_3GPP_COMMON "Oci" +#define OGS_SBI_CUSTOM_CLIENT_CREDENTIALS \ + OGS_SBI_CUSTOM_3GPP_COMMON "Client-Credentials" +#define OGS_SBI_CUSTOM_NRF_URI \ + OGS_SBI_CUSTOM_3GPP_COMMON "Nrf-Uri" +#define OGS_SBI_CUSTOM_TARGET_NF_ID \ + OGS_SBI_CUSTOM_3GPP_COMMON "Target-Nf-Id" +#define OGS_SBI_CUSTOM_ACCESS_SCOPE \ + OGS_SBI_CUSTOM_3GPP_COMMON "Access-Scope" +#define OGS_SBI_CUSTOM_ACCESS_TOKEN \ + OGS_SBI_CUSTOM_3GPP_COMMON "Access-Token" + +#define OGS_SBI_PARAM_TARGET_NF_TYPE "target-nf-type" +#define OGS_SBI_PARAM_REQUESTER_NF_TYPE "requester-nf-type" +#define OGS_SBI_PARAM_TARGET_NF_INSTANCE_ID "target-nf-instance-id" +#define OGS_SBI_PARAM_REQUESTER_NF_INSTANCE_ID "requester-nf-instance-id" +#define OGS_SBI_PARAM_SERVICE_NAMES "service-names" + +#define OGS_SBI_PARAM_NF_ID "nf-id" +#define OGS_SBI_PARAM_NF_TYPE "nf-type" +#define OGS_SBI_PARAM_LIMIT "limit" +#define OGS_SBI_PARAM_DNN "dnn" +#define OGS_SBI_PARAM_PLMN_ID "plmn-id" +#define OGS_SBI_PARAM_SINGLE_NSSAI "single-nssai" +#define OGS_SBI_PARAM_SNSSAI "snssai" +#define OGS_SBI_PARAM_SLICE_INFO_REQUEST_FOR_PDU_SESSION \ + "slice-info-request-for-pdu-session" +#define OGS_SBI_PARAM_IPV4ADDR "ipv4Addr" +#define OGS_SBI_PARAM_IPV6PREFIX "ipv6Prefix" #define OGS_SBI_CONTENT_JSON_TYPE \ OGS_SBI_APPLICATION_TYPE "/" OGS_SBI_APPLICATION_JSON_TYPE @@ -337,6 +364,14 @@ typedef struct ogs_sbi_part_s { ogs_pkbuf_t *pkbuf; } ogs_sbi_part_t; +typedef struct ogs_sbi_discovery_option_s { + char *target_nf_instance_id; + char *requester_nf_instance_id; + + int num_of_service_names; + char *service_names[OGS_MAX_NUM_OF_NF_SERVICE]; +} ogs_sbi_discovery_option_t; + typedef struct ogs_sbi_message_s { ogs_sbi_header_t h; @@ -349,8 +384,14 @@ typedef struct ogs_sbi_message_s { } http; struct { + /* Discovery Parameter */ OpenAPI_nf_type_e target_nf_type; OpenAPI_nf_type_e requester_nf_type; + + /* Discovery Option Parameter */ + ogs_sbi_discovery_option_t discovery_option; + + /* URL Query Parameter */ char *nf_id; OpenAPI_nf_type_e nf_type; int limit; @@ -494,6 +535,20 @@ void ogs_sbi_header_free(ogs_sbi_header_t *h); void ogs_sbi_http_hash_free(ogs_hash_t *hash); +ogs_sbi_discovery_option_t *ogs_sbi_discovery_option_new(void); +void ogs_sbi_discovery_option_free( + ogs_sbi_discovery_option_t *discovery_option); + +void ogs_sbi_discovery_option_set_target_nf_instance_id( + ogs_sbi_discovery_option_t *discovery_option, + char *target_nf_instance_id); +void ogs_sbi_discovery_option_set_requester_nf_instance_id( + ogs_sbi_discovery_option_t *discovery_option, + char *requester_nf_instance_id); +void ogs_sbi_discovery_option_add_service_names( + ogs_sbi_discovery_option_t *discovery_option, + char *service_name); + #ifdef __cplusplus } #endif diff --git a/lib/sbi/nnrf-build.c b/lib/sbi/nnrf-build.c index 029634065..cf43ec90d 100644 --- a/lib/sbi/nnrf-build.c +++ b/lib/sbi/nnrf-build.c @@ -501,8 +501,11 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_profile_retrieve(char *nf_instance_id) } ogs_sbi_request_t *ogs_nnrf_disc_build_discover( - OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type) + OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type, + ogs_sbi_discovery_option_t *discovery_option) { + int i; + ogs_sbi_message_t message; ogs_sbi_request_t *request = NULL; @@ -519,6 +522,21 @@ ogs_sbi_request_t *ogs_nnrf_disc_build_discover( message.param.target_nf_type = target_nf_type; message.param.requester_nf_type = requester_nf_type; + if (discovery_option) { + message.param.discovery_option.target_nf_instance_id = + discovery_option->target_nf_instance_id; + message.param.discovery_option.requester_nf_instance_id = + discovery_option->requester_nf_instance_id; + + message.param.discovery_option.num_of_service_names = + discovery_option->num_of_service_names; + for (i = 0; + i < message.param.discovery_option.num_of_service_names; i++) { + message.param.discovery_option.service_names[i] = + discovery_option->service_names[i];; + } + } + request = ogs_sbi_build_request(&message); return request; diff --git a/lib/sbi/nnrf-build.h b/lib/sbi/nnrf-build.h index 7c22fef80..edd8ee0db 100644 --- a/lib/sbi/nnrf-build.h +++ b/lib/sbi/nnrf-build.h @@ -37,7 +37,8 @@ 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( - OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type); + OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type, + ogs_sbi_discovery_option_t *discovery_option); #ifdef __cplusplus } diff --git a/lib/sbi/path.c b/lib/sbi/path.c index 84f94cc57..fff71596b 100644 --- a/lib/sbi/path.c +++ b/lib/sbi/path.c @@ -20,7 +20,7 @@ #include "ogs-sbi.h" #include "ogs-app.h" -bool ogs_sbi_send(ogs_sbi_nf_instance_t *nf_instance, +bool ogs_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_client_cb_f client_cb, ogs_sbi_xact_t *xact) { ogs_sbi_request_t *request = NULL; @@ -77,49 +77,49 @@ bool ogs_sbi_send(ogs_sbi_nf_instance_t *nf_instance, return true; } -bool ogs_sbi_discover_and_send(ogs_sbi_xact_t *xact, - ogs_fsm_handler_t nf_state_registered, ogs_sbi_client_cb_f client_cb) +bool ogs_sbi_discover_and_send( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + OpenAPI_nf_type_e requester_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_client_cb_f client_cb, void *data) { ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(xact); - ogs_assert(xact->sbi_object); - ogs_assert(xact->target_nf_type); - ogs_assert(nf_state_registered); + ogs_assert(sbi_object); + ogs_assert(target_nf_type); + ogs_assert(requester_nf_type); ogs_assert(client_cb); /* Target NF-Instance */ - nf_instance = OGS_SBI_NF_INSTANCE(xact->sbi_object, xact->target_nf_type); + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); if (!nf_instance) { - ogs_assert(xact->target_nf_type != OpenAPI_nf_type_NRF); - ogs_sbi_select_nf( - xact->sbi_object, xact->target_nf_type, nf_state_registered); - nf_instance = OGS_SBI_NF_INSTANCE( - xact->sbi_object, xact->target_nf_type); + ogs_assert(target_nf_type != OpenAPI_nf_type_NRF); + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); } if (nf_instance) { - return ogs_sbi_send(nf_instance, client_cb, xact); + return ogs_sbi_send_request(nf_instance, client_cb, data); } /* NRF NF-Instance */ - nf_instance = OGS_SBI_NF_INSTANCE(xact->sbi_object, OpenAPI_nf_type_NRF); + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, OpenAPI_nf_type_NRF); if (!nf_instance) { - ogs_sbi_select_nf( - xact->sbi_object, OpenAPI_nf_type_NRF, nf_state_registered); - nf_instance = OGS_SBI_NF_INSTANCE( - xact->sbi_object, OpenAPI_nf_type_NRF); + ogs_sbi_select_nf(sbi_object, OpenAPI_nf_type_NRF, NULL); + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, OpenAPI_nf_type_NRF); } if (nf_instance) { ogs_warn("Try to discover [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); + OpenAPI_nf_type_ToString(target_nf_type)); return ogs_nnrf_disc_send_nf_discover( - nf_instance, xact->target_nf_type, xact); + nf_instance, + target_nf_type, requester_nf_type, discovery_option, + data); } - ogs_error("Cannot discover [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); + ogs_error("Cannot discover [%s]", OpenAPI_nf_type_ToString(target_nf_type)); return false; } @@ -141,51 +141,6 @@ bool ogs_nnrf_nfm_send_nf_register( return ogs_sbi_scp_send_request(client, client->cb, request, nf_instance); } -bool ogs_sbi_discover_by_nf_instanceid_and_send(ogs_sbi_xact_t *xact, - ogs_fsm_handler_t nf_state_registered, ogs_sbi_client_cb_f client_cb, - char *nf_instance_id) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(xact); - ogs_assert(xact->sbi_object); - ogs_assert(xact->target_nf_type); - ogs_assert(nf_state_registered); - ogs_assert(client_cb); - ogs_assert(nf_instance_id); - - /* Target NF-Instance - search by NF Instance Id */ - ogs_assert(xact->target_nf_type != OpenAPI_nf_type_NRF); - ogs_sbi_select_nf_by_instanceid( - xact->sbi_object, xact->target_nf_type, nf_state_registered, - nf_instance_id); - - nf_instance = OGS_SBI_NF_INSTANCE( - xact->sbi_object, xact->target_nf_type); - - if (nf_instance) { - return ogs_sbi_send(nf_instance, client_cb, xact); - } - - /* NRF NF-Instance */ - nf_instance = OGS_SBI_NF_INSTANCE(xact->sbi_object, OpenAPI_nf_type_NRF); - if (!nf_instance) { - ogs_sbi_select_nf( - xact->sbi_object, OpenAPI_nf_type_NRF, nf_state_registered); - nf_instance = OGS_SBI_NF_INSTANCE( - xact->sbi_object, OpenAPI_nf_type_NRF); - } - - if (nf_instance) { - ogs_warn("Try to retrieve [%s]", nf_instance_id); - return ogs_nnrf_nfm_send_nf_profile_retrieve(nf_instance, - nf_instance_id, xact); - } - - ogs_error("Cannot retrieve [%s]", nf_instance_id); - return false; -} - bool ogs_nnrf_nfm_send_nf_update(ogs_sbi_nf_instance_t *nf_instance) { ogs_sbi_request_t *request = NULL; @@ -279,17 +234,22 @@ bool ogs_nnrf_nfm_send_nf_status_unsubscribe( client, client->cb, request, subscription); } -bool ogs_nnrf_disc_send_nf_discover(ogs_sbi_nf_instance_t *nf_instance, - OpenAPI_nf_type_e target_nf_type, void *data) +bool ogs_nnrf_disc_send_nf_discover( + ogs_sbi_nf_instance_t *nf_instance, + OpenAPI_nf_type_e target_nf_type, + OpenAPI_nf_type_e requester_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + void *data) { ogs_sbi_client_t *client = NULL; ogs_sbi_request_t *request = NULL; ogs_assert(nf_instance); + ogs_assert(target_nf_type); + ogs_assert(requester_nf_type); - ogs_assert(ogs_sbi_self()->nf_instance); request = ogs_nnrf_disc_build_discover( - target_nf_type, ogs_sbi_self()->nf_instance->nf_type); + target_nf_type, requester_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 9edfca182..6ba2d092a 100644 --- a/lib/sbi/path.h +++ b/lib/sbi/path.h @@ -26,13 +26,14 @@ extern "C" { #endif -bool ogs_sbi_send(ogs_sbi_nf_instance_t *nf_instance, +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_and_send(ogs_sbi_xact_t *xact, - ogs_fsm_handler_t nf_state_registered, ogs_sbi_client_cb_f client_cb); -bool ogs_sbi_discover_by_nf_instanceid_and_send(ogs_sbi_xact_t *xact, - ogs_fsm_handler_t nf_state_registered, ogs_sbi_client_cb_f client_cb, - char *nf_instance_id); +bool ogs_sbi_discover_and_send( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + OpenAPI_nf_type_e requester_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_client_cb_f client_cb, void *data); bool ogs_nnrf_nfm_send_nf_register( ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_request_t *(*build)(void)); @@ -47,8 +48,12 @@ bool ogs_nnrf_nfm_send_nf_status_subscribe(ogs_sbi_client_t *client, bool ogs_nnrf_nfm_send_nf_status_unsubscribe( ogs_sbi_subscription_t *subscription); -bool ogs_nnrf_disc_send_nf_discover(ogs_sbi_nf_instance_t *nf_instance, - OpenAPI_nf_type_e target_nf_type, void *data); +bool ogs_nnrf_disc_send_nf_discover( + ogs_sbi_nf_instance_t *nf_instance, + OpenAPI_nf_type_e target_nf_type, + OpenAPI_nf_type_e requester_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) diff --git a/src/amf/context.c b/src/amf/context.c index ab4380bbb..60fff81fc 100644 --- a/src/amf/context.c +++ b/src/amf/context.c @@ -1780,40 +1780,46 @@ amf_sess_t *amf_sess_cycle(amf_sess_t *sess) return ogs_pool_cycle(&amf_sess_pool, sess); } -void amf_ue_select_nf(amf_ue_t *amf_ue, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(amf_ue); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&amf_ue->sbi, nf_type, amf_nf_state_registered); -} - -void amf_sess_select_nf(amf_sess_t *sess, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(sess); - ogs_assert(nf_type); - - if (nf_type == OpenAPI_nf_type_SMF) - amf_sess_select_smf(sess); - else - ogs_sbi_select_nf(&sess->sbi, nf_type, amf_nf_state_registered); -} - static bool check_smf_info(amf_sess_t *sess, ogs_list_t *nf_info_list); -void amf_sess_select_smf(amf_sess_t *sess) +void amf_sbi_select_nf( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option) { ogs_sbi_nf_instance_t *nf_instance = NULL; + amf_sess_t *sess = NULL; - ogs_assert(sess); + ogs_assert(ogs_sbi_self()->nf_state_registered); + ogs_assert(sbi_object); + ogs_assert(target_nf_type); - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (OGS_FSM_CHECK(&nf_instance->sm, amf_nf_state_registered) && - nf_instance->nf_type == OpenAPI_nf_type_SMF && - check_smf_info(sess, &nf_instance->nf_info_list) == true) { - OGS_SBI_SETUP_NF(&sess->sbi, OpenAPI_nf_type_SMF, nf_instance); + switch(sbi_object->type) { + case OGS_SBI_OBJ_UE_TYPE: + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + break; + case OGS_SBI_OBJ_SESS_TYPE: + sess = (amf_sess_t *)sbi_object; + ogs_assert(sess); + + 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; + + if (target_nf_type == OpenAPI_nf_type_SMF) { + if (check_smf_info(sess, &nf_instance->nf_info_list) == false) + continue; + } + + OGS_SBI_SETUP_NF(sbi_object, target_nf_type, nf_instance); break; } + break; + default: + ogs_fatal("(NF discover search result) Not implemented [%d]", + sbi_object->type); + ogs_assert_if_reached(); } } diff --git a/src/amf/context.h b/src/amf/context.h index 4b6da1806..9bf51c38c 100644 --- a/src/amf/context.h +++ b/src/amf/context.h @@ -752,10 +752,10 @@ amf_sess_t *amf_sess_find_by_dnn(amf_ue_t *amf_ue, char *dnn); amf_ue_t *amf_ue_cycle(amf_ue_t *amf_ue); amf_sess_t *amf_sess_cycle(amf_sess_t *sess); -void amf_ue_select_nf(amf_ue_t *amf_ue, OpenAPI_nf_type_e nf_type); -void amf_sess_select_nf(amf_sess_t *sess, OpenAPI_nf_type_e nf_type); - -void amf_sess_select_smf(amf_sess_t *sess); +void amf_sbi_select_nf( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option); #define AMF_SESSION_SYNC_DONE(__aMF, __sTATE) \ (amf_sess_xact_state_count(__aMF, __sTATE) == 0) diff --git a/src/amf/gmm-handler.c b/src/amf/gmm-handler.c index c9f93b22f..995405992 100644 --- a/src/amf/gmm-handler.c +++ b/src/amf/gmm-handler.c @@ -720,8 +720,8 @@ int gmm_handle_authentication_response(amf_ue_t *amf_ue, authentication_response_parameter->length); ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate_confirmation)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate_confirmation, amf_ue, NULL)); return OGS_OK; } @@ -1067,20 +1067,22 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, nf_instance = OGS_SBI_NF_INSTANCE( &sess->sbi, OpenAPI_nf_type_SMF); if (!nf_instance) { - amf_sess_select_smf(sess); + amf_sbi_select_nf(&sess->sbi, OpenAPI_nf_type_SMF, NULL); nf_instance = OGS_SBI_NF_INSTANCE( &sess->sbi, OpenAPI_nf_type_SMF); } if (nf_instance) { ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL, - amf_nsmf_pdusession_build_create_sm_context)); + amf_sess_sbi_discover_and_send( + OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_create_sm_context, + sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL)); } else { ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_NSSF, - sess, 0, NULL, amf_nnssf_nsselection_build_get)); + amf_sess_sbi_discover_and_send( + OpenAPI_nf_type_NSSF, NULL, + amf_nnssf_nsselection_build_get, sess, 0, NULL)); } } else { @@ -1090,9 +1092,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, param.cause = OpenAPI_cause_REL_DUE_TO_DUPLICATE_SESSION_ID; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_DUPLICATED_PDU_SESSION_ID, - ¶m, amf_nsmf_pdusession_build_update_sm_context)); + ¶m)); } } else { @@ -1115,15 +1118,15 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, param.ue_timezone = true; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_N1_RELEASED, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_N1_RELEASED, ¶m)); } else { ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, ¶m)); } switch (gsm_header->message_type) { diff --git a/src/amf/gmm-sm.c b/src/amf/gmm-sm.c index da705bc1f..fad56b944 100644 --- a/src/amf/gmm-sm.c +++ b/src/amf/gmm-sm.c @@ -177,8 +177,9 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, amf_ue, NULL, - amf_npcf_am_policy_control_build_create)); + OpenAPI_nf_type_PCF, NULL, + amf_npcf_am_policy_control_build_create, + amf_ue, NULL)); OGS_FSM_TRAN(s, &gmm_state_initial_context_setup); break; } @@ -199,9 +200,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); } OGS_FSM_TRAN(s, &gmm_state_authentication); @@ -277,9 +277,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); } OGS_FSM_TRAN(s, &gmm_state_authentication); @@ -585,9 +584,8 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) case OGS_5GMM_CAUSE_NGKSI_ALREADY_IN_USE: ogs_warn("Authentication failure(ngKSI already in use)"); ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); return; case OGS_5GMM_CAUSE_SYNCH_FAILURE: @@ -598,9 +596,9 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) break; } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, amf_ue, - authentication_failure_parameter->auts, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, + amf_ue, authentication_failure_parameter->auts)); return; default: @@ -630,8 +628,8 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); break; case OGS_NAS_5GS_5GMM_STATUS: @@ -834,8 +832,8 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) amf_ue->nhcc = 1; ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, amf_ue, NULL, - amf_nudm_uecm_build_registration)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + amf_nudm_uecm_build_registration, amf_ue, NULL)); if (amf_ue->nas.message_type == OGS_NAS_5GS_REGISTRATION_REQUEST) { OGS_FSM_TRAN(s, &gmm_state_initial_context_setup); @@ -869,8 +867,8 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); OGS_FSM_TRAN(s, &gmm_state_authentication); break; @@ -996,9 +994,9 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) CASE(OGS_SBI_HTTP_METHOD_PUT) ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_UDM, amf_ue, - (char *)OGS_SBI_RESOURCE_NAME_AM_DATA, - amf_nudm_sdm_build_get)); + OpenAPI_nf_type_UDM, NULL, + amf_nudm_sdm_build_get, + amf_ue, (char *)OGS_SBI_RESOURCE_NAME_AM_DATA)); break; DEFAULT @@ -1196,9 +1194,8 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); } OGS_FSM_TRAN(s, &gmm_state_authentication); break; @@ -1361,8 +1358,9 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, amf_ue, NULL, - amf_npcf_am_policy_control_build_create)); + OpenAPI_nf_type_PCF, NULL, + amf_npcf_am_policy_control_build_create, + amf_ue, NULL)); OGS_FSM_TRAN(s, &gmm_state_initial_context_setup); break; } @@ -1383,9 +1381,8 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); } OGS_FSM_TRAN(s, &gmm_state_authentication); diff --git a/src/amf/namf-handler.c b/src/amf/namf-handler.c index 8ed4cea30..0d178ed52 100644 --- a/src/amf/namf-handler.c +++ b/src/amf/namf-handler.c @@ -577,9 +577,8 @@ int amf_namf_callback_handle_dereg_notify( if (ogs_list_count(&amf_ue->sess_list) == 0) ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, amf_ue, - NULL, amf_npcf_am_policy_control_build_delete)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_npcf_am_policy_control_build_delete, amf_ue, NULL)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_de_registered); } diff --git a/src/amf/ngap-handler.c b/src/amf/ngap-handler.c index e2a2b44b9..f1f4defa0 100644 --- a/src/amf/ngap-handler.c +++ b/src/amf/ngap-handler.c @@ -904,9 +904,9 @@ void ngap_handle_initial_context_setup_response( ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -1643,9 +1643,9 @@ void ngap_handle_pdu_session_resource_setup_response( ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -1762,9 +1762,9 @@ void ngap_handle_pdu_session_resource_setup_response( amf_ue->deactivation.cause = NGAP_CauseNas_normal_release; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_SETUP_FAIL, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_SETUP_FAIL, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -1942,9 +1942,9 @@ void ngap_handle_pdu_session_resource_modify_response( ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -2117,9 +2117,9 @@ void ngap_handle_pdu_session_resource_release_response( ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_N2_RELEASED, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_N2_RELEASED, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -2539,9 +2539,9 @@ void ngap_handle_path_switch_request( ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_PATH_SWITCH_REQUEST, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_PATH_SWITCH_REQUEST, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -2855,9 +2855,9 @@ void ngap_handle_handover_required( param.TargetID = TargetID; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQUIRED, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQUIRED, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -3079,9 +3079,9 @@ void ngap_handle_handover_request_ack( param.hoState = OpenAPI_ho_state_PREPARED; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQ_ACK, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQ_ACK, ¶m)); ogs_pkbuf_free(param.n2smbuf); } @@ -3324,9 +3324,9 @@ void ngap_handle_handover_cancel( param.ngApCause.value = (int)Cause->choice.radioNetwork; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_CANCEL, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_CANCEL, ¶m)); } } @@ -3604,9 +3604,9 @@ void ngap_handle_handover_notification( param.hoState = OpenAPI_ho_state_COMPLETED; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_NOTIFY, ¶m, - amf_nsmf_pdusession_build_update_sm_context)); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, + sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_NOTIFY, ¶m)); } } diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c index f184ad7e4..d921e074a 100644 --- a/src/amf/nnrf-handler.c +++ b/src/amf/nnrf-handler.c @@ -255,16 +255,19 @@ void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; - amf_ue_t *amf_ue = NULL; - amf_sess_t *sess = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; OpenAPI_search_result_t *SearchResult = NULL; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -272,59 +275,27 @@ void amf_nnrf_handle_nf_discover( return; } - amf_nnrf_handle_nf_discover_search_result(sbi_object, SearchResult); + amf_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); - if (!nf_instance) { - 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, - OpenAPI_nf_type_ToString(xact->target_nf_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, - OpenAPI_nf_type_ToString(xact->target_nf_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]", - OpenAPI_nf_type_ToString(xact->target_nf_type), - sbi_object->type); - ogs_assert_if_reached(); - } - } else { - ogs_assert(true == amf_sbi_send(nf_instance, xact)); - } + amf_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + ogs_expect(true == amf_sbi_send_request(sbi_object, target_nf_type, xact)); } void amf_nnrf_handle_nf_discover_search_result( - ogs_sbi_object_t *sbi_object, OpenAPI_search_result_t *SearchResult) + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + OpenAPI_search_result_t *SearchResult) { bool handled; OpenAPI_lnode_t *node = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; + amf_sess_t *sess = NULL; + ogs_assert(sbi_object); ogs_assert(SearchResult); @@ -355,9 +326,6 @@ void amf_nnrf_handle_nf_discover_search_result( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - amf_ue_t *amf_ue = NULL; - amf_sess_t *sess = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -374,23 +342,6 @@ void amf_nnrf_handle_nf_discover_search_result( continue; } - switch(sbi_object->type) { - case OGS_SBI_OBJ_UE_TYPE: - amf_ue = (amf_ue_t *)sbi_object; - ogs_assert(amf_ue); - amf_ue_select_nf(amf_ue, nf_instance->nf_type); - break; - case OGS_SBI_OBJ_SESS_TYPE: - sess = (amf_sess_t *)sbi_object; - ogs_assert(sess); - amf_sess_select_nf(sess, nf_instance->nf_type); - break; - default: - ogs_fatal("(NF discover search result) Not implemented [%d]", - sbi_object->type); - ogs_assert_if_reached(); - } - /* TIME : Update validity from NRF */ if (SearchResult->is_validity_period && SearchResult->validity_period) { diff --git a/src/amf/nnrf-handler.h b/src/amf/nnrf-handler.h index b51fc158a..38b766b6a 100644 --- a/src/amf/nnrf-handler.h +++ b/src/amf/nnrf-handler.h @@ -37,7 +37,10 @@ bool amf_nnrf_handle_nf_status_notify( void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg); void amf_nnrf_handle_nf_discover_search_result( - ogs_sbi_object_t *sbi_object, OpenAPI_search_result_t *SearchResult); + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + OpenAPI_search_result_t *SearchResult); #ifdef __cplusplus } diff --git a/src/amf/nsmf-handler.c b/src/amf/nsmf-handler.c index f6fd6552c..ec610f962 100644 --- a/src/amf/nsmf-handler.c +++ b/src/amf/nsmf-handler.c @@ -231,8 +231,9 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, amf_ue, NULL, - amf_npcf_am_policy_control_build_create)); + OpenAPI_nf_type_PCF, NULL, + amf_npcf_am_policy_control_build_create, + amf_ue, NULL)); } else { CLEAR_AMF_UE_TIMER(amf_ue->t3550); ogs_assert(OGS_OK == @@ -562,9 +563,9 @@ int amf_nsmf_pdusession_handle_update_sm_context( ogs_warn("[%s:%d] Receive Update SM context" "(DUPLICATED_PDU_SESSION_ID)", amf_ue->supi, sess->psi); - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL, - amf_nsmf_pdusession_build_create_sm_context); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_create_sm_context, + sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL); } else if (state == AMF_UPDATE_SM_CONTEXT_PATH_SWITCH_REQUEST) { @@ -815,9 +816,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, amf_ue, NULL, - amf_npcf_am_policy_control_build_create)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_npcf_am_policy_control_build_create, amf_ue, NULL)); } else { CLEAR_AMF_UE_TIMER(amf_ue->t3550); ogs_assert(OGS_OK == @@ -868,9 +868,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_authentication)) { ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_AUSF, amf_ue, NULL, - amf_nausf_auth_build_authenticate)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_nausf_auth_build_authenticate, amf_ue, NULL)); } else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_de_registered)) { @@ -886,9 +885,9 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) */ ogs_assert(true == - amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, amf_ue, - NULL, amf_npcf_am_policy_control_build_delete)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_npcf_am_policy_control_build_delete, + amf_ue, NULL)); } else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered)) { /* diff --git a/src/amf/nudm-handler.c b/src/amf/nudm-handler.c index 6958bbdf9..63c76fb9e 100644 --- a/src/amf/nudm-handler.c +++ b/src/amf/nudm-handler.c @@ -140,9 +140,9 @@ int amf_nudm_sdm_handle_provisioned( } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, amf_ue, - (char *)OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA, - amf_nudm_sdm_build_get)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + amf_nudm_sdm_build_get, + amf_ue, (char *)OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA)); break; CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA) @@ -212,15 +212,15 @@ int amf_nudm_sdm_handle_provisioned( } } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, amf_ue, - (char *)OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA, - amf_nudm_sdm_build_get)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + amf_nudm_sdm_build_get, + amf_ue, (char *)OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)); break; CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, amf_ue, - NULL, amf_npcf_am_policy_control_build_create)); + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_npcf_am_policy_control_build_create, amf_ue, NULL)); break; DEFAULT diff --git a/src/amf/sbi-path.c b/src/amf/sbi-path.c index 7d8937bf0..188f80f57 100644 --- a/src/amf/sbi-path.c +++ b/src/amf/sbi-path.c @@ -19,6 +19,7 @@ #include "sbi-path.h" #include "nas-path.h" +#include "ngap-path.h" #include "nnrf-handler.h" static int server_cb(ogs_sbi_request_t *request, void *data) @@ -81,9 +82,6 @@ int amf_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -126,6 +124,16 @@ int amf_sbi_open(void) amf_nf_fsm_init(nf_instance); } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = amf_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)amf_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } @@ -135,24 +143,84 @@ void amf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool amf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool amf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data) { - return ogs_sbi_send(nf_instance, client_cb, xact); + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(sbi_object); + ogs_assert(target_nf_type); + ogs_assert(data); + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_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, + OpenAPI_nf_type_ToString(target_nf_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, + OpenAPI_nf_type_ToString(target_nf_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]", + OpenAPI_nf_type_ToString(target_nf_type), + sbi_object->type); + ogs_assert_if_reached(); + } + + return false; + } + + return ogs_sbi_send_request(nf_instance, client_cb, data); } bool amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, amf_ue_t *amf_ue, void *data, - ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data)) + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data), + amf_ue_t *amf_ue, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(target_nf_type); ogs_assert(amf_ue); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &amf_ue->sbi, - (ogs_sbi_build_f)build, amf_ue, data, - amf_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &amf_ue->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, amf_ue, data); if (!xact) { ogs_error("amf_ue_sbi_discover_and_send() failed"); ogs_assert(OGS_OK == @@ -161,8 +229,10 @@ bool amf_ue_sbi_discover_and_send( return false; } - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)amf_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &amf_ue->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("amf_ue_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(OGS_OK == @@ -174,19 +244,26 @@ bool amf_ue_sbi_discover_and_send( return true; } -bool amf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - amf_sess_t *sess, int state, void *data, - ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data)) +bool amf_sess_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data), + amf_sess_t *sess, int state, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(target_nf_type); ogs_assert(sess); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &sess->sbi, - (ogs_sbi_build_f)build, sess, data, - amf_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &sess->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("amf_sess_sbi_discover_and_send() failed"); ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, @@ -196,8 +273,10 @@ bool amf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, xact->state = state; - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)amf_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &sess->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("amf_sess_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, @@ -252,7 +331,9 @@ static int client_discover_cb( } amf_nnrf_handle_nf_discover_search_result( - &sess->sbi, message.SearchResult); + &sess->sbi, OpenAPI_nf_type_SMF, NULL, message.SearchResult); + + amf_sbi_select_nf(&sess->sbi, OpenAPI_nf_type_SMF, NULL); if (!OGS_SBI_NF_INSTANCE(&sess->sbi, OpenAPI_nf_type_SMF)) { ogs_error("Cannot discover [%s]", @@ -265,9 +346,9 @@ static int client_discover_cb( goto cleanup; } - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL, - amf_nsmf_pdusession_build_create_sm_context); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_create_sm_context, + sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL); cleanup: ogs_sbi_message_free(&message); @@ -306,9 +387,8 @@ void amf_sbi_send_activating_session(amf_sess_t *sess, int state) memset(¶m, 0, sizeof(param)); param.upCnxState = OpenAPI_up_cnx_state_ACTIVATING; - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, state, ¶m, - amf_nsmf_pdusession_build_update_sm_context); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, sess, state, ¶m); } void amf_sbi_send_deactivate_session( @@ -325,8 +405,8 @@ void amf_sbi_send_deactivate_session( param.ue_location = true; param.ue_timezone = true; - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, - sess, state, ¶m, amf_nsmf_pdusession_build_update_sm_context); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_update_sm_context, sess, state, ¶m); } void amf_sbi_send_deactivate_all_sessions( @@ -387,9 +467,8 @@ void amf_sbi_send_release_session(amf_sess_t *sess, int state) { ogs_assert(sess); - amf_sess_sbi_discover_and_send( - OpenAPI_nf_type_SMF, sess, state, NULL, - amf_nsmf_pdusession_build_release_sm_context); + amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_nsmf_pdusession_build_release_sm_context, sess, state, NULL); /* Prevent to invoke SMF for this session */ CLEAR_SM_CONTEXT_REF(sess); diff --git a/src/amf/sbi-path.h b/src/amf/sbi-path.h index 954f797c7..76bd53dc4 100644 --- a/src/amf/sbi-path.h +++ b/src/amf/sbi-path.h @@ -34,10 +34,15 @@ extern "C" { int amf_sbi_open(void); void amf_sbi_close(void); -bool amf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); -bool amf_ue_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - amf_ue_t *amf_ue, void *data, - ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data)); +bool amf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data); +bool amf_ue_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data), + amf_ue_t *amf_ue, void *data); #define AMF_CREATE_SM_CONTEXT_NO_STATE 0 #define AMF_UPDATE_SM_CONTEXT_ACTIVATED 11 @@ -61,9 +66,11 @@ bool amf_ue_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, #define AMF_REMOVE_S1_CONTEXT_BY_LO_CONNREFUSED 51 #define AMF_REMOVE_S1_CONTEXT_BY_RESET_ALL 52 #define AMF_REMOVE_S1_CONTEXT_BY_RESET_PARTIAL 53 -bool amf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - amf_sess_t *sess, int state, void *data, - ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data)); +bool amf_sess_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data), + amf_sess_t *sess, int state, void *data); bool amf_sess_sbi_discover_by_nsi( OpenAPI_nf_type_e target_nf_type, amf_sess_t *sess); diff --git a/src/ausf/context.c b/src/ausf/context.c index 9d666db5b..6c01afcab 100644 --- a/src/ausf/context.c +++ b/src/ausf/context.c @@ -222,11 +222,3 @@ ausf_ue_t *ausf_ue_cycle(ausf_ue_t *ausf_ue) { return ogs_pool_cycle(&ausf_ue_pool, ausf_ue); } - -void ausf_ue_select_nf(ausf_ue_t *ausf_ue, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(ausf_ue); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&ausf_ue->sbi, nf_type, ausf_nf_state_registered); -} diff --git a/src/ausf/context.h b/src/ausf/context.h index 3f0fe9d4d..7f382f195 100644 --- a/src/ausf/context.h +++ b/src/ausf/context.h @@ -97,8 +97,6 @@ ausf_ue_t *ausf_ue_find_by_ctx_id(char *ctx_id); ausf_ue_t *ausf_ue_cycle(ausf_ue_t *ausf_ue); -void ausf_ue_select_nf(ausf_ue_t *ausf_ue, OpenAPI_nf_type_e nf_type); - #ifdef __cplusplus } #endif diff --git a/src/ausf/nausf-handler.c b/src/ausf/nausf-handler.c index fb006e355..80c0d0d78 100644 --- a/src/ausf/nausf-handler.c +++ b/src/ausf/nausf-handler.c @@ -55,9 +55,9 @@ bool ausf_nausf_auth_handle_authenticate(ausf_ue_t *ausf_ue, ogs_assert(ausf_ue->serving_network_name); ogs_assert(true == - ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, ausf_ue, stream, - AuthenticationInfo->resynchronization_info, - ausf_nudm_ueau_build_get)); + ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + ausf_nudm_ueau_build_get, + ausf_ue, stream, AuthenticationInfo->resynchronization_info)); return true; } @@ -104,8 +104,9 @@ bool ausf_nausf_auth_handle_authenticate_confirmation(ausf_ue_t *ausf_ue, } ogs_assert(true == - ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, ausf_ue, stream, NULL, - ausf_nudm_ueau_build_result_confirmation_inform)); + ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + ausf_nudm_ueau_build_result_confirmation_inform, + ausf_ue, stream, NULL)); return true; } diff --git a/src/ausf/nnrf-handler.c b/src/ausf/nnrf-handler.c index 1a04197fe..1f44cd34c 100644 --- a/src/ausf/nnrf-handler.c +++ b/src/ausf/nnrf-handler.c @@ -252,16 +252,22 @@ void ausf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; OpenAPI_lnode_t *node = NULL; bool handled; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -296,8 +302,6 @@ void ausf_nnrf_handle_nf_discover( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - ausf_ue_t *ausf_ue = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -314,10 +318,6 @@ void ausf_nnrf_handle_nf_discover( continue; } - ausf_ue = (ausf_ue_t *)sbi_object; - ogs_assert(ausf_ue); - ausf_ue_select_nf(ausf_ue, nf_instance->nf_type); - /* TIME : Update validity from NRF */ if (SearchResult->is_validity_period && SearchResult->validity_period) { @@ -336,12 +336,7 @@ void ausf_nnrf_handle_nf_discover( } } - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); - } else { - ogs_assert(true == ausf_sbi_send(nf_instance, xact)); - } + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + ogs_expect(true == ausf_sbi_send_request(sbi_object, target_nf_type, xact)); } diff --git a/src/ausf/sbi-path.c b/src/ausf/sbi-path.c index a2e05b2f2..2c1dbc77c 100644 --- a/src/ausf/sbi-path.c +++ b/src/ausf/sbi-path.c @@ -79,9 +79,6 @@ int ausf_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -114,6 +111,16 @@ int ausf_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = ausf_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)ausf_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } @@ -123,25 +130,44 @@ void ausf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool ausf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool ausf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data) { - return ogs_sbi_send(nf_instance, client_cb, xact); + ogs_sbi_nf_instance_t *nf_instance = NULL; + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + OpenAPI_nf_type_ToString(target_nf_type)); + return false; + } + + return ogs_sbi_send_request(nf_instance, client_cb, data); } -bool ausf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data)) +bool ausf_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data), + ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(target_nf_type); ogs_assert(ausf_ue); ogs_assert(stream); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &ausf_ue->sbi, - (ogs_sbi_build_f)build, ausf_ue, data, - ausf_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &ausf_ue->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, ausf_ue, data); if (!xact) { ogs_error("ausf_sbi_discover_and_send() failed"); ogs_assert(true == @@ -153,8 +179,10 @@ bool ausf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)ausf_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &ausf_ue->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("ausf_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true == diff --git a/src/ausf/sbi-path.h b/src/ausf/sbi-path.h index 17ebeca3e..0ec3df789 100644 --- a/src/ausf/sbi-path.h +++ b/src/ausf/sbi-path.h @@ -30,10 +30,15 @@ extern "C" { int ausf_sbi_open(void); void ausf_sbi_close(void); -bool ausf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); -bool ausf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data)); +bool ausf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data); +bool ausf_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data), + ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data); #ifdef __cplusplus } diff --git a/src/bsf/context.c b/src/bsf/context.c index 91ac65883..3013ca31f 100644 --- a/src/bsf/context.c +++ b/src/bsf/context.c @@ -323,11 +323,3 @@ bsf_sess_t *bsf_sess_find_by_ipv6prefix(char *ipv6prefix_string) return ogs_hash_get(self.ipv6prefix_hash, &ipv6prefix, (ipv6prefix.len >> 3) + 1); } - -void bsf_sess_select_nf(bsf_sess_t *sess, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(sess); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&sess->sbi, nf_type, bsf_nf_state_registered); -} diff --git a/src/bsf/context.h b/src/bsf/context.h index ed9353f07..842d47888 100644 --- a/src/bsf/context.h +++ b/src/bsf/context.h @@ -114,8 +114,6 @@ bsf_sess_t *bsf_sess_find_by_binding_id(char *binding_id); bsf_sess_t *bsf_sess_find_by_ipv4addr(char *ipv4addr_string); bsf_sess_t *bsf_sess_find_by_ipv6prefix(char *ipv6prefix_string); -void bsf_sess_select_nf(bsf_sess_t *sess, OpenAPI_nf_type_e nf_type); - #ifdef __cplusplus } #endif diff --git a/src/bsf/nnrf-handler.c b/src/bsf/nnrf-handler.c index e17f0aabc..38eeb2b89 100644 --- a/src/bsf/nnrf-handler.c +++ b/src/bsf/nnrf-handler.c @@ -253,16 +253,22 @@ void bsf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; OpenAPI_lnode_t *node = NULL; bool handled; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -297,8 +303,6 @@ void bsf_nnrf_handle_nf_discover( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - bsf_sess_t *sess = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -315,10 +319,6 @@ void bsf_nnrf_handle_nf_discover( continue; } - sess = (bsf_sess_t *)sbi_object; - ogs_assert(sess); - bsf_sess_select_nf(sess, nf_instance->nf_type); - /* TIME : Update validity from NRF */ if (SearchResult->is_validity_period && SearchResult->validity_period) { @@ -337,12 +337,7 @@ void bsf_nnrf_handle_nf_discover( } } - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); - } else { - bsf_sbi_send(nf_instance, xact); - } + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + ogs_expect(true == bsf_sbi_send_request(sbi_object, target_nf_type, xact)); } diff --git a/src/bsf/sbi-path.c b/src/bsf/sbi-path.c index b59ed8ac5..834a9dbfa 100644 --- a/src/bsf/sbi-path.c +++ b/src/bsf/sbi-path.c @@ -79,9 +79,6 @@ int bsf_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -114,6 +111,16 @@ int bsf_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = bsf_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)bsf_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } @@ -123,26 +130,43 @@ void bsf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool bsf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool bsf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data) { - return ogs_sbi_send(nf_instance, client_cb, xact); + ogs_sbi_nf_instance_t *nf_instance = NULL; + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + OpenAPI_nf_type_ToString(target_nf_type)); + return false; + } + + return ogs_sbi_send_request(nf_instance, client_cb, data); } -bool bsf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data)) +bool bsf_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data), + bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - ogs_assert(target_nf_type); + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(sess); ogs_assert(stream); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &sess->sbi, - (ogs_sbi_build_f)build, sess, data, - bsf_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &sess->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("bsf_sbi_discover_and_send() failed"); ogs_assert(true == @@ -154,8 +178,10 @@ bool bsf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)bsf_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &sess->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("bsf_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true == diff --git a/src/bsf/sbi-path.h b/src/bsf/sbi-path.h index 3996af7c0..61d17cec2 100644 --- a/src/bsf/sbi-path.h +++ b/src/bsf/sbi-path.h @@ -29,11 +29,15 @@ extern "C" { int bsf_sbi_open(void); void bsf_sbi_close(void); -bool bsf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); - -bool bsf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data)); +bool bsf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data); +bool bsf_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data), + bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data); void bsf_sbi_send_response(ogs_sbi_stream_t *stream, int status); diff --git a/src/nrf/nnrf-handler.c b/src/nrf/nnrf-handler.c index ea821d8a1..0b7c7e265 100644 --- a/src/nrf/nnrf-handler.c +++ b/src/nrf/nnrf-handler.c @@ -426,6 +426,21 @@ bool nrf_nnrf_handle_nf_discover( OpenAPI_nf_type_ToString(recvmsg->param.requester_nf_type), OpenAPI_nf_type_ToString(recvmsg->param.target_nf_type)); + if (recvmsg->param.discovery_option.target_nf_instance_id) { + ogs_debug("target-nf-instance-id[%s]", + recvmsg->param.discovery_option.target_nf_instance_id); + } + if (recvmsg->param.discovery_option.requester_nf_instance_id) { + ogs_debug("requester-nf-instance-id[%s]", + recvmsg->param.discovery_option.requester_nf_instance_id); + } + if (recvmsg->param.discovery_option.num_of_service_names) { + for (i = 0; + i < recvmsg->param.discovery_option.num_of_service_names; i++) + ogs_debug("[%d] service-names[%s]", i, + recvmsg->param.discovery_option.service_names[i]); + } + SearchResult = ogs_calloc(1, sizeof(*SearchResult)); ogs_assert(SearchResult); @@ -441,7 +456,9 @@ bool nrf_nnrf_handle_nf_discover( ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { if (nf_instance->nf_type != recvmsg->param.target_nf_type) continue; - if (nf_instance->nf_type == recvmsg->param.requester_nf_type) + if (recvmsg->param.discovery_option.target_nf_instance_id && + strcmp(nf_instance->id, + recvmsg->param.discovery_option.target_nf_instance_id) != 0) continue; if (!recvmsg->param.limit || diff --git a/src/nrf/sbi-path.c b/src/nrf/sbi-path.c index 9deeb6796..74ee6d55b 100644 --- a/src/nrf/sbi-path.c +++ b/src/nrf/sbi-path.c @@ -82,9 +82,6 @@ int nrf_sbi_open(void) { ogs_sbi_nf_instance_t *nf_instance = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Initialize SCP NF Instance */ nf_instance = ogs_sbi_self()->scp_instance; if (nf_instance) { @@ -96,6 +93,16 @@ int nrf_sbi_open(void) client->cb = client_notify_cb; } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = nrf_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)nrf_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } diff --git a/src/nrf/timer.c b/src/nrf/timer.c index 749a38eed..5e78ca256 100644 --- a/src/nrf/timer.c +++ b/src/nrf/timer.c @@ -82,3 +82,8 @@ void nrf_timer_subscription_validity(void *data) { timer_send_event(NRF_TIMER_SUBSCRIPTION_VALIDITY, data); } + +void nrf_timer_sbi_client_wait_expire(void *data) +{ + timer_send_event(NRF_TIMER_SBI_CLIENT_WAIT, data); +} diff --git a/src/nrf/timer.h b/src/nrf/timer.h index b2dac6c29..69e4c2ba6 100644 --- a/src/nrf/timer.h +++ b/src/nrf/timer.h @@ -32,6 +32,7 @@ typedef enum { NRF_TIMER_NF_INSTANCE_NO_HEARTBEAT, NRF_TIMER_SUBSCRIPTION_VALIDITY, + NRF_TIMER_SBI_CLIENT_WAIT, MAX_NUM_OF_NRF_TIMER, @@ -48,6 +49,7 @@ const char *nrf_timer_get_name(nrf_timer_e id); void nrf_timer_nf_instance_no_heartbeat(void *data); void nrf_timer_subscription_validity(void *data); +void nrf_timer_sbi_client_wait_expire(void *data); #ifdef __cplusplus } diff --git a/src/nssf/sbi-path.c b/src/nssf/sbi-path.c index 139d160bc..f38d35b5e 100644 --- a/src/nssf/sbi-path.c +++ b/src/nssf/sbi-path.c @@ -79,9 +79,6 @@ int nssf_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -114,6 +111,16 @@ int nssf_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = nssf_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)nssf_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } diff --git a/src/nssf/timer.c b/src/nssf/timer.c index ec77556a6..2a105758e 100644 --- a/src/nssf/timer.c +++ b/src/nssf/timer.c @@ -94,3 +94,8 @@ void nssf_timer_subscription_validity(void *data) { sbi_timer_send_event(NSSF_TIMER_SUBSCRIPTION_VALIDITY, data); } + +void nssf_timer_sbi_client_wait_expire(void *data) +{ + sbi_timer_send_event(NSSF_TIMER_SBI_CLIENT_WAIT, data); +} diff --git a/src/nssf/timer.h b/src/nssf/timer.h index 549574d18..67e10cac5 100644 --- a/src/nssf/timer.h +++ b/src/nssf/timer.h @@ -35,6 +35,7 @@ typedef enum { NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, NSSF_TIMER_NF_INSTANCE_VALIDITY, NSSF_TIMER_SUBSCRIPTION_VALIDITY, + NSSF_TIMER_SBI_CLIENT_WAIT, MAX_NUM_OF_NSSF_TIMER, @@ -47,6 +48,7 @@ void nssf_timer_nf_instance_heartbeat_interval(void *data); void nssf_timer_nf_instance_no_heartbeat(void *data); void nssf_timer_nf_instance_validity(void *data); void nssf_timer_subscription_validity(void *data); +void nssf_timer_sbi_client_wait_expire(void *data); #ifdef __cplusplus } diff --git a/src/pcf/context.c b/src/pcf/context.c index e1ef6b61a..2fbb7d15a 100644 --- a/src/pcf/context.c +++ b/src/pcf/context.c @@ -499,22 +499,6 @@ pcf_sess_t *pcf_sess_cycle(pcf_sess_t *sess) return ogs_pool_cycle(&pcf_sess_pool, sess); } -void pcf_ue_select_nf(pcf_ue_t *pcf_ue, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(pcf_ue); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&pcf_ue->sbi, nf_type, pcf_nf_state_registered); -} - -void pcf_sess_select_nf(pcf_sess_t *sess, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(sess); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&sess->sbi, nf_type, pcf_nf_state_registered); -} - pcf_app_t *pcf_app_add(pcf_sess_t *sess) { pcf_app_t *app = NULL; diff --git a/src/pcf/context.h b/src/pcf/context.h index 3ffdb6a30..860da3291 100644 --- a/src/pcf/context.h +++ b/src/pcf/context.h @@ -184,9 +184,6 @@ int pcf_sessions_number_by_snssai_and_dnn( pcf_ue_t *pcf_ue_cycle(pcf_ue_t *pcf_ue); pcf_sess_t *pcf_sess_cycle(pcf_sess_t *sess); -void pcf_ue_select_nf(pcf_ue_t *pcf_ue, OpenAPI_nf_type_e nf_type); -void pcf_sess_select_nf(pcf_sess_t *sess, OpenAPI_nf_type_e nf_type); - pcf_app_t *pcf_app_add(pcf_sess_t *sess); int pcf_app_remove(pcf_app_t *app); void pcf_app_remove_all(pcf_sess_t *sess); diff --git a/src/pcf/nnrf-handler.c b/src/pcf/nnrf-handler.c index 0c15944e9..a45e41852 100644 --- a/src/pcf/nnrf-handler.c +++ b/src/pcf/nnrf-handler.c @@ -253,18 +253,23 @@ void pcf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; - pcf_ue_t *pcf_ue = NULL; - pcf_sess_t *sess = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; OpenAPI_lnode_t *node = NULL; bool handled; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -299,9 +304,6 @@ void pcf_nnrf_handle_nf_discover( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - pcf_ue_t *pcf_ue = NULL; - pcf_sess_t *sess = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -318,23 +320,6 @@ void pcf_nnrf_handle_nf_discover( continue; } - switch(sbi_object->type) { - case OGS_SBI_OBJ_UE_TYPE: - pcf_ue = (pcf_ue_t *)sbi_object; - ogs_assert(pcf_ue); - pcf_ue_select_nf(pcf_ue, nf_instance->nf_type); - break; - case OGS_SBI_OBJ_SESS_TYPE: - sess = (pcf_sess_t *)sbi_object; - ogs_assert(sess); - pcf_sess_select_nf(sess, nf_instance->nf_type); - break; - default: - ogs_fatal("(NF discover search result) Not implemented [%d]", - sbi_object->type); - ogs_assert_if_reached(); - } - /* TIME : Update validity from NRF */ if (SearchResult->is_validity_period && SearchResult->validity_period) { @@ -353,31 +338,7 @@ void pcf_nnrf_handle_nf_discover( } } - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); - if (!nf_instance) { - 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, - OpenAPI_nf_type_ToString(xact->target_nf_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, - OpenAPI_nf_type_ToString(xact->target_nf_type)); - break; - default: - ogs_fatal("(NF discover) Not implemented [%s:%d]", - OpenAPI_nf_type_ToString(xact->target_nf_type), - sbi_object->type); - ogs_assert_if_reached(); - } - } else { - ogs_assert(true == pcf_sbi_send(nf_instance, xact)); - } + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + ogs_expect(true == pcf_sbi_send_request(sbi_object, target_nf_type, xact)); } diff --git a/src/pcf/npcf-handler.c b/src/pcf/npcf-handler.c index a2998350f..cb8f35f2f 100644 --- a/src/pcf/npcf-handler.c +++ b/src/pcf/npcf-handler.c @@ -148,8 +148,8 @@ bool pcf_npcf_am_policy_contrtol_handle_create(pcf_ue_t *pcf_ue, pcf_ue->subscribed_ue_ambr, PolicyAssociationRequest->ue_ambr); ogs_assert(true == - pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDR, pcf_ue, stream, NULL, - pcf_nudr_dr_build_query_am_data)); + pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + pcf_nudr_dr_build_query_am_data, pcf_ue, stream, NULL)); return true; } @@ -298,8 +298,8 @@ bool pcf_npcf_smpolicycontrol_handle_create(pcf_sess_t *sess, sess->subscribed_default_qos, SmPolicyContextData->subs_def_qos); ogs_assert(true == - pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_UDR, sess, stream, NULL, - pcf_nudr_dr_build_query_sm_data)); + pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + pcf_nudr_dr_build_query_sm_data, sess, stream, NULL)); return true; @@ -352,9 +352,8 @@ bool pcf_npcf_smpolicycontrol_handle_delete(pcf_sess_t *sess, ogs_assert(true == ogs_sbi_server_send_response(stream, response)); } else { ogs_assert(true == - pcf_sess_sbi_discover_and_send( - OpenAPI_nf_type_BSF, sess, stream, NULL, - pcf_nbsf_management_build_de_register)); + pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_BSF, NULL, + pcf_nbsf_management_build_de_register, sess, stream, NULL)); } return true; diff --git a/src/pcf/nudr-handler.c b/src/pcf/nudr-handler.c index b79c19bed..f2e7c055b 100644 --- a/src/pcf/nudr-handler.c +++ b/src/pcf/nudr-handler.c @@ -194,9 +194,8 @@ bool pcf_nudr_dr_handle_query_sm_data( } ogs_assert(true == - pcf_sess_sbi_discover_and_send( - OpenAPI_nf_type_BSF, sess, stream, NULL, - pcf_nbsf_management_build_register)); + pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_BSF, NULL, + pcf_nbsf_management_build_register, sess, stream, NULL)); return true; diff --git a/src/pcf/sbi-path.c b/src/pcf/sbi-path.c index 7c547f990..56c85a1c0 100644 --- a/src/pcf/sbi-path.c +++ b/src/pcf/sbi-path.c @@ -79,9 +79,6 @@ int pcf_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -127,6 +124,16 @@ int pcf_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = pcf_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)pcf_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } @@ -136,31 +143,76 @@ void pcf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool pcf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool pcf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data) { - return ogs_sbi_send(nf_instance, client_cb, xact); + ogs_sbi_nf_instance_t *nf_instance = NULL; + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_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, + OpenAPI_nf_type_ToString(target_nf_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, + OpenAPI_nf_type_ToString(target_nf_type)); + break; + default: + ogs_fatal("(NF discover) Not implemented [%s:%d]", + OpenAPI_nf_type_ToString(target_nf_type), + sbi_object->type); + ogs_assert_if_reached(); + } + + return false; + } + + return ogs_sbi_send_request(nf_instance, client_cb, data); } -static bool pcf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - ogs_sbi_object_t *sbi_object, ogs_sbi_stream_t *stream, - ogs_sbi_build_f build, void *context, void *data) +static bool pcf_sbi_discover_and_send( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_build_f build, + void *context, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(target_nf_type); ogs_assert(sbi_object); ogs_assert(stream); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, sbi_object, - build, context, data, - pcf_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + sbi_object, target_nf_type, discovery_option, + build, context, data); ogs_expect_or_return_val(xact, false); xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)pcf_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + sbi_object, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("ogs_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); return false; @@ -169,12 +221,15 @@ static bool pcf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, return true; } -bool pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data)) +bool pcf_ue_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data), + pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data) { - if (pcf_sbi_discover_and_send(target_nf_type, &pcf_ue->sbi, stream, - (ogs_sbi_build_f)build, pcf_ue, data) != true) { + if (pcf_sbi_discover_and_send( + &pcf_ue->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, pcf_ue, stream, data) != true) { ogs_error("pcf_ue_sbi_discover_and_send() failed"); ogs_assert(true == ogs_sbi_server_send_error(stream, @@ -186,12 +241,15 @@ bool pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, return true; } -bool pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data)) +bool pcf_sess_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + 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) { - if (pcf_sbi_discover_and_send(target_nf_type, &sess->sbi, stream, - (ogs_sbi_build_f)build, sess, data) != true) { + if (pcf_sbi_discover_and_send( + &sess->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, sess, stream, data) != true) { ogs_error("pcf_sess_sbi_discover_and_send() failed"); ogs_assert(true == ogs_sbi_server_send_error(stream, diff --git a/src/pcf/sbi-path.h b/src/pcf/sbi-path.h index 85d6b8dfe..2fc612554 100644 --- a/src/pcf/sbi-path.h +++ b/src/pcf/sbi-path.h @@ -34,13 +34,20 @@ extern "C" { int pcf_sbi_open(void); void pcf_sbi_close(void); -bool pcf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); -bool pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data)); -bool pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data)); +bool pcf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data); +bool pcf_ue_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data), + pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data); +bool pcf_sess_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + 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_sbi_send_am_policy_control_notify(pcf_ue_t *pcf_ue); bool pcf_sbi_send_smpolicycontrol_update_notify( diff --git a/src/scp/context.c b/src/scp/context.c index 8ee3b4764..f08d2e389 100644 --- a/src/scp/context.c +++ b/src/scp/context.c @@ -153,11 +153,3 @@ scp_conn_t *scp_conn_find(uint32_t index) { return ogs_pool_find(&scp_conn_pool, index); } - -void scp_conn_select_nf(scp_conn_t *sess, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(sess); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&sess->sbi, nf_type, scp_nf_state_registered); -} diff --git a/src/scp/context.h b/src/scp/context.h index db4198c7f..4474c72d7 100644 --- a/src/scp/context.h +++ b/src/scp/context.h @@ -79,8 +79,6 @@ void scp_conn_remove_all(void); scp_conn_t *scp_conn_find(uint32_t index); -void scp_conn_select_nf(scp_conn_t *sess, OpenAPI_nf_type_e nf_type); - #ifdef __cplusplus } #endif diff --git a/src/scp/nf-sm.c b/src/scp/nf-sm.c index ecd3af198..4af54d0e1 100644 --- a/src/scp/nf-sm.c +++ b/src/scp/nf-sm.c @@ -229,6 +229,47 @@ void scp_nf_state_registered(ogs_fsm_t *s, scp_event_t *e) nf_instance->time.heartbeat_interval + ogs_app()->time.nf_instance.no_heartbeat_margin)); } + + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_AMF)); + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_AUSF)); + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_BSF)); + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_NSSF)); + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_PCF)); + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_SMF)); + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_UDM)); + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + OpenAPI_nf_type_UDR)); } break; diff --git a/src/scp/nnrf-handler.c b/src/scp/nnrf-handler.c index c58781dd6..714368cf8 100644 --- a/src/scp/nnrf-handler.c +++ b/src/scp/nnrf-handler.c @@ -253,16 +253,22 @@ void scp_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; OpenAPI_lnode_t *node = NULL; bool handled; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -297,8 +303,6 @@ void scp_nnrf_handle_nf_discover( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - scp_conn_t *conn = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -315,10 +319,6 @@ void scp_nnrf_handle_nf_discover( continue; } - conn = (scp_conn_t *)sbi_object; - ogs_assert(conn); - scp_conn_select_nf(conn, nf_instance->nf_type); - /* TIME : Update validity from NRF */ if (SearchResult->is_validity_period && SearchResult->validity_period) { @@ -337,11 +337,12 @@ void scp_nnrf_handle_nf_discover( } } - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); if (!nf_instance) { ogs_error("(NF discover) No [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); + OpenAPI_nf_type_ToString(target_nf_type)); } else { scp_sbi_send(nf_instance, xact); } diff --git a/src/scp/sbi-path.c b/src/scp/sbi-path.c index 3c101c761..ce15f7679 100644 --- a/src/scp/sbi-path.c +++ b/src/scp/sbi-path.c @@ -29,9 +29,6 @@ int scp_sbi_open(void) { ogs_sbi_nf_instance_t *nf_instance = NULL; - if (ogs_sbi_server_start_all(request_handler) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -65,6 +62,16 @@ int scp_sbi_open(void) scp_nf_fsm_init(nf_instance); } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = scp_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)scp_nf_state_registered; + + if (ogs_sbi_server_start_all(request_handler) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } @@ -266,35 +273,25 @@ static int request_handler(ogs_sbi_request_t *source, void *data) return OGS_ERROR; } } else { - ogs_sbi_message_t message; + scp_event_t *e = NULL; + int rv; - ogs_error("Unknown HTTP Headers"); - ogs_error(" [%s:%s]", source->h.method, source->h.uri); - for (hi = ogs_hash_first(source->http.headers); - hi; hi = ogs_hash_next(hi)) { - char *key = (char *)ogs_hash_this_key(hi); - char *val = ogs_hash_this_val(hi); - ogs_error(" [%s:%s]", key, val); - } + ogs_assert(source); + ogs_assert(data); - rv = ogs_sbi_parse_request(&message, source); + e = scp_event_new(SCP_EVT_SBI_SERVER); + ogs_assert(e); + + e->sbi.request = source; + e->sbi.data = data; + + rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { - ogs_error("cannot parse HTTP sbi_message"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - NULL, "cannot parse HTTP sbi_message", NULL)); + ogs_error("ogs_queue_push() failed:%d", (int)rv); + ogs_sbi_request_free(source); + scp_event_free(e); return OGS_ERROR; } - - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - &message, "SCP - HTTP Client", NULL)); - - ogs_sbi_message_free(&message); - - return OGS_OK; } return OGS_OK; @@ -366,24 +363,29 @@ static int client_cb(int status, ogs_sbi_response_t *response, void *data) bool scp_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) { - return ogs_sbi_send(nf_instance, client_cb, xact); + return ogs_sbi_send_request(nf_instance, client_cb, xact); } -bool scp_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data)) +bool scp_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data), + scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - ogs_assert(target_nf_type); + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(conn); ogs_assert(stream); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &conn->sbi, - (ogs_sbi_build_f)build, conn, data, - scp_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &conn->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, conn, data); if (!xact) { ogs_error("scp_sbi_discover_and_send() failed"); ogs_assert(true == @@ -395,8 +397,10 @@ bool scp_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)scp_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &conn->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("scp_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true == diff --git a/src/scp/sbi-path.h b/src/scp/sbi-path.h index 04a2aeda7..2dba2758e 100644 --- a/src/scp/sbi-path.h +++ b/src/scp/sbi-path.h @@ -31,9 +31,11 @@ void scp_sbi_close(void); bool scp_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); -bool scp_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data)); +bool scp_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data), + scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data); #ifdef __cplusplus } diff --git a/src/smf/context.c b/src/smf/context.c index cfc094c8a..6527137d0 100644 --- a/src/smf/context.c +++ b/src/smf/context.c @@ -80,7 +80,7 @@ void smf_context_init(void) ogs_log_install_domain(&__smf_log_domain, "smf", ogs_core()->log.level); ogs_log_install_domain(&__gsm_log_domain, "gsm", ogs_core()->log.level); - ogs_pool_init(&smf_gtp_node_pool, ogs_app()->pool.gtp_node); + ogs_pool_init(&smf_gtp_node_pool, ogs_app()->pool.nf); ogs_pool_init(&smf_ue_pool, ogs_app()->max.ue); ogs_pool_init(&smf_sess_pool, ogs_app()->pool.sess); ogs_pool_init(&smf_bearer_pool, ogs_app()->pool.bearer); @@ -2528,14 +2528,6 @@ smf_bearer_t *smf_qos_flow_cycle(smf_bearer_t *qos_flow) return ogs_pool_cycle(&smf_bearer_pool, qos_flow); } -void smf_sess_select_nf(smf_sess_t *sess, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(sess); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&sess->sbi, nf_type, smf_nf_state_registered); -} - smf_pf_t *smf_pf_add(smf_bearer_t *bearer) { smf_sess_t *sess = NULL; diff --git a/src/smf/context.h b/src/smf/context.h index 29d6b5b62..be7443fc8 100644 --- a/src/smf/context.h +++ b/src/smf/context.h @@ -502,8 +502,6 @@ smf_sess_t *smf_sess_cycle(smf_sess_t *sess); smf_bearer_t *smf_qos_flow_cycle(smf_bearer_t *qos_flow); smf_bearer_t *smf_bearer_cycle(smf_bearer_t *bearer); -void smf_sess_select_nf(smf_sess_t *sess, OpenAPI_nf_type_e nf_type); - smf_pf_t *smf_pf_add(smf_bearer_t *bearer); int smf_pf_remove(smf_pf_t *pf); void smf_pf_remove_all(smf_bearer_t *bearer); diff --git a/src/smf/gsm-handler.c b/src/smf/gsm-handler.c index 30d148605..8e7a21fc2 100644 --- a/src/smf/gsm-handler.c +++ b/src/smf/gsm-handler.c @@ -67,9 +67,9 @@ int gsm_handle_pdu_session_establishment_request( } ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_UDM, sess, stream, - 0, (char *)OGS_SBI_RESOURCE_NAME_SM_DATA, - smf_nudm_sdm_build_get)); + smf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + smf_nudm_sdm_build_get, + sess, stream, 0, (char *)OGS_SBI_RESOURCE_NAME_SM_DATA)); return OGS_OK; } diff --git a/src/smf/gsm-sm.c b/src/smf/gsm-sm.c index 735de066f..20a9a8f69 100644 --- a/src/smf/gsm-sm.c +++ b/src/smf/gsm-sm.c @@ -996,9 +996,10 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e) NGAP_CauseNas_normal_release; ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, sess, stream, - OGS_PFCP_DELETE_TRIGGER_UE_REQUESTED, ¶m, - smf_npcf_smpolicycontrol_build_delete)); + smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_npcf_smpolicycontrol_build_delete, + sess, stream, + OGS_PFCP_DELETE_TRIGGER_UE_REQUESTED, ¶m)); } else { ogs_error("[%s:%d] No PolicyAssociationId", smf_ue->supi, sess->psi); diff --git a/src/smf/nnrf-handler.c b/src/smf/nnrf-handler.c index 417114b2e..f50bc207a 100644 --- a/src/smf/nnrf-handler.c +++ b/src/smf/nnrf-handler.c @@ -253,16 +253,22 @@ void smf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; OpenAPI_lnode_t *node = NULL; bool handled; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -297,8 +303,6 @@ void smf_nnrf_handle_nf_discover( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - smf_sess_t *sess = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -315,10 +319,6 @@ void smf_nnrf_handle_nf_discover( continue; } - sess = (smf_sess_t *)sbi_object; - ogs_assert(sess); - smf_sess_select_nf(sess, nf_instance->nf_type); - /* TIME : Update validity from NRF */ if (SearchResult->is_validity_period && SearchResult->validity_period) { @@ -337,85 +337,7 @@ void smf_nnrf_handle_nf_discover( } } - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); - } else { - ogs_assert(true == smf_sbi_send(nf_instance, xact)); - } -} - -void smf_nnrf_handle_nf_profile_retrieve( - ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) -{ - ogs_sbi_object_t *sbi_object = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - bool handled; - - ogs_assert(xact); - sbi_object = xact->sbi_object; - ogs_assert(sbi_object); - ogs_assert(recvmsg); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - smf_nf_fsm_init(nf_instance); - - 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); - - ogs_warn("[%s] (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - smf_sess_t *sess = NULL; - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("ogs_sbi_nnrf_handle_nf_profile() failed [%s]", - nf_instance->id); - SMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - return; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("[%s] Cannot assciate NF EndPoint", nf_instance->id); - SMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - return; - } - - sess = (smf_sess_t *)sbi_object; - ogs_assert(sess); - smf_sess_select_nf(sess, nf_instance->nf_type); - - ogs_info("[%s] (NF-discover) NF Profile updated", nf_instance->id); - } - - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); - } else { - ogs_assert(true == smf_sbi_send(nf_instance, xact)); - } + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + ogs_expect(true == smf_sbi_send_request(sbi_object, target_nf_type, xact)); } diff --git a/src/smf/nnrf-handler.h b/src/smf/nnrf-handler.h index d159d8b3e..431b6c933 100644 --- a/src/smf/nnrf-handler.h +++ b/src/smf/nnrf-handler.h @@ -36,8 +36,6 @@ bool smf_nnrf_handle_nf_status_notify( void smf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg); -void smf_nnrf_handle_nf_profile_retrieve( - ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg); #ifdef __cplusplus } diff --git a/src/smf/npcf-handler.c b/src/smf/npcf-handler.c index 626c85646..c0b3d481b 100644 --- a/src/smf/npcf-handler.c +++ b/src/smf/npcf-handler.c @@ -683,9 +683,9 @@ bool smf_npcf_smpolicycontrol_handle_terminate_notify( memset(¶m, 0, sizeof(param)); ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, sess, NULL, - OGS_PFCP_DELETE_TRIGGER_PCF_INITIATED, ¶m, - smf_npcf_smpolicycontrol_build_delete)); + smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_npcf_smpolicycontrol_build_delete, + sess, NULL, OGS_PFCP_DELETE_TRIGGER_PCF_INITIATED, ¶m)); return true; } diff --git a/src/smf/nsmf-handler.c b/src/smf/nsmf-handler.c index 1b22f9831..f613431f6 100644 --- a/src/smf/nsmf-handler.c +++ b/src/smf/nsmf-handler.c @@ -590,9 +590,10 @@ bool smf_nsmf_handle_update_sm_context( param.ue_timezone = true; ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, sess, stream, - OGS_PFCP_DELETE_TRIGGER_AMF_UPDATE_SM_CONTEXT, ¶m, - smf_npcf_smpolicycontrol_build_delete)); + smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_npcf_smpolicycontrol_build_delete, + sess, stream, + OGS_PFCP_DELETE_TRIGGER_AMF_UPDATE_SM_CONTEXT, ¶m)); } } else { ogs_error("No PolicyAssociationId"); @@ -665,9 +666,10 @@ bool smf_nsmf_handle_release_sm_context( if (sess->policy_association_id) { ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, sess, stream, - OGS_PFCP_DELETE_TRIGGER_AMF_RELEASE_SM_CONTEXT, ¶m, - smf_npcf_smpolicycontrol_build_delete)); + smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_npcf_smpolicycontrol_build_delete, + sess, stream, + OGS_PFCP_DELETE_TRIGGER_AMF_RELEASE_SM_CONTEXT, ¶m)); } else { ogs_error("No PolicyAssociationId"); ogs_assert(true == diff --git a/src/smf/nudm-handler.c b/src/smf/nudm-handler.c index 9741e5b67..c6f030605 100644 --- a/src/smf/nudm-handler.c +++ b/src/smf/nudm-handler.c @@ -288,8 +288,8 @@ bool smf_nudm_sdm_handle_get(smf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_free(sendmsg.http.location); ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, sess, stream, - 0, NULL, smf_npcf_smpolicycontrol_build_create)); + smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_npcf_smpolicycontrol_build_create, sess, stream, 0, NULL)); return true; diff --git a/src/smf/sbi-path.c b/src/smf/sbi-path.c index 553541355..f9852466b 100644 --- a/src/smf/sbi-path.c +++ b/src/smf/sbi-path.c @@ -81,9 +81,6 @@ int smf_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -116,6 +113,16 @@ int smf_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = smf_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)smf_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } @@ -125,29 +132,47 @@ void smf_sbi_close(void) ogs_sbi_server_stop_all(); } -bool smf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool smf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data) { - return ogs_sbi_send(nf_instance, client_cb, xact); + ogs_sbi_nf_instance_t *nf_instance = NULL; + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + OpenAPI_nf_type_ToString(target_nf_type)); + return false; + } + + return ogs_sbi_send_request(nf_instance, client_cb, data); } -bool smf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data, - ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data)) +bool smf_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data), + smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data) { - ogs_sbi_xact_t *xact = NULL; smf_ue_t *smf_ue = NULL; + ogs_sbi_xact_t *xact = NULL; - ogs_assert(target_nf_type); + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; ogs_assert(sess); smf_ue = sess->smf_ue; ogs_assert(smf_ue); + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); + ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &sess->sbi, - (ogs_sbi_build_f)build, sess, data, - smf_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &sess->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("smf_sbi_discover_and_send() failed"); ogs_assert(true == @@ -160,8 +185,10 @@ bool smf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, xact->state = state; xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)smf_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &sess->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("smf_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); @@ -179,8 +206,12 @@ bool smf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, void smf_namf_comm_send_n1_n2_message_transfer( smf_sess_t *sess, smf_n1_n2_message_transfer_param_t *param) { - ogs_sbi_xact_t *xact = NULL; smf_ue_t *smf_ue = NULL; + ogs_sbi_xact_t *xact = NULL; + + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + ogs_sbi_discovery_option_t *discovery_option = NULL; ogs_assert(param); ogs_assert(param->state); @@ -190,9 +221,21 @@ void smf_namf_comm_send_n1_n2_message_transfer( smf_ue = sess->smf_ue; ogs_assert(smf_ue); - xact = ogs_sbi_xact_add(OpenAPI_nf_type_AMF, &sess->sbi, + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); + + target_nf_type = OpenAPI_nf_type_AMF; + + discovery_option = ogs_sbi_discovery_option_new(); + ogs_assert(discovery_option); + ogs_sbi_discovery_option_set_target_nf_instance_id( + discovery_option, sess->serving_nf_id); + + xact = ogs_sbi_xact_add( + &sess->sbi, target_nf_type, discovery_option, (ogs_sbi_build_f)smf_namf_comm_build_n1_n2_message_transfer, - sess, param, smf_timer_sbi_client_wait_expire); + sess, param); if (!xact) { ogs_error("smf_namf_comm_send_n1_n2_message_transfer() failed"); return; @@ -200,10 +243,10 @@ void smf_namf_comm_send_n1_n2_message_transfer( xact->state = param->state; - if (ogs_sbi_discover_by_nf_instanceid_and_send(xact, - (ogs_fsm_handler_t)smf_nf_state_registered, client_cb, - sess->serving_nf_id) != true) - { + if (ogs_sbi_discover_and_send( + &sess->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("smf_namf_comm_send_n1_n2_message_transfer() failed"); ogs_sbi_xact_remove(xact); } diff --git a/src/smf/sbi-path.h b/src/smf/sbi-path.h index 0de2b6324..46124c47d 100644 --- a/src/smf/sbi-path.h +++ b/src/smf/sbi-path.h @@ -34,11 +34,15 @@ extern "C" { int smf_sbi_open(void); void smf_sbi_close(void); -bool smf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); - -bool smf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data, - ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data)); +bool smf_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data); +bool smf_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data), + smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data); void smf_namf_comm_send_n1_n2_message_transfer( smf_sess_t *sess, smf_n1_n2_message_transfer_param_t *param); diff --git a/src/smf/smf-sm.c b/src/smf/smf-sm.c index f91618067..f3ae98f32 100644 --- a/src/smf/smf-sm.c +++ b/src/smf/smf-sm.c @@ -658,27 +658,12 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e) SWITCH(sbi_message.h.resource.component[0]) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - SWITCH(sbi_message.h.method) - CASE(OGS_SBI_HTTP_METHOD_GET) - sbi_xact = e->sbi.data; - ogs_assert(sbi_xact); - - if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_OK) - smf_nnrf_handle_nf_profile_retrieve( - sbi_xact, &sbi_message); - else - ogs_error("HTTP response error [%d]", - sbi_message.res_status); - break; - DEFAULT - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - - e->sbi.message = &sbi_message; - ogs_fsm_dispatch(&nf_instance->sm, e); - END + e->sbi.message = &sbi_message; + ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) diff --git a/src/udm/context.c b/src/udm/context.c index f3a22fa59..b35b566e7 100644 --- a/src/udm/context.c +++ b/src/udm/context.c @@ -229,11 +229,3 @@ udm_ue_t *udm_ue_cycle(udm_ue_t *udm_ue) { return ogs_pool_cycle(&udm_ue_pool, udm_ue); } - -void udm_ue_select_nf(udm_ue_t *udm_ue, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(udm_ue); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&udm_ue->sbi, nf_type, udm_nf_state_registered); -} diff --git a/src/udm/context.h b/src/udm/context.h index b5d898834..9ded283ca 100644 --- a/src/udm/context.h +++ b/src/udm/context.h @@ -106,8 +106,6 @@ udm_ue_t *udm_ue_find_by_ctx_id(char *ctx_id); udm_ue_t *udm_ue_cycle(udm_ue_t *udm_ue); -void udm_ue_select_nf(udm_ue_t *udm_ue, OpenAPI_nf_type_e nf_type); - #ifdef __cplusplus } #endif diff --git a/src/udm/nnrf-handler.c b/src/udm/nnrf-handler.c index de16a12fe..59b966c33 100644 --- a/src/udm/nnrf-handler.c +++ b/src/udm/nnrf-handler.c @@ -253,16 +253,22 @@ void udm_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; OpenAPI_lnode_t *node = NULL; bool handled; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -297,8 +303,6 @@ void udm_nnrf_handle_nf_discover( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - udm_ue_t *udm_ue = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -315,10 +319,6 @@ void udm_nnrf_handle_nf_discover( continue; } - udm_ue = (udm_ue_t *)sbi_object; - ogs_assert(udm_ue); - udm_ue_select_nf(udm_ue, nf_instance->nf_type); - /* TIME : Update validity from NRF */ if (SearchResult->is_validity_period && SearchResult->validity_period) { @@ -337,12 +337,7 @@ void udm_nnrf_handle_nf_discover( } } - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); - } else { - ogs_assert(true == udm_sbi_send(nf_instance, xact)); - } + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + ogs_expect(true == udm_sbi_send_request(sbi_object, target_nf_type, xact)); } diff --git a/src/udm/nudm-handler.c b/src/udm/nudm-handler.c index 2a0b8cb1e..407f3129f 100644 --- a/src/udm/nudm-handler.c +++ b/src/udm/nudm-handler.c @@ -73,9 +73,10 @@ bool udm_nudm_ueau_handle_get( ResynchronizationInfo = AuthenticationInfoRequest->resynchronization_info; if (!ResynchronizationInfo) { - ogs_assert(true == udm_sbi_discover_and_send( - OpenAPI_nf_type_UDR, udm_ue, stream, NULL, - udm_nudr_dr_build_authentication_subscription)); + ogs_assert(true == + udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_nudr_dr_build_authentication_subscription, + udm_ue, stream, NULL)); } else { uint8_t rand[OGS_RAND_LEN]; @@ -162,9 +163,9 @@ bool udm_nudm_ueau_handle_get( ogs_uint64_to_buffer(sqn, OGS_SQN_LEN, udm_ue->sqn); ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, - udm_ue, stream, udm_ue->sqn, - udm_nudr_dr_build_authentication_subscription)); + udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_nudr_dr_build_authentication_subscription, + udm_ue, stream, udm_ue->sqn)); } return true; @@ -232,8 +233,9 @@ bool udm_nudm_ueau_handle_result_confirmation_inform( udm_ue->auth_event, message->AuthEvent); ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, udm_ue, stream, NULL, - udm_nudr_dr_build_update_authentication_status)); + udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_nudr_dr_build_update_authentication_status, + udm_ue, stream, NULL)); return true; } @@ -330,8 +332,8 @@ bool udm_nudm_uecm_handle_registration( message->Amf3GppAccessRegistration); ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, udm_ue, stream, NULL, - udm_nudr_dr_build_update_amf_context)); + udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_nudr_dr_build_update_amf_context, udm_ue, stream, NULL)); return true; } @@ -437,8 +439,9 @@ bool udm_nudm_uecm_handle_registration_update( } ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, udm_ue, stream, - PatchItemList, udm_nudr_dr_build_patch_amf_context)); + udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_nudr_dr_build_patch_amf_context, + udm_ue, stream, PatchItemList)); return true; } diff --git a/src/udm/sbi-path.c b/src/udm/sbi-path.c index 83cc9f3b0..1e1c87317 100644 --- a/src/udm/sbi-path.c +++ b/src/udm/sbi-path.c @@ -79,9 +79,6 @@ int udm_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -129,6 +126,16 @@ int udm_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = udm_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)udm_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } @@ -138,25 +145,44 @@ void udm_sbi_close(void) ogs_sbi_server_stop_all(); } -bool udm_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool udm_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data) { - return ogs_sbi_send(nf_instance, client_cb, xact); + ogs_sbi_nf_instance_t *nf_instance = NULL; + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + OpenAPI_nf_type_ToString(target_nf_type)); + return false; + } + + return ogs_sbi_send_request(nf_instance, client_cb, data); } -bool udm_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data)) +bool udm_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data), + udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(target_nf_type); ogs_assert(udm_ue); ogs_assert(stream); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &udm_ue->sbi, - (ogs_sbi_build_f)build, udm_ue, data, - udm_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &udm_ue->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, udm_ue, data); if (!xact) { ogs_error("udm_sbi_discover_and_send() failed"); ogs_assert(true == @@ -168,8 +194,10 @@ bool udm_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)udm_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &udm_ue->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("udm_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true == diff --git a/src/udm/sbi-path.h b/src/udm/sbi-path.h index 32252ca6f..c7dd32759 100644 --- a/src/udm/sbi-path.h +++ b/src/udm/sbi-path.h @@ -30,10 +30,15 @@ extern "C" { int udm_sbi_open(void); void udm_sbi_close(void); -bool udm_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); -bool udm_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data, - ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data)); +bool udm_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data); +bool udm_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data), + udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data); #ifdef __cplusplus } diff --git a/src/udm/ue-sm.c b/src/udm/ue-sm.c index 3fcf2fe08..16781925b 100644 --- a/src/udm/ue-sm.c +++ b/src/udm/ue-sm.c @@ -143,9 +143,9 @@ void udm_ue_state_operational(ogs_fsm_t *s, udm_event_t *e) CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA) CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) ogs_assert(true == - udm_sbi_discover_and_send( - OpenAPI_nf_type_UDR, udm_ue, stream, message, - udm_nudr_dr_build_query_subscription_provisioned)); + udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_nudr_dr_build_query_subscription_provisioned, + udm_ue, stream, message)); break; CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) diff --git a/src/udr/sbi-path.c b/src/udr/sbi-path.c index d4bce2155..91f6b39f2 100644 --- a/src/udr/sbi-path.c +++ b/src/udr/sbi-path.c @@ -79,9 +79,6 @@ int udr_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -116,6 +113,16 @@ int udr_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = udr_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)udr_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + return OGS_OK; } diff --git a/src/udr/timer.c b/src/udr/timer.c index f567ba0b0..e672f3724 100644 --- a/src/udr/timer.c +++ b/src/udr/timer.c @@ -94,3 +94,8 @@ void udr_timer_subscription_validity(void *data) { sbi_timer_send_event(UDR_TIMER_SUBSCRIPTION_VALIDITY, data); } + +void udr_timer_sbi_client_wait_expire(void *data) +{ + sbi_timer_send_event(UDR_TIMER_SBI_CLIENT_WAIT, data); +} diff --git a/src/udr/timer.h b/src/udr/timer.h index c5abf0a57..7f078afb8 100644 --- a/src/udr/timer.h +++ b/src/udr/timer.h @@ -35,6 +35,7 @@ typedef enum { UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT, UDR_TIMER_NF_INSTANCE_VALIDITY, UDR_TIMER_SUBSCRIPTION_VALIDITY, + UDR_TIMER_SBI_CLIENT_WAIT, MAX_NUM_OF_UDR_TIMER, @@ -47,6 +48,7 @@ void udr_timer_nf_instance_heartbeat_interval(void *data); void udr_timer_nf_instance_no_heartbeat(void *data); void udr_timer_nf_instance_validity(void *data); void udr_timer_subscription_validity(void *data); +void udr_timer_sbi_client_wait_expire(void *data); #ifdef __cplusplus } diff --git a/tests/af/af-sm.c b/tests/af/af-sm.c index 0736c1794..a1c05164e 100644 --- a/tests/af/af-sm.c +++ b/tests/af/af-sm.c @@ -455,8 +455,8 @@ void af_state_operational(ogs_fsm_t *s, af_event_t *e) switch(e->local_id) { case AF_LOCAL_DISCOVER_AND_SEND: - af_sbi_discover_and_send(e->local.target_nf_type, - e->sess, e->local.data, e->local.build); + af_sbi_discover_and_send(e->local.target_nf_type, NULL, + e->local.build, e->sess, e->local.data); break; case AF_LOCAL_SEND_TO_PCF: af_sbi_send_to_pcf(e->sess, e->local.data, e->local.build); diff --git a/tests/af/context.c b/tests/af/context.c index b81abb3f6..25c33ddd6 100644 --- a/tests/af/context.c +++ b/tests/af/context.c @@ -262,14 +262,6 @@ af_sess_t *af_sess_find_by_pcf_app_session_id(char *pcf_app_session_id) pcf_app_session_id, strlen(pcf_app_session_id)); } -void af_sess_select_nf(af_sess_t *sess, OpenAPI_nf_type_e nf_type) -{ - ogs_assert(sess); - ogs_assert(nf_type); - - ogs_sbi_select_nf(&sess->sbi, nf_type, af_nf_state_registered); -} - static ogs_sbi_client_t *find_client_by_fqdn(char *fqdn, int port) { int rv; diff --git a/tests/af/context.h b/tests/af/context.h index d20989bd5..3ac13b893 100644 --- a/tests/af/context.h +++ b/tests/af/context.h @@ -113,8 +113,6 @@ af_sess_t *af_sess_find(uint32_t index); af_sess_t *af_sess_find_by_af_app_session_id(char *af_app_session_id); af_sess_t *af_sess_find_by_pcf_app_session_id(char *pcf_app_session_id); -void af_sess_select_nf(af_sess_t *sess, OpenAPI_nf_type_e nf_type); - void af_sess_associate_pcf_client(af_sess_t *sess); #ifdef __cplusplus diff --git a/tests/af/nnrf-handler.c b/tests/af/nnrf-handler.c index c7c0bbc1d..46f7f9c8d 100644 --- a/tests/af/nnrf-handler.c +++ b/tests/af/nnrf-handler.c @@ -257,16 +257,22 @@ void af_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; + OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_discovery_option_t *discovery_option = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; OpenAPI_lnode_t *node = NULL; bool handled; + ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - ogs_assert(recvmsg); + target_nf_type = xact->target_nf_type; + ogs_assert(target_nf_type); + + discovery_option = xact->discovery_option; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -301,8 +307,6 @@ void af_nnrf_handle_nf_discover( } if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - af_sess_t *sess = NULL; - handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, NULL, NULL); if (!handled) { @@ -319,10 +323,6 @@ void af_nnrf_handle_nf_discover( continue; } - sess = (af_sess_t *)sbi_object; - ogs_assert(sess); - af_sess_select_nf(sess, nf_instance->nf_type); - /* TIME : Update validity from NRF */ if (SearchResult->validity_period) { nf_instance->time.validity_duration = @@ -340,12 +340,7 @@ void af_nnrf_handle_nf_discover( } } - ogs_assert(xact->target_nf_type); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, xact->target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); - } else { - af_sbi_send(nf_instance, xact); - } + ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + + ogs_expect(true == af_sbi_send_request(sbi_object, target_nf_type, xact)); } diff --git a/tests/af/sbi-path.c b/tests/af/sbi-path.c index 6a81d652b..43e354d66 100644 --- a/tests/af/sbi-path.c +++ b/tests/af/sbi-path.c @@ -79,9 +79,6 @@ int af_sbi_open(void) ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) - return OGS_ERROR; - /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -112,6 +109,17 @@ int af_sbi_open(void) } } + /* Timer expiration handler of client wait timer */ + ogs_sbi_self()->client_wait_expire = af_timer_sbi_client_wait_expire; + + /* NF register state in NF state machine */ + ogs_sbi_self()->nf_state_registered = + (ogs_fsm_handler_t)af_nf_state_registered; + + if (ogs_sbi_server_start_all(server_cb) != OGS_OK) + return OGS_ERROR; + + return OGS_OK; } @@ -136,32 +144,53 @@ bool af_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance) client, client->cb, request, nf_instance); } -void af_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool af_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data) { - ogs_sbi_send(nf_instance, client_cb, xact); + ogs_sbi_nf_instance_t *nf_instance = NULL; + + nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + if (!nf_instance) { + ogs_error("(NF discover) No [%s]", + OpenAPI_nf_type_ToString(target_nf_type)); + return false; + } + + return ogs_sbi_send_request(nf_instance, client_cb, data); } -void af_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - af_sess_t *sess, void *data, - ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data)) +void af_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data), + af_sess_t *sess, void *data) { ogs_sbi_xact_t *xact = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); ogs_assert(target_nf_type); ogs_assert(sess); ogs_assert(build); - xact = ogs_sbi_xact_add(target_nf_type, &sess->sbi, - (ogs_sbi_build_f)build, sess, data, - af_timer_sbi_client_wait_expire); + xact = ogs_sbi_xact_add( + &sess->sbi, target_nf_type, discovery_option, + (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("af_sbi_discover_and_send() failed"); return; } - if (ogs_sbi_discover_and_send(xact, - (ogs_fsm_handler_t)af_nf_state_registered, client_cb) != true) { + if (ogs_sbi_discover_and_send( + &sess->sbi, + target_nf_type, requester_nf_type, discovery_option, + client_cb, xact) != true) { ogs_error("af_sbi_discover_and_send() failed"); return; } diff --git a/tests/af/sbi-path.h b/tests/af/sbi-path.h index e398b1f3d..d487f04d7 100644 --- a/tests/af/sbi-path.h +++ b/tests/af/sbi-path.h @@ -33,11 +33,15 @@ void af_sbi_close(void); bool af_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance); -void af_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); - -void af_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, - af_sess_t *sess, void *data, - ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data)); +bool af_sbi_send_request( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + void *data); +void af_sbi_discover_and_send( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data), + af_sess_t *sess, void *data); void af_sbi_send_to_pcf( af_sess_t *sess, void *data, diff --git a/tests/app/5gc-init.c b/tests/app/5gc-init.c index d7c787079..b1ad017ac 100644 --- a/tests/app/5gc-init.c +++ b/tests/app/5gc-init.c @@ -101,8 +101,8 @@ void app_terminate(void) if (udm_thread) ogs_thread_destroy(udm_thread); if (ausf_thread) ogs_thread_destroy(ausf_thread); - if (nrf_thread) ogs_thread_destroy(nrf_thread); if (scp_thread) ogs_thread_destroy(scp_thread); + if (nrf_thread) ogs_thread_destroy(nrf_thread); } void test_5gc_init(void) diff --git a/tests/app/app-init.c b/tests/app/app-init.c index ce8a98dbf..3926bae76 100644 --- a/tests/app/app-init.c +++ b/tests/app/app-init.c @@ -123,8 +123,9 @@ void app_terminate(void) if (hss_thread) ogs_thread_destroy(hss_thread); if (pcrf_thread) ogs_thread_destroy(pcrf_thread); - if (nrf_thread) ogs_thread_destroy(nrf_thread); + if (scp_thread) ogs_thread_destroy(scp_thread); + if (nrf_thread) ogs_thread_destroy(nrf_thread); } void test_app_init(void)