[SBI] Change NfInstance.Id to Optional

This commit is contained in:
Sukchan Lee 2022-06-18 23:56:12 +09:00
parent 0313910ac6
commit c528e0d5bc
94 changed files with 1260 additions and 1014 deletions

View File

@ -33,6 +33,8 @@ static OGS_POOL(nf_info_pool, ogs_sbi_nf_info_t);
void ogs_sbi_context_init(void)
{
char nf_instance_id[OGS_UUID_FORMATTED_LENGTH + 1];
ogs_assert(context_initialized == 0);
/* Initialize SBI context */
@ -57,8 +59,14 @@ void ogs_sbi_context_init(void)
ogs_pool_init(&nf_info_pool, ogs_app()->pool.nf * OGS_MAX_NUM_OF_NF_INFO);
/* Add SELF NF instance */
self.nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(self.nf_instance);
ogs_uuid_get(&self.uuid);
ogs_uuid_format(self.nf_instance_id, &self.uuid);
ogs_uuid_format(nf_instance_id, &self.uuid);
ogs_sbi_nf_instance_set_id(self.nf_instance, nf_instance_id);
context_initialized = 1;
}
@ -74,8 +82,6 @@ void ogs_sbi_context_final(void)
ogs_sbi_nf_instance_remove_all();
ogs_sbi_nf_info_remove_all(&self.nf_info_list);
ogs_pool_final(&nf_instance_pool);
ogs_pool_final(&nf_service_pool);
ogs_pool_final(&smf_info_pool);
@ -470,9 +476,10 @@ int ogs_sbi_context_parse_config(const char *local, const char *remote)
client = ogs_sbi_client_add(addr);
ogs_assert(client);
nf_instance = ogs_sbi_nf_instance_add(
ogs_sbi_self()->nf_instance_id);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_type(
nf_instance, OpenAPI_nf_type_NRF);
OGS_SBI_SETUP_CLIENT(nf_instance, client);
@ -494,17 +501,10 @@ int ogs_sbi_context_parse_config(const char *local, const char *remote)
return OGS_OK;
}
bool ogs_sbi_nf_instance_maximum_number_is_reached()
{
return nf_instance_pool.avail <= 0;
}
ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id)
ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_assert(id);
ogs_pool_alloc(&nf_instance_pool, &nf_instance);
ogs_assert(nf_instance);
memset(nf_instance, 0, sizeof(ogs_sbi_nf_instance_t));
@ -512,9 +512,6 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id)
nf_instance->reference_count++;
ogs_trace("ogs_sbi_nf_instance_add()");
nf_instance->id = ogs_strdup(id);
ogs_assert(nf_instance->id);
nf_instance->time.heartbeat_interval =
ogs_app()->time.nf_instance.heartbeat_interval;
@ -540,6 +537,33 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id)
return nf_instance;
}
void ogs_sbi_nf_instance_set_id(ogs_sbi_nf_instance_t *nf_instance, char *id)
{
ogs_assert(nf_instance);
ogs_assert(id);
nf_instance->id = ogs_strdup(id);
ogs_assert(nf_instance->id);
}
void ogs_sbi_nf_instance_set_type(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e nf_type)
{
ogs_assert(nf_instance);
ogs_assert(nf_type);
nf_instance->nf_type = nf_type;
}
void ogs_sbi_nf_instance_set_status(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_status_e nf_status)
{
ogs_assert(nf_instance);
ogs_assert(nf_status);
nf_instance->nf_status = nf_status;
}
void ogs_sbi_nf_instance_add_allowed_nf_type(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e allowed_nf_type)
{
@ -592,13 +616,14 @@ void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_nf_info_remove_all(&nf_instance->nf_info_list);
ogs_sbi_subscription_remove_all_by_nf_instance_id(nf_instance->id);
ogs_sbi_nf_service_remove_all(nf_instance);
ogs_sbi_nf_instance_clear(nf_instance);
ogs_assert(nf_instance->id);
ogs_free(nf_instance->id);
if (nf_instance->id) {
ogs_sbi_subscription_remove_all_by_nf_instance_id(nf_instance->id);
ogs_free(nf_instance->id);
}
ogs_timer_delete(nf_instance->t_registration_interval);
ogs_timer_delete(nf_instance->t_heartbeat_interval);
@ -630,15 +655,20 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find(char *id)
ogs_assert(id);
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_assert(nf_instance->id);
if (strcmp(nf_instance->id, id) == 0)
if (nf_instance->id && strcmp(nf_instance->id, id) == 0)
break;
}
return nf_instance;
}
ogs_sbi_nf_service_t *ogs_sbi_nf_service_add(ogs_sbi_nf_instance_t *nf_instance,
bool ogs_sbi_nf_instance_maximum_number_is_reached()
{
return nf_instance_pool.avail <= 0;
}
ogs_sbi_nf_service_t *ogs_sbi_nf_service_add(
ogs_sbi_nf_instance_t *nf_instance,
char *id, char *name, OpenAPI_uri_scheme_e scheme)
{
ogs_sbi_nf_service_t *nf_service = NULL;
@ -884,9 +914,10 @@ void ogs_sbi_nf_instance_build_default(
char *hostname = NULL;
ogs_assert(nf_instance);
ogs_assert(nf_type);
nf_instance->nf_type = nf_type;
nf_instance->nf_status = OpenAPI_nf_status_REGISTERED;
ogs_sbi_nf_instance_set_type(nf_instance, nf_type);
ogs_sbi_nf_instance_set_status(nf_instance, OpenAPI_nf_status_REGISTERED);
hostname = NULL;
ogs_list_for_each(&ogs_sbi_self()->server_list, server) {
@ -933,11 +964,11 @@ ogs_sbi_nf_service_t *ogs_sbi_nf_service_build_default(
ogs_sbi_nf_instance_t *nf_instance, char *name)
{
ogs_sbi_server_t *server = NULL;
ogs_sbi_client_t *client = NULL;
ogs_sbi_nf_service_t *nf_service = NULL;
ogs_uuid_t uuid;
char id[OGS_UUID_FORMATTED_LENGTH + 1];
char *hostname = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
ogs_assert(nf_instance);
ogs_assert(name);
@ -945,14 +976,27 @@ ogs_sbi_nf_service_t *ogs_sbi_nf_service_build_default(
ogs_uuid_get(&uuid);
ogs_uuid_format(id, &uuid);
client = nf_instance->client;
ogs_assert(client);
ogs_list_for_each(&ogs_sbi_self()->server_list, server) {
OpenAPI_uri_scheme_e s;
nf_service = ogs_sbi_nf_service_add(nf_instance, id, name,
(client->tls.key && client->tls.pem) ?
OpenAPI_uri_scheme_https : OpenAPI_uri_scheme_http);
if (server->tls.key && server->tls.pem)
s = OpenAPI_uri_scheme_https;
else
s = OpenAPI_uri_scheme_http;
if (scheme == OpenAPI_uri_scheme_NULL) {
scheme = s;
} else if (scheme != s) {
ogs_fatal("Please CHECK CONFIGURATION - sbi[%d:%s]",
nf_instance->nf_type,
OpenAPI_nf_type_ToString(nf_instance->nf_type));
ogs_assert_if_reached();
return NULL;
}
}
nf_service = ogs_sbi_nf_service_add(nf_instance, id, name, scheme);
ogs_assert(nf_service);
OGS_SBI_SETUP_CLIENT(nf_service, client);
hostname = NULL;
ogs_list_for_each(&ogs_sbi_self()->server_list, server) {
@ -1092,19 +1136,7 @@ static void nf_service_associate_client_all(ogs_sbi_nf_instance_t *nf_instance)
nf_service_associate_client(nf_service);
}
void ogs_sbi_select_nrf(ogs_sbi_object_t *sbi_object, void *state)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_assert(sbi_object);
/* SELF NF Instace is used for NRF Instance */
nf_instance = ogs_sbi_nf_instance_find(ogs_sbi_self()->nf_instance_id);
if (nf_instance && OGS_FSM_CHECK(&nf_instance->sm, state))
OGS_SBI_SETUP_NF(sbi_object, OpenAPI_nf_type_NRF, nf_instance);
}
void ogs_sbi_select_first_nf(
void ogs_sbi_select_nf(
ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e nf_type, void *state)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;

View File

@ -34,43 +34,48 @@ extern "C" {
typedef struct ogs_sbi_client_s ogs_sbi_client_t;
typedef struct ogs_sbi_smf_info_s ogs_sbi_smf_info_t;
typedef struct ogs_sbi_nf_instance_s ogs_sbi_nf_instance_t;
typedef struct ogs_sbi_context_s {
uint32_t sbi_port; /* SBI local port */
uint32_t sbi_port; /* SBI local port */
ogs_list_t server_list;
ogs_list_t client_list;
ogs_list_t server_list;
ogs_list_t client_list;
ogs_uuid_t uuid;
char nf_instance_id[OGS_UUID_FORMATTED_LENGTH + 1];
ogs_uuid_t uuid;
ogs_list_t nf_instance_list;
ogs_list_t subscription_list;
ogs_list_t nf_instance_list;
ogs_list_t subscription_list;
ogs_list_t nf_info_list;
ogs_sbi_nf_instance_t *nf_instance; /* SELF NF Instance */
const char *content_encoding;
const char *content_encoding;
} ogs_sbi_context_t;
typedef struct ogs_sbi_nf_instance_s {
ogs_lnode_t lnode;
ogs_lnode_t lnode;
ogs_fsm_t sm; /* A state machine */
ogs_timer_t *t_registration_interval; /* timer to retry
ogs_fsm_t sm; /* A state machine */
ogs_timer_t *t_registration_interval; /* timer to retry
to register peer node */
struct {
int heartbeat_interval;
int validity_duration;
} time;
ogs_timer_t *t_heartbeat_interval; /* heartbeat interval */
ogs_timer_t *t_no_heartbeat; /* check heartbeat */
ogs_timer_t *t_validity; /* check validation */
ogs_timer_t *t_heartbeat_interval; /* heartbeat interval */
ogs_timer_t *t_no_heartbeat; /* check heartbeat */
ogs_timer_t *t_validity; /* check validation */
#define NF_INSTANCE_IS_SELF(_iD) \
strcmp((_iD), ogs_sbi_self()->nf_instance_id) == 0
(_iD) && ogs_sbi_self()->nf_instance && \
strcmp((_iD), ogs_sbi_self()->nf_instance->id) == 0
#define NF_INSTANCE_IS_OTHERS(_iD) \
strcmp((_iD), ogs_sbi_self()->nf_instance_id) != 0
(_iD) && ogs_sbi_self()->nf_instance && \
strcmp((_iD), ogs_sbi_self()->nf_instance->id) != 0
#define NF_INSTANCE_IS_NRF(__nFInstance) \
((__nFInstance->nf_type) == OpenAPI_nf_type_NRF)
char *id; /* NFInstanceId */
@ -246,14 +251,19 @@ void ogs_sbi_context_final(void);
ogs_sbi_context_t *ogs_sbi_self(void);
int ogs_sbi_context_parse_config(const char *local, const char *remote);
bool ogs_sbi_nf_instance_maximum_number_is_reached(void);
ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id);
ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void);
void ogs_sbi_nf_instance_set_id(ogs_sbi_nf_instance_t *nf_instance, char *id);
void ogs_sbi_nf_instance_set_type(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e nf_type);
void ogs_sbi_nf_instance_set_status(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_status_e nf_status);
void ogs_sbi_nf_instance_add_allowed_nf_type(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e allowed_nf_type);
void ogs_sbi_nf_instance_clear(ogs_sbi_nf_instance_t *nf_instance);
void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance);
void ogs_sbi_nf_instance_remove_all(void);
ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find(char *id);
bool ogs_sbi_nf_instance_maximum_number_is_reached(void);
ogs_sbi_nf_service_t *ogs_sbi_nf_service_add(ogs_sbi_nf_instance_t *nf_instance,
char *id, char *name, OpenAPI_uri_scheme_e scheme);
@ -309,8 +319,7 @@ OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void);
(__nFInstance)->reference_count); \
} while(0)
void ogs_sbi_select_nrf(ogs_sbi_object_t *sbi_object, void *state);
void ogs_sbi_select_first_nf(
void ogs_sbi_select_nf(
ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e nf_type, void *state);
void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object);

View File

@ -20,9 +20,9 @@
#include "ogs-sbi.h"
#include "ogs-app.h"
OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
ogs_sbi_nf_instance_t *nf_instance)
OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_nf_service_t *nf_service = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
@ -39,7 +39,9 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
char *ipstr = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
NFProfile = ogs_calloc(1, sizeof(*NFProfile));
ogs_expect_or_return_val(NFProfile, NULL);
@ -331,15 +333,19 @@ void ogs_sbi_nnrf_free_nf_profile(OpenAPI_nf_profile_t *NFProfile)
ogs_free(NFProfile);
}
ogs_sbi_request_t *ogs_nnrf_nfm_build_update(ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *ogs_nnrf_nfm_build_update(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
OpenAPI_list_t *PatchItemList;
OpenAPI_patch_item_t item;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PATCH;
@ -347,7 +353,8 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_update(ogs_sbi_nf_instance_t *nf_instance)
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_type = (char *)OGS_SBI_CONTENT_PATCH_TYPE;
PatchItemList = OpenAPI_list_create();
@ -372,13 +379,16 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_update(ogs_sbi_nf_instance_t *nf_instance)
return request;
}
ogs_sbi_request_t *ogs_nnrf_nfm_build_de_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *ogs_nnrf_nfm_build_de_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;

View File

@ -24,14 +24,11 @@
extern "C" {
#endif
OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
ogs_sbi_nf_instance_t *nf_instance);
OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(void);
void ogs_sbi_nnrf_free_nf_profile(OpenAPI_nf_profile_t *NFProfile);
ogs_sbi_request_t *ogs_nnrf_nfm_build_update(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *ogs_nnrf_nfm_build_de_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *ogs_nnrf_nfm_build_update(void);
ogs_sbi_request_t *ogs_nnrf_nfm_build_de_register(void);
ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe(
ogs_sbi_subscription_t *subscription);

View File

@ -39,7 +39,8 @@ bool ogs_sbi_send(ogs_sbi_nf_instance_t *nf_instance,
client = ogs_sbi_client_find_by_service_name(nf_instance,
request->h.service.name, request->h.api.version);
if (!client) {
ogs_error("[%s] Cannot find client [%s:%s]",
ogs_error("[%s:%s] Cannot find client [%s:%s]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id,
request->h.service.name, request->h.api.version);
return false;
@ -50,12 +51,16 @@ bool ogs_sbi_send(ogs_sbi_nf_instance_t *nf_instance,
addr = ogs_sbi_getaddr_from_uri(request->h.uri);
if (!addr) {
ogs_error("[%s] Invalid URL [%s]", nf_instance->id, request->h.uri);
ogs_error("[%s:%s] Invalid URL [%s]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, request->h.uri);
return false;
}
client = ogs_sbi_client_find(addr);
if (!client) {
ogs_error("[%s] Cannot find client [%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Cannot find client [%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id,
OGS_ADDR(addr, buf), OGS_PORT(addr));
ogs_freeaddrinfo(addr);
return false;
@ -88,7 +93,7 @@ bool ogs_sbi_discover_and_send(ogs_sbi_xact_t *xact,
nf_instance = OGS_SBI_NF_INSTANCE(xact->sbi_object, xact->target_nf_type);
if (!nf_instance) {
ogs_assert(xact->target_nf_type != OpenAPI_nf_type_NRF);
ogs_sbi_select_first_nf(
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);
@ -101,7 +106,8 @@ bool ogs_sbi_discover_and_send(ogs_sbi_xact_t *xact,
/* NRF NF-Instance */
nf_instance = OGS_SBI_NF_INSTANCE(xact->sbi_object, OpenAPI_nf_type_NRF);
if (!nf_instance) {
ogs_sbi_select_nrf(xact->sbi_object, nf_state_registered);
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);
}
@ -128,7 +134,7 @@ bool ogs_nnrf_nfm_send_nf_update(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = ogs_nnrf_nfm_build_update(nf_instance);
request = ogs_nnrf_nfm_build_update();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(
@ -144,7 +150,7 @@ bool ogs_nnrf_nfm_send_nf_de_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = ogs_nnrf_nfm_build_de_register(nf_instance);
request = ogs_nnrf_nfm_build_de_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(

View File

@ -537,7 +537,8 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
ogs_fsm_dispatch(&nf_instance->sm, e);
if (OGS_FSM_CHECK(&nf_instance->sm, amf_nf_state_exception))
ogs_error("[%s] State machine exception [%d]",
ogs_error("[%s:%s] State machine exception [%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, e->timer_id);
break;
@ -545,9 +546,11 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
amf_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("[%s] Subscription validity expired", subscription->id);

View File

@ -114,8 +114,6 @@ amf_context_t *amf_self(void)
static int amf_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_AMF;
self.relative_capacity = 0xff;
self.ngap_port = OGS_NGAP_SCTP_PORT;
@ -1780,10 +1778,7 @@ void amf_ue_select_nf(amf_ue_t *amf_ue, OpenAPI_nf_type_e nf_type)
ogs_assert(amf_ue);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&amf_ue->sbi, amf_nf_state_registered);
else
ogs_sbi_select_first_nf(&amf_ue->sbi, nf_type, amf_nf_state_registered);
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)
@ -1791,12 +1786,10 @@ 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_NRF)
ogs_sbi_select_nrf(&sess->sbi, amf_nf_state_registered);
else if (nf_type == OpenAPI_nf_type_SMF)
if (nf_type == OpenAPI_nf_type_SMF)
amf_sess_select_smf(sess);
else
ogs_sbi_select_first_nf(&sess->sbi, nf_type, amf_nf_state_registered);
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);

View File

@ -48,8 +48,6 @@ typedef struct amf_ue_s amf_ue_t;
typedef uint32_t amf_m_tmsi_t;
typedef struct amf_context_s {
OpenAPI_nf_type_e nf_type;
/* Served GUAMI */
uint8_t num_of_served_guami;
ogs_guami_t served_guami[MAX_NUM_OF_SERVED_GUAMI];

View File

@ -30,9 +30,10 @@ int amf_initialize()
int rv;
ogs_metrics_context_init();
ogs_sbi_context_init();
amf_context_init();
amf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("amf", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void amf_nf_state_initial(ogs_fsm_t *s, amf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void amf_nf_state_initial(ogs_fsm_t *s, amf_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = amf_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &amf_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &amf_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == amf_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case AMF_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e)
OGS_FSM_TRAN(s, &amf_nf_state_registered);
} else {
ogs_error("[%s] HTTP Response Status Code [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &amf_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,17 +160,18 @@ void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == amf_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
amf_timer_get_name(e->timer_id), e->timer_id);
}
break;
@ -191,12 +194,14 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -212,26 +217,36 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e)
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(client,
amf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_AUSF));
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,
amf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_UDM));
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,
amf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_PCF));
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,
amf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_SMF));
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,
amf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_NSSF));
ogs_sbi_self()->nf_instance->nf_type,
ogs_sbi_self()->nf_instance->id,
OpenAPI_nf_type_NSSF));
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -265,7 +280,8 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &amf_nf_state_exception);
}
@ -273,13 +289,14 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -294,26 +311,31 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e)
break;
case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &amf_nf_state_will_register);
break;
case AMF_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &amf_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &amf_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
amf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("Unknown event %s", amf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
amf_event_get_name(e));
break;
}
}
@ -328,11 +350,12 @@ void amf_nf_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -340,7 +363,10 @@ void amf_nf_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
break;
default:
ogs_error("Unknown event %s", amf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
amf_event_get_name(e));
break;
}
}
@ -358,18 +384,21 @@ void amf_nf_state_exception(ogs_fsm_t *s, amf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case AMF_EVT_SBI_TIMER:
@ -380,15 +409,17 @@ void amf_nf_state_exception(ogs_fsm_t *s, amf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &amf_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
amf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -413,8 +444,10 @@ void amf_nf_state_exception(ogs_fsm_t *s, amf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, amf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
amf_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *amf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *amf_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *amf_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *amf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *amf_nnrf_nfm_build_register(void);
ogs_sbi_request_t *amf_nnrf_disc_build_discover(
char *nrf_id,

View File

@ -173,9 +173,10 @@ bool amf_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
amf_nf_fsm_init(nf_instance);
@ -336,8 +337,9 @@ void amf_nnrf_handle_nf_discover_search_result(
nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id);
amf_nf_fsm_init(nf_instance);

View File

@ -34,8 +34,9 @@ ogs_sbi_request_t *amf_nnssf_nsselection_build_get(
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NETWORK_SLICE_INFORMATION;
message.param.nf_id = ogs_sbi_self()->nf_instance_id;
message.param.nf_type = amf_self()->nf_type;
ogs_assert(ogs_sbi_self()->nf_instance);
message.param.nf_id = ogs_sbi_self()->nf_instance->id;
message.param.nf_type = ogs_sbi_self()->nf_instance->nf_type;
message.param.slice_info_request_for_pdu_session_presence = true;
message.param.roaming_indication = OpenAPI_roaming_indication_NON_ROAMING;

View File

@ -51,7 +51,8 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_create_sm_context(
memset(&SmContextCreateData, 0, sizeof(SmContextCreateData));
SmContextCreateData.serving_nf_id = ogs_sbi_self()->nf_instance_id;
ogs_assert(ogs_sbi_self()->nf_instance);
SmContextCreateData.serving_nf_id = ogs_sbi_self()->nf_instance->id;
SmContextCreateData.serving_network =
ogs_sbi_build_plmn_id_nid(&amf_ue->nr_tai.plmn_id);

View File

@ -44,7 +44,8 @@ ogs_sbi_request_t *amf_nudm_uecm_build_registration(
memset(&Amf3GppAccessRegistration, 0, sizeof(Amf3GppAccessRegistration));
Amf3GppAccessRegistration.amf_instance_id = ogs_sbi_self()->nf_instance_id;
ogs_assert(ogs_sbi_self()->nf_instance);
Amf3GppAccessRegistration.amf_instance_id = ogs_sbi_self()->nf_instance->id;
server = ogs_list_first(&ogs_sbi_self()->server_list);
ogs_assert(server);

View File

@ -70,43 +70,41 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AMF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SMF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NAMF_COMM);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, amf_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_SMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NAMF_COMM);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
amf_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
amf_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -126,7 +124,7 @@ bool amf_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = amf_nnrf_nfm_build_register(nf_instance);
request = amf_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(
@ -277,8 +275,10 @@ bool amf_sess_sbi_discover_by_nsi(
client = sess->nssf.nrf.client;
ogs_assert(client);
ogs_assert(ogs_sbi_self()->nf_instance);
request = amf_nnrf_disc_build_discover(
sess->nssf.nrf.id, target_nf_type, amf_self()->nf_type);
sess->nssf.nrf.id, target_nf_type,
ogs_sbi_self()->nf_instance->nf_type);
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(

View File

@ -323,7 +323,8 @@ void ausf_state_operational(ogs_fsm_t *s, ausf_event_t *e)
ogs_fsm_dispatch(&nf_instance->sm, e);
if (OGS_FSM_CHECK(&nf_instance->sm, ausf_nf_state_exception))
ogs_error("[%s] State machine exception [%d]",
ogs_error("[%s:%s] State machine exception [%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, e->timer_id);
break;
@ -331,9 +332,11 @@ void ausf_state_operational(ogs_fsm_t *s, ausf_event_t *e)
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
ausf_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("[%s] Subscription validity expired", subscription->id);

View File

@ -70,8 +70,6 @@ ausf_context_t *ausf_self(void)
static int ausf_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_AUSF;
return OGS_OK;
}
@ -230,9 +228,5 @@ void ausf_ue_select_nf(ausf_ue_t *ausf_ue, OpenAPI_nf_type_e nf_type)
ogs_assert(ausf_ue);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&ausf_ue->sbi, ausf_nf_state_registered);
else
ogs_sbi_select_first_nf(
&ausf_ue->sbi, nf_type, ausf_nf_state_registered);
ogs_sbi_select_nf(&ausf_ue->sbi, nf_type, ausf_nf_state_registered);
}

View File

@ -39,8 +39,6 @@ extern int __ausf_log_domain;
#define OGS_LOG_DOMAIN __ausf_log_domain
typedef struct ausf_context_s {
OpenAPI_nf_type_e nf_type;
ogs_list_t ausf_ue_list;
ogs_hash_t *suci_hash;
ogs_hash_t *supi_hash;

View File

@ -27,9 +27,10 @@ int ausf_initialize()
{
int rv;
ogs_sbi_context_init();
ausf_context_init();
ausf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("ausf", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void ausf_nf_state_initial(ogs_fsm_t *s, ausf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void ausf_nf_state_initial(ogs_fsm_t *s, ausf_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = ausf_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &ausf_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &ausf_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == ausf_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case AUSF_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e)
OGS_FSM_TRAN(s, &ausf_nf_state_registered);
} else {
ogs_error("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &ausf_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,17 +160,18 @@ void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == ausf_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
ausf_timer_get_name(e->timer_id), e->timer_id);
}
break;
@ -191,12 +194,14 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -212,14 +217,16 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e)
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(client,
ausf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_UDM));
ogs_sbi_self()->nf_instance->nf_type,
ogs_sbi_self()->nf_instance->id,
OpenAPI_nf_type_UDM));
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -253,7 +260,8 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &ausf_nf_state_exception);
}
@ -261,13 +269,14 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -282,27 +291,31 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e)
break;
case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &ausf_nf_state_will_register);
break;
case AUSF_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &ausf_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &ausf_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
ausf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, ausf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
ausf_event_get_name(e));
break;
}
}
@ -317,11 +330,12 @@ void ausf_nf_state_de_registered(ogs_fsm_t *s, ausf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -329,8 +343,10 @@ void ausf_nf_state_de_registered(ogs_fsm_t *s, ausf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, ausf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
ausf_event_get_name(e));
break;
}
}
@ -348,18 +364,21 @@ void ausf_nf_state_exception(ogs_fsm_t *s, ausf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case AUSF_EVT_SBI_TIMER:
@ -370,15 +389,17 @@ void ausf_nf_state_exception(ogs_fsm_t *s, ausf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &ausf_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
ausf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -403,8 +424,10 @@ void ausf_nf_state_exception(ogs_fsm_t *s, ausf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, ausf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
ausf_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *ausf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *ausf_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *ausf_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *ausf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *ausf_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -170,9 +170,10 @@ bool ausf_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
ausf_nf_fsm_init(nf_instance);
@ -277,8 +278,9 @@ void ausf_nnrf_handle_nf_discover(
nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id);
ausf_nf_fsm_init(nf_instance);

View File

@ -43,8 +43,9 @@ ogs_sbi_request_t *ausf_nudm_ueau_build_get(ausf_ue_t *ausf_ue, void *data)
AuthenticationInfoRequest.serving_network_name =
ausf_ue->serving_network_name;
ogs_assert(ogs_sbi_self()->nf_instance);
AuthenticationInfoRequest.ausf_instance_id =
ogs_sbi_self()->nf_instance_id;
ogs_sbi_self()->nf_instance->id;
if (data) {
OpenAPI_resynchronization_info_t *recvinfo = data;
@ -88,7 +89,8 @@ ogs_sbi_request_t *ausf_nudm_ueau_build_result_confirmation_inform(
AuthEvent->time_stamp = ogs_sbi_localtime_string(ogs_time_now());
ogs_expect_or_return_val(AuthEvent->time_stamp, NULL);
AuthEvent->nf_instance_id = ogs_sbi_self()->nf_instance_id;
ogs_assert(ogs_sbi_self()->nf_instance);
AuthEvent->nf_instance_id = ogs_sbi_self()->nf_instance->id;
if (ausf_ue->auth_result == OpenAPI_auth_result_AUTHENTICATION_SUCCESS)
AuthEvent->success = true;
else

View File

@ -68,44 +68,41 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AUSF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NAUSF_AUTH);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, ausf_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_AMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NAUSF_AUTH);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
ausf_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
ausf_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -125,7 +122,7 @@ bool ausf_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = ausf_nnrf_nfm_build_register(nf_instance);
request = ausf_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(

View File

@ -317,16 +317,20 @@ void bsf_state_operational(ogs_fsm_t *s, bsf_event_t *e)
ogs_fsm_dispatch(&nf_instance->sm, e);
if (OGS_FSM_CHECK(&nf_instance->sm, bsf_nf_state_exception))
ogs_error("State machine exception [%d]", e->timer_id);
ogs_error("[%s:%s] State machine exception [%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, e->timer_id);
break;
case BSF_TIMER_SUBSCRIPTION_VALIDITY:
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
bsf_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("Subscription validity expired [%s]", subscription->id);

View File

@ -72,8 +72,6 @@ bsf_context_t *bsf_self(void)
static int bsf_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_BSF;
return OGS_OK;
}
@ -331,8 +329,5 @@ void bsf_sess_select_nf(bsf_sess_t *sess, OpenAPI_nf_type_e nf_type)
ogs_assert(sess);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&sess->sbi, bsf_nf_state_registered);
else
ogs_sbi_select_first_nf(&sess->sbi, nf_type, bsf_nf_state_registered);
ogs_sbi_select_nf(&sess->sbi, nf_type, bsf_nf_state_registered);
}

View File

@ -36,8 +36,6 @@ extern int __bsf_log_domain;
#define OGS_LOG_DOMAIN __bsf_log_domain
typedef struct bsf_context_s {
OpenAPI_nf_type_e nf_type;
ogs_hash_t *ipv4addr_hash;
ogs_hash_t *ipv6prefix_hash;

View File

@ -29,9 +29,10 @@ int bsf_initialize()
{
int rv;
ogs_sbi_context_init();
bsf_context_init();
bsf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("bsf", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void bsf_nf_state_initial(ogs_fsm_t *s, bsf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void bsf_nf_state_initial(ogs_fsm_t *s, bsf_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = bsf_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &bsf_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &bsf_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void bsf_nf_state_will_register(ogs_fsm_t *s, bsf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == bsf_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case BSF_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void bsf_nf_state_will_register(ogs_fsm_t *s, bsf_event_t *e)
OGS_FSM_TRAN(s, &bsf_nf_state_registered);
} else {
ogs_error("[%s] HTTP Response Status Code [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &bsf_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,24 +160,25 @@ void bsf_nf_state_will_register(ogs_fsm_t *s, bsf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == bsf_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
bsf_timer_get_name(e->timer_id), e->timer_id);
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, bsf_event_get_name(e));
ogs_sbi_self()->nf_instance->id, bsf_event_get_name(e));
break;
}
}
@ -192,12 +195,14 @@ void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -215,8 +220,8 @@ void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e)
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -250,7 +255,8 @@ void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &bsf_nf_state_exception);
}
@ -258,13 +264,14 @@ void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -279,27 +286,31 @@ void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e)
break;
case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &bsf_nf_state_will_register);
break;
case BSF_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &bsf_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &bsf_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
bsf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, bsf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
bsf_event_get_name(e));
break;
}
}
@ -314,11 +325,12 @@ void bsf_nf_state_de_registered(ogs_fsm_t *s, bsf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -326,8 +338,10 @@ void bsf_nf_state_de_registered(ogs_fsm_t *s, bsf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, bsf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
bsf_event_get_name(e));
break;
}
}
@ -345,18 +359,21 @@ void bsf_nf_state_exception(ogs_fsm_t *s, bsf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case BSF_EVT_SBI_TIMER:
@ -367,15 +384,17 @@ void bsf_nf_state_exception(ogs_fsm_t *s, bsf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &bsf_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
bsf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -400,8 +419,10 @@ void bsf_nf_state_exception(ogs_fsm_t *s, bsf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, bsf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
bsf_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *bsf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *bsf_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *bsf_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *bsf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *bsf_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -171,9 +171,10 @@ bool bsf_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
bsf_nf_fsm_init(nf_instance);
@ -278,8 +279,9 @@ void bsf_nnrf_handle_nf_discover(
nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id);
bsf_nf_fsm_init(nf_instance);

View File

@ -68,44 +68,41 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_BSF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_PCF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, bsf_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_PCF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
bsf_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
bsf_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -125,7 +122,7 @@ bool bsf_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = bsf_nnrf_nfm_build_register(nf_instance);
request = bsf_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(

View File

@ -27,9 +27,10 @@ int nrf_initialize()
{
int rv;
ogs_sbi_context_init();
nrf_context_init();
nrf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("nrf", NULL);
if (rv != OGS_OK) return rv;

View File

@ -36,6 +36,7 @@ ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify(
ogs_assert(subscription);
ogs_assert(event);
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;

View File

@ -105,7 +105,8 @@ void nrf_state_operational(ogs_fsm_t *s, nrf_event_t *e)
if (!nf_instance) {
SWITCH(message.h.method)
CASE(OGS_SBI_HTTP_METHOD_PUT)
if (ogs_sbi_nf_instance_maximum_number_is_reached()) {
if (ogs_sbi_nf_instance_maximum_number_is_reached())
{
ogs_warn("Can't add instance [%s] "
"due to insufficient space",
message.h.resource.component[1]);
@ -118,9 +119,11 @@ void nrf_state_operational(ogs_fsm_t *s, nrf_event_t *e)
message.h.resource.component[1]));
break;
}
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
nrf_nf_fsm_init(nf_instance);
break;
DEFAULT

View File

@ -59,8 +59,6 @@ nssf_context_t *nssf_self(void)
static int nssf_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_NSSF;
return OGS_OK;
}

View File

@ -38,8 +38,6 @@ extern int __nssf_log_domain;
#define OGS_LOG_DOMAIN __nssf_log_domain
typedef struct nssf_context_s {
OpenAPI_nf_type_e nf_type;
ogs_list_t nsi_list; /* NSI List */
} nssf_context_t;

View File

@ -27,9 +27,10 @@ int nssf_initialize()
{
int rv;
ogs_sbi_context_init();
nssf_context_init();
nssf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("nssf", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void nssf_nf_state_initial(ogs_fsm_t *s, nssf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void nssf_nf_state_initial(ogs_fsm_t *s, nssf_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = nssf_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &nssf_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &nssf_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void nssf_nf_state_will_register(ogs_fsm_t *s, nssf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == nssf_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case NSSF_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void nssf_nf_state_will_register(ogs_fsm_t *s, nssf_event_t *e)
OGS_FSM_TRAN(s, &nssf_nf_state_registered);
} else {
ogs_error("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &nssf_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,17 +160,18 @@ void nssf_nf_state_will_register(ogs_fsm_t *s, nssf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == nssf_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
nssf_timer_get_name(e->timer_id), e->timer_id);
}
break;
@ -191,12 +194,14 @@ void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -214,8 +219,8 @@ void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e)
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -249,7 +254,8 @@ void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &nssf_nf_state_exception);
}
@ -257,13 +263,14 @@ void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -278,27 +285,31 @@ void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e)
break;
case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &nssf_nf_state_will_register);
break;
case NSSF_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &nssf_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &nssf_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
nssf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, nssf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
nssf_event_get_name(e));
break;
}
}
@ -313,11 +324,12 @@ void nssf_nf_state_de_registered(ogs_fsm_t *s, nssf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -325,8 +337,10 @@ void nssf_nf_state_de_registered(ogs_fsm_t *s, nssf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, nssf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
nssf_event_get_name(e));
break;
}
}
@ -344,18 +358,21 @@ void nssf_nf_state_exception(ogs_fsm_t *s, nssf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case NSSF_EVT_SBI_TIMER:
@ -366,15 +383,17 @@ void nssf_nf_state_exception(ogs_fsm_t *s, nssf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &nssf_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
nssf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -399,8 +418,10 @@ void nssf_nf_state_exception(ogs_fsm_t *s, nssf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, nssf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
nssf_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *nssf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *nssf_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *nssf_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *nssf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *nssf_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -170,9 +170,10 @@ bool nssf_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
nssf_nf_fsm_init(nf_instance);

View File

@ -234,7 +234,8 @@ void nssf_state_operational(ogs_fsm_t *s, nssf_event_t *e)
ogs_fsm_dispatch(&nf_instance->sm, e);
if (OGS_FSM_CHECK(&nf_instance->sm, nssf_nf_state_exception))
ogs_error("[%s] State machine exception [%d]",
ogs_error("[%s:%s] State machine exception [%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, e->timer_id);
break;
@ -242,9 +243,11 @@ void nssf_state_operational(ogs_fsm_t *s, nssf_event_t *e)
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
nssf_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("[%s] Subscription validity expired", subscription->id);

View File

@ -68,44 +68,41 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_NSSF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2,
(char*)OGS_SBI_API_V2_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, nssf_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_AMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2,
(char*)OGS_SBI_API_V2_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
nssf_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
nssf_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -125,7 +122,7 @@ bool nssf_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = nssf_nnrf_nfm_build_register(nf_instance);
request = nssf_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(

View File

@ -85,8 +85,6 @@ pcf_context_t *pcf_self(void)
static int pcf_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_PCF;
return OGS_OK;
}
@ -506,10 +504,7 @@ void pcf_ue_select_nf(pcf_ue_t *pcf_ue, OpenAPI_nf_type_e nf_type)
ogs_assert(pcf_ue);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&pcf_ue->sbi, pcf_nf_state_registered);
else
ogs_sbi_select_first_nf(&pcf_ue->sbi, nf_type, pcf_nf_state_registered);
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)
@ -517,10 +512,7 @@ void pcf_sess_select_nf(pcf_sess_t *sess, OpenAPI_nf_type_e nf_type)
ogs_assert(sess);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&sess->sbi, pcf_nf_state_registered);
else
ogs_sbi_select_first_nf(&sess->sbi, nf_type, pcf_nf_state_registered);
ogs_sbi_select_nf(&sess->sbi, nf_type, pcf_nf_state_registered);
}
pcf_app_t *pcf_app_add(pcf_sess_t *sess)

View File

@ -40,8 +40,6 @@ extern int __pcf_log_domain;
#define OGS_LOG_DOMAIN __pcf_log_domain
typedef struct pcf_context_s {
OpenAPI_nf_type_e nf_type;
ogs_list_t pcf_ue_list;
ogs_hash_t *supi_hash;

View File

@ -27,9 +27,10 @@ int pcf_initialize()
{
int rv;
ogs_sbi_context_init();
pcf_context_init();
pcf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("pcf", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -63,7 +63,7 @@ ogs_sbi_request_t *pcf_nbsf_management_build_register(
ogs_expect_or_return_val(sess->dnn, NULL);
PcfBinding.dnn = sess->dnn;
nf_instance = ogs_sbi_nf_instance_find(ogs_sbi_self()->nf_instance_id);
nf_instance = ogs_sbi_self()->nf_instance;
ogs_expect_or_return_val(nf_instance, NULL);
nf_service = ogs_list_first(&nf_instance->nf_service_list);
ogs_expect_or_return_val(nf_service, NULL);

View File

@ -60,7 +60,6 @@ void pcf_nf_state_initial(ogs_fsm_t *s, pcf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void pcf_nf_state_initial(ogs_fsm_t *s, pcf_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = pcf_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &pcf_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &pcf_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void pcf_nf_state_will_register(ogs_fsm_t *s, pcf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == pcf_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case PCF_EVT_SBI_CLIENT:
@ -133,20 +133,23 @@ void pcf_nf_state_will_register(ogs_fsm_t *s, pcf_event_t *e)
OGS_FSM_TRAN(s, &pcf_nf_state_registered);
} else {
ogs_error("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &pcf_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id,
message->h.service.name);
END
break;
@ -158,17 +161,18 @@ void pcf_nf_state_will_register(ogs_fsm_t *s, pcf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == pcf_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
pcf_timer_get_name(e->timer_id), e->timer_id);
}
break;
@ -191,12 +195,14 @@ void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -212,17 +218,21 @@ void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e)
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(client,
pcf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_BSF));
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,
pcf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_UDR));
ogs_sbi_self()->nf_instance->nf_type,
ogs_sbi_self()->nf_instance->id,
OpenAPI_nf_type_UDR));
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -256,7 +266,8 @@ void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &pcf_nf_state_exception);
}
@ -264,13 +275,14 @@ void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -285,27 +297,31 @@ void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e)
break;
case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &pcf_nf_state_will_register);
break;
case PCF_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &pcf_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &pcf_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
pcf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, pcf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
pcf_event_get_name(e));
break;
}
}
@ -320,11 +336,12 @@ void pcf_nf_state_de_registered(ogs_fsm_t *s, pcf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -332,8 +349,10 @@ void pcf_nf_state_de_registered(ogs_fsm_t *s, pcf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, pcf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
pcf_event_get_name(e));
break;
}
}
@ -351,18 +370,21 @@ void pcf_nf_state_exception(ogs_fsm_t *s, pcf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case PCF_EVT_SBI_TIMER:
@ -373,15 +395,17 @@ void pcf_nf_state_exception(ogs_fsm_t *s, pcf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &pcf_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
pcf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -406,8 +430,10 @@ void pcf_nf_state_exception(ogs_fsm_t *s, pcf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, pcf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
pcf_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *pcf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *pcf_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *pcf_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *pcf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *pcf_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -171,9 +171,10 @@ bool pcf_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
pcf_nf_fsm_init(nf_instance);
@ -280,8 +281,9 @@ void pcf_nnrf_handle_nf_discover(
nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id);
pcf_nf_fsm_init(nf_instance);

View File

@ -527,7 +527,8 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
ogs_fsm_dispatch(&nf_instance->sm, e);
if (OGS_FSM_CHECK(&nf_instance->sm, pcf_nf_state_exception))
ogs_error("[%s] State machine exception [%d]",
ogs_error("[%s:%s] State machine exception [%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, e->timer_id);
break;
@ -535,9 +536,11 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
pcf_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("[%s] Subscription validity expired", subscription->id);

View File

@ -68,60 +68,54 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_PCF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SMF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_NEF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF);
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AF);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, pcf_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_AMF);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_SMF);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_NEF);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_AF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF);
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
pcf_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
pcf_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -141,7 +135,7 @@ bool pcf_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = pcf_nnrf_nfm_build_register(nf_instance);
request = pcf_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(

View File

@ -148,15 +148,18 @@ static int smf_context_prepare(void)
{
self.diam_config->cnf_port = DIAMETER_PORT;
self.diam_config->cnf_port_tls = DIAMETER_SECURE_PORT;
self.nf_type = OpenAPI_nf_type_SMF;
return OGS_OK;
}
static int smf_context_validation(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_nf_info_t *nf_info = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
if (self.dns[0] == NULL && self.dns6[0] == NULL) {
ogs_error("No smf.dns in '%s'", ogs_app()->file);
return OGS_ERROR;
@ -170,7 +173,7 @@ static int smf_context_validation(void)
return OGS_ERROR;
}
ogs_list_for_each(&ogs_sbi_self()->nf_info_list, nf_info) {
ogs_list_for_each(&nf_instance->nf_info_list, nf_info) {
int i;
ogs_sbi_smf_info_t *smf_info = &nf_info->smf;
ogs_assert(smf_info);
@ -479,8 +482,14 @@ int smf_context_parse_config(void)
} while (ogs_yaml_iter_type(&p_cscf_iter) ==
YAML_SEQUENCE_NODE);
} else if (!strcmp(smf_key, "info")) {
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_yaml_iter_t info_array, info_iter;
ogs_yaml_iter_recurse(&smf_iter, &info_array);
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
do {
ogs_sbi_nf_info_t *nf_info = NULL;
ogs_sbi_smf_info_t *smf_info = NULL;
@ -501,7 +510,7 @@ int smf_context_parse_config(void)
ogs_assert_if_reached();
nf_info = ogs_sbi_nf_info_add(
&ogs_sbi_self()->nf_info_list,
&nf_instance->nf_info_list,
OpenAPI_nf_type_SMF);
ogs_assert(nf_info);
@ -2471,10 +2480,7 @@ void smf_sess_select_nf(smf_sess_t *sess, OpenAPI_nf_type_e nf_type)
ogs_assert(sess);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&sess->sbi, smf_nf_state_registered);
else
ogs_sbi_select_first_nf(&sess->sbi, nf_type, smf_nf_state_registered);
ogs_sbi_select_nf(&sess->sbi, nf_type, smf_nf_state_registered);
}
smf_pf_t *smf_pf_add(smf_bearer_t *bearer)

View File

@ -69,8 +69,6 @@ typedef struct smf_context_s {
const char* diam_conf_path; /* SMF Diameter conf path */
ogs_diam_config_t *diam_config; /* SMF Diameter config */
OpenAPI_nf_type_e nf_type;
#define MAX_NUM_OF_DNS 2
const char *dns[MAX_NUM_OF_DNS];
const char *dns6[MAX_NUM_OF_DNS];

View File

@ -36,10 +36,10 @@ int smf_initialize()
ogs_metrics_context_init();
ogs_gtp_context_init(ogs_app()->pool.nf * OGS_MAX_NUM_OF_GTPU_RESOURCE);
ogs_pfcp_context_init();
ogs_sbi_context_init();
smf_context_init();
smf_event_init();
ogs_sbi_context_init();
rv = ogs_gtp_xact_init();
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void smf_nf_state_initial(ogs_fsm_t *s, smf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void smf_nf_state_initial(ogs_fsm_t *s, smf_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = smf_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &smf_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &smf_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void smf_nf_state_will_register(ogs_fsm_t *s, smf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == smf_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case SMF_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void smf_nf_state_will_register(ogs_fsm_t *s, smf_event_t *e)
OGS_FSM_TRAN(s, &smf_nf_state_registered);
} else {
ogs_error("[%s] HTTP Response Status Code [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &smf_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,24 +160,25 @@ void smf_nf_state_will_register(ogs_fsm_t *s, smf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == smf_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
smf_timer_get_name(e->timer_id), e->timer_id);
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, smf_event_get_name(e));
ogs_sbi_self()->nf_instance->id, smf_event_get_name(e));
break;
}
}
@ -192,12 +195,14 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -213,23 +218,30 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e)
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(client,
smf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_AMF));
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,
smf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_UDM));
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,
smf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_PCF));
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,
smf_self()->nf_type, nf_instance->id, OpenAPI_nf_type_UPF));
ogs_sbi_self()->nf_instance->nf_type,
ogs_sbi_self()->nf_instance->id,
OpenAPI_nf_type_UPF));
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -263,7 +275,8 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &smf_nf_state_exception);
}
@ -271,13 +284,14 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -292,27 +306,31 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e)
break;
case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &smf_nf_state_will_register);
break;
case SMF_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &smf_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &smf_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
smf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, smf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
smf_event_get_name(e));
break;
}
}
@ -327,11 +345,12 @@ void smf_nf_state_de_registered(ogs_fsm_t *s, smf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -339,8 +358,10 @@ void smf_nf_state_de_registered(ogs_fsm_t *s, smf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, smf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
smf_event_get_name(e));
break;
}
}
@ -358,18 +379,21 @@ void smf_nf_state_exception(ogs_fsm_t *s, smf_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case SMF_EVT_SBI_TIMER:
@ -380,15 +404,17 @@ void smf_nf_state_exception(ogs_fsm_t *s, smf_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &smf_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
smf_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -413,8 +439,10 @@ void smf_nf_state_exception(ogs_fsm_t *s, smf_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, smf_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
smf_event_get_name(e));
break;
}
}

