[SBI] Support service-names in discovery option

This commit is contained in:
Sukchan Lee 2022-08-27 00:12:22 +09:00
parent e79e35dd74
commit f020732ce9
79 changed files with 2488 additions and 1360 deletions

View File

@ -105,6 +105,65 @@ smf:
connect:
- identity: pcrf.localdomain
addr: 127.0.0.9
#
# <NF Discovery Query Parameter>
#
# o (Default) If you do not set Query Parameter as shown below,
#
# amf:
# sbi:
# - addr: 127.0.0.5
# port: 7777
#
# - 'service-names' is included.
# - 'requester-nf-instance-id' is NOT included.
#
# amf:
# sbi:
# - addr: 127.0.0.5
# port: 7777
# discovery:
# option:
# no_service_names: false
# prefer_requester_nf_instance_id: false
#
# o To remove 'service-names' from URI query parameters in NS Discovery
# no_service_names: true
#
# * For Indirect Communication with Delegated Discovery,
# 'service-names' is always included in the URI query parameter.
# * That is, 'no_service_names' has no effect.
#
# o To add 'requester-nf-instance-id' from URI query parameters in NS Discovery
# prefer_requester_nf_instance_id: true
#
#
# <For Indirect Communication with Delegated Discovery>
#
# o (Default) If you do not set Delegated Discovery as shown below,
#
# amf:
# sbi:
# - addr: 127.0.0.5
# port: 7777
#
# - Use SCP if SCP avaiable. Otherwise NRF is used.
# => App fails if both NRF and SCP are unavailable.
#
# amf:
# sbi:
# - addr: 127.0.0.5
# port: 7777
# discovery:
# delegated: auto
#
# o To use SCP always => App fails if no SCP available.
# delegated: yes
#
# o Don't use SCP server => App fails if no NRF available.
# delegated: no
#
amf:
sbi:
- addr: 127.0.0.5
@ -233,26 +292,6 @@ nrf:
# l_onoff: true
# l_linger: 10
#
# <Discovery>
#
# o NF Discovery and Selection
# for indirect communication with Delegated Discovery;
#
# o delegated:
# o auto: (Default)
# Use SCP if SCP avaiable. Otherwise NRF is used.
# => App fails if both NRF and SCP are unavailable.
# o yes: Use SCP always.
# => App fails if no SCP available.
# o no: Don't use SCP server.
# => App fails if no NRF available.
#
# scp:
# sbi:
# - addr: 127.0.1.10
# port: 7777
# discovery:
# delegated: auto|yes|no
#
scp:
sbi:

View File

@ -71,9 +71,6 @@ static void recalculate_pool_size(void)
self.pool.bearer = self.pool.sess * OGS_MAX_NUM_OF_BEARER;
self.pool.tunnel = self.pool.bearer * MAX_NUM_OF_TUNNEL;
#define OGS_MAX_NUM_OF_NF_SUBSCRIPTION 4 /* Num of Subscription per NF */
self.pool.nf_service = self.max.peer * OGS_MAX_NUM_OF_NF_SERVICE;
#define POOL_NUM_PER_UE 16
self.pool.timer = self.max.ue * POOL_NUM_PER_UE;
self.pool.message = self.max.ue * POOL_NUM_PER_UE;
@ -84,6 +81,9 @@ static void recalculate_pool_size(void)
self.pool.stream = self.max.ue * POOL_NUM_PER_UE;
self.pool.nf = self.max.peer;
#define NF_SERVICE_PER_NF_INSTANCE 16
self.pool.nf_service = self.pool.nf * NF_SERVICE_PER_NF_INSTANCE;
self.pool.gtp_node = self.pool.nf;
if (self.max.gtp_peer)
self.pool.gtp_node = self.max.gtp_peer;

View File

