Support Discovery Optional Parameter (#1671)

To support target-nf-instance-id in the discovery,
Discovery optional parameter is implemeted
This commit is contained in:
Sukchan Lee 2022-07-24 15:10:09 +09:00
parent eb03704015
commit a5010a61ef
89 changed files with 1346 additions and 998 deletions

View File

@ -200,33 +200,33 @@ nrf:
#
# <SBI Client>>
#
# 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:

View File

@ -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);
}

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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++;
}

View File

@ -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

View File

@ -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;

View File

@ -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
}

View File

@ -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;

View File

@ -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)

View File

@ -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();
}
}

View File

@ -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)

View File

@ -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,
&param, amf_nsmf_pdusession_build_update_sm_context));
&param));
}
} 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, &param,
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, &param));
} else {
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF,
sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, &param,
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, &param));
}
switch (gsm_header->message_type) {

View File

@ -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);

View File

@ -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);
}

View File

@ -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, &param,
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, &param));
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, &param,
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, &param));
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, &param,
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, &param));
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, &param,
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, &param));
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, &param,
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, &param));
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, &param,
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, &param));
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, &param,
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, &param));
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, &param,
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, &param));
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, &param,
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, &param));
}
}
@ -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, &param,
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, &param));
}
}

View File

@ -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) {

View File

@ -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
}

View File

@ -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)) {
/*

View File

@ -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

View File

@ -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(&param, 0, sizeof(param));
param.upCnxState = OpenAPI_up_cnx_state_ACTIVATING;
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF,
sess, state, &param,
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, &param);
}
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, &param, 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, &param);
}
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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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 ==

View File

@ -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
}

View File

@ -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);
}

View File

@ -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

View File

@ -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));
}

View File

@ -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 ==

View File

@ -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);

View File

@ -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 ||

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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
}

View File

@ -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;

View File

@ -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);

View File

@ -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));
}

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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(

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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);
}

View File

@ -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 ==

View File

@ -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
}

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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, &param,
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, &param));
} else {
ogs_error("[%s:%d] No PolicyAssociationId",
smf_ue->supi, sess->psi);

View File

@ -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));
}

View File

@ -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
}

View File

@ -683,9 +683,9 @@ bool smf_npcf_smpolicycontrol_handle_terminate_notify(
memset(&param, 0, sizeof(param));
ogs_assert(true ==
smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, sess, NULL,
OGS_PFCP_DELETE_TRIGGER_PCF_INITIATED, &param,
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, &param));
return true;
}

View File

@ -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, &param,
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, &param));
}
} 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, &param,
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, &param));
} else {
ogs_error("No PolicyAssociationId");
ogs_assert(true ==

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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)

View File

@ -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);
}

View File

@ -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

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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 ==

View File

@ -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
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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
}

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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,

View File

@ -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)

View File

@ -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)