View File

@ -19,15 +19,14 @@
#include "nnrf-build.h"
ogs_sbi_request_t *smf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *smf_nnrf_nfm_build_register(void)
{
int i, j;
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_nf_info_t *nf_info = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
@ -51,9 +50,9 @@ ogs_sbi_request_t *smf_nnrf_nfm_build_register(
OpenAPI_lnode_t *node = NULL, *node2 = NULL, *node3 = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -61,7 +60,7 @@ ogs_sbi_request_t *smf_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
@ -69,7 +68,8 @@ ogs_sbi_request_t *smf_nnrf_nfm_build_register(
ogs_assert(SmfInfoList);
SmfInfoMapKey = 0;
ogs_list_for_each(&ogs_sbi_self()->nf_info_list, nf_info) {
ogs_list_for_each(&nf_instance->nf_info_list, nf_info) {
if (nf_info->nf_type != OpenAPI_nf_type_SMF) {
ogs_fatal("Not implemented NF-type[%s]",
OpenAPI_nf_type_ToString(nf_info->nf_type));
@ -199,7 +199,7 @@ ogs_sbi_request_t *smf_nnrf_nfm_build_register(
OpenAPI_list_add(SmfInfoList, SmfInfoMap);
}
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
if (SmfInfoList->count == 1) {

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *smf_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *smf_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -171,9 +171,10 @@ bool smf_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
smf_nf_fsm_init(nf_instance);
@ -278,8 +279,9 @@ void smf_nnrf_handle_nf_discover(
nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id);
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);

View File

@ -70,44 +70,41 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_SMF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, smf_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_AMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
smf_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
smf_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -127,7 +124,7 @@ bool smf_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = smf_nnrf_nfm_build_register(nf_instance);
request = smf_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(
client, client->cb, request, nf_instance);

View File

@ -776,16 +776,20 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e)
ogs_fsm_dispatch(&nf_instance->sm, e);
if (OGS_FSM_CHECK(&nf_instance->sm, smf_nf_state_exception))
ogs_error("State machine exception [%d]", e->timer_id);
ogs_error("[%s:%s] State machine exception [%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, e->timer_id);
break;
case SMF_TIMER_SUBSCRIPTION_VALIDITY:
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
smf_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("Subscription validity expired [%s]", subscription->id);

View File

@ -70,8 +70,6 @@ udm_context_t *udm_self(void)
static int udm_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_UDM;
return OGS_OK;
}
@ -237,8 +235,5 @@ void udm_ue_select_nf(udm_ue_t *udm_ue, OpenAPI_nf_type_e nf_type)
ogs_assert(udm_ue);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&udm_ue->sbi, udm_nf_state_registered);
else
ogs_sbi_select_first_nf(&udm_ue->sbi, nf_type, udm_nf_state_registered);
ogs_sbi_select_nf(&udm_ue->sbi, nf_type, udm_nf_state_registered);
}

View File

@ -39,8 +39,6 @@ extern int __udm_log_domain;
#define OGS_LOG_DOMAIN __udm_log_domain
typedef struct udm_context_s {
OpenAPI_nf_type_e nf_type;
ogs_list_t udm_ue_list;
ogs_hash_t *suci_hash;
ogs_hash_t *supi_hash;

View File

@ -27,9 +27,10 @@ int udm_initialize()
{
int rv;
ogs_sbi_context_init();
udm_context_init();
udm_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("udm", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void udm_nf_state_initial(ogs_fsm_t *s, udm_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void udm_nf_state_initial(ogs_fsm_t *s, udm_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = udm_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &udm_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &udm_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void udm_nf_state_will_register(ogs_fsm_t *s, udm_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == udm_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case UDM_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void udm_nf_state_will_register(ogs_fsm_t *s, udm_event_t *e)
OGS_FSM_TRAN(s, &udm_nf_state_registered);
} else {
ogs_error("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &udm_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,17 +160,18 @@ void udm_nf_state_will_register(ogs_fsm_t *s, udm_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == udm_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
udm_timer_get_name(e->timer_id), e->timer_id);
}
break;
@ -191,12 +194,14 @@ void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -212,14 +217,16 @@ void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e)
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(client,
udm_self()->nf_type, nf_instance->id, OpenAPI_nf_type_UDR));
ogs_sbi_self()->nf_instance->nf_type,
ogs_sbi_self()->nf_instance->id,
OpenAPI_nf_type_UDR));
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -253,7 +260,8 @@ void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &udm_nf_state_exception);
}
@ -261,13 +269,14 @@ void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -282,27 +291,31 @@ void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e)
break;
case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &udm_nf_state_will_register);
break;
case UDM_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &udm_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &udm_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udm_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, udm_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udm_event_get_name(e));
break;
}
}
@ -317,11 +330,12 @@ void udm_nf_state_de_registered(ogs_fsm_t *s, udm_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -329,8 +343,10 @@ void udm_nf_state_de_registered(ogs_fsm_t *s, udm_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, udm_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udm_event_get_name(e));
break;
}
}
@ -348,18 +364,21 @@ void udm_nf_state_exception(ogs_fsm_t *s, udm_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case UDM_EVT_SBI_TIMER:
@ -370,15 +389,17 @@ void udm_nf_state_exception(ogs_fsm_t *s, udm_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &udm_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udm_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -403,8 +424,10 @@ void udm_nf_state_exception(ogs_fsm_t *s, udm_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, udm_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udm_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *udm_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *udm_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *udm_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *udm_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *udm_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -171,9 +171,10 @@ bool udm_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
udm_nf_fsm_init(nf_instance);
@ -278,8 +279,9 @@ void udm_nnrf_handle_nf_discover(
nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id);
udm_nf_fsm_init(nf_instance);

View File

@ -68,61 +68,56 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_UDM);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SMF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AUSF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDM_UEAU);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AUSF);
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDM_UECM);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDM_SDM);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2,
(char*)OGS_SBI_API_V2_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, udm_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_AMF);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_SMF);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_AUSF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDM_UEAU);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AUSF);
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDM_UECM);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDM_SDM);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2,
(char*)OGS_SBI_API_V2_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
udm_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
udm_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -142,7 +137,7 @@ bool udm_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = udm_nnrf_nfm_build_register(nf_instance);
request = udm_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(
client, client->cb, request, nf_instance);