@ -33,9 +33,6 @@ extern "C" {
#define OGS_BEARER_PER_UE 8 /* Num of Bearer per UE */
#define OGS_MAX_NUM_OF_PACKET_BUFFER 64 /* Num of PacketBuffer per UE */
/* Num of NF Service per NF Instance */
#define OGS_MAX_NUM_OF_NF_SERVICE 16
/*
* The array of TLV messages is limited to 8.
* So, Flow(PDI.SDF_Filter) in PDR is limited to 8.

View File

@ -120,36 +120,35 @@ static int ogs_sbi_context_validation(
return OGS_ERROR;
}
if (context_initialized == 1) {
switch (self.discovery_config.delegated) {
case OGS_SBI_DISCOVERY_DELEGATED_AUTO:
if (strcmp(local, "nrf") != 0 && /* Skip NRF */
strcmp(local, "smf") != 0 && /* Skip SMF since SMF can run 4G */
ogs_sbi_self()->nrf_instance == NULL &&
ogs_sbi_self()->scp_instance == NULL) {
ogs_error("DELEGATED_AUTO - Both NRF and %s are unavailable",
strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP");
return OGS_ERROR;
}
break;
case OGS_SBI_DISCOVERY_DELEGATED_YES:
if (ogs_sbi_self()->scp_instance == NULL) {
ogs_error("DELEGATED_YES - no %s available",
strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP");
return OGS_ERROR;
}
break;
case OGS_SBI_DISCOVERY_DELEGATED_NO:
if (ogs_sbi_self()->nrf_instance == NULL) {
ogs_error("DELEGATED_NO - no NRF available");
return OGS_ERROR;
}
break;
default:
ogs_fatal("Invalid dicovery-config delegated [%d]",
self.discovery_config.delegated);
ogs_assert_if_reached();
ogs_assert(context_initialized == 1);
switch (self.discovery_config.delegated) {
case OGS_SBI_DISCOVERY_DELEGATED_AUTO:
if (strcmp(local, "nrf") != 0 && /* Skip NRF */
strcmp(local, "smf") != 0 && /* Skip SMF since SMF can run 4G */
ogs_sbi_self()->nrf_instance == NULL &&
ogs_sbi_self()->scp_instance == NULL) {
ogs_error("DELEGATED_AUTO - Both NRF and %s are unavailable",
strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP");
return OGS_ERROR;
}
break;
case OGS_SBI_DISCOVERY_DELEGATED_YES:
if (ogs_sbi_self()->scp_instance == NULL) {
ogs_error("DELEGATED_YES - no %s available",
strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP");
return OGS_ERROR;
}
break;
case OGS_SBI_DISCOVERY_DELEGATED_NO:
if (ogs_sbi_self()->nrf_instance == NULL) {
ogs_error("DELEGATED_NO - no NRF available");
return OGS_ERROR;
}
break;
default:
ogs_fatal("Invalid dicovery-config delegated [%d]",
self.discovery_config.delegated);
ogs_assert_if_reached();
}
return OGS_OK;
@ -420,6 +419,53 @@ int ogs_sbi_context_parse_config(
} while (ogs_yaml_iter_type(
&service_name_iter) == YAML_SEQUENCE_NODE);
} else if (!strcmp(local_key, "discovery")) {
ogs_yaml_iter_t discovery_iter;
ogs_yaml_iter_recurse(&local_iter, &discovery_iter);
while (ogs_yaml_iter_next(&discovery_iter)) {
const char *discovery_key =
ogs_yaml_iter_key(&discovery_iter);
ogs_assert(discovery_key);
if (!strcmp(discovery_key, "delegated")) {
const char *delegated =
ogs_yaml_iter_value(&discovery_iter);
if (!strcmp(delegated, "auto"))
self.discovery_config.delegated =
OGS_SBI_DISCOVERY_DELEGATED_AUTO;
else if (!strcmp(delegated, "yes"))
self.discovery_config.delegated =
OGS_SBI_DISCOVERY_DELEGATED_YES;
else if (!strcmp(delegated, "no"))
self.discovery_config.delegated =
OGS_SBI_DISCOVERY_DELEGATED_NO;
else
ogs_warn("unknown 'delegated' value `%s`",
delegated);
} else if (!strcmp(discovery_key, "option")) {
ogs_yaml_iter_t option_iter;
ogs_yaml_iter_recurse(
&discovery_iter, &option_iter);
while (ogs_yaml_iter_next(&option_iter)) {
const char *option_key =
ogs_yaml_iter_key(&option_iter);
ogs_assert(option_key);
if (!strcmp(option_key, "no_service_names")) {
self.discovery_config.no_service_names =
ogs_yaml_iter_bool(&option_iter);
} else if (!strcmp(option_key,
"prefer_requester_nf_instance_id")) {
self.discovery_config.
prefer_requester_nf_instance_id =
ogs_yaml_iter_bool(&option_iter);
} else
ogs_warn("unknown key `%s`", option_key);
}
} else
ogs_warn("unknown key `%s`", discovery_key);
}
}
}
} else if (nrf && !strcmp(root_key, nrf)) {
@ -680,35 +726,6 @@ int ogs_sbi_context_parse_config(
} while (ogs_yaml_iter_type(&sbi_array) ==
YAML_SEQUENCE_NODE);
} else if (!strcmp(scp_key, "discovery")) {
ogs_yaml_iter_t discovery_iter;
yaml_node_t *node = yaml_document_get_node(
document, scp_iter.pair->value);
ogs_assert(node);
ogs_assert(node->type == YAML_MAPPING_NODE);
ogs_yaml_iter_recurse(&scp_iter, &discovery_iter);
while (ogs_yaml_iter_next(&discovery_iter)) {
const char *discovery_key =
ogs_yaml_iter_key(&discovery_iter);
ogs_assert(discovery_key);
if (!strcmp(discovery_key, "delegated")) {
const char *delegated =
ogs_yaml_iter_value(&discovery_iter);
if (!strcmp(delegated, "auto"))
self.discovery_config.delegated =
OGS_SBI_DISCOVERY_DELEGATED_AUTO;
else if (!strcmp(delegated, "yes"))
self.discovery_config.delegated =
OGS_SBI_DISCOVERY_DELEGATED_YES;
else if (!strcmp(delegated, "no"))
self.discovery_config.delegated =
OGS_SBI_DISCOVERY_DELEGATED_NO;
else
ogs_warn("unknown 'delegated' value `%s`",
delegated);
} else
ogs_warn("unknown key `%s`", discovery_key);
}
}
}
}
@ -821,6 +838,7 @@ void ogs_sbi_nf_instance_clear(ogs_sbi_nf_instance_t *nf_instance)
if (nf_instance->fqdn)
ogs_free(nf_instance->fqdn);
nf_instance->fqdn = NULL;
for (i = 0; i < nf_instance->num_of_ipv4; i++) {
if (nf_instance->ipv4[i])
@ -864,9 +882,6 @@ void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance)
if (nf_instance->client)
ogs_sbi_client_remove(nf_instance->client);
if (nf_instance->nf_profile)
OpenAPI_nf_profile_free(nf_instance->nf_profile);
ogs_pool_free(&nf_instance_pool, nf_instance);
}
@ -964,7 +979,7 @@ void ogs_sbi_nf_service_add_allowed_nf_type(
ogs_assert(allowed_nf_type);
if (nf_service->num_of_allowed_nf_type < OGS_SBI_MAX_NUM_OF_NF_TYPE) {
nf_service->allowed_nf_types[nf_service->num_of_allowed_nf_type] =
nf_service->allowed_nf_type[nf_service->num_of_allowed_nf_type] =
allowed_nf_type;
nf_service->num_of_allowed_nf_type++;
}
@ -981,6 +996,7 @@ void ogs_sbi_nf_service_clear(ogs_sbi_nf_service_t *nf_service)
if (nf_service->fqdn)
ogs_free(nf_service->fqdn);
nf_service->fqdn = NULL;
for (i = 0; i < nf_service->num_of_version; i++) {
if (nf_service->version[i].in_uri)
@ -1138,6 +1154,22 @@ void ogs_sbi_nf_info_remove_all(ogs_list_t *list)
ogs_sbi_nf_info_remove(list, nf_info);
}
ogs_sbi_nf_info_t *ogs_sbi_nf_info_find(
ogs_list_t *list, OpenAPI_nf_type_e nf_type)
{
ogs_sbi_nf_info_t *nf_info = NULL;
ogs_assert(list);
ogs_assert(nf_type);
ogs_list_for_each(list, nf_info) {
if (nf_info->nf_type == nf_type)
return nf_info;
}
return NULL;
}
void ogs_sbi_nf_instance_build_default(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e nf_type)
{
@ -1367,6 +1399,43 @@ static void nf_service_associate_client_all(ogs_sbi_nf_instance_t *nf_instance)
nf_service_associate_client(nf_service);
}
bool ogs_sbi_discovery_option_is_matched(
ogs_sbi_nf_instance_t *nf_instance,
ogs_sbi_discovery_option_t *discovery_option)
{
ogs_assert(nf_instance);
ogs_assert(discovery_option);
if (discovery_option->target_nf_instance_id &&
nf_instance->id && strcmp(nf_instance->id,
discovery_option->target_nf_instance_id) != 0) {
return false;
}
if (discovery_option->num_of_service_names) {
ogs_sbi_nf_service_t *nf_service = NULL;
bool exist = false;
int i;
ogs_list_for_each(&nf_instance->nf_service_list, nf_service) {
for (i = 0; i < discovery_option->num_of_service_names; i++) {
if (nf_service->name &&
discovery_option->service_names[i] &&
strcmp(nf_service->name,
discovery_option->service_names[i]) == 0) {
exist = true;
break;
}
}
if (exist == true) break;
}
if (exist == false) return false;
}
return true;
}
bool ogs_sbi_discovery_param_is_matched(
ogs_sbi_nf_instance_t *nf_instance,
OpenAPI_nf_type_e target_nf_type,
@ -1381,24 +1450,25 @@ bool ogs_sbi_discovery_param_is_matched(
if (nf_instance->nf_type != target_nf_type)
return false;
if (discovery_option) {
if (discovery_option->target_nf_instance_id &&
strcmp(nf_instance->id,
discovery_option->target_nf_instance_id) != 0)
return false;
}
if (discovery_option &&
ogs_sbi_discovery_option_is_matched(
nf_instance, discovery_option) == false)
return false;
return true;
}
void ogs_sbi_select_nf(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(sbi_object);
ogs_assert(service_type);
target_nf_type = ogs_sbi_service_type_to_nf_type(service_type);
ogs_assert(target_nf_type);
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
@ -1406,7 +1476,7 @@ void ogs_sbi_select_nf(
nf_instance, target_nf_type, discovery_option) == false)
continue;
OGS_SBI_SETUP_NF(sbi_object, target_nf_type, nf_instance);
OGS_SBI_SETUP_NF_INSTANCE(sbi_object, service_type, nf_instance);
break;
}
}
@ -1464,7 +1534,7 @@ void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object)
if (ogs_list_count(&sbi_object->xact_list))
ogs_error("SBI running [%d]", ogs_list_count(&sbi_object->xact_list));
for (i = 0; i < OGS_SBI_MAX_NF_TYPE; i++) {
for (i = 0; i < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE; i++) {
if (OGS_SBI_NF_INSTANCE(sbi_object, i))
ogs_sbi_nf_instance_remove(OGS_SBI_NF_INSTANCE(sbi_object, i));
}
@ -1472,7 +1542,7 @@ void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object)
ogs_sbi_xact_t *ogs_sbi_xact_add(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_build_f build, void *context, void *data)
{
@ -1485,22 +1555,25 @@ ogs_sbi_xact_t *ogs_sbi_xact_add(
memset(xact, 0, sizeof(ogs_sbi_xact_t));
xact->sbi_object = sbi_object;
xact->service_type = service_type;
xact->target_nf_type = target_nf_type;
xact->discovery_option = discovery_option;
xact->request = (*build)(context, data);
if (!xact->request) {
ogs_error("SBI build failed");
ogs_pool_free(&xact_pool, xact);
return NULL;
/* Always insert one service-name in the discovery option */
if (!discovery_option) {
discovery_option = ogs_sbi_discovery_option_new();
ogs_assert(discovery_option);
}
if (!discovery_option->num_of_service_names) {
ogs_sbi_discovery_option_add_service_names(
discovery_option,
(char *)ogs_sbi_service_type_to_name(service_type));
}
xact->discovery_option = discovery_option;
xact->t_response = ogs_timer_add(
ogs_app()->timer_mgr, ogs_timer_sbi_client_wait_expire, xact);
if (!xact->t_response) {
ogs_error("ogs_timer_add() failed");
ogs_sbi_request_free(xact->request);
ogs_pool_free(&xact_pool, xact);
return NULL;
}
@ -1508,6 +1581,42 @@ ogs_sbi_xact_t *ogs_sbi_xact_add(
ogs_timer_start(xact->t_response,
ogs_app()->time.message.sbi.client_wait_duration);
if (build) {
xact->request = (*build)(context, data);
if (!xact->request) {
ogs_error("SBI build failed");
ogs_timer_delete(xact->t_response);
ogs_pool_free(&xact_pool, xact);
return NULL;
}
if (!xact->request->h.uri) {
const char *service_name = NULL;
ogs_assert(xact->service_type);
service_name = ogs_sbi_service_type_to_name(xact->service_type);
ogs_assert(service_name);
ogs_assert(xact->request->h.service.name);
/*
* Make sure the service matches
* between discover and build functions:
*
* DISCOVER : amf_ue_sbi_discover_and_send(
* OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL,
* BUILD : amf_npcf_am_policy_control_build_create()
* message.h.service.name =
* (char *)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL;
*/
if (strcmp(service_name, xact->request->h.service.name) != 0) {
ogs_fatal("[%s:%d] is not the same with [%s]",
service_name, xact->service_type,
xact->request->h.service.name);
ogs_assert_if_reached();
}
}
}
ogs_list_add(&sbi_object->xact_list, xact);
return xact;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
* Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
@ -28,8 +28,6 @@
extern "C" {
#endif
#define OGS_SBI_MAX_NF_TYPE 64
#define OGS_MAX_NUM_OF_NF_INFO 8
typedef struct ogs_sbi_client_s ogs_sbi_client_t;
@ -44,6 +42,8 @@ typedef enum {
typedef struct ogs_sbi_discovery_config_s {
ogs_sbi_discovery_delegated_mode delegated;
bool no_service_names;
bool prefer_requester_nf_instance_id;
} ogs_sbi_discovery_config_t;
typedef struct ogs_sbi_context_s {
@ -66,9 +66,9 @@ typedef struct ogs_sbi_context_s {
const char *content_encoding;
int num_of_service_name;
const char *service_name[OGS_MAX_NUM_OF_NF_SERVICE];
const char *service_name[OGS_SBI_MAX_NUM_OF_SERVICE_TYPE];
#define OGS_SBI_MAX_NUM_OF_NF_TYPE 16
#define OGS_SBI_MAX_NUM_OF_NF_TYPE 128
int num_of_to_be_notified_nf_type;
OpenAPI_nf_type_e to_be_notified_nf_type[OGS_SBI_MAX_NUM_OF_NF_TYPE];
} ogs_sbi_context_t;
@ -122,18 +122,15 @@ typedef struct ogs_sbi_nf_instance_s {
int load;
ogs_list_t nf_service_list;
ogs_list_t nf_info_list;
void *client; /* only used in CLIENT */
unsigned int reference_count; /* reference count for memory free */
ogs_list_t nf_info_list;
OpenAPI_nf_profile_t *nf_profile; /* stored NF Profile */
} ogs_sbi_nf_instance_t;
typedef struct ogs_sbi_nf_type_array_s {
typedef struct ogs_sbi_nf_instance_array_s {
ogs_sbi_nf_instance_t *nf_instance;
} ogs_sbi_nf_type_array_t[OGS_SBI_MAX_NF_TYPE];
} ogs_sbi_nf_instance_array_t[OGS_SBI_MAX_NUM_OF_SERVICE_TYPE];
typedef enum {
OGS_SBI_OBJ_BASE = 0,
@ -149,7 +146,7 @@ typedef struct ogs_sbi_object_s {
ogs_sbi_obj_type_e type;
ogs_sbi_nf_type_array_t nf_type_array;
ogs_sbi_nf_instance_array_t nf_instance_array;
ogs_list_t xact_list;
@ -161,7 +158,7 @@ typedef ogs_sbi_request_t *(*ogs_sbi_build_f)(
typedef struct ogs_sbi_xact_s {
ogs_lnode_t lnode;
OpenAPI_nf_type_e target_nf_type;
ogs_sbi_service_type_e service_type;
ogs_sbi_discovery_option_t *discovery_option;
ogs_sbi_request_t *request;
@ -199,7 +196,7 @@ typedef struct ogs_sbi_nf_service_s {
} addr[OGS_SBI_MAX_NUM_OF_IP_ADDRESS];
int num_of_allowed_nf_type;
OpenAPI_nf_type_e allowed_nf_types[OGS_SBI_MAX_NUM_OF_NF_TYPE];
OpenAPI_nf_type_e allowed_nf_type[OGS_SBI_MAX_NUM_OF_NF_TYPE];
int priority;
int capacity;
@ -229,6 +226,9 @@ typedef struct ogs_sbi_subscription_s {
OpenAPI_nf_type_e nf_type; /* nfType */
} subscr_cond;
uint64_t requester_features;
uint64_t nrf_supported_features;
void *client; /* only used in SERVER */
} ogs_sbi_subscription_t;
@ -313,6 +313,8 @@ ogs_sbi_nf_info_t *ogs_sbi_nf_info_add(
ogs_list_t *list, OpenAPI_nf_type_e nf_type);
void ogs_sbi_nf_info_remove(ogs_list_t *list, ogs_sbi_nf_info_t *nf_info);
void ogs_sbi_nf_info_remove_all(ogs_list_t *list);
ogs_sbi_nf_info_t *ogs_sbi_nf_info_find(
ogs_list_t *list, OpenAPI_nf_type_e nf_type);
void ogs_sbi_nf_instance_build_default(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e nf_type);
@ -326,25 +328,25 @@ void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance);
OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void);
#define OGS_SBI_NF_INSTANCE(__sBIObject, __nFType) \
(((__sBIObject)->nf_type_array)[__nFType].nf_instance)
#define OGS_SBI_NF_INSTANCE(__sBIObject, __sERVICEType) \
(((__sBIObject)->nf_instance_array)[__sERVICEType].nf_instance)
#define OGS_SBI_SETUP_NF(__sBIObject, __nFType, __nFInstance) \
#define OGS_SBI_SETUP_NF_INSTANCE(__sBIObject, __sERVICEType, __nFInstance) \
do { \
ogs_assert((__sBIObject)); \
ogs_assert((__nFType)); \
ogs_assert((__sERVICEType)); \
ogs_assert((__nFInstance)); \
\
if (OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType))) { \
if (OGS_SBI_NF_INSTANCE((__sBIObject), (__sERVICEType))) { \
ogs_warn("UE %s-EndPoint updated [%s]", \
OpenAPI_nf_type_ToString((__nFType)), \
ogs_sbi_service_type_to_name((__sERVICEType)), \
(__nFInstance)->id); \
ogs_sbi_nf_instance_remove( \
OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType))); \
OGS_SBI_NF_INSTANCE((__sBIObject), (__sERVICEType))); \
} \
\
OGS_OBJECT_REF(__nFInstance); \
OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType)) = (__nFInstance); \
OGS_SBI_NF_INSTANCE((__sBIObject), (__sERVICEType)) = (__nFInstance); \
} while(0)
bool ogs_sbi_discovery_param_is_matched(
@ -352,16 +354,20 @@ bool ogs_sbi_discovery_param_is_matched(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_discovery_option_t *discovery_option);
bool ogs_sbi_discovery_option_is_matched(
ogs_sbi_nf_instance_t *nf_instance,
ogs_sbi_discovery_option_t *discovery_option);
void ogs_sbi_select_nf(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option);
void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object);
ogs_sbi_xact_t *ogs_sbi_xact_add(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_build_f build, void *context, void *data);
void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact);

View File

@ -27,6 +27,7 @@ libsbi_sources = files('''
custom/patch_item.c
yuarel.c
types.c
conv.c
timer.c
message.c

View File

@ -2337,7 +2337,7 @@ void ogs_sbi_discovery_option_add_service_names(
ogs_assert(service_name);
ogs_assert(discovery_option->num_of_service_names <
OGS_MAX_NUM_OF_NF_SERVICE);
OGS_SBI_MAX_NUM_OF_SERVICE_TYPE);
discovery_option->service_names[discovery_option->num_of_service_names] =
ogs_strdup(service_name);

View File

@ -80,19 +80,15 @@ extern "C" {
#define OGS_SBI_API_V2 "v2"
#define OGS_SBI_API_V2_0_0 "2.0.0"
#define OGS_SBI_SERVICE_NAME_NNRF_NFM "nnrf-nfm"
#define OGS_SBI_SERVICE_NAME_NNRF_DISC "nnrf-disc"
#define OGS_SBI_RESOURCE_NAME_NF_INSTANCES "nf-instances"
#define OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS "subscriptions"
#define OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY "nf-status-notify"
#define OGS_SBI_SERVICE_NAME_NAUSF_AUTH "nausf-auth"
#define OGS_SBI_RESOURCE_NAME_UE_AUTHENTICATIONS "ue-authentications"
#define OGS_SBI_RESOURCE_NAME_5G_AKA "5g-aka"
#define OGS_SBI_RESOURCE_NAME_5G_AKA_CONFIRMATION "5g-aka-confirmation"
#define OGS_SBI_RESOURCE_NAME_EAP_SESSION "eap-session"
#define OGS_SBI_SERVICE_NAME_NUDM_SDM "nudm-sdm"
#define OGS_SBI_RESOURCE_NAME_AM_DATA "am-data"
#define OGS_SBI_RESOURCE_NAME_SM_DATA "sm-data"
#define OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA "smf-select-data"
@ -100,15 +96,12 @@ extern "C" {
#define OGS_SBI_RESOURCE_NAME_SMF_SELECTION_SUBSCRIPTION_DATA \
"smf-selection-subscription-data"
#define OGS_SBI_SERVICE_NAME_NUDM_UEAU "nudm-ueau"
#define OGS_SBI_RESOURCE_NAME_SECURITY_INFORMATION "security-information"
#define OGS_SBI_RESOURCE_NAME_GENERATE_AUTH_DATA "generate-auth-data"
#define OGS_SBI_RESOURCE_NAME_AUTH_EVENTS "auth-events"
#define OGS_SBI_SERVICE_NAME_NUDM_UECM "nudm-uecm"
#define OGS_SBI_RESOURCE_NAME_REGISTRATIONS "registrations"
#define OGS_SBI_RESOURCE_NAME_AMF_3GPP_ACCESS "amf-3gpp-access"
#define OGS_SBI_SERVICE_NAME_NUDR_DR "nudr-dr"
#define OGS_SBI_RESOURCE_NAME_SUBSCRIPTION_DATA "subscription-data"
#define OGS_SBI_RESOURCE_NAME_AUTHENTICATION_DATA "authentication-data"
#define OGS_SBI_RESOURCE_NAME_AUTHENTICATION_SUBSCRIPTION \
@ -120,51 +113,42 @@ extern "C" {
#define OGS_SBI_RESOURCE_NAME_UES "ues"
#define OGS_SBI_RESOURCE_NAME_AM_DATA "am-data"
#define OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION "nsmf-pdusession"
#define OGS_SBI_RESOURCE_NAME_SM_CONTEXTS "sm-contexts"
#define OGS_SBI_RESOURCE_NAME_MODIFY "modify"
#define OGS_SBI_RESOURCE_NAME_RELEASE "release"
#define OGS_SBI_SERVICE_NAME_NSMF_CALLBACK "nsmf-callback"
#define OGS_SBI_RESOURCE_NAME_SM_POLICY_NOTIFY "sm-policy-notify"
#define OGS_SBI_RESOURCE_NAME_N1_N2_FAILURE_NOTIFY "n1-n2-failure-notify"
#define OGS_SBI_SERVICE_NAME_NAMF_COMM "namf-comm"
#define OGS_SBI_RESOURCE_NAME_UE_CONTEXTS "ue-contexts"
#define OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES "n1-n2-messages"
#define OGS_SBI_SERVICE_NAME_NAMF_CALLBACK "namf-callback"
#define OGS_SBI_RESOURCE_NAME_SM_CONTEXT_STATUS "sm-context-status"
#define OGS_SBI_RESOURCE_NAME_AM_POLICY_NOTIFY "am-policy-notify"
#define OGS_SBI_RESOURCE_NAME_DEREG_NOTIFY "dereg-notify"
#define OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL "npcf-am-policy-control"
#define OGS_SBI_RESOURCE_NAME_POLICIES "policies"
#define OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL "npcf-smpolicycontrol"
#define OGS_SBI_RESOURCE_NAME_SM_POLICIES "sm-policies"
#define OGS_SBI_RESOURCE_NAME_DELETE "delete"
#define OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION \
"npcf-policyauthorization"
#define OGS_SBI_RESOURCE_NAME_APP_SESSIONS "app-sessions"
#define OGS_SBI_RESOURCE_NAME_NOTIFY "notify"
#define OGS_SBI_SERVICE_NAME_NPCF_CALLBACK "npcf-callback"
#define OGS_SBI_RESOURCE_NAME_UPDATE "update"
#define OGS_SBI_RESOURCE_NAME_TERMINATE "terminate"
#define OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION "nnssf-nsselection"
#define OGS_SBI_RESOURCE_NAME_NETWORK_SLICE_INFORMATION \
"network-slice-information"
#define OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT "nbsf-management"
#define OGS_SBI_RESOURCE_NAME_PCF_BINDINGS "pcfBindings"
#define OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE "naf-eventexposure"
#define OGS_SBI_FEATURES_IS_SET(__fEATURES, __n) \
(__fEATURES & (1 << ((__n)-1)))
#define OGS_SBI_FEATURES_SET(__fEATURES, __n) \
__fEATURES |= (1 << ((__n)-1))
#define OGS_SBI_NNRF_NFM_SERVICE_MAP 1
#define OGS_SBI_NNRF_NFM_EMPTY_OBJECTS_NRF_INFO 2
#define OGS_SBI_NPCF_AM_POLICY_CONTROL_SLICE_SUPPORT 1
#define OGS_SBI_NPCF_AM_POLICY_CONTROL_PENDING_TRANSACTION 2
#define OGS_SBI_NPCF_AM_POLICY_CONTROL_UE_AMBR_AUTHORIZATION 3
@ -368,7 +352,7 @@ typedef struct ogs_sbi_discovery_option_s {
char *requester_nf_instance_id;
int num_of_service_names;
char *service_names[OGS_MAX_NUM_OF_NF_SERVICE];
char *service_names[OGS_SBI_MAX_NUM_OF_SERVICE_TYPE];
} ogs_sbi_discovery_option_t;
typedef struct ogs_sbi_message_s {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
* Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
@ -24,8 +24,11 @@
extern "C" {
#endif
OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(void);
void ogs_sbi_nnrf_free_nf_profile(OpenAPI_nf_profile_t *NFProfile);
OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
ogs_sbi_nf_instance_t *nf_instance,
ogs_sbi_discovery_option_t *discovery_option,
uint64_t supported_features);
void ogs_nnrf_nfm_free_nf_profile(OpenAPI_nf_profile_t *NFProfile);
ogs_sbi_request_t *ogs_nnrf_nfm_build_register(void);
ogs_sbi_request_t *ogs_nnrf_nfm_build_update(void);
@ -38,7 +41,7 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_unsubscribe(
ogs_sbi_request_t *ogs_nnrf_nfm_build_profile_retrieve(char *nf_instance_id);
ogs_sbi_request_t *ogs_nnrf_disc_build_discover(
OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option);
#ifdef __cplusplus

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
* Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
@ -19,6 +19,8 @@
#include "ogs-sbi.h"
static void handle_nf_service(
ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_service_t *NFService);
static void handle_smf_info(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_smf_info_t *SmfInfo);
@ -44,14 +46,11 @@ void ogs_sbi_nnrf_handle_nf_register(
nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer;
}
void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
OpenAPI_nf_profile_t *NFProfile,
ogs_sbi_stream_t *stream, ogs_sbi_message_t *message)
void ogs_sbi_nnrf_handle_nf_profile(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_profile_t *NFProfile)
{
int rv;
OpenAPI_lnode_t *node;
ogs_sbi_nf_service_t *nf_service = NULL, *next_nf_service = NULL;
ogs_assert(nf_instance);
ogs_assert(NFProfile);
@ -59,41 +58,6 @@ void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
ogs_assert(NFProfile->nf_type);
ogs_assert(NFProfile->nf_status);
ogs_list_for_each_safe(&nf_instance->nf_service_list,
next_nf_service, nf_service) {
bool nf_service_should_not_be_deleted = false;
ogs_assert(nf_service->id);
OpenAPI_list_for_each(NFProfile->nf_services, node) {
OpenAPI_nf_service_t *NFService = node->data;
if (!NFService) continue;
if (!NFService->service_instance_id) continue;
if (!NFService->service_name) continue;
if (strcmp(nf_service->id, NFService->service_instance_id) == 0) {
nf_service_should_not_be_deleted = true;
break;
}
}
if (nf_service_should_not_be_deleted == false) {
ogs_warn("NFService[%s:%s] removed",
nf_service->id, nf_service->name);
OpenAPI_list_for_each(NFProfile->nf_services, node) {
OpenAPI_nf_service_t *NFService = node->data;
if (!NFService) continue;
if (!NFService->service_instance_id) continue;
if (!NFService->service_name) continue;
ogs_warn("NFService[%s:%s] will be added",
NFService->service_instance_id, NFService->service_name);
}
ogs_sbi_nf_service_remove(nf_service);
}
}
ogs_sbi_nf_instance_clear(nf_instance);
nf_instance->nf_type = NFProfile->nf_type;
@ -111,11 +75,13 @@ void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
if (NFProfile->is_load == true)
nf_instance->load = NFProfile->load;
/* Only one time handles RegisterNFInstance operation */
OpenAPI_list_for_each(NFProfile->ipv4_addresses, node) {
ogs_sockaddr_t *addr = NULL;
if (!node->data) continue;
if (!node->data) {
ogs_error("No IPv4 Address");
continue;
}
if (nf_instance->num_of_ipv4 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
@ -130,7 +96,10 @@ void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
OpenAPI_list_for_each(NFProfile->ipv6_addresses, node) {
ogs_sockaddr_t *addr = NULL;
if (!node->data) continue;
if (!node->data) {
ogs_error("No IPv6 Address");
continue;
}
if (nf_instance->num_of_ipv6 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
@ -143,107 +112,93 @@ void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
}
}
OpenAPI_list_for_each(NFProfile->allowed_nf_types, node) {
OpenAPI_nf_type_e AllowedNfType = (uintptr_t)node->data;
if (!AllowedNfType) {
ogs_error("AllowedNfType");
continue;
}
if (nf_instance->num_of_allowed_nf_type <
OGS_SBI_MAX_NUM_OF_NF_TYPE) {
nf_instance->allowed_nf_type[
nf_instance->num_of_allowed_nf_type] = AllowedNfType;
nf_instance->num_of_allowed_nf_type++;
}
}
OpenAPI_list_for_each(NFProfile->nf_services, node) {
ogs_sbi_nf_service_t *nf_service = NULL;
OpenAPI_nf_service_t *NFService = node->data;
OpenAPI_list_t *VersionList = NULL;
OpenAPI_list_t *IpEndPointList = NULL;
OpenAPI_list_t *AllowedNfTypeList = NULL;
OpenAPI_lnode_t *node2 = NULL;
if (!NFService) continue;
if (!NFService->service_instance_id) continue;
if (!NFService->service_name) continue;
if (!NFService) {
ogs_error("No NFService");
continue;
}
VersionList = NFService->versions;
IpEndPointList = NFService->ip_end_points;
AllowedNfTypeList = NFService->allowed_nf_types;
if (!NFService->service_instance_id) {
ogs_error("No NFService.service_instance_id");
continue;
}
nf_service = ogs_sbi_nf_service_find_by_id(nf_instance,
NFService->service_instance_id);
if (!NFService->service_name) {
ogs_error("No NFService.service_name");
continue;
}
nf_service = ogs_sbi_nf_service_find_by_id(
nf_instance, NFService->service_instance_id);
if (!nf_service) {
nf_service = ogs_sbi_nf_service_add(nf_instance,
NFService->service_instance_id,
NFService->service_name, NFService->scheme);
nf_service = ogs_sbi_nf_service_add(
nf_instance,
NFService->service_instance_id,
NFService->service_name, NFService->scheme);
ogs_assert(nf_service);
}
ogs_sbi_nf_service_clear(nf_service);
OpenAPI_list_for_each(VersionList, node2) {
OpenAPI_nf_service_version_t *NFServiceVersion = node2->data;
handle_nf_service(nf_service, NFService);
}
if (!NFServiceVersion) continue;
OpenAPI_list_for_each(NFProfile->nf_service_list, node) {
ogs_sbi_nf_service_t *nf_service = NULL;
OpenAPI_map_t *NFServiceMap = NULL;
OpenAPI_nf_service_t *NFService = node->data;
ogs_sbi_nf_service_add_version(nf_service,
NFServiceVersion->api_version_in_uri,
NFServiceVersion->api_full_version,
NFServiceVersion->expiry);
}
if (NFService->fqdn)
nf_service->fqdn = ogs_strdup(NFService->fqdn);
OpenAPI_list_for_each(IpEndPointList, node2) {
OpenAPI_ip_end_point_t *IpEndPoint = node2->data;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
int port = 0;
if (!IpEndPoint) continue;
if (nf_service->num_of_addr < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
if (!IpEndPoint->is_port) {
if (nf_service->scheme == OpenAPI_uri_scheme_http)
port = OGS_SBI_HTTP_PORT;
else if (nf_service->scheme == OpenAPI_uri_scheme_https)
port = OGS_SBI_HTTPS_PORT;
else
continue;
} else {
port = IpEndPoint->port;
}
if (IpEndPoint->ipv4_address) {
rv = ogs_getaddrinfo(&addr, AF_UNSPEC,
IpEndPoint->ipv4_address, port, 0);
if (rv != OGS_OK) continue;
}
if (IpEndPoint->ipv6_address) {
rv = ogs_getaddrinfo(&addr6, AF_UNSPEC,
IpEndPoint->ipv6_address, port, 0);
if (rv != OGS_OK) continue;
}
if (addr || addr6) {
nf_service->addr[nf_service->num_of_addr].
port = port;
nf_service->addr[nf_service->num_of_addr].
ipv4 = addr;
nf_service->addr[nf_service->num_of_addr].
ipv6 = addr6;
nf_service->num_of_addr++;
}
NFServiceMap = node->data;
if (NFServiceMap) {
NFService = NFServiceMap->value;
if (!NFService) {
ogs_error("No NFService");
continue;
}
}
OpenAPI_list_for_each(AllowedNfTypeList, node2) {
OpenAPI_nf_type_e AllowedNfType = (uintptr_t)node2->data;
if (!AllowedNfType) continue;
if (nf_service->num_of_allowed_nf_type <
OGS_SBI_MAX_NUM_OF_NF_TYPE) {
nf_service->allowed_nf_types[
nf_service->num_of_allowed_nf_type] = AllowedNfType;
nf_service->num_of_allowed_nf_type++;
if (!NFService->service_instance_id) {
ogs_error("No NFService.service_instance_id");
continue;
}
}
if (NFService->is_priority == true)
nf_service->priority = NFService->priority;
if (NFService->is_capacity == true)
nf_service->capacity = NFService->capacity;
if (NFService->is_load == true)
nf_service->load = NFService->load;
if (!NFService->service_name) {
ogs_error("No NFService.service_name");
continue;
}
nf_service = ogs_sbi_nf_service_find_by_id(
nf_instance, NFService->service_instance_id);
if (!nf_service) {
nf_service = ogs_sbi_nf_service_add(
nf_instance,
NFService->service_instance_id,
NFService->service_name, NFService->scheme);
ogs_assert(nf_service);
}
ogs_sbi_nf_service_clear(nf_service);
handle_nf_service(nf_service, NFService);
}
}
ogs_sbi_nf_info_remove_all(&nf_instance->nf_info_list);
@ -258,6 +213,111 @@ void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
}
}
static void handle_nf_service(
ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_service_t *NFService)
{
int rv;
OpenAPI_lnode_t *node = NULL;
ogs_assert(nf_service);
ogs_assert(NFService);
OpenAPI_list_for_each(NFService->versions, node) {
OpenAPI_nf_service_version_t *NFServiceVersion = node->data;
if (!NFServiceVersion) {
ogs_error("No NFServiceVersion");
continue;
}
ogs_sbi_nf_service_add_version(nf_service,
NFServiceVersion->api_version_in_uri,
NFServiceVersion->api_full_version,
NFServiceVersion->expiry);
}
if (NFService->fqdn)
nf_service->fqdn = ogs_strdup(NFService->fqdn);
OpenAPI_list_for_each(NFService->ip_end_points, node) {
OpenAPI_ip_end_point_t *IpEndPoint = node->data;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
int port = 0;
if (!IpEndPoint) {
ogs_error("No IpEndPoint");
continue;
}
if (nf_service->num_of_addr < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
if (!IpEndPoint->is_port) {
if (nf_service->scheme == OpenAPI_uri_scheme_http)
port = OGS_SBI_HTTP_PORT;
else if (nf_service->scheme == OpenAPI_uri_scheme_https)
port = OGS_SBI_HTTPS_PORT;
else {
ogs_error("Invalid scheme [%d]", nf_service->scheme);
continue;
}
} else {
port = IpEndPoint->port;
}
if (IpEndPoint->ipv4_address) {
rv = ogs_getaddrinfo(&addr, AF_UNSPEC,
IpEndPoint->ipv4_address, port, 0);
if (rv != OGS_OK) {
ogs_error("ogs_getaddrinfo[%s] failed",
IpEndPoint->ipv4_address);
continue;
}
}
if (IpEndPoint->ipv6_address) {
rv = ogs_getaddrinfo(&addr6, AF_UNSPEC,
IpEndPoint->ipv6_address, port, 0);
if (rv != OGS_OK) {
ogs_error("ogs_getaddrinfo[%s] failed",
IpEndPoint->ipv6_address);
continue;
}
}
if (addr || addr6) {
nf_service->addr[nf_service->num_of_addr].
port = port;
nf_service->addr[nf_service->num_of_addr].
ipv4 = addr;
nf_service->addr[nf_service->num_of_addr].
ipv6 = addr6;
nf_service->num_of_addr++;
}
}
}
OpenAPI_list_for_each(NFService->allowed_nf_types, node) {
OpenAPI_nf_type_e AllowedNfType = (uintptr_t)node->data;
if (!AllowedNfType) {
ogs_error("AllowedNfType");
continue;
}
if (nf_service->num_of_allowed_nf_type <
OGS_SBI_MAX_NUM_OF_NF_TYPE) {
nf_service->allowed_nf_type[
nf_service->num_of_allowed_nf_type] = AllowedNfType;
nf_service->num_of_allowed_nf_type++;
}
}
if (NFService->is_priority == true)
nf_service->priority = NFService->priority;
if (NFService->is_capacity == true)
nf_service->capacity = NFService->capacity;
if (NFService->is_load == true)
nf_service->load = NFService->load;
}
static void handle_smf_info(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_smf_info_t *SmfInfo)
{
@ -415,6 +475,14 @@ void ogs_nnrf_handle_nf_status_subscribe(
ogs_sbi_subscription_set_id(
subscription, SubscriptionData->subscription_id);
/* SBI Features */
if (SubscriptionData->nrf_supported_features) {
subscription->nrf_supported_features =
ogs_uint64_from_string(SubscriptionData->nrf_supported_features);
} else {
subscription->nrf_supported_features = 0;
}
if (SubscriptionData->validity_time) {
#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */
ogs_time_t time, duration;
@ -564,7 +632,7 @@ bool ogs_nnrf_handle_nf_status_notify(
message.h.resource.component[1]);
}
ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile, stream, recvmsg);
ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile);
ogs_info("[%s] (NRF-notify) NF Profile updated", nf_instance->id);
@ -617,15 +685,11 @@ bool ogs_nnrf_handle_nf_status_notify(
}
void ogs_nnrf_handle_nf_discover_search_result(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_discovery_option_t *discovery_option,
OpenAPI_search_result_t *SearchResult)
{
OpenAPI_lnode_t *node = NULL;
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_assert(sbi_object);
ogs_assert(SearchResult);
OpenAPI_list_for_each(SearchResult->nf_instances, node) {
@ -672,7 +736,7 @@ void ogs_nnrf_handle_nf_discover_search_result(
}
if (NF_INSTANCE_ID_IS_OTHERS(nf_instance->id)) {
ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile, NULL, NULL);
ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile);
ogs_sbi_client_associate(nf_instance);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
* Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
@ -26,9 +26,8 @@ extern "C" {
void ogs_sbi_nnrf_handle_nf_register(
ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg);
void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
OpenAPI_nf_profile_t *NFProfile,
ogs_sbi_stream_t *stream, ogs_sbi_message_t *message);
void ogs_sbi_nnrf_handle_nf_profile(
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_profile_t *NFProfile);
void ogs_nnrf_handle_nf_status_subscribe(
ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg);
@ -36,9 +35,6 @@ bool ogs_nnrf_handle_nf_status_notify(
ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg);
void ogs_nnrf_handle_nf_discover_search_result(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_discovery_option_t *discovery_option,
OpenAPI_search_result_t *SearchResult);
#ifdef __cplusplus

View File

@ -86,6 +86,7 @@
#define OGS_SBI_INSIDE
#include "sbi/types.h"
#include "sbi/conv.h"
#include "sbi/timer.h"
#include "sbi/message.h"

View File

@ -20,7 +20,9 @@ OpenAPI_subscription_data_t *OpenAPI_subscription_data_create(
OpenAPI_list_t *req_per_plmn_snssais,
OpenAPI_list_t *req_plmn_list,
OpenAPI_list_t *req_snpn_list,
OpenAPI_list_t *serving_scope
OpenAPI_list_t *serving_scope,
char *requester_features,
char *nrf_supported_features
)
{
OpenAPI_subscription_data_t *subscription_data_local_var = ogs_malloc(sizeof(OpenAPI_subscription_data_t));
@ -42,6 +44,8 @@ OpenAPI_subscription_data_t *OpenAPI_subscription_data_create(
subscription_data_local_var->req_plmn_list = req_plmn_list;
subscription_data_local_var->req_snpn_list = req_snpn_list;
subscription_data_local_var->serving_scope = serving_scope;
subscription_data_local_var->requester_features = requester_features;
subscription_data_local_var->nrf_supported_features = nrf_supported_features;
return subscription_data_local_var;
}
@ -82,6 +86,8 @@ void OpenAPI_subscription_data_free(OpenAPI_subscription_data_t *subscription_da
ogs_free(node->data);
}
OpenAPI_list_free(subscription_data->serving_scope);
ogs_free(subscription_data->requester_features);
ogs_free(subscription_data->nrf_supported_features);
ogs_free(subscription_data);
}
@ -292,6 +298,20 @@ cJSON *OpenAPI_subscription_data_convertToJSON(OpenAPI_subscription_data_t *subs
}
}
if (subscription_data->requester_features) {
if (cJSON_AddStringToObject(item, "requesterFeatures", subscription_data->requester_features) == NULL) {
ogs_error("OpenAPI_subscription_data_convertToJSON() failed [requester_features]");
goto end;
}
}
if (subscription_data->nrf_supported_features) {
if (cJSON_AddStringToObject(item, "nrfSupportedFeatures", subscription_data->nrf_supported_features) == NULL) {
ogs_error("OpenAPI_subscription_data_convertToJSON() failed [nrf_supported_features]");
goto end;
}
}
end:
return item;
}
@ -545,6 +565,24 @@ OpenAPI_subscription_data_t *OpenAPI_subscription_data_parseFromJSON(cJSON *subs
}
}
cJSON *requester_features = cJSON_GetObjectItemCaseSensitive(subscription_dataJSON, "requesterFeatures");
if (requester_features) {
if (!cJSON_IsString(requester_features)) {
ogs_error("OpenAPI_subscription_data_parseFromJSON() failed [requester_features]");
goto end;
}
}
cJSON *nrf_supported_features = cJSON_GetObjectItemCaseSensitive(subscription_dataJSON, "nrfSupportedFeatures");
if (nrf_supported_features) {
if (!cJSON_IsString(nrf_supported_features)) {
ogs_error("OpenAPI_subscription_data_parseFromJSON() failed [nrf_supported_features]");
goto end;
}
}
subscription_data_local_var = OpenAPI_subscription_data_create (
ogs_strdup(nf_status_notification_uri->valuestring),
req_nf_instance_id ? ogs_strdup(req_nf_instance_id->valuestring) : NULL,
@ -561,7 +599,9 @@ OpenAPI_subscription_data_t *OpenAPI_subscription_data_parseFromJSON(cJSON *subs
req_per_plmn_snssais ? req_per_plmn_snssaisList : NULL,
req_plmn_list ? req_plmn_listList : NULL,
req_snpn_list ? req_snpn_listList : NULL,
serving_scope ? serving_scopeList : NULL
serving_scope ? serving_scopeList : NULL,
requester_features ? ogs_strdup(requester_features->valuestring) : NULL,
nrf_supported_features ? ogs_strdup(nrf_supported_features->valuestring) : NULL
);
return subscription_data_local_var;

View File

@ -43,6 +43,8 @@ typedef struct OpenAPI_subscription_data_s {
OpenAPI_list_t *req_plmn_list;
OpenAPI_list_t *req_snpn_list;
OpenAPI_list_t *serving_scope;
char *requester_features;
char *nrf_supported_features;
} OpenAPI_subscription_data_t;
OpenAPI_subscription_data_t *OpenAPI_subscription_data_create(
@ -61,7 +63,9 @@ OpenAPI_subscription_data_t *OpenAPI_subscription_data_create(
OpenAPI_list_t *req_per_plmn_snssais,
OpenAPI_list_t *req_plmn_list,
OpenAPI_list_t *req_snpn_list,
OpenAPI_list_t *serving_scope
OpenAPI_list_t *serving_scope,
char *requester_features,
char *nrf_supported_features
);
void OpenAPI_subscription_data_free(OpenAPI_subscription_data_t *subscription_data);
OpenAPI_subscription_data_t *OpenAPI_subscription_data_parseFromJSON(cJSON *subscription_dataJSON);

View File

@ -77,48 +77,51 @@ bool ogs_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance,
}
bool ogs_sbi_discover_and_send(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
OpenAPI_nf_type_e requester_nf_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_client_cb_f client_cb, void *data)
ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_object_t *sbi_object = NULL;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
ogs_assert(target_nf_type);
ogs_assert(requester_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
ogs_assert(client_cb);
discovery_option = xact->discovery_option;
/* Target NF-Instance */
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
ogs_assert(target_nf_type != OpenAPI_nf_type_NRF);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
}
if (nf_instance) {
return ogs_sbi_send_request(nf_instance, client_cb, data);
return ogs_sbi_send_request(nf_instance, client_cb, xact);
}
/* NRF NF-Instance */
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, OpenAPI_nf_type_NRF);
nf_instance = OGS_SBI_NF_INSTANCE(
sbi_object, OGS_SBI_SERVICE_TYPE_NNRF_DISC);
if (!nf_instance) {
ogs_sbi_select_nf(sbi_object, OpenAPI_nf_type_NRF, NULL);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, OpenAPI_nf_type_NRF);
ogs_sbi_select_nf(sbi_object, OGS_SBI_SERVICE_TYPE_NNRF_DISC, NULL);
nf_instance = OGS_SBI_NF_INSTANCE(
sbi_object, OGS_SBI_SERVICE_TYPE_NNRF_DISC);
}
if (nf_instance) {
ogs_warn("Try to discover [%s]",
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
return ogs_nnrf_disc_send_nf_discover(
nf_instance,
target_nf_type, requester_nf_type, discovery_option,
data);
nf_instance, service_type, discovery_option, xact);
}
ogs_error("Cannot discover [%s]", OpenAPI_nf_type_ToString(target_nf_type));
ogs_error("Cannot discover [%s]",
ogs_sbi_service_type_to_name(service_type));
return false;
}
@ -233,8 +236,7 @@ bool ogs_nnrf_nfm_send_nf_status_unsubscribe(
bool ogs_nnrf_disc_send_nf_discover(
ogs_sbi_nf_instance_t *nf_instance,
OpenAPI_nf_type_e target_nf_type,
OpenAPI_nf_type_e requester_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
void *data)
{
@ -242,11 +244,8 @@ bool ogs_nnrf_disc_send_nf_discover(
ogs_sbi_request_t *request = NULL;
ogs_assert(nf_instance);
ogs_assert(target_nf_type);
ogs_assert(requester_nf_type);
request = ogs_nnrf_disc_build_discover(
target_nf_type, requester_nf_type, discovery_option);
request = ogs_nnrf_disc_build_discover(service_type, discovery_option);
ogs_expect_or_return_val(request, false);
client = nf_instance->client;

View File

@ -29,11 +29,7 @@ extern "C" {
bool ogs_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance,
ogs_sbi_client_cb_f client_cb, ogs_sbi_xact_t *xact);
bool ogs_sbi_discover_and_send(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
OpenAPI_nf_type_e requester_nf_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_client_cb_f client_cb, void *data);
ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb);
bool ogs_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance);
bool ogs_nnrf_nfm_send_nf_update(ogs_sbi_nf_instance_t *nf_instance);
@ -49,8 +45,7 @@ bool ogs_nnrf_nfm_send_nf_status_unsubscribe(
bool ogs_nnrf_disc_send_nf_discover(
ogs_sbi_nf_instance_t *nf_instance,
OpenAPI_nf_type_e target_nf_type,
OpenAPI_nf_type_e requester_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
void *data);

View File

@ -1442,11 +1442,13 @@ components:
items:
type: string
minItems: 1
# requesterFeatures:
requesterFeatures:
$ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures'
# writeOnly: true
# allOf:
# - $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures'
# nrfSupportedFeatures:
nrfSupportedFeatures:
$ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures'
# readOnly: true
# allOf:
# - $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures'

View File

@ -43,6 +43,7 @@
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <float.h>
#ifdef ENABLE_LOCALES
#include <locale.h>
@ -58,9 +59,32 @@
#include "cJSON.h"
/* define our own boolean type */
#ifdef true
#undef true
#endif
#define true ((cJSON_bool)1)
#ifdef false
#undef false
#endif
#define false ((cJSON_bool)0)
/* define isnan and isinf for ANSI C, if in C99 or above, isnan and isinf has been defined in math.h */
#ifndef isinf
#define isinf(d) (isnan((d - d)) && !isnan(d))
#endif
#ifndef isnan
#define isnan(d) (d != d)
#endif
#ifndef NAN
#ifdef _WIN32
#define NAN sqrt(-1.0)
#else
#define NAN 0.0/0.0
#endif
#endif
typedef struct {
const unsigned char *json;
size_t position;
@ -72,16 +96,28 @@ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
return (const char*) (global_error.json + global_error.position);
}
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) {
if (!cJSON_IsString(item)) {
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item)
{
if (!cJSON_IsString(item))
{
return NULL;
}
return item->valuestring;
}
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
{
if (!cJSON_IsNumber(item))
{
return (double) NAN;
}
return item->valuedouble;
}
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 7)
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 15)
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
#endif
@ -119,31 +155,30 @@ static int case_insensitive_strcmp(const unsigned char *string1, const unsigned
typedef struct internal_hooks
{
void *(*allocate)(size_t size);
void (*deallocate)(void *pointer);
void *(*reallocate)(void *pointer, size_t size);
void *(CJSON_CDECL *allocate)(size_t size);
void (CJSON_CDECL *deallocate)(void *pointer);
void *(CJSON_CDECL *reallocate)(void *pointer, size_t size);
} internal_hooks;
#if 0 /* modified by acetcom */
#if defined(_MSC_VER)
/* work around MSVC error C2322: '...' address of dillimport '...' is not static */
static void *internal_malloc(size_t size)
/* work around MSVC error C2322: '...' address of dllimport '...' is not static */
static void * CJSON_CDECL internal_malloc(size_t size)
{
return malloc(size);
}
static void internal_free(void *pointer)
static void CJSON_CDECL internal_free(void *pointer)
{
free(pointer);
}
static void *internal_realloc(void *pointer, size_t size)
static void * CJSON_CDECL internal_realloc(void *pointer, size_t size)
{
return realloc(pointer, size);
}
#else
#if 0 /* modified by acetcom */
#define internal_malloc malloc
#define internal_free free
#define internal_realloc realloc
#endif
#else
#include "ogs-core.h"
static void *internal_malloc(size_t size)
@ -163,6 +198,10 @@ static void *internal_realloc(void *pointer, size_t size)
return ptr;
}
#endif
#endif
/* strlen of character literals resolved at compile time */
#define static_strlen(string_literal) (sizeof(string_literal) - sizeof(""))
static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
@ -344,7 +383,7 @@ loop_end:
{
item->valueint = INT_MAX;
}
else if (number <= INT_MIN)
else if (number <= (double)INT_MIN)
{
item->valueint = INT_MIN;
}
@ -366,7 +405,7 @@ CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number)
{
object->valueint = INT_MAX;
}
else if (number <= INT_MIN)
else if (number <= (double)INT_MIN)
{
object->valueint = INT_MIN;
}
@ -378,6 +417,33 @@ CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number)
return object->valuedouble = number;
}
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
{
char *copy = NULL;
/* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */
if (!(object->type & cJSON_String) || (object->type & cJSON_IsReference))
{
return NULL;
}
if (strlen(valuestring) <= strlen(object->valuestring))
{
strcpy(object->valuestring, valuestring);
return object->valuestring;
}
copy = (char*) cJSON_strdup((const unsigned char*)valuestring, &global_hooks);
if (copy == NULL)
{
return NULL;
}
if (object->valuestring != NULL)
{
cJSON_free(object->valuestring);
}
object->valuestring = copy;
return copy;
}
typedef struct
{
unsigned char *buffer;
@ -465,10 +531,8 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
return NULL;
}
if (newbuffer)
{
memcpy(newbuffer, p->buffer, p->offset + 1);
}
memcpy(newbuffer, p->buffer, p->offset + 1);
p->hooks.deallocate(p->buffer);
}
p->length = newsize;
@ -490,6 +554,13 @@ static void update_offset(printbuffer * const buffer)
buffer->offset += strlen((const char*)buffer_pointer);
}
/* securely comparison of floating-point variables */
static cJSON_bool compare_double(double a, double b)
{
double maxVal = fabs(a) > fabs(b) ? fabs(a) : fabs(b);
return (fabs(a - b) <= maxVal * DBL_EPSILON);
}
/* Render the number nicely from the given item into a string. */
static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer)
{
@ -497,9 +568,9 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
double d = item->valuedouble;
int length = 0;
size_t i = 0;
unsigned char number_buffer[26]; /* temporary buffer to print the number into */
unsigned char number_buffer[26] = {0}; /* temporary buffer to print the number into */
unsigned char decimal_point = get_decimal_point();
double test;
double test = 0.0;
if (output_buffer == NULL)
{
@ -507,24 +578,28 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
}
/* This checks for NaN and Infinity */
if ((d * 0) != 0)
if (isnan(d) || isinf(d))
{
length = sprintf((char*)number_buffer, "null");
}
else if(d == (double)item->valueint)
{
length = sprintf((char*)number_buffer, "%d", item->valueint);
}
else
{
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
length = sprintf((char*)number_buffer, "%1.15g", d);
/* Check whether the original double can be recovered */
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || ((double)test != d))
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d))
{
/* If not, print with 17 decimal places of precision */
length = sprintf((char*)number_buffer, "%1.17g", d);
}
}
/* sprintf failed or buffer overrun occured */
/* sprintf failed or buffer overrun occurred */
if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1)))
{
return false;
@ -987,6 +1062,11 @@ static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer)
return NULL;
}
if (cannot_access_at_index(buffer, 0))
{
return buffer;
}
while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32))
{
buffer->offset++;
@ -1016,8 +1096,23 @@ static parse_buffer *skip_utf8_bom(parse_buffer * const buffer)
return buffer;
}
/* Parse an object - create a new root, and populate. */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)
{
size_t buffer_length;
if (NULL == value)
{
return NULL;
}
/* Adding null character size due to require_null_terminated. */
buffer_length = strlen(value) + sizeof("");
return cJSON_ParseWithLengthOpts(value, buffer_length, return_parse_end, require_null_terminated);
}
/* Parse an object - create a new root, and populate. */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated)
{
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
cJSON *item = NULL;
@ -1026,13 +1121,13 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return
global_error.json = NULL;
global_error.position = 0;
if (value == NULL)
if (value == NULL || 0 == buffer_length)
{
goto fail;
}
buffer.content = (const unsigned char*)value;
buffer.length = strlen((const char*)value) + sizeof("");
buffer.length = buffer_length;
buffer.offset = 0;
buffer.hooks = global_hooks;
@ -1102,7 +1197,12 @@ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
return cJSON_ParseWithOpts(value, 0, 0);
}
#define cjson_min(a, b) ((a < b) ? a : b)
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length)
{
return cJSON_ParseWithLengthOpts(value, buffer_length, 0, 0);
}
#define cjson_min(a, b) (((a) < (b)) ? (a) : (b))
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
{
@ -1209,20 +1309,20 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
return (char*)p.buffer;
}
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt)
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
{
printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
if ((len < 0) || (buf == NULL))
if ((length < 0) || (buffer == NULL))
{
return false;
}
p.buffer = (unsigned char*)buf;
p.length = (size_t)len;
p.buffer = (unsigned char*)buffer;
p.length = (size_t)length;
p.offset = 0;
p.noalloc = true;
p.format = fmt;
p.format = format;
p.hooks = global_hooks;
return print_value(item, &p);
@ -1435,6 +1535,10 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
success:
input_buffer->depth--;
if (head != NULL) {
head->prev = current_item;
}
item->type = cJSON_Array;
item->child = head;
@ -1575,7 +1679,7 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
buffer_skip_whitespace(input_buffer);
if (!parse_string(current_item, input_buffer))
{
goto fail; /* faile to parse name */
goto fail; /* failed to parse name */
}
buffer_skip_whitespace(input_buffer);
@ -1607,6 +1711,10 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
success:
input_buffer->depth--;
if (head != NULL) {
head->prev = current_item;
}
item->type = cJSON_Object;
item->child = head;
@ -1695,7 +1803,7 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out
update_offset(output_buffer);
/* print comma if not last */
length = (size_t) ((output_buffer->format ? 1 : 0) + (current_item->next ? 1 : 0));
length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0));
output_pointer = ensure(output_buffer, length + 1);
if (output_pointer == NULL)
{
@ -1801,7 +1909,7 @@ static cJSON *get_object_item(const cJSON * const object, const char * const nam
current_element = object->child;
if (case_sensitive)
{
while ((current_element != NULL) && (strcmp(name, current_element->string) != 0))
while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0))
{
current_element = current_element->next;
}
@ -1814,6 +1922,10 @@ static cJSON *get_object_item(const cJSON * const object, const char * const nam
}
}
if ((current_element == NULL) || (current_element->string == NULL)) {
return NULL;
}
return current_element;
}
@ -1865,35 +1977,39 @@ static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
{
cJSON *child = NULL;
if ((item == NULL) || (array == NULL))
if ((item == NULL) || (array == NULL) || (array == item))
{
return false;
}
child = array->child;
/*
* To find the last item in array quickly, we use prev in array
*/
if (child == NULL)
{
/* list is empty, start new one */
array->child = item;
item->prev = item;
item->next = NULL;
}
else
{
/* append to the end */
while (child->next)
if (child->prev)
{
child = child->next;
suffix_object(child->prev, item);
array->child->prev = item;
}
suffix_object(child, item);
}
return true;
}
/* Add item to array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item)
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item)
{
add_item_to_array(array, item);
return add_item_to_array(array, item);
}
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
@ -1917,7 +2033,7 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
char *new_key = NULL;
int new_type = cJSON_Invalid;
if ((object == NULL) || (string == NULL) || (item == NULL))
if ((object == NULL) || (string == NULL) || (item == NULL) || (object == item))
{
return false;
}
@ -1949,35 +2065,35 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
return add_item_to_array(object, item);
}
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
{
add_item_to_object(object, string, item, &global_hooks, false);
return add_item_to_object(object, string, item, &global_hooks, false);
}
/* Add an item to an object with constant string as key */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
{
add_item_to_object(object, string, item, &global_hooks, true);
return add_item_to_object(object, string, item, &global_hooks, true);
}
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
{
if (array == NULL)
{
return;
return false;
}
add_item_to_array(array, create_reference(item, &global_hooks));
return add_item_to_array(array, create_reference(item, &global_hooks));
}
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
{
if ((object == NULL) || (string == NULL))
{
return;
return false;
}
add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
}
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
@ -2095,7 +2211,7 @@ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const it
return NULL;
}
if (item->prev != NULL)
if (item != parent->child)
{
/* not the first element */
item->prev->next = item->next;
@ -2111,6 +2227,12 @@ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const it
/* first element */
parent->child = item->next;
}
else if (item->next == NULL)
{
/* last element */
parent->child->prev = item->prev;
}
/* make sure the detached item doesn't point anywhere anymore */
item->prev = NULL;
item->next = NULL;
@ -2158,20 +2280,19 @@ CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const
}
/* Replace array/object items with new ones. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
{
cJSON *after_inserted = NULL;
if (which < 0)
{
return;
return false;
}
after_inserted = get_array_item(array, (size_t)which);
if (after_inserted == NULL)
{
add_item_to_array(array, newitem);
return;
return add_item_to_array(array, newitem);
}
newitem->next = after_inserted;
@ -2185,6 +2306,7 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
{
newitem->prev->next = newitem;
}
return true;
}
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
@ -2206,14 +2328,28 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON
{
replacement->next->prev = replacement;
}
if (replacement->prev != NULL)
{
replacement->prev->next = replacement;
}
if (parent->child == item)
{
if (parent->child->prev == parent->child)
{
replacement->prev = replacement;
}
parent->child = replacement;
}
else
{ /*
* To find the last item in array quickly, we use prev in array.
* We can't modify the last item's next pointer where this item was the parent's child
*/
if (replacement->prev != NULL)
{
replacement->prev->next = replacement;
}
if (replacement->next == NULL)
{
parent->child->prev = replacement;
}
}
item->next = NULL;
item->prev = NULL;
@ -2222,14 +2358,14 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON
return true;
}
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
{
if (which < 0)
{
return;
return false;
}
cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem);
return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem);
}
static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
@ -2245,21 +2381,24 @@ static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSO
cJSON_free(replacement->string);
}
replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
if (replacement->string == NULL)
{
return false;
}
replacement->type &= ~cJSON_StringIsConst;
cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
return true;
return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
}
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
{
replace_item_in_object(object, string, newitem, false);
return replace_item_in_object(object, string, newitem, false);
}
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
{
replace_item_in_object(object, string, newitem, true);
return replace_item_in_object(object, string, newitem, true);
}
/* Create basic types: */
@ -2296,12 +2435,12 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool b)
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
{
item->type = b ? cJSON_True : cJSON_False;
item->type = boolean ? cJSON_True : cJSON_False;
}
return item;
@ -2320,7 +2459,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
{
item->valueint = INT_MAX;
}
else if (num <= INT_MIN)
else if (num <= (double)INT_MIN)
{
item->valueint = INT_MIN;
}
@ -2436,6 +2575,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
}
a = cJSON_CreateArray();
for(i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
@ -2455,6 +2595,10 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
p = n;
}
if (a && a->child) {
a->child->prev = n;
}
return a;
}
@ -2491,6 +2635,10 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
p = n;
}
if (a && a->child) {
a->child->prev = n;
}
return a;
}
@ -2508,7 +2656,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
a = cJSON_CreateArray();
for(i = 0;a && (i < (size_t)count); i++)
for(i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
if(!n)
@ -2527,10 +2675,14 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
p = n;
}
if (a && a->child) {
a->child->prev = n;
}
return a;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
{
size_t i = 0;
cJSON *n = NULL;
@ -2563,6 +2715,10 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
p = n;
}
if (a && a->child) {
a->child->prev = n;
}
return a;
}
@ -2634,6 +2790,10 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
}
child = child->next;
}
if (newitem && newitem->child)
{
newitem->child->prev = newchild;
}
return newitem;
@ -2646,69 +2806,96 @@ fail:
return NULL;
}
static void skip_oneline_comment(char **input)
{
*input += static_strlen("//");
for (; (*input)[0] != '\0'; ++(*input))
{
if ((*input)[0] == '\n') {
*input += static_strlen("\n");
return;
}
}
}
static void skip_multiline_comment(char **input)
{
*input += static_strlen("/*");
for (; (*input)[0] != '\0'; ++(*input))
{
if (((*input)[0] == '*') && ((*input)[1] == '/'))
{
*input += static_strlen("*/");
return;
}
}
}
static void minify_string(char **input, char **output) {
(*output)[0] = (*input)[0];
*input += static_strlen("\"");
*output += static_strlen("\"");
for (; (*input)[0] != '\0'; (void)++(*input), ++(*output)) {
(*output)[0] = (*input)[0];
if ((*input)[0] == '\"') {
(*output)[0] = '\"';
*input += static_strlen("\"");
*output += static_strlen("\"");
return;
} else if (((*input)[0] == '\\') && ((*input)[1] == '\"')) {
(*output)[1] = (*input)[1];
*input += static_strlen("\"");
*output += static_strlen("\"");
}
}
}
CJSON_PUBLIC(void) cJSON_Minify(char *json)
{
unsigned char *into = (unsigned char*)json;
char *into = json;
if (json == NULL)
{
return;
}
while (*json)
while (json[0] != '\0')
{
if (*json == ' ')
switch (json[0])
{
json++;
}
else if (*json == '\t')
{
/* Whitespace characters. */
json++;
}
else if (*json == '\r')
{
json++;
}
else if (*json=='\n')
{
json++;
}
else if ((*json == '/') && (json[1] == '/'))
{
/* double-slash comments, to end of line. */
while (*json && (*json != '\n'))
{
case ' ':
case '\t':
case '\r':
case '\n':
json++;
}
}
else if ((*json == '/') && (json[1] == '*'))
{
/* multiline comments. */
while (*json && !((*json == '*') && (json[1] == '/')))
{
json++;
}
json += 2;
}
else if (*json == '\"')
{
/* string literals, which are \" sensitive. */
*into++ = (unsigned char)*json++;
while (*json && (*json != '\"'))
{
if (*json == '\\')
break;
case '/':
if (json[1] == '/')
{
*into++ = (unsigned char)*json++;
skip_oneline_comment(&json);
}
*into++ = (unsigned char)*json++;
}
*into++ = (unsigned char)*json++;
}
else
{
/* All other characters. */
*into++ = (unsigned char)*json++;
else if (json[1] == '*')
{
skip_multiline_comment(&json);
} else {
json++;
}
break;
case '\"':
minify_string(&json, (char**)&into);
break;
default:
into[0] = json[0];
json++;
into++;
}
}
@ -2818,7 +3005,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item)
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive)
{
if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a))
if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)))
{
return false;
}
@ -2855,7 +3042,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons
return true;
case cJSON_Number:
if (a->valuedouble == b->valuedouble)
if (compare_double(a->valuedouble, b->valuedouble))
{
return true;
}

View File

@ -28,10 +28,60 @@ extern "C"
{
#endif
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
#define __WINDOWS__
#endif
#ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar behavior by
setting default visibility to hidden by adding
-fvisibility=hidden (for gcc)
or
-xldscope=hidden (for sun cc)
to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
*/
#define CJSON_CDECL __cdecl
#define CJSON_STDCALL __stdcall
/* export symbols by default, this is necessary for copy pasting the C and header file */
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_EXPORT_SYMBOLS
#endif
#if defined(CJSON_HIDE_SYMBOLS)
#define CJSON_PUBLIC(type) type CJSON_STDCALL
#elif defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
#elif defined(CJSON_IMPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
#endif
#else /* !__WINDOWS__ */
#define CJSON_CDECL
#define CJSON_STDCALL
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else
#define CJSON_PUBLIC(type) type
#endif
#endif
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 7
#define CJSON_VERSION_PATCH 15
#include <stddef.h>
@ -74,55 +124,13 @@ typedef struct cJSON
typedef struct cJSON_Hooks
{
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
void *(CJSON_CDECL *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr);
} cJSON_Hooks;
typedef int cJSON_bool;
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
#define __WINDOWS__
#endif
#ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 2 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar behavior by
setting default visibility to hidden by adding
-fvisibility=hidden (for gcc)
or
-xldscope=hidden (for sun cc)
to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
*/
/* export symbols by default, this is necessary for copy pasting the C and header file */
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_EXPORT_SYMBOLS
#endif
#if defined(CJSON_HIDE_SYMBOLS)
#define CJSON_PUBLIC(type) type __stdcall
#elif defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllexport) type __stdcall
#elif defined(CJSON_IMPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllimport) type __stdcall
#endif
#else /* !WIN32 */
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else
#define CJSON_PUBLIC(type) type
#endif
#endif
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
* This is to prevent stack overflows. */
#ifndef CJSON_NESTING_LIMIT
@ -138,9 +146,11 @@ CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
/* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
@ -152,7 +162,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
/* Delete a cJSON entity and all subentities. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
/* Returns the number of items in an array (or object). */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
@ -165,8 +175,9 @@ CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *st
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
/* Check if the item is a string and return its valuestring */
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
/* Check item type and return its value */
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
/* These functions check the type of an item */
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
@ -195,29 +206,30 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
/* Create a string where valuestring references a string so
* it will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
/* Create an object/arrray that only references it's elements so
/* Create an object/array that only references it's elements so
* they will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
/* These utilities create an Array of count items. */
/* These utilities create an Array of count items.
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
/* Append item to the specified array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
* writing to `item->string` */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
/* Remove/Detach items from Arrays/Objects. */
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
@ -227,22 +239,24 @@ CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string)
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
/* Update array items. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
* The item->next and ->prev pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
* The input pointer json cannot point to a read-only address area, such as a string constant,
* but should point to a readable and writable address area. */
CJSON_PUBLIC(void) cJSON_Minify(char *json);
/* Helper functions for creating and adding items to an object at the same time.
@ -262,6 +276,15 @@ CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * c
/* helper for the cJSON_SetNumberValue macro */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/
#define cJSON_SetBoolValue(object, boolValue) ( \
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
cJSON_Invalid\
)
/* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)

118
lib/sbi/types.c Normal file
View File

@ -0,0 +1,118 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ogs-sbi.h"
struct service_desc_s {
OpenAPI_nf_type_e nf_type;
const char *service_name;
};
static struct service_desc_s service_desc[] = {
{ OpenAPI_nf_type_NULL, NULL },
{ OpenAPI_nf_type_NRF, OGS_SBI_SERVICE_NAME_NNRF_NFM },
{ OpenAPI_nf_type_NRF, OGS_SBI_SERVICE_NAME_NNRF_DISC },
{ OpenAPI_nf_type_NRF, OGS_SBI_SERVICE_NAME_NNRF_OAUTH2 },
{ OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM },
{ OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UECM },
{ OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UEAU },
{ OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_EE },
{ OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_PP },
{ OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_NIDDAU },
{ OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_MT },
{ OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_COMM },
{ OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_EVTS },
{ OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_MT },
{ OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_LOC },
{ OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION },
{ OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_EVENT_EXPOSURE },
{ OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_NIDD },
{ OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_AUTH },
{ OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_SORPROTECTION },
{ OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_UPUPROTECTION },
{ OpenAPI_nf_type_NEF, OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT },
{ OpenAPI_nf_type_NEF, OGS_SBI_SERVICE_NAME_NNEF_SMCONTEXT },
{ OpenAPI_nf_type_NEF, OGS_SBI_SERVICE_NAME_NNEF_EVENTEXPOSURE },
{ OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL },
{ OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL },
{ OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION },
{ OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_BDTPOLICYCONTROL },
{ OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_EVENTEXPOSURE },
{ OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_UE_POLICY_CONTROL },
{ OpenAPI_nf_type_SMSF, OGS_SBI_SERVICE_NAME_NSMSF_SMS },
{ OpenAPI_nf_type_NSSF, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION },
{ OpenAPI_nf_type_NSSF, OGS_SBI_SERVICE_NAME_NNSSF_NSSAIAVAILABILITY },
{ OpenAPI_nf_type_UDR, OGS_SBI_SERVICE_NAME_NUDR_DR },
{ OpenAPI_nf_type_UDR, OGS_SBI_SERVICE_NAME_NUDR_GROUP_ID_MAP },
{ OpenAPI_nf_type_LMF, OGS_SBI_SERVICE_NAME_NLMF_LOC },
{ OpenAPI_nf_type_5G_EIR, OGS_SBI_SERVICE_NAME_N5G_EIR_EIC },
{ OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT },
{ OpenAPI_nf_type_CHF, OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL },
{ OpenAPI_nf_type_CHF, OGS_SBI_SERVICE_NAME_NCHF_CONVERGEDCHARGING },
{ OpenAPI_nf_type_CHF, OGS_SBI_SERVICE_NAME_NCHF_OFFLINEONLYCHARGING },
{ OpenAPI_nf_type_NWDAF, OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION },
{ OpenAPI_nf_type_NWDAF, OGS_SBI_SERVICE_NAME_NNWDAF_ANALYTICSINFO },
{ OpenAPI_nf_type_GMLC, OGS_SBI_SERVICE_NAME_NGMLC_LOC },
{ OpenAPI_nf_type_UCMF, OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING },
{ OpenAPI_nf_type_UCMF, OGS_SBI_SERVICE_NAME_NUCMF_UECAPABILITYMANAGEMENT },
{ OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_SDM },
{ OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_UECM },
{ OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_UEAU },
{ OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_EE },
{ OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_IMS_SDM },
{ OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_IMS_UECM },
{ OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_IMS_UEAU },
{ OpenAPI_nf_type_SEPP, OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC },
{ OpenAPI_nf_type_SOR_AF, OGS_SBI_SERVICE_NAME_NSORAF_SOR },
{ OpenAPI_nf_type_SPAF, OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET },
{ OpenAPI_nf_type_UDSF, OGS_SBI_SERVICE_NAME_NUDSF_DR },
{ OpenAPI_nf_type_NSSAAF, OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA },
};
OpenAPI_nf_type_e ogs_sbi_service_type_to_nf_type(ogs_sbi_service_type_e type)
{
ogs_assert(type > OGS_SBI_SERVICE_TYPE_NULL &&
type < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE);
return service_desc[type].nf_type;
}
const char *ogs_sbi_service_type_to_name(ogs_sbi_service_type_e type)
{
ogs_assert(type > OGS_SBI_SERVICE_TYPE_NULL &&
type < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE);
ogs_assert(service_desc[type].service_name);
return service_desc[type].service_name;
}
ogs_sbi_service_type_e ogs_sbi_service_type_from_name(const char *name)
{
int i;
ogs_assert(name);
for (i = 0; i < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE; i++) {
if (service_desc[i].service_name &&
strcmp(name, service_desc[i].service_name) == 0)
return (ogs_sbi_service_type_e)i;
}
return OGS_SBI_SERVICE_TYPE_NULL;
}

168
lib/sbi/types.h Normal file
View File

@ -0,0 +1,168 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if !defined(OGS_SBI_INSIDE) && !defined(OGS_SBI_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_SBI_TYPES_H
#define OGS_SBI_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
OGS_SBI_SERVICE_TYPE_NULL = 0,
OGS_SBI_SERVICE_TYPE_NNRF_NFM,
OGS_SBI_SERVICE_TYPE_NNRF_DISC,
OGS_SBI_SERVICE_TYPE_NNRF_OAUTH2,
OGS_SBI_SERVICE_TYPE_NUDM_SDM,
OGS_SBI_SERVICE_TYPE_NUDM_UECM,
OGS_SBI_SERVICE_TYPE_NUDM_UEAU,
OGS_SBI_SERVICE_TYPE_NUDM_EE,
OGS_SBI_SERVICE_TYPE_NUDM_PP,
OGS_SBI_SERVICE_TYPE_NUDM_NIDDAU,
OGS_SBI_SERVICE_TYPE_NUDM_MT,
OGS_SBI_SERVICE_TYPE_NAMF_COMM,
OGS_SBI_SERVICE_TYPE_NAMF_EVTS,
OGS_SBI_SERVICE_TYPE_NAMF_MT,
OGS_SBI_SERVICE_TYPE_NAMF_LOC,
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION,
OGS_SBI_SERVICE_TYPE_NSMF_EVENT_EXPOSURE,
OGS_SBI_SERVICE_TYPE_NSMF_NIDD,
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH,
OGS_SBI_SERVICE_TYPE_NAUSF_SORPROTECTION,
OGS_SBI_SERVICE_TYPE_NAUSF_UPUPROTECTION,
OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT,
OGS_SBI_SERVICE_TYPE_NNEF_SMCONTEXT,
OGS_SBI_SERVICE_TYPE_NNEF_EVENTEXPOSURE,
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL,
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL,
OGS_SBI_SERVICE_TYPE_NPCF_POLICYAUTHORIZATION,
OGS_SBI_SERVICE_TYPE_NPCF_BDTPOLICYCONTROL,
OGS_SBI_SERVICE_TYPE_NPCF_EVENTEXPOSURE,
OGS_SBI_SERVICE_TYPE_NPCF_UE_POLICY_CONTROL,
OGS_SBI_SERVICE_TYPE_NSMSF_SMS,
OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION,
OGS_SBI_SERVICE_TYPE_NNSSF_NSSAIAVAILABILITY,
OGS_SBI_SERVICE_TYPE_NUDR_DR,
OGS_SBI_SERVICE_TYPE_NUDR_GROUP_ID_MAP,
OGS_SBI_SERVICE_TYPE_NLMF_LOC,
OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC,
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL,
OGS_SBI_SERVICE_TYPE_NCHF_CONVERGEDCHARGING,
OGS_SBI_SERVICE_TYPE_NCHF_OFFLINEONLYCHARGING,
OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION,
OGS_SBI_SERVICE_TYPE_NNWDAF_ANALYTICSINFO,
OGS_SBI_SERVICE_TYPE_NGMLC_LOC,
OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING,
OGS_SBI_SERVICE_TYPE_NUCMF_UECAPABILITYMANAGEMENT,
OGS_SBI_SERVICE_TYPE_NHSS_SDM,
OGS_SBI_SERVICE_TYPE_NHSS_UECM,
OGS_SBI_SERVICE_TYPE_NHSS_UEAU,
OGS_SBI_SERVICE_TYPE_NHSS_EE,
OGS_SBI_SERVICE_TYPE_NHSS_IMS_SDM,
OGS_SBI_SERVICE_TYPE_NHSS_IMS_UECM,
OGS_SBI_SERVICE_TYPE_NHSS_IMS_UEAU,
OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC,
OGS_SBI_SERVICE_TYPE_NSORAF_SOR,
OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET,
OGS_SBI_SERVICE_TYPE_NUDSF_DR,
OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA,
OGS_SBI_MAX_NUM_OF_SERVICE_TYPE,
} ogs_sbi_service_type_e;
#define OGS_SBI_SERVICE_NAME_NNRF_NFM "nnrf-nfm"
#define OGS_SBI_SERVICE_NAME_NNRF_DISC "nnrf-disc"
#define OGS_SBI_SERVICE_NAME_NNRF_OAUTH2 "nnrf-oauth2"
#define OGS_SBI_SERVICE_NAME_NUDM_SDM "nudm-sdm"
#define OGS_SBI_SERVICE_NAME_NUDM_UECM "nudm-uecm"
#define OGS_SBI_SERVICE_NAME_NUDM_UEAU "nudm-ueau"
#define OGS_SBI_SERVICE_NAME_NUDM_EE "nudm-ee"
#define OGS_SBI_SERVICE_NAME_NUDM_PP "nudm-pp"
#define OGS_SBI_SERVICE_NAME_NUDM_NIDDAU "nudm-niddau"
#define OGS_SBI_SERVICE_NAME_NUDM_MT "nudm-mt"
#define OGS_SBI_SERVICE_NAME_NAMF_COMM "namf-comm"
#define OGS_SBI_SERVICE_NAME_NAMF_EVTS "namf-evts"
#define OGS_SBI_SERVICE_NAME_NAMF_MT "namf-mt"
#define OGS_SBI_SERVICE_NAME_NAMF_LOC "namf-loc"
#define OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION "nsmf-pdusession"
#define OGS_SBI_SERVICE_NAME_NSMF_EVENT_EXPOSURE "nsmf-event-exposure"
#define OGS_SBI_SERVICE_NAME_NSMF_NIDD "nsmf-nidd"
#define OGS_SBI_SERVICE_NAME_NAUSF_AUTH "nausf-auth"
#define OGS_SBI_SERVICE_NAME_NAUSF_SORPROTECTION "nausf-sorprotection"
#define OGS_SBI_SERVICE_NAME_NAUSF_UPUPROTECTION "nausf-upuprotection"
#define OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT "nnef-pfdmanagement"
#define OGS_SBI_SERVICE_NAME_NNEF_SMCONTEXT "nnef-smcontext"
#define OGS_SBI_SERVICE_NAME_NNEF_EVENTEXPOSURE "nnef-eventexposure"
#define OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL "npcf-am-policy-control"
#define OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL "npcf-smpolicycontrol"
#define OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION "npcf-policyauthorization"
#define OGS_SBI_SERVICE_NAME_NPCF_BDTPOLICYCONTROL "npcf-bdtpolicycontrol"
#define OGS_SBI_SERVICE_NAME_NPCF_EVENTEXPOSURE "npcf-eventexposure"
#define OGS_SBI_SERVICE_NAME_NPCF_UE_POLICY_CONTROL "npcf-ue-policy-control"
#define OGS_SBI_SERVICE_NAME_NSMSF_SMS "nsmsf-sms"
#define OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION "nnssf-nsselection"
#define OGS_SBI_SERVICE_NAME_NNSSF_NSSAIAVAILABILITY "nnssf-nssaiavailability"
#define OGS_SBI_SERVICE_NAME_NUDR_DR "nudr-dr"
#define OGS_SBI_SERVICE_NAME_NUDR_GROUP_ID_MAP "nudr-group-id-map"
#define OGS_SBI_SERVICE_NAME_NLMF_LOC "nlmf-loc"
#define OGS_SBI_SERVICE_NAME_N5G_EIR_EIC "n5g-eir-eic"
#define OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT "nbsf-management"
#define OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL \
"nchf-spendinglimitcontrol"
#define OGS_SBI_SERVICE_NAME_NCHF_CONVERGEDCHARGING "nchf-convergedcharging"
#define OGS_SBI_SERVICE_NAME_NCHF_OFFLINEONLYCHARGING "nchf-offlineonlycharging"
#define OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION \
"nnwdaf-eventssubscription"
#define OGS_SBI_SERVICE_NAME_NNWDAF_ANALYTICSINFO "nnwdaf-analyticsinfo"
#define OGS_SBI_SERVICE_NAME_NGMLC_LOC "ngmlc-loc"
#define OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING "nucmf-provisioning"
#define OGS_SBI_SERVICE_NAME_NUCMF_UECAPABILITYMANAGEMENT \
"nucmf-uecapabilitymanagement"
#define OGS_SBI_SERVICE_NAME_NHSS_SDM "nhss-sdm"
#define OGS_SBI_SERVICE_NAME_NHSS_UECM "nhss-uecm"
#define OGS_SBI_SERVICE_NAME_NHSS_UEAU "nhss-ueau"
#define OGS_SBI_SERVICE_NAME_NHSS_EE "nhss-ee"
#define OGS_SBI_SERVICE_NAME_NHSS_IMS_SDM "nhss-ims-sdm"
#define OGS_SBI_SERVICE_NAME_NHSS_IMS_UECM "nhss-ims-uecm"
#define OGS_SBI_SERVICE_NAME_NHSS_IMS_UEAU "nhss-ims-ueau"
#define OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC "nsepp-telescopic"
#define OGS_SBI_SERVICE_NAME_NSORAF_SOR "nsoraf-sor"
#define OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET "nspaf-secured-packet"
#define OGS_SBI_SERVICE_NAME_NUDSF_DR "nudsf-dr"
#define OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA "nnssaaf-nssaa"
#define OGS_SBI_SERVICE_NAME_NAMF_CALLBACK "namf-callback"
#define OGS_SBI_SERVICE_NAME_NSMF_CALLBACK "nsmf-callback"
OpenAPI_nf_type_e ogs_sbi_service_type_to_nf_type(
ogs_sbi_service_type_e service_type);
const char *ogs_sbi_service_type_to_name(ogs_sbi_service_type_e service_type);
ogs_sbi_service_type_e ogs_sbi_service_type_from_name(const char *service_name);
#ifdef __cplusplus
}
#endif
#endif /* OGS_SBI_TYPES_H */

View File

@ -68,7 +68,7 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
int state = AMF_CREATE_SM_CONTEXT_NO_STATE;
ogs_sbi_stream_t *stream = NULL;
ogs_sbi_request_t *sbi_request = NULL;
OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_subscription_t *subscription = NULL;
@ -398,10 +398,11 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
state = sbi_xact->state;
ogs_sbi_xact_remove(sbi_xact);
sess = (amf_sess_t *)sbi_xact->sbi_object;
ogs_assert(sess);
ogs_sbi_xact_remove(sbi_xact);
sess = amf_sess_cycle(sess);
if (!sess) {
/*
@ -590,7 +591,7 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
sbi_object = sbi_xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = sbi_xact->target_nf_type;
service_type = sbi_xact->service_type;
ogs_sbi_xact_remove(sbi_xact);
@ -640,7 +641,8 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
default:
ogs_fatal("Not implemented [%s:%d]",
OpenAPI_nf_type_ToString(target_nf_type), sbi_object->type);
ogs_sbi_service_type_to_name(service_type),
sbi_object->type);
ogs_assert_if_reached();
}
break;

View File

@ -1778,22 +1778,26 @@ amf_sess_t *amf_sess_cycle(amf_sess_t *sess)
return ogs_pool_cycle(&amf_sess_pool, sess);
}
static bool check_smf_info(amf_sess_t *sess, ogs_list_t *nf_info_list);
static bool check_smf_info(ogs_sbi_nf_info_t *nf_info, void *context);
void amf_sbi_select_nf(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option)
{
OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL;
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_nf_info_t *nf_info = NULL;
amf_sess_t *sess = NULL;
ogs_assert(sbi_object);
ogs_assert(service_type);
target_nf_type = ogs_sbi_service_type_to_nf_type(service_type);
ogs_assert(target_nf_type);
switch(sbi_object->type) {
case OGS_SBI_OBJ_UE_TYPE:
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
break;
case OGS_SBI_OBJ_SESS_TYPE:
sess = (amf_sess_t *)sbi_object;
@ -1804,12 +1808,15 @@ void amf_sbi_select_nf(
nf_instance, target_nf_type, discovery_option) == false)
continue;
if (target_nf_type == OpenAPI_nf_type_SMF) {
if (check_smf_info(sess, &nf_instance->nf_info_list) == false)
nf_info = ogs_sbi_nf_info_find(
&nf_instance->nf_info_list, nf_instance->nf_type);
if (nf_info) {
if (nf_instance->nf_type == OpenAPI_nf_type_SMF &&
check_smf_info(nf_info, sess) == false)
continue;
}
OGS_SBI_SETUP_NF(sbi_object, target_nf_type, nf_instance);
OGS_SBI_SETUP_NF_INSTANCE(sbi_object, service_type, nf_instance);
break;
}
break;
@ -2106,35 +2113,29 @@ static void stats_remove_amf_session(void)
}
static bool check_smf_info_s_nssai(
amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info);
ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess);
static bool check_smf_info_nr_tai(
amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info);
ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess);
static bool check_smf_info(amf_sess_t *sess, ogs_list_t *nf_info_list)
static bool check_smf_info(ogs_sbi_nf_info_t *nf_info, void *context)
{
ogs_sbi_nf_info_t *nf_info = NULL;
amf_sess_t *sess = NULL;
ogs_assert(nf_info);
ogs_assert(nf_info->nf_type == OpenAPI_nf_type_SMF);
sess = context;
ogs_assert(sess);
ogs_assert(nf_info_list);
if (ogs_list_count(nf_info_list) == 0) {
return true;
}
if (check_smf_info_s_nssai(&nf_info->smf, sess) == false)
return false;
if (check_smf_info_nr_tai(&nf_info->smf, sess) == false)
return false;
ogs_list_for_each(nf_info_list, nf_info) {
ogs_sbi_smf_info_t *smf_info = &nf_info->smf;
ogs_assert(smf_info);
if (check_smf_info_s_nssai(sess, smf_info) == true &&
check_smf_info_nr_tai(sess, smf_info) == true)
return true;
}
return false;
return true;
}
static bool check_smf_info_s_nssai(
amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info)
ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess)
{
int i, j;
@ -2157,7 +2158,7 @@ static bool check_smf_info_s_nssai(
}
static bool check_smf_info_nr_tai(
amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info)
ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess)
{
amf_ue_t *amf_ue = NULL;
int i, j;

View File

@ -738,7 +738,7 @@ amf_sess_t *amf_sess_cycle(amf_sess_t *sess);
void amf_sbi_select_nf(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option);
#define AMF_SESSION_SYNC_DONE(__aMF, __sTATE) \

View File

@ -720,8 +720,9 @@ int gmm_handle_authentication_response(amf_ue_t *amf_ue,
authentication_response_parameter->length);
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_nausf_auth_build_authenticate_confirmation, amf_ue, NULL));
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate_confirmation, amf_ue, NULL));
return OGS_OK;
}
@ -1063,25 +1064,39 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue,
if (!SESSION_CONTEXT_IN_SMF(sess)) {
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
discovery_option = ogs_sbi_discovery_option_new();
ogs_assert(discovery_option);
ogs_sbi_discovery_option_add_service_names(
discovery_option,
(char *)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION);
nf_instance = OGS_SBI_NF_INSTANCE(
&sess->sbi, OpenAPI_nf_type_SMF);
&sess->sbi,
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION);
if (!nf_instance) {
amf_sbi_select_nf(&sess->sbi, OpenAPI_nf_type_SMF, NULL);
amf_sbi_select_nf(
&sess->sbi,
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION,
discovery_option);
nf_instance = OGS_SBI_NF_INSTANCE(
&sess->sbi, OpenAPI_nf_type_SMF);
&sess->sbi,
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION);
}
ogs_sbi_discovery_option_free(discovery_option);
if (nf_instance) {
ogs_assert(true ==
amf_sess_sbi_discover_and_send(
OpenAPI_nf_type_SMF, NULL,
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_create_sm_context,
sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL));
} else {
ogs_assert(true ==
amf_sess_sbi_discover_and_send(
OpenAPI_nf_type_NSSF, NULL,
OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION, NULL,
amf_nnssf_nsselection_build_get, sess, 0, NULL));
}
@ -1092,7 +1107,8 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue,
param.cause = OpenAPI_cause_REL_DUE_TO_DUPLICATE_SESSION_ID;
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_DUPLICATED_PDU_SESSION_ID,
&param));
@ -1118,13 +1134,15 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue,
param.ue_timezone = true;
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_N1_RELEASED, &param));
} else {
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, &param));
}

View File

@ -177,7 +177,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e)
if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(
OpenAPI_nf_type_PCF, NULL,
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL,
NULL,
amf_npcf_am_policy_control_build_create,
amf_ue, NULL));
OGS_FSM_TRAN(s, &gmm_state_initial_context_setup);
@ -200,7 +201,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e)
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
if (amf_sess_xact_count(amf_ue) == xact_count) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
}
@ -277,7 +279,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e)
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
if (amf_sess_xact_count(amf_ue) == xact_count) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
}
@ -584,7 +587,8 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e)
case OGS_5GMM_CAUSE_NGKSI_ALREADY_IN_USE:
ogs_warn("Authentication failure(ngKSI already in use)");
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
return;
@ -596,7 +600,8 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e)
break;
}
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate,
amf_ue, authentication_failure_parameter->auts));
return;
@ -628,7 +633,8 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e)
}
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
break;
@ -832,7 +838,8 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e)
amf_ue->nhcc = 1;
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL,
amf_nudm_uecm_build_registration, amf_ue, NULL));
if (amf_ue->nas.message_type == OGS_NAS_5GS_REGISTRATION_REQUEST) {
@ -867,7 +874,8 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e)
}
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
OGS_FSM_TRAN(s, &gmm_state_authentication);
@ -994,7 +1002,7 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e)
CASE(OGS_SBI_HTTP_METHOD_PUT)
ogs_assert(true ==
amf_ue_sbi_discover_and_send(
OpenAPI_nf_type_UDM, NULL,
OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL,
amf_nudm_sdm_build_get,
amf_ue, (char *)OGS_SBI_RESOURCE_NAME_AM_DATA));
break;
@ -1194,7 +1202,8 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e)
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
if (amf_sess_xact_count(amf_ue) == xact_count) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
}
OGS_FSM_TRAN(s, &gmm_state_authentication);
@ -1358,7 +1367,8 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(
OpenAPI_nf_type_PCF, NULL,
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL,
NULL,
amf_npcf_am_policy_control_build_create,
amf_ue, NULL));
OGS_FSM_TRAN(s, &gmm_state_initial_context_setup);
@ -1381,7 +1391,8 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
if (amf_sess_xact_count(amf_ue) == xact_count) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
}

View File

@ -577,7 +577,8 @@ int amf_namf_callback_handle_dereg_notify(
if (ogs_list_count(&amf_ue->sess_list) == 0)
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL,
amf_npcf_am_policy_control_build_delete, amf_ue, NULL));
OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_de_registered);

View File

@ -904,7 +904,8 @@ void ngap_handle_initial_context_setup_response(
ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size);
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, &param));
@ -1643,7 +1644,8 @@ void ngap_handle_pdu_session_resource_setup_response(
ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size);
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, &param));
@ -1762,7 +1764,8 @@ void ngap_handle_pdu_session_resource_setup_response(
amf_ue->deactivation.cause = NGAP_CauseNas_normal_release;
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_SETUP_FAIL, &param));
@ -1942,7 +1945,8 @@ void ngap_handle_pdu_session_resource_modify_response(
ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size);
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, &param));
@ -2117,7 +2121,8 @@ void ngap_handle_pdu_session_resource_release_response(
ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size);
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_N2_RELEASED, &param));
@ -2539,7 +2544,8 @@ void ngap_handle_path_switch_request(
ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size);
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_PATH_SWITCH_REQUEST, &param));
@ -2855,7 +2861,8 @@ void ngap_handle_handover_required(
param.TargetID = TargetID;
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQUIRED, &param));
@ -3079,7 +3086,8 @@ void ngap_handle_handover_request_ack(
param.hoState = OpenAPI_ho_state_PREPARED;
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQ_ACK, &param));
@ -3324,7 +3332,8 @@ void ngap_handle_handover_cancel(
param.ngApCause.value = (int)Cause->choice.radioNetwork;
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_CANCEL, &param));
}
@ -3604,7 +3613,8 @@ void ngap_handle_handover_notification(
param.hoState = OpenAPI_ho_state_COMPLETED;
ogs_assert(true ==
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context,
sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_NOTIFY, &param));
}

View File

@ -21,13 +21,23 @@
ogs_sbi_request_t *amf_nnrf_disc_build_discover(
char *nrf_id,
OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type)
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option)
{
ogs_sbi_message_t message;
ogs_sbi_request_t *request = NULL;
OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(nrf_id);
ogs_assert(service_type);
target_nf_type = ogs_sbi_service_type_to_nf_type(service_type);
ogs_assert(target_nf_type);
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
memset(&message, 0, sizeof(message));
@ -37,6 +47,8 @@ ogs_sbi_request_t *amf_nnrf_disc_build_discover(
message.param.target_nf_type = target_nf_type;
message.param.requester_nf_type = requester_nf_type;
message.param.discovery_option = discovery_option;
request = ogs_sbi_build_request(&message);
return request;

View File

@ -28,7 +28,8 @@ extern "C" {
ogs_sbi_request_t *amf_nnrf_disc_build_discover(
char *nrf_id,
OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type);
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option);
#ifdef __cplusplus
}

View File

@ -26,7 +26,7 @@ void amf_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -35,8 +35,8 @@ void amf_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -46,10 +46,9 @@ void amf_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
amf_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
amf_sbi_select_nf(sbi_object, service_type, discovery_option);
ogs_expect(true == amf_sbi_send_request(sbi_object, target_nf_type, xact));
ogs_expect(true == amf_sbi_send_request(sbi_object, service_type, xact));
}

View File

@ -98,7 +98,8 @@ int amf_nnssf_nsselection_handle_get(
ogs_freeaddrinfo(addr);
ogs_assert(true == amf_sess_sbi_discover_by_nsi(OpenAPI_nf_type_SMF, sess));
ogs_assert(true == amf_sess_sbi_discover_by_nsi(
sess, OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL));
return OGS_OK;
}

View File

@ -120,7 +120,9 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_create_sm_context(
SmContextCreateData.ue_time_zone = ogs_sbi_timezone_string(ogs_timezone());
ogs_expect_or_return_val(SmContextCreateData.ue_time_zone, NULL);
pcf_nf_instance = OGS_SBI_NF_INSTANCE(&amf_ue->sbi, OpenAPI_nf_type_PCF);
pcf_nf_instance = OGS_SBI_NF_INSTANCE(
&amf_ue->sbi,
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL);
ogs_expect_or_return_val(pcf_nf_instance, NULL);
SmContextCreateData.pcf_id = pcf_nf_instance->id;

View File

@ -233,7 +233,8 @@ int amf_nsmf_pdusession_handle_update_sm_context(
if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(
OpenAPI_nf_type_PCF, NULL,
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL,
NULL,
amf_npcf_am_policy_control_build_create,
amf_ue, NULL));
} else {
@ -565,7 +566,8 @@ int amf_nsmf_pdusession_handle_update_sm_context(
ogs_warn("[%s:%d] Receive Update SM context"
"(DUPLICATED_PDU_SESSION_ID)", amf_ue->supi, sess->psi);
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_create_sm_context,
sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL);
@ -816,7 +818,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state)
if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL,
amf_npcf_am_policy_control_build_create, amf_ue, NULL));
} else {
CLEAR_AMF_UE_TIMER(amf_ue->t3550);
@ -868,7 +871,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state)
if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_authentication)) {
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL,
amf_nausf_auth_build_authenticate, amf_ue, NULL));
} else if (OGS_FSM_CHECK(&amf_ue->sm,
@ -885,7 +889,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state)
*/
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL,
amf_npcf_am_policy_control_build_delete,
amf_ue, NULL));

View File

@ -140,7 +140,8 @@ int amf_nudm_sdm_handle_provisioned(
}
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL,
amf_nudm_sdm_build_get,
amf_ue, (char *)OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA));
break;
@ -212,14 +213,16 @@ int amf_nudm_sdm_handle_provisioned(
}
}
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL,
amf_nudm_sdm_build_get,
amf_ue, (char *)OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA));
break;
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)
ogs_assert(true ==
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL,
amf_npcf_am_policy_control_build_create, amf_ue, NULL));
break;

View File

@ -148,16 +148,16 @@ void amf_sbi_close(void)
bool amf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_assert(service_type);
ogs_assert(sbi_object);
ogs_assert(target_nf_type);
ogs_assert(data);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
amf_ue_t *amf_ue = NULL;
amf_sess_t *sess = NULL;
@ -169,7 +169,7 @@ bool amf_sbi_send_request(
amf_ue = (amf_ue_t *)sbi_object;
ogs_assert(amf_ue);
ogs_error("[%s] (NF discover) No [%s]", amf_ue->suci,
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
ogs_assert(OGS_OK ==
nas_5gs_send_gmm_reject_from_sbi(amf_ue,
OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT));
@ -178,7 +178,7 @@ bool amf_sbi_send_request(
sess = (amf_sess_t *)sbi_object;
ogs_assert(sess);
ogs_error("[%d:%d] (NF discover) No [%s]", sess->psi, sess->pti,
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
if (sess->payload_container_type) {
ogs_assert(OGS_OK ==
nas_5gs_send_back_gsm_message(sess,
@ -193,8 +193,7 @@ bool amf_sbi_send_request(
break;
default:
ogs_fatal("(NF discover) Not implemented [%s:%d]",
OpenAPI_nf_type_ToString(target_nf_type),
sbi_object->type);
ogs_sbi_service_type_to_name(service_type), sbi_object->type);
ogs_assert_if_reached();
}
@ -205,24 +204,19 @@ bool amf_sbi_send_request(
}
bool amf_ue_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data),
amf_ue_t *amf_ue, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(target_nf_type);
ogs_assert(service_type);
ogs_assert(amf_ue);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&amf_ue->sbi, target_nf_type, discovery_option,
&amf_ue->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, amf_ue, data);
if (!xact) {
ogs_error("amf_ue_sbi_discover_and_send() failed");
@ -232,10 +226,7 @@ bool amf_ue_sbi_discover_and_send(
return false;
}
if (ogs_sbi_discover_and_send(
&amf_ue->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("amf_ue_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
ogs_assert(OGS_OK ==
@ -248,24 +239,19 @@ bool amf_ue_sbi_discover_and_send(
}
bool amf_sess_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data),
amf_sess_t *sess, int state, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(target_nf_type);
ogs_assert(service_type);
ogs_assert(sess);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&sess->sbi, target_nf_type, discovery_option,
&sess->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, sess, data);
if (!xact) {
ogs_error("amf_sess_sbi_discover_and_send() failed");
@ -276,10 +262,7 @@ bool amf_sess_sbi_discover_and_send(
xact->state = state;
if (ogs_sbi_discover_and_send(
&sess->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("amf_sess_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess,
@ -293,21 +276,50 @@ static int client_discover_cb(
int status, ogs_sbi_response_t *response, void *data)
{
int rv;
ogs_sbi_message_t message;
amf_sess_t *sess = data;
ogs_sbi_xact_t *xact = NULL;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
amf_ue_t *amf_ue = NULL;
amf_sess_t *sess = NULL;
ogs_assert(response);
xact = data;
ogs_assert(xact);
xact = ogs_sbi_xact_cycle(xact);
if (!xact) {
ogs_error("SBI transaction has already been removed");
return OGS_ERROR;
}
sess = (amf_sess_t *)xact->sbi_object;
ogs_assert(sess);
service_type = xact->service_type;
discovery_option = xact->discovery_option;
sess = amf_sess_cycle(sess);
if (!sess) {
ogs_error("Session has already been removed");
ogs_sbi_xact_remove(xact);
return OGS_ERROR;
}
ogs_assert(sess->sbi.type == OGS_SBI_OBJ_SESS_TYPE);
amf_ue = sess->amf_ue;
ogs_assert(amf_ue);
if (status != OGS_OK) {
ogs_log_message(
status == OGS_DONE ? OGS_LOG_DEBUG : OGS_LOG_WARN, 0,
"client_discover_cb() failed [%d]", status);
ogs_sbi_xact_remove(xact);
return OGS_ERROR;
}
ogs_assert(response);
ogs_assert(sess);
ogs_assert(sess->sbi.type == OGS_SBI_OBJ_SESS_TYPE);
rv = ogs_sbi_parse_response(&message, response);
if (rv != OGS_OK) {
ogs_error("cannot parse HTTP response");
@ -333,14 +345,14 @@ static int client_discover_cb(
goto cleanup;
}
ogs_nnrf_handle_nf_discover_search_result(
&sess->sbi, OpenAPI_nf_type_SMF, NULL, message.SearchResult);
ogs_nnrf_handle_nf_discover_search_result(message.SearchResult);
amf_sbi_select_nf(&sess->sbi, OpenAPI_nf_type_SMF, NULL);
amf_sbi_select_nf(&sess->sbi, service_type, discovery_option);
if (!OGS_SBI_NF_INSTANCE(&sess->sbi, OpenAPI_nf_type_SMF)) {
ogs_error("Cannot discover [%s]",
OpenAPI_nf_type_ToString(OpenAPI_nf_type_SMF));
if (!OGS_SBI_NF_INSTANCE(&sess->sbi, service_type)) {
ogs_error("[%s:%d] (NF discover) No [%s]",
amf_ue->supi, sess->psi,
ogs_sbi_service_type_to_name(service_type));
ogs_assert(OGS_OK ==
nas_5gs_send_back_gsm_message(sess,
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
@ -349,11 +361,14 @@ static int client_discover_cb(
goto cleanup;
}
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
service_type, NULL,
amf_nsmf_pdusession_build_create_sm_context,
sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL);
cleanup:
ogs_sbi_xact_remove(xact);
ogs_sbi_message_free(&message);
ogs_sbi_response_free(response);
@ -361,24 +376,31 @@ cleanup:
}
bool amf_sess_sbi_discover_by_nsi(
OpenAPI_nf_type_e target_nf_type, amf_sess_t *sess)
amf_sess_t *sess,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option)
{
ogs_sbi_request_t *request = NULL;
ogs_sbi_xact_t *xact = NULL;
ogs_sbi_client_t *client = NULL;
ogs_assert(target_nf_type);
ogs_assert(sess);
client = sess->nssf.nrf.client;
ogs_assert(client);
ogs_assert(service_type);
ogs_assert(ogs_sbi_self()->nf_instance);
request = amf_nnrf_disc_build_discover(
sess->nssf.nrf.id, target_nf_type,
ogs_sbi_self()->nf_instance->nf_type);
ogs_expect_or_return_val(request, false);
ogs_warn("Try to discover [%s]",
ogs_sbi_service_type_to_name(service_type));
return ogs_sbi_client_send_request(
client, client_discover_cb, request, sess);
xact = ogs_sbi_xact_add(
&sess->sbi, service_type, discovery_option, NULL, NULL, NULL);
ogs_expect_or_return_val(xact, false);
xact->request = amf_nnrf_disc_build_discover(
sess->nssf.nrf.id, xact->service_type, xact->discovery_option);
ogs_expect_or_return_val(xact->request, false);
return ogs_sbi_client_send_reqmem_persistent(
client, client_discover_cb, xact->request, xact);
}
void amf_sbi_send_activating_session(amf_sess_t *sess, int state)
@ -390,7 +412,8 @@ void amf_sbi_send_activating_session(amf_sess_t *sess, int state)
memset(&param, 0, sizeof(param));
param.upCnxState = OpenAPI_up_cnx_state_ACTIVATING;
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context, sess, state, &param);
}
@ -408,7 +431,8 @@ void amf_sbi_send_deactivate_session(
param.ue_location = true;
param.ue_timezone = true;
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_update_sm_context, sess, state, &param);
}
@ -470,7 +494,8 @@ void amf_sbi_send_release_session(amf_sess_t *sess, int state)
{
ogs_assert(sess);
amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL,
amf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL,
amf_nsmf_pdusession_build_release_sm_context, sess, state, NULL);
/* Prevent to invoke SMF for this session */

View File

@ -36,10 +36,10 @@ void amf_sbi_close(void);
bool amf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data);
bool amf_ue_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data),
amf_ue_t *amf_ue, void *data);
@ -67,13 +67,15 @@ bool amf_ue_sbi_discover_and_send(
#define AMF_REMOVE_S1_CONTEXT_BY_RESET_ALL 52
#define AMF_REMOVE_S1_CONTEXT_BY_RESET_PARTIAL 53
bool amf_sess_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data),
amf_sess_t *sess, int state, void *data);
bool amf_sess_sbi_discover_by_nsi(
OpenAPI_nf_type_e target_nf_type, amf_sess_t *sess);
amf_sess_t *sess,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option);
void amf_sbi_send_activating_session(amf_sess_t *sess, int state);

View File

@ -55,7 +55,8 @@ bool ausf_nausf_auth_handle_authenticate(ausf_ue_t *ausf_ue,
ogs_assert(ausf_ue->serving_network_name);
ogs_assert(true ==
ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL,
ausf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UEAU, NULL,
ausf_nudm_ueau_build_get,
ausf_ue, stream, AuthenticationInfo->resynchronization_info));
@ -104,7 +105,8 @@ bool ausf_nausf_auth_handle_authenticate_confirmation(ausf_ue_t *ausf_ue,
}
ogs_assert(true ==
ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL,
ausf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UEAU, NULL,
ausf_nudm_ueau_build_result_confirmation_inform,
ausf_ue, stream, NULL));

View File

@ -24,7 +24,7 @@ void ausf_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -33,8 +33,8 @@ void ausf_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -44,10 +44,9 @@ void ausf_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
ogs_expect(true == ausf_sbi_send_request(sbi_object, target_nf_type, xact));
ogs_expect(true == ausf_sbi_send_request(sbi_object, service_type, xact));
}

View File

@ -130,15 +130,17 @@ void ausf_sbi_close(void)
bool ausf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
ogs_assert(service_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
ogs_error("(NF discover) No [%s]",
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
return false;
}
@ -146,25 +148,20 @@ bool ausf_sbi_send_request(
}
bool ausf_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data),
ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(target_nf_type);
ogs_assert(service_type);
ogs_assert(ausf_ue);
ogs_assert(stream);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&ausf_ue->sbi, target_nf_type, discovery_option,
&ausf_ue->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, ausf_ue, data);
if (!xact) {
ogs_error("ausf_sbi_discover_and_send() failed");
@ -177,10 +174,7 @@ bool ausf_sbi_discover_and_send(
xact->assoc_stream = stream;
if (ogs_sbi_discover_and_send(
&ausf_ue->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("ausf_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
ogs_assert(true ==

View File

@ -31,10 +31,10 @@ void ausf_sbi_close(void);
bool ausf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data);
bool ausf_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data),
ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data);

View File

@ -24,7 +24,7 @@ void bsf_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -33,8 +33,8 @@ void bsf_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -44,10 +44,9 @@ void bsf_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
ogs_expect(true == bsf_sbi_send_request(sbi_object, target_nf_type, xact));
ogs_expect(true == bsf_sbi_send_request(sbi_object, service_type, xact));
}

View File

@ -130,15 +130,17 @@ void bsf_sbi_close(void)
bool bsf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
ogs_assert(service_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
ogs_error("(NF discover) No [%s]",
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
return false;
}
@ -146,24 +148,20 @@ bool bsf_sbi_send_request(
}
bool bsf_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data),
bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(service_type);
ogs_assert(sess);
ogs_assert(stream);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&sess->sbi, target_nf_type, discovery_option,
&sess->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, sess, data);
if (!xact) {
ogs_error("bsf_sbi_discover_and_send() failed");
@ -176,10 +174,7 @@ bool bsf_sbi_discover_and_send(
xact->assoc_stream = stream;
if (ogs_sbi_discover_and_send(
&sess->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("bsf_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
ogs_assert(true ==

View File

@ -31,10 +31,10 @@ void bsf_sbi_close(void);
bool bsf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data);
bool bsf_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data),
bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
* Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
@ -61,8 +61,10 @@ ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify(
ogs_expect_or_return_val(NotificationData->nf_instance_uri, NULL);
if (event != OpenAPI_notification_event_type_NF_DEREGISTERED) {
ogs_expect_or_return_val(nf_instance->nf_profile, NULL);
NotificationData->nf_profile = nf_instance->nf_profile;
NotificationData->nf_profile =
ogs_nnrf_nfm_build_nf_profile(
nf_instance, NULL, subscription->requester_features);
ogs_expect_or_return_val(NotificationData->nf_profile, NULL);
}
message.NotificationData = NotificationData;
@ -70,6 +72,9 @@ ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify(
request = ogs_sbi_build_request(&message);
ogs_expect_or_return_val(request, NULL);
if (NotificationData->nf_profile)
ogs_nnrf_nfm_free_nf_profile(NotificationData->nf_profile);
ogs_free(NotificationData->nf_instance_uri);
ogs_free(NotificationData);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
* Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
@ -40,12 +40,7 @@ bool nrf_nnrf_handle_nf_register(ogs_sbi_nf_instance_t *nf_instance,
return false;
}
/* Store NFProfile */
nf_instance->nf_profile = OpenAPI_nf_profile_copy(
nf_instance->nf_profile, NFProfile);
/* ogs_sbi_nnrf_handle_nf_profile() sends error response */
ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile, stream, recvmsg);
ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile);
if (OGS_FSM_CHECK(&nf_instance->sm, nrf_nf_state_will_register)) {
recvmsg->http.location = recvmsg->h.uri;
@ -218,6 +213,23 @@ bool nrf_nnrf_handle_nf_status_subscribe(
SubscriptionData->subscription_id = ogs_strdup(subscription->id);
ogs_expect_or_return_val(SubscriptionData->subscription_id, NULL);
if (SubscriptionData->requester_features) {
subscription->requester_features =
ogs_uint64_from_string(SubscriptionData->requester_features);
/* No need to send SubscriptionData->requester_features to the NF */
ogs_free(SubscriptionData->requester_features);
SubscriptionData->requester_features = NULL;
} else {
subscription->requester_features = 0;
}
OGS_SBI_FEATURES_SET(subscription->nrf_supported_features,
OGS_SBI_NNRF_NFM_SERVICE_MAP);
SubscriptionData->nrf_supported_features =
ogs_uint64_to_string(subscription->nrf_supported_features);
ogs_expect_or_return_val(SubscriptionData->nrf_supported_features, NULL);
SubscrCond = SubscriptionData->subscr_cond;
if (SubscrCond) {
subscription->subscr_cond.nf_type = SubscrCond->nf_type;
@ -303,6 +315,7 @@ bool nrf_nnrf_handle_nf_list_retrieval(
ogs_sbi_server_t *server = NULL;
ogs_sbi_response_t *response = NULL;
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
int i = 0;
ogs_sbi_links_t *links = NULL;
@ -320,11 +333,19 @@ bool nrf_nnrf_handle_nf_list_retrieval(
links->self = ogs_sbi_server_uri(server, &recvmsg->h);
if (recvmsg->param.discovery_option)
discovery_option = recvmsg->param.discovery_option;
i = 0;
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
if (recvmsg->param.nf_type &&
recvmsg->param.nf_type != nf_instance->nf_type)
recvmsg->param.nf_type != nf_instance->nf_type)
continue;
if (discovery_option &&
ogs_sbi_discovery_option_is_matched(
nf_instance, discovery_option) == false)
continue;
if (!recvmsg->param.limit ||
@ -364,6 +385,8 @@ bool nrf_nnrf_handle_nf_profile_retrieval(
ogs_sbi_message_t sendmsg;
ogs_sbi_response_t *response = NULL;
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
uint64_t supported_features = 0;
ogs_assert(stream);
ogs_assert(recvmsg);
@ -379,15 +402,22 @@ bool nrf_nnrf_handle_nf_profile_retrieval(
return false;
}
if (recvmsg->param.discovery_option)
discovery_option = recvmsg->param.discovery_option;
memset(&sendmsg, 0, sizeof(sendmsg));
ogs_assert(nf_instance->nf_profile);
sendmsg.NFProfile = nf_instance->nf_profile;
OGS_SBI_FEATURES_SET(supported_features, OGS_SBI_NNRF_NFM_SERVICE_MAP);
sendmsg.NFProfile = ogs_nnrf_nfm_build_nf_profile(
nf_instance, discovery_option, supported_features);
ogs_expect_or_return_val(sendmsg.NFProfile, NULL);
response = ogs_sbi_build_response(&sendmsg, OGS_SBI_HTTP_STATUS_OK);
ogs_assert(response);
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
ogs_nnrf_nfm_free_nf_profile(sendmsg.NFProfile);
return true;
}
@ -400,6 +430,9 @@ bool nrf_nnrf_handle_nf_discover(
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
OpenAPI_lnode_t *node = NULL;
uint64_t supported_features = 0;
int i;
ogs_assert(stream);
@ -459,28 +492,27 @@ bool nrf_nnrf_handle_nf_discover(
if (nf_instance->nf_type != recvmsg->param.target_nf_type)
continue;
if (discovery_option) {
if (discovery_option->target_nf_instance_id &&
strcmp(nf_instance->id,
discovery_option->target_nf_instance_id) != 0)
continue;
}
if (discovery_option &&
ogs_sbi_discovery_option_is_matched(
nf_instance, discovery_option) == false)
continue;
if (!recvmsg->param.limit ||
(recvmsg->param.limit && i < recvmsg->param.limit)) {
if (recvmsg->param.limit && i >= recvmsg->param.limit)
break;
ogs_debug("[%s:%d] NF-Discovered [NF-Type:%s,NF-Status:%s,"
"IPv4:%d,IPv6:%d]", nf_instance->id, i,
OpenAPI_nf_type_ToString(nf_instance->nf_type),
OpenAPI_nf_status_ToString(nf_instance->nf_status),
nf_instance->num_of_ipv4, nf_instance->num_of_ipv6);
ogs_debug("[%s:%d] NF-Discovered [NF-Type:%s,NF-Status:%s,"
"IPv4:%d,IPv6:%d]", nf_instance->id, i,
OpenAPI_nf_type_ToString(nf_instance->nf_type),
OpenAPI_nf_status_ToString(nf_instance->nf_status),
nf_instance->num_of_ipv4, nf_instance->num_of_ipv6);
ogs_assert(nf_instance->nf_profile);
OpenAPI_list_add(SearchResult->nf_instances,
nf_instance->nf_profile);
OGS_SBI_FEATURES_SET(
supported_features, OGS_SBI_NNRF_NFM_SERVICE_MAP);
NFProfile = ogs_nnrf_nfm_build_nf_profile(
nf_instance, discovery_option, supported_features);
OpenAPI_list_add(SearchResult->nf_instances, NFProfile);
i++;
}
i++;
}
if (recvmsg->param.limit) SearchResult->num_nf_inst_complete = i;
@ -495,6 +527,10 @@ bool nrf_nnrf_handle_nf_discover(
ogs_assert(response);
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
OpenAPI_list_for_each(SearchResult->nf_instances, node) {
NFProfile = node->data;
if (NFProfile) ogs_nnrf_nfm_free_nf_profile(NFProfile);
}
OpenAPI_list_free(SearchResult->nf_instances);
if (sendmsg.http.cache_control)

View File

@ -24,7 +24,7 @@ void pcf_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -33,8 +33,8 @@ void pcf_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -44,10 +44,9 @@ void pcf_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
ogs_expect(true == pcf_sbi_send_request(sbi_object, target_nf_type, xact));
ogs_expect(true == pcf_sbi_send_request(sbi_object, service_type, xact));
}

View File

@ -148,7 +148,7 @@ bool pcf_npcf_am_policy_contrtol_handle_create(pcf_ue_t *pcf_ue,
pcf_ue->subscribed_ue_ambr, PolicyAssociationRequest->ue_ambr);
ogs_assert(true ==
pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
pcf_ue_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
pcf_nudr_dr_build_query_am_data, pcf_ue, stream, NULL));
return true;
@ -164,8 +164,6 @@ bool pcf_npcf_smpolicycontrol_handle_create(pcf_sess_t *sess,
OpenAPI_sm_policy_context_data_t *SmPolicyContextData = NULL;
OpenAPI_snssai_t *sliceInfo = NULL;
uint64_t supported_features = 0;
ogs_sbi_client_t *client = NULL;
ogs_sockaddr_t *addr = NULL;
@ -250,7 +248,7 @@ bool pcf_npcf_smpolicycontrol_handle_create(pcf_sess_t *sess,
}
if (SmPolicyContextData->supp_feat) {
supported_features =
uint64_t supported_features =
ogs_uint64_from_string(SmPolicyContextData->supp_feat);
sess->smpolicycontrol_features &= supported_features;
} else {
@ -298,7 +296,8 @@ bool pcf_npcf_smpolicycontrol_handle_create(pcf_sess_t *sess,
sess->subscribed_default_qos, SmPolicyContextData->subs_def_qos);
ogs_assert(true ==
pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
pcf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
pcf_nudr_dr_build_query_sm_data, sess, stream, NULL));
return true;
@ -352,7 +351,8 @@ bool pcf_npcf_smpolicycontrol_handle_delete(pcf_sess_t *sess,
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
} else {
ogs_assert(true ==
pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_BSF, NULL,
pcf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL,
pcf_nbsf_management_build_de_register, sess, stream, NULL));
}

View File

@ -194,7 +194,8 @@ bool pcf_nudr_dr_handle_query_sm_data(
}
ogs_assert(true ==
pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_BSF, NULL,
pcf_sess_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL,
pcf_nbsf_management_build_register, sess, stream, NULL));
return true;

View File

@ -49,7 +49,7 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
ogs_sbi_object_t *sbi_object = NULL;
ogs_sbi_xact_t *sbi_xact = NULL;
OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
pcf_ue_t *pcf_ue = NULL;
pcf_sess_t *sess = NULL;
@ -591,7 +591,7 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
stream = sbi_xact->assoc_stream;
ogs_assert(stream);
target_nf_type = sbi_xact->target_nf_type;
service_type = sbi_xact->service_type;
ogs_sbi_xact_remove(sbi_xact);
@ -623,7 +623,8 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
default:
ogs_fatal("Not implemented [%s:%d]",
OpenAPI_nf_type_ToString(target_nf_type), sbi_object->type);
ogs_sbi_service_type_to_name(service_type),
sbi_object->type);
ogs_assert_if_reached();
}

View File

@ -158,12 +158,14 @@ void pcf_sbi_close(void)
bool pcf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
ogs_assert(service_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
pcf_ue_t *pcf_ue = NULL;
pcf_sess_t *sess = NULL;
@ -175,18 +177,17 @@ bool pcf_sbi_send_request(
pcf_ue = (pcf_ue_t *)sbi_object;
ogs_assert(pcf_ue);
ogs_error("[%s] (NF discover) No [%s]", pcf_ue->supi,
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
break;
case OGS_SBI_OBJ_SESS_TYPE:
sess = (pcf_sess_t *)sbi_object;
ogs_assert(sess);
ogs_error("[%d] (NF discover) No [%s]", sess->psi,
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
break;
default:
ogs_fatal("(NF discover) Not implemented [%s:%d]",
OpenAPI_nf_type_ToString(target_nf_type),
sbi_object->type);
ogs_sbi_service_type_to_name(service_type), sbi_object->type);
ogs_assert_if_reached();
}
@ -198,34 +199,26 @@ bool pcf_sbi_send_request(
static bool pcf_sbi_discover_and_send(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_build_f build,
void *context, ogs_sbi_stream_t *stream, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(target_nf_type);
ogs_assert(service_type);
ogs_assert(sbi_object);
ogs_assert(stream);
ogs_assert(build);
xact = ogs_sbi_xact_add(
sbi_object, target_nf_type, discovery_option,
sbi_object, service_type, discovery_option,
build, context, data);
ogs_expect_or_return_val(xact, false);
xact->assoc_stream = stream;
if (ogs_sbi_discover_and_send(
sbi_object,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("ogs_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
return false;
@ -235,13 +228,13 @@ static bool pcf_sbi_discover_and_send(
}
bool pcf_ue_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data),
pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data)
{
if (pcf_sbi_discover_and_send(
&pcf_ue->sbi, target_nf_type, discovery_option,
&pcf_ue->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, pcf_ue, stream, data) != true) {
ogs_error("pcf_ue_sbi_discover_and_send() failed");
ogs_assert(true ==
@ -255,13 +248,13 @@ bool pcf_ue_sbi_discover_and_send(
}
bool pcf_sess_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data),
pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data)
{
if (pcf_sbi_discover_and_send(
&sess->sbi, target_nf_type, discovery_option,
&sess->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, sess, stream, data) != true) {
ogs_error("pcf_sess_sbi_discover_and_send() failed");
ogs_assert(true ==

View File

@ -35,15 +35,15 @@ void pcf_sbi_close(void);
bool pcf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data);
bool pcf_ue_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data),
pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data);
bool pcf_sess_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data),
pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data);

View File

@ -24,9 +24,8 @@ void scp_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
ogs_sbi_nf_instance_t *nf_instance = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -34,8 +33,8 @@ void scp_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -45,16 +44,9 @@ void scp_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
if (!nf_instance) {
ogs_error("(NF discover) No [%s]",
OpenAPI_nf_type_ToString(target_nf_type));
} else {
scp_sbi_send(nf_instance, xact);
}
scp_sbi_send_request(sbi_object, service_type, xact);
}

View File

@ -364,31 +364,40 @@ static int client_cb(int status, ogs_sbi_response_t *response, void *data)
return OGS_OK;
}
bool scp_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact)
bool scp_sbi_send_request(
ogs_sbi_object_t *sbi_object,
ogs_sbi_service_type_e service_type,
void *data)
{
return ogs_sbi_send_request(nf_instance, client_cb, xact);
ogs_sbi_nf_instance_t *nf_instance = NULL;
ogs_assert(service_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
ogs_error("(NF discover) No [%s]",
ogs_sbi_service_type_to_name(service_type));
return false;
}
return ogs_sbi_send_request(nf_instance, client_cb, data);
}
bool scp_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data),
scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(service_type);
ogs_assert(conn);
ogs_assert(stream);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&conn->sbi, target_nf_type, discovery_option,
&conn->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, conn, data);
if (!xact) {
ogs_error("scp_sbi_discover_and_send() failed");
@ -401,10 +410,7 @@ bool scp_sbi_discover_and_send(
xact->assoc_stream = stream;
if (ogs_sbi_discover_and_send(
&conn->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("scp_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
ogs_assert(true ==

View File

@ -29,10 +29,12 @@ extern "C" {
int scp_sbi_open(void);
void scp_sbi_close(void);
bool scp_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact);
bool scp_sbi_send_request(
ogs_sbi_object_t *sbi_object,
ogs_sbi_service_type_e service_type,
void *data);
bool scp_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data),
scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data);

View File

@ -67,7 +67,7 @@ int gsm_handle_pdu_session_establishment_request(
}
ogs_assert(true ==
smf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL,
smf_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL,
smf_nudm_sdm_build_get,
sess, stream, 0, (char *)OGS_SBI_RESOURCE_NAME_SM_DATA));

View File

@ -996,7 +996,8 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e)
NGAP_CauseNas_normal_release;
ogs_assert(true ==
smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
smf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL,
smf_npcf_smpolicycontrol_build_delete,
sess, stream,
OGS_PFCP_DELETE_TRIGGER_UE_REQUESTED, &param));

View File

@ -24,7 +24,7 @@ void smf_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -33,8 +33,8 @@ void smf_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -44,10 +44,9 @@ void smf_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
ogs_expect(true == smf_sbi_send_request(sbi_object, target_nf_type, xact));
ogs_expect(true == smf_sbi_send_request(sbi_object, service_type, xact));
}

View File

@ -276,8 +276,6 @@ bool smf_npcf_smpolicycontrol_handle_create(
char buf1[OGS_ADDRSTRLEN];
char buf2[OGS_ADDRSTRLEN];
uint64_t supported_features;
char *strerror = NULL;
smf_ue_t *smf_ue = NULL;
@ -345,7 +343,7 @@ bool smf_npcf_smpolicycontrol_handle_create(
/* SBI Features */
if (SmPolicyDecision->supp_feat) {
supported_features =
uint64_t supported_features =
ogs_uint64_from_string(SmPolicyDecision->supp_feat);
sess->smpolicycontrol_features &= supported_features;
} else {
@ -683,7 +681,8 @@ bool smf_npcf_smpolicycontrol_handle_terminate_notify(
memset(&param, 0, sizeof(param));
ogs_assert(true ==
smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
smf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL,
smf_npcf_smpolicycontrol_build_delete,
sess, NULL, OGS_PFCP_DELETE_TRIGGER_PCF_INITIATED, &param));

View File

@ -590,7 +590,8 @@ bool smf_nsmf_handle_update_sm_context(
param.ue_timezone = true;
ogs_assert(true ==
smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
smf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL,
smf_npcf_smpolicycontrol_build_delete,
sess, stream,
OGS_PFCP_DELETE_TRIGGER_AMF_UPDATE_SM_CONTEXT, &param));
@ -666,7 +667,8 @@ bool smf_nsmf_handle_release_sm_context(
if (sess->policy_association_id) {
ogs_assert(true ==
smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
smf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL,
smf_npcf_smpolicycontrol_build_delete,
sess, stream,
OGS_PFCP_DELETE_TRIGGER_AMF_RELEASE_SM_CONTEXT, &param));

View File

@ -288,7 +288,8 @@ bool smf_nudm_sdm_handle_get(smf_sess_t *sess, ogs_sbi_stream_t *stream,
ogs_free(sendmsg.http.location);
ogs_assert(true ==
smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL,
smf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL,
smf_npcf_smpolicycontrol_build_create, sess, stream, 0, NULL));
return true;

View File

@ -135,15 +135,17 @@ void smf_sbi_close(void)
bool smf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
ogs_assert(service_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
ogs_error("(NF discover) No [%s]",
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
return false;
}
@ -151,7 +153,7 @@ bool smf_sbi_send_request(
}
bool smf_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data),
smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data)
@ -159,20 +161,14 @@ bool smf_sbi_discover_and_send(
smf_ue_t *smf_ue = NULL;
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(service_type);
ogs_assert(sess);
smf_ue = sess->smf_ue;
ogs_assert(smf_ue);
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&sess->sbi, target_nf_type, discovery_option,
&sess->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, sess, data);
if (!xact) {
ogs_error("smf_sbi_discover_and_send() failed");
@ -186,10 +182,7 @@ bool smf_sbi_discover_and_send(
xact->state = state;
xact->assoc_stream = stream;
if (ogs_sbi_discover_and_send(
&sess->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("smf_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
@ -209,24 +202,15 @@ void smf_namf_comm_send_n1_n2_message_transfer(
{
smf_ue_t *smf_ue = NULL;
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
ogs_assert(param);
ogs_assert(param->state);
ogs_assert(param->n1smbuf || param->n2smbuf);
ogs_assert(sess);
smf_ue = sess->smf_ue;
ogs_assert(smf_ue);
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
target_nf_type = OpenAPI_nf_type_AMF;
ogs_assert(param);
ogs_assert(param->state);
ogs_assert(param->n1smbuf || param->n2smbuf);
discovery_option = ogs_sbi_discovery_option_new();
ogs_assert(discovery_option);
@ -234,7 +218,7 @@ void smf_namf_comm_send_n1_n2_message_transfer(
discovery_option, sess->serving_nf_id);
xact = ogs_sbi_xact_add(
&sess->sbi, target_nf_type, discovery_option,
&sess->sbi, OGS_SBI_SERVICE_TYPE_NAMF_COMM, discovery_option,
(ogs_sbi_build_f)smf_namf_comm_build_n1_n2_message_transfer,
sess, param);
if (!xact) {
@ -244,10 +228,7 @@ void smf_namf_comm_send_n1_n2_message_transfer(
xact->state = param->state;
if (ogs_sbi_discover_and_send(
&sess->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("smf_namf_comm_send_n1_n2_message_transfer() failed");
ogs_sbi_xact_remove(xact);
}

View File

@ -35,10 +35,10 @@ void smf_sbi_close(void);
bool smf_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data);
bool smf_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data),
smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data);

View File

@ -24,7 +24,7 @@ void udm_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -33,8 +33,8 @@ void udm_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -44,10 +44,9 @@ void udm_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
ogs_expect(true == udm_sbi_send_request(sbi_object, target_nf_type, xact));
ogs_expect(true == udm_sbi_send_request(sbi_object, service_type, xact));
}

View File

@ -74,7 +74,7 @@ bool udm_nudm_ueau_handle_get(
if (!ResynchronizationInfo) {
ogs_assert(true ==
udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
udm_nudr_dr_build_authentication_subscription,
udm_ue, stream, NULL));
@ -163,7 +163,7 @@ bool udm_nudm_ueau_handle_get(
ogs_uint64_to_buffer(sqn, OGS_SQN_LEN, udm_ue->sqn);
ogs_assert(true ==
udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
udm_nudr_dr_build_authentication_subscription,
udm_ue, stream, udm_ue->sqn));
}
@ -233,7 +233,7 @@ bool udm_nudm_ueau_handle_result_confirmation_inform(
udm_ue->auth_event, message->AuthEvent);
ogs_assert(true ==
udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
udm_nudr_dr_build_update_authentication_status,
udm_ue, stream, NULL));
@ -332,7 +332,7 @@ bool udm_nudm_uecm_handle_registration(
message->Amf3GppAccessRegistration);
ogs_assert(true ==
udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
udm_nudr_dr_build_update_amf_context, udm_ue, stream, NULL));
return true;
@ -439,7 +439,7 @@ bool udm_nudm_uecm_handle_registration_update(
}
ogs_assert(true ==
udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
udm_nudr_dr_build_patch_amf_context,
udm_ue, stream, PatchItemList));

View File

@ -151,15 +151,17 @@ void udm_sbi_close(void)
bool udm_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
ogs_assert(service_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
ogs_error("(NF discover) No [%s]",
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
return false;
}
@ -167,25 +169,20 @@ bool udm_sbi_send_request(
}
bool udm_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data),
udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(target_nf_type);
ogs_assert(service_type);
ogs_assert(udm_ue);
ogs_assert(stream);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&udm_ue->sbi, target_nf_type, discovery_option,
&udm_ue->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, udm_ue, data);
if (!xact) {
ogs_error("udm_sbi_discover_and_send() failed");
@ -198,10 +195,7 @@ bool udm_sbi_discover_and_send(
xact->assoc_stream = stream;
if (ogs_sbi_discover_and_send(
&udm_ue->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("udm_sbi_discover_and_send() failed");
ogs_sbi_xact_remove(xact);
ogs_assert(true ==

View File

@ -31,10 +31,10 @@ void udm_sbi_close(void);
bool udm_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data);
bool udm_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data),
udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data);

View File

@ -143,7 +143,8 @@ void udm_ue_state_operational(ogs_fsm_t *s, udm_event_t *e)
CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA)
CASE(OGS_SBI_RESOURCE_NAME_SM_DATA)
ogs_assert(true ==
udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL,
udm_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
udm_nudr_dr_build_query_subscription_provisioned,
udm_ue, stream, message));
break;

View File

@ -455,7 +455,7 @@ void af_state_operational(ogs_fsm_t *s, af_event_t *e)
switch(e->local_id) {
case AF_LOCAL_DISCOVER_AND_SEND:
af_sbi_discover_and_send(e->local.target_nf_type, NULL,
af_sbi_discover_and_send(e->local.service_type, NULL,
e->local.build, e->sess, e->local.data);
break;
case AF_LOCAL_SEND_TO_PCF:

View File

@ -44,7 +44,7 @@ typedef struct af_event_s {
ogs_pkbuf_t *pkbuf;
struct {
OpenAPI_nf_type_e target_nf_type;
ogs_sbi_service_type_e service_type;
void *data;
ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data);
} local;

View File

@ -31,7 +31,8 @@ const char *af_local_get_name(af_local_e id)
return "UNKNOWN_LOCAL";
}
void af_local_discover_and_send(OpenAPI_nf_type_e target_nf_type,
void af_local_discover_and_send(
ogs_sbi_service_type_e service_type,
af_sess_t *sess, void *data,
ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data))
{
@ -44,7 +45,7 @@ void af_local_discover_and_send(OpenAPI_nf_type_e target_nf_type,
e->local_id = AF_LOCAL_DISCOVER_AND_SEND;
e->sess = sess;
e->local.target_nf_type = target_nf_type;
e->local.service_type = service_type;
e->local.data = data;
e->local.build = build;

View File

@ -39,7 +39,8 @@ typedef enum {
const char *af_local_get_name(af_local_e id);
void af_local_discover_and_send(OpenAPI_nf_type_e target_nf_type,
void af_local_discover_and_send(
ogs_sbi_service_type_e service_type,
af_sess_t *sess, void *data,
ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data));

View File

@ -24,7 +24,7 @@ void af_nnrf_handle_nf_discover(
ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg)
{
ogs_sbi_object_t *sbi_object = NULL;
OpenAPI_nf_type_e target_nf_type = 0;
ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
ogs_sbi_discovery_option_t *discovery_option = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
@ -33,8 +33,8 @@ void af_nnrf_handle_nf_discover(
ogs_assert(xact);
sbi_object = xact->sbi_object;
ogs_assert(sbi_object);
target_nf_type = xact->target_nf_type;
ogs_assert(target_nf_type);
service_type = xact->service_type;
ogs_assert(service_type);
discovery_option = xact->discovery_option;
@ -44,10 +44,9 @@ void af_nnrf_handle_nf_discover(
return;
}
ogs_nnrf_handle_nf_discover_search_result(
sbi_object, target_nf_type, discovery_option, SearchResult);
ogs_nnrf_handle_nf_discover_search_result(SearchResult);
ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
ogs_sbi_select_nf(sbi_object, service_type, discovery_option);
ogs_expect(true == af_sbi_send_request(sbi_object, target_nf_type, xact));
ogs_expect(true == af_sbi_send_request(sbi_object, service_type, xact));
}

View File

@ -77,7 +77,6 @@ static int client_cb(int status, 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;
/* To be notified when NF Instances registered/deregistered in NRF
* or when their profile is modified */
@ -90,16 +89,6 @@ int af_sbi_open(void)
/* 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. */
if (ogs_sbi_nf_service_is_available(
OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE)) {
service = ogs_sbi_nf_service_build_default(
nf_instance, OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE);
ogs_assert(service);
ogs_sbi_nf_service_add_version(
service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL);
}
/* Initialize NRF NF Instance */
nf_instance = ogs_sbi_self()->nrf_instance;
if (nf_instance) {
@ -129,15 +118,17 @@ void af_sbi_close(void)
bool af_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data)
{
ogs_sbi_nf_instance_t *nf_instance = NULL;
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type);
ogs_assert(service_type);
nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, service_type);
if (!nf_instance) {
ogs_error("(NF discover) No [%s]",
OpenAPI_nf_type_ToString(target_nf_type));
ogs_sbi_service_type_to_name(service_type));
return false;
}
@ -145,35 +136,26 @@ bool af_sbi_send_request(
}
void af_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data),
af_sess_t *sess, void *data)
{
ogs_sbi_xact_t *xact = NULL;
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
ogs_assert(ogs_sbi_self()->nf_instance);
requester_nf_type = ogs_sbi_self()->nf_instance->nf_type;
ogs_assert(requester_nf_type);
ogs_assert(target_nf_type);
ogs_assert(service_type);
ogs_assert(sess);
ogs_assert(build);
xact = ogs_sbi_xact_add(
&sess->sbi, target_nf_type, discovery_option,
&sess->sbi, service_type, discovery_option,
(ogs_sbi_build_f)build, sess, data);
if (!xact) {
ogs_error("af_sbi_discover_and_send() failed");
return;
}
if (ogs_sbi_discover_and_send(
&sess->sbi,
target_nf_type, requester_nf_type, discovery_option,
client_cb, xact) != true) {
if (ogs_sbi_discover_and_send(xact, client_cb) != true) {
ogs_error("af_sbi_discover_and_send() failed");
return;
}

View File

@ -32,10 +32,10 @@ void af_sbi_close(void);
bool af_sbi_send_request(
ogs_sbi_object_t *sbi_object,
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
void *data);
void af_sbi_discover_and_send(
OpenAPI_nf_type_e target_nf_type,
ogs_sbi_service_type_e service_type,
ogs_sbi_discovery_option_t *discovery_option,
ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data),
af_sess_t *sess, void *data);

View File

@ -625,6 +625,165 @@ static void sbi_message_test6(abts_case *tc, void *data)
ogs_free(content);
}
static void sbi_message_test7(abts_case *tc, void *data)
{
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NRF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NNRF_NFM));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNRF_NFM,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNRF_NFM));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNRF_NFM,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NNRF_NFM));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UDM,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NUDM_SDM));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUDM_SDM,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUDM_SDM));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUDM_SDM,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NUDM_SDM));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_AMF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NAMF_COMM));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NAMF_COMM,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NAMF_COMM));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NAMF_COMM,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NAMF_COMM));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SMF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_AUSF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NAUSF_AUTH));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NAUSF_AUTH,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NAUSF_AUTH));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NAUSF_AUTH,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NAUSF_AUTH));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NEF,
ogs_sbi_service_type_to_nf_type(
OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT,
ogs_sbi_service_type_from_name(
OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_PCF,
ogs_sbi_service_type_to_nf_type(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL,
ogs_sbi_service_type_to_name(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL,
ogs_sbi_service_type_from_name(
OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SMSF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSMSF_SMS));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSMSF_SMS,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSMSF_SMS));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSMSF_SMS,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSMSF_SMS));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NSSF,
ogs_sbi_service_type_to_nf_type(
OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UDR,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NUDR_DR));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUDR_DR,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUDR_DR));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUDR_DR,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NUDR_DR));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_LMF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NLMF_LOC));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NLMF_LOC,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NLMF_LOC));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NLMF_LOC,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NLMF_LOC));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_5G_EIR,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_N5G_EIR_EIC,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_N5G_EIR_EIC));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_BSF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_CHF,
ogs_sbi_service_type_to_nf_type(
OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL,
ogs_sbi_service_type_to_name(
OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL,
ogs_sbi_service_type_from_name(
OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NWDAF,
ogs_sbi_service_type_to_nf_type(
OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION,
ogs_sbi_service_type_to_name(
OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION,
ogs_sbi_service_type_from_name(
OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_GMLC,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NGMLC_LOC));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NGMLC_LOC,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NGMLC_LOC));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NGMLC_LOC,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NGMLC_LOC));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UCMF,
ogs_sbi_service_type_to_nf_type(
OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING,
ogs_sbi_service_type_from_name(
OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_HSS,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NHSS_SDM));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NHSS_SDM,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NHSS_SDM));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NHSS_SDM,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NHSS_SDM));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SEPP,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SOR_AF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSORAF_SOR));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSORAF_SOR,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSORAF_SOR));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSORAF_SOR,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSORAF_SOR));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SPAF,
ogs_sbi_service_type_to_nf_type(
OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET,
ogs_sbi_service_type_to_name(
OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET,
ogs_sbi_service_type_from_name(
OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UDSF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NUDSF_DR));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUDSF_DR,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUDSF_DR));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUDSF_DR,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NUDSF_DR));
ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NSSAAF,
ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA));
ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA,
ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA));
ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA,
ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA));
}
abts_suite *test_sbi_message(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@ -635,6 +794,7 @@ abts_suite *test_sbi_message(abts_suite *suite)
abts_run_test(suite, sbi_message_test4, NULL);
abts_run_test(suite, sbi_message_test5, NULL);
abts_run_test(suite, sbi_message_test6, NULL);
abts_run_test(suite, sbi_message_test7, NULL);
return suite;
}

View File

@ -303,7 +303,9 @@ static void test1_func(abts_case *tc, void *data)
af_sess->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */
@ -1027,7 +1029,9 @@ static void test2_func(abts_case *tc, void *data)
af_sess->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */
@ -1461,7 +1465,9 @@ static void test3_func(abts_case *tc, void *data)
af_sess->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */
@ -1970,7 +1976,9 @@ static void test4_func(abts_case *tc, void *data)
af_sess->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */
@ -2565,7 +2573,9 @@ static void test5_func(abts_case *tc, void *data)
af_sess->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */
@ -3263,7 +3273,9 @@ static void test6_func(abts_case *tc, void *data)
af_sess1->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess1->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess1, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess1, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */
@ -3329,7 +3341,9 @@ static void test6_func(abts_case *tc, void *data)
af_sess2->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess2->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess2, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess2, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */
@ -3801,7 +3815,9 @@ static void test7_func(abts_case *tc, void *data)
af_sess->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */

View File

@ -303,7 +303,9 @@ static void test1_func(abts_case *tc, void *data)
af_sess->dnn = ogs_strdup(sess->dnn);
ogs_assert(af_sess->dnn);
af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL,
af_local_discover_and_send(
OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT,
af_sess, NULL,
af_nbsf_management_build_discover);
/* Wait for PCF-Discovery */