View File

@ -364,7 +364,8 @@ void udm_state_operational(ogs_fsm_t *s, udm_event_t *e)
ogs_fsm_dispatch(&nf_instance->sm, e);
if (OGS_FSM_CHECK(&nf_instance->sm, udm_nf_state_exception))
ogs_error("[%s] State machine exception [%d]",
ogs_error("[%s:%s] State machine exception [%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id, e->timer_id);
break;
@ -372,9 +373,11 @@ void udm_state_operational(ogs_fsm_t *s, udm_event_t *e)
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
udm_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("[%s] Subscription validity expired", subscription->id);

View File

@ -52,8 +52,6 @@ udr_context_t *udr_self(void)
static int udr_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_UDR;
return OGS_OK;
}

View File

@ -39,8 +39,6 @@ extern int __udr_log_domain;
#define OGS_LOG_DOMAIN __udr_log_domain
typedef struct udr_context_s {
OpenAPI_nf_type_e nf_type;
} udr_context_t;
#define UDR_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \

View File

@ -27,9 +27,10 @@ int udr_initialize()
{
int rv;
ogs_sbi_context_init();
udr_context_init();
udr_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("udr", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void udr_nf_state_initial(ogs_fsm_t *s, udr_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void udr_nf_state_initial(ogs_fsm_t *s, udr_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = udr_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &udr_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &udr_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void udr_nf_state_will_register(ogs_fsm_t *s, udr_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == udr_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case UDR_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void udr_nf_state_will_register(ogs_fsm_t *s, udr_event_t *e)
OGS_FSM_TRAN(s, &udr_nf_state_registered);
} else {
ogs_error("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &udr_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,17 +160,18 @@ void udr_nf_state_will_register(ogs_fsm_t *s, udr_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == udr_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
udr_timer_get_name(e->timer_id), e->timer_id);
}
break;
@ -191,12 +194,14 @@ void udr_nf_state_registered(ogs_fsm_t *s, udr_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -214,8 +219,8 @@ void udr_nf_state_registered(ogs_fsm_t *s, udr_event_t *e)
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -249,7 +254,8 @@ void udr_nf_state_registered(ogs_fsm_t *s, udr_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &udr_nf_state_exception);
}
@ -257,13 +263,14 @@ void udr_nf_state_registered(ogs_fsm_t *s, udr_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -278,27 +285,31 @@ void udr_nf_state_registered(ogs_fsm_t *s, udr_event_t *e)
break;
case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &udr_nf_state_will_register);
break;
case UDR_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &udr_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &udr_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udr_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, udr_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udr_event_get_name(e));
break;
}
}
@ -313,11 +324,12 @@ void udr_nf_state_de_registered(ogs_fsm_t *s, udr_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -325,8 +337,10 @@ void udr_nf_state_de_registered(ogs_fsm_t *s, udr_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, udr_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udr_event_get_name(e));
break;
}
}
@ -344,18 +358,21 @@ void udr_nf_state_exception(ogs_fsm_t *s, udr_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case UDR_EVT_SBI_TIMER:
@ -366,15 +383,17 @@ void udr_nf_state_exception(ogs_fsm_t *s, udr_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &udr_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udr_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
@ -399,8 +418,10 @@ void udr_nf_state_exception(ogs_fsm_t *s, udr_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, udr_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
udr_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *udr_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *udr_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *udr_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *udr_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *udr_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -171,9 +171,10 @@ bool udr_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
udr_nf_fsm_init(nf_instance);

View File

@ -68,47 +68,43 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_UDR);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_PCF);
ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_UDM);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDR_DR);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_UDM);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, udr_self()->nf_type);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_PCF);
ogs_sbi_nf_instance_add_allowed_nf_type(
nf_instance, OpenAPI_nf_type_UDM);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NUDR_DR);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF);
ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_UDM);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
udr_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
udr_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -128,7 +124,7 @@ bool udr_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = udr_nnrf_nfm_build_register(nf_instance);
request = udr_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(client, client->cb, request, nf_instance);
}

View File

@ -292,9 +292,11 @@ void udr_state_operational(ogs_fsm_t *s, udr_event_t *e)
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
udr_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("[%s] Subscription validity expired", subscription->id);

View File

@ -406,9 +406,11 @@ void af_state_operational(ogs_fsm_t *s, af_event_t *e)
subscription = e->sbi.data;
ogs_assert(subscription);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client,
af_self()->nf_type, subscription->req_nf_instance_id,
ogs_sbi_self()->nf_instance->nf_type,
subscription->req_nf_instance_id,
subscription->subscr_cond.nf_type));
ogs_info("Subscription validity expired [%s]", subscription->id);

View File

@ -79,8 +79,6 @@ af_context_t *af_self(void)
static int af_context_prepare(void)
{
self.nf_type = OpenAPI_nf_type_AF;
return OGS_OK;
}
@ -269,10 +267,7 @@ void af_sess_select_nf(af_sess_t *sess, OpenAPI_nf_type_e nf_type)
ogs_assert(sess);
ogs_assert(nf_type);
if (nf_type == OpenAPI_nf_type_NRF)
ogs_sbi_select_nrf(&sess->sbi, af_nf_state_registered);
else
ogs_sbi_select_first_nf(&sess->sbi, nf_type, af_nf_state_registered);
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)

View File

@ -38,8 +38,6 @@ extern int __af_log_domain;
#define OGS_LOG_DOMAIN __af_log_domain
typedef struct af_context_s {
OpenAPI_nf_type_e nf_type;
ogs_hash_t *supi_hash; /* hash table (SUPI) */
ogs_hash_t *ipv4_hash; /* hash table (IPv4 Address) */
ogs_hash_t *ipv6_hash; /* hash table (IPv6 Address) */

View File

@ -29,9 +29,10 @@ int af_initialize()
{
int rv;
ogs_sbi_context_init();
af_context_init();
af_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("af", "nrf");
if (rv != OGS_OK) return rv;

View File

@ -60,7 +60,6 @@ void af_nf_state_initial(ogs_fsm_t *s, af_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(nf_instance->id);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_registration_interval->cb =
@ -73,9 +72,10 @@ void af_nf_state_initial(ogs_fsm_t *s, af_event_t *e)
ogs_assert(nf_instance->t_validity);
nf_instance->t_validity->cb = af_timer_nf_instance_validity;
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
OGS_FSM_TRAN(s, &af_nf_state_will_register);
} else {
ogs_assert(nf_instance->id);
OGS_FSM_TRAN(s, &af_nf_state_registered);
}
}
@ -102,19 +102,19 @@ void af_nf_state_will_register(ogs_fsm_t *s, af_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
ogs_assert(NF_INSTANCE_IS_NRF(nf_instance));
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == af_nnrf_nfm_send_nf_register(nf_instance));
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_stop(nf_instance->t_registration_interval);
ogs_timer_stop(nf_instance->t_registration_interval);
break;
case AF_EVT_SBI_CLIENT:
@ -133,20 +133,22 @@ void af_nf_state_will_register(ogs_fsm_t *s, af_event_t *e)
OGS_FSM_TRAN(s, &af_nf_state_registered);
} else {
ogs_error("[%s] HTTP Response Status Code [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &af_nf_state_exception);
}
break;
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -158,24 +160,25 @@ void af_nf_state_will_register(ogs_fsm_t *s, af_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.nf_register_interval);
ogs_assert(true == af_nnrf_nfm_send_nf_register(nf_instance));
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s] Unknown timer[%s:%d]",
ogs_sbi_self()->nf_instance->id,
af_timer_get_name(e->timer_id), e->timer_id);
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, af_event_get_name(e));
ogs_sbi_self()->nf_instance->id, af_event_get_name(e));
break;
}
}
@ -192,12 +195,14 @@ void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF registered [Heartbeat:%ds]",
nf_instance->id, nf_instance->time.heartbeat_interval);
ogs_sbi_self()->nf_instance->id,
nf_instance->time.heartbeat_interval);
client = nf_instance->client;
ogs_assert(client);
@ -213,14 +218,16 @@ void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e)
ogs_assert(true ==
ogs_nnrf_nfm_send_nf_status_subscribe(client,
af_self()->nf_type, nf_instance->id, OpenAPI_nf_type_BSF));
ogs_sbi_self()->nf_instance->nf_type,
ogs_sbi_self()->nf_instance->id,
OpenAPI_nf_type_BSF));
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
if (nf_instance->time.heartbeat_interval) {
ogs_timer_stop(nf_instance->t_heartbeat_interval);
@ -254,7 +261,8 @@ void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e)
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
nf_instance->id, message->res_status);
ogs_sbi_self()->nf_instance->id,
message->res_status);
OGS_FSM_TRAN(s, &af_nf_state_exception);
}
@ -262,13 +270,14 @@ void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e)
DEFAULT
ogs_error("[%s] Invalid resource name [%s]",
nf_instance->id, message->h.resource.component[0]);
ogs_sbi_self()->nf_instance->id,
message->h.resource.component[0]);
END
break;
DEFAULT
ogs_error("[%s] Invalid API name [%s]",
nf_instance->id, message->h.service.name);
ogs_sbi_self()->nf_instance->id, message->h.service.name);
END
break;
@ -283,27 +292,32 @@ void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e)
break;
case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s] No heartbeat", nf_instance->id);
ogs_error("[%s] No heartbeat", ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &af_nf_state_will_register);
break;
case AF_TIMER_NF_INSTANCE_VALIDITY:
if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) {
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &af_nf_state_de_registered);
}
ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id);
OGS_FSM_TRAN(s, &af_nf_state_de_registered);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
af_timer_get_name(e->timer_id), e->timer_id);
break;
}
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, af_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
af_event_get_name(e));
break;
}
}
@ -318,11 +332,12 @@ void af_nf_state_de_registered(ogs_fsm_t *s, af_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id)) {
ogs_info("[%s] NF de-registered", nf_instance->id);
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_info("[%s] NF de-registered", ogs_sbi_self()->nf_instance->id);
}
break;
@ -330,8 +345,10 @@ void af_nf_state_de_registered(ogs_fsm_t *s, af_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, af_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
af_event_get_name(e));
break;
}
}
@ -349,18 +366,21 @@ void af_nf_state_exception(ogs_fsm_t *s, af_event_t *e)
nf_instance = e->sbi.data;
ogs_assert(nf_instance);
ogs_assert(ogs_sbi_self()->nf_instance);
switch (e->id) {
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_start(nf_instance->t_registration_interval,
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
}
break;
case OGS_FSM_EXIT_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_timer_stop(nf_instance->t_registration_interval);
}
break;
case AF_EVT_SBI_TIMER:
@ -371,13 +391,16 @@ void af_nf_state_exception(ogs_fsm_t *s, af_event_t *e)
addr = client->node.addr;
ogs_assert(addr);
ogs_warn("[%s] Retry to registration with NRF", nf_instance->id);
ogs_warn("[%s] Retry to registration with NRF",
ogs_sbi_self()->nf_instance->id);
OGS_FSM_TRAN(s, &af_nf_state_will_register);
break;
default:
ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id,
ogs_error("[%s:%s] Unknown timer[%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
af_timer_get_name(e->timer_id), e->timer_id);
break;
}
@ -404,8 +427,10 @@ void af_nf_state_exception(ogs_fsm_t *s, af_event_t *e)
break;
default:
ogs_error("[%s] Unknown event %s",
nf_instance->id, af_event_get_name(e));
ogs_error("[%s:%s] Unknown event %s",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined",
af_event_get_name(e));
break;
}
}

View File

@ -19,18 +19,18 @@
#include "nnrf-build.h"
ogs_sbi_request_t *af_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_request_t *af_nnrf_nfm_build_register(void)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
ogs_sbi_client_t *client = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
client = nf_instance->client;
ogs_assert(client);
ogs_assert(nf_instance->id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
@ -38,11 +38,11 @@ ogs_sbi_request_t *af_nnrf_nfm_build_register(
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES;
message.h.resource.component[1] = ogs_sbi_self()->nf_instance_id;
message.h.resource.component[1] = nf_instance->id;
message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding;
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
NFProfile = ogs_nnrf_nfm_build_nf_profile();
ogs_expect_or_return_val(NFProfile, NULL);
message.NFProfile = NFProfile;

View File

@ -26,8 +26,7 @@
extern "C" {
#endif
ogs_sbi_request_t *af_nnrf_nfm_build_register(
ogs_sbi_nf_instance_t *nf_instance);
ogs_sbi_request_t *af_nnrf_nfm_build_register(void);
#ifdef __cplusplus
}

View File

@ -175,9 +175,10 @@ bool af_nnrf_handle_nf_status_notify(
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(
message.h.resource.component[1]);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance,
message.h.resource.component[1]);
af_nf_fsm_init(nf_instance);
@ -282,8 +283,9 @@ void af_nnrf_handle_nf_discover(
nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id);
if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id);
nf_instance = ogs_sbi_nf_instance_add();
ogs_assert(nf_instance);
ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id);
af_nf_fsm_init(nf_instance);

View File

@ -68,41 +68,39 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
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;
/*
* The connection between NF and NRF is a little special.
*
* NF and NRF share nf_instance. I get the NRF EndPoint(client) information
* the configuration file via lib/sbi/context.c.
* And, the NFService information will be transmitted to NRF.
*
* ogs_sbi_self()->nf_instance_id means NF's InstanceId.
*/
/* Add SELF NF instance */
nf_instance = ogs_sbi_self()->nf_instance;
ogs_assert(nf_instance);
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AF);
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
/* Initialize NRF NF Instance */
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
ogs_sbi_nf_service_t *service = NULL;
ogs_sbi_client_t *client = NULL;
if (NF_INSTANCE_IS_NRF(nf_instance)) {
ogs_sbi_client_t *client = NULL;
/* Build NF instance information. It will be transmitted to NRF. */
ogs_sbi_nf_instance_build_default(nf_instance, af_self()->nf_type);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* Build NF service information. It will be transmitted to NRF. */
service = ogs_sbi_nf_service_build_default(nf_instance,
(char*)OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE);
ogs_assert(service);
ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1,
(char*)OGS_SBI_API_V1_0_0, NULL);
/* Client callback is only used when NF sends to NRF */
client = nf_instance->client;
ogs_assert(client);
client->cb = client_cb;
/* NFRegister is sent and the response is received
* by the above client callback. */
af_nf_fsm_init(nf_instance);
/* NFRegister is sent and the response is received
* by the above client callback. */
af_nf_fsm_init(nf_instance);
}
}
return OGS_OK;
@ -122,7 +120,7 @@ bool af_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance->client;
ogs_assert(client);
request = af_nnrf_nfm_build_register(nf_instance);
request = af_nnrf_nfm_build_register();
ogs_expect_or_return_val(request, false);
return ogs_sbi_client_send_request(
client, client->cb, request, nf_instance);