Compare commits

..

No commits in common. "4c00edd839c279963f2d123904bc35771b6e5b25" and "f960047ccb1007f233775a6a5f2cdbe6f08a607f" have entirely different histories.

71 changed files with 296 additions and 1003 deletions

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/amf.log
file: @localstatedir@/log/open5gs/amf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/ausf.log
file: @localstatedir@/log/open5gs/ausf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/bsf.log
file: @localstatedir@/log/open5gs/bsf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,7 +1,6 @@
db_uri: mongodb://localhost/open5gs
logger:
file:
path: @localstatedir@/log/open5gs/hss.log
file: @localstatedir@/log/open5gs/hss.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/mme.log
file: @localstatedir@/log/open5gs/mme.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/nrf.log
file: @localstatedir@/log/open5gs/nrf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/nssf.log
file: @localstatedir@/log/open5gs/nssf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,7 +1,6 @@
db_uri: mongodb://localhost/open5gs
logger:
file:
path: @localstatedir@/log/open5gs/pcf.log
file: @localstatedir@/log/open5gs/pcf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,7 +1,6 @@
db_uri: mongodb://localhost/open5gs
logger:
file:
path: @localstatedir@/log/open5gs/pcrf.log
file: @localstatedir@/log/open5gs/pcrf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/scp.log
file: @localstatedir@/log/open5gs/scp.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/sepp1.log
file: @localstatedir@/log/open5gs/sepp1.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/sepp2.log
file: @localstatedir@/log/open5gs/sepp2.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/sgwc.log
file: @localstatedir@/log/open5gs/sgwc.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/sgwu.log
file: @localstatedir@/log/open5gs/sgwu.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/smf.log
file: @localstatedir@/log/open5gs/smf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/udm.log
file: @localstatedir@/log/open5gs/udm.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,7 +1,6 @@
db_uri: mongodb://localhost/open5gs
logger:
file:
path: @localstatedir@/log/open5gs/udr.log
file: @localstatedir@/log/open5gs/udr.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -1,6 +1,5 @@
logger:
file:
path: @localstatedir@/log/open5gs/upf.log
file: @localstatedir@/log/open5gs/upf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:

View File

@ -5,14 +5,6 @@ Name=ogstun
Address=10.45.0.1/16
Address=2001:db8:cafe::1/48
[Route]
Gateway=0.0.0.0
Destination=10.45.0.0/16
[Route]
Gateway=::
Destination=2001:db8:cafe::0/48
[Link]
MTUBytes=1400
RequiredForOnline=false

30
debian/changelog vendored
View File

@ -1,33 +1,3 @@
open5gs (2.7.1) unstable; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:21:46 +0900
open5gs (2.7.1~mantic) mantic; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:18:53 +0900
open5gs (2.7.1~bionic) bionic; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:16:21 +0900
open5gs (2.7.1~jammy) jammy; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:11:30 +0900
open5gs (2.7.1~focal) focal; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:08:46 +0900
open5gs (2.7.0) unstable; urgency=medium
* 5G Roaming with SEPP

View File

@ -428,34 +428,6 @@ $ sudo systemctl restart open5gs-amfd
$ sudo systemctl restart open5gs-upfd
```
#### Configure logging
The Open5GS components log to `/var/log/open5gs/*.log` and to `stderr` by
default.
##### Avoid duplicate timestamps in journalctl
Open5GS adds timestamps to each log line in the log file, and on `stderr`. If
you run Open5GS with systemd and prefer looking at the logs with `journalctl`,
then each line will have two timestamps. To fix this, disable the timestamp for
`stderr` with the following configuration change:
```diff
diff --git a/configs/open5gs/mme.yaml.in b/configs/open5gs/mme.yaml.in
index 87c251b9d..599032b8a 100644
--- a/configs/open5gs/mme.yaml.in
+++ b/configs/open5gs/mme.yaml.in
@@ -1,6 +1,9 @@
logger:
+ default:
+ timestamp: false
file:
path: /var/log/open5gs/mme.log
+ timestamp: true
# level: info # fatal|error|warn|info(default)|debug|trace
global:
```
#### Register Subscriber Information
---

View File

@ -169,8 +169,7 @@ index a70143f08..e0dba560c 100644
+++ b/configs/open5gs/amf.yaml.in
@@ -1,6 +1,6 @@
logger:
file:
path: @localstatedir@/log/open5gs/amf.log
file: @localstatedir@/log/open5gs/amf.log
-# level: info # fatal|error|warn|info(default)|debug|trace
+ level: debug

View File

@ -485,8 +485,7 @@ index a70143f08..e0dba560c 100644
+++ b/configs/open5gs/amf.yaml.in
@@ -1,6 +1,6 @@
logger:
file:
path: @localstatedir@/log/open5gs/amf.log
file: @localstatedir@/log/open5gs/amf.log
-# level: info # fatal|error|warn|info(default)|debug|trace
+ level: debug

View File

@ -92,8 +92,7 @@ NRF shall follow TS23.003(28.3.2.3.2 Format of NRF FQDN) for routing.
```bash
$ sh -c 'cat << EOF > ./install/etc/open5gs/h-nrf.yaml
logger:
file:
path: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/h-nrf.log
file: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/h-nrf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
@ -117,8 +116,7 @@ EOF'
```bash
$ sh -c 'cat << EOF > ./install/etc/open5gs/h-scp.yaml
logger:
file:
path: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/h-scp.log
file: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/h-scp.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
@ -304,8 +302,7 @@ $ diff -u ./install/etc/open5gs/pcf.yaml.old ./install/etc/open5gs/pcf.yaml
@@ -1,4 +1,3 @@
-db_uri: mongodb://localhost/open5gs
logger:
file:
path: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/pcf.log
file: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/pcf.log
# level: info # fatal|error|warn|info(default)|debug|trace
@@ -22,6 +21,29 @@
server:
@ -649,8 +646,7 @@ For now we will set up SEPP without using TLS.
```bash
$ sh -c 'cat << EOF > ./install/etc/open5gs/sepp.yaml
logger:
file:
path: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sepp.log
file: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sepp.log
# level: info # fatal|error|warn|info(default)|debug|trace
max:
@ -970,8 +966,7 @@ For now we will set up SEPP without using TLS.
```bash
$ sh -c 'cat << EOF > ./install/etc/open5gs/sepp.yaml
logger:
file:
path: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sepp.log
file: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sepp.log
# level: info # fatal|error|warn|info(default)|debug|trace
max:
@ -1291,8 +1286,7 @@ For now we will set up SEPP without using TLS.
```bash
$ sh -c 'cat << EOF > ./install/etc/open5gs/sepp.yaml
logger:
file:
path: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sepp.log
file: /home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sepp.log
# level: info # fatal|error|warn|info(default)|debug|trace
max:

View File

@ -25,8 +25,7 @@ Example of sgw.yaml to use this feature:
```
logger:
file:
path: /var/log/open5gs/sgw.log
file: /var/log/open5gs/sgw.log
level: debug
parameter:

View File

@ -1,15 +0,0 @@
---
title: "v2.7.1 - Bug Fixed"
date: 2024-04-19 21:23:00 +0900
categories:
- Release
tags:
- News
- Release
head_inline: "<style> ul { padding-bottom: 1em; } .blue { color: blue; }</style>"
---
See [Release Note](https://github.com/open5gs/open5gs/releases/tag/v2.7.1)
Download -- [v2.7.1.tar.gz](https://github.com/open5gs/open5gs/archive/v2.7.1.tar.gz)
{: .notice--info}

View File

@ -36,15 +36,10 @@ typedef struct ogs_app_context_s {
const char *db_uri;
struct {
ogs_log_ts_e timestamp;
} logger_default;
struct {
const char *file;
const char *level;
const char *domain;
ogs_log_ts_e timestamp;
} logger;
ogs_queue_t *queue;

View File

@ -114,9 +114,6 @@ int ogs_app_initialize(
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
ogs_log_set_timestamp(ogs_app()->logger_default.timestamp,
ogs_app()->logger.timestamp);
/**************************************************************************
* Stage 5 : Setup Database Module
*/
@ -257,57 +254,6 @@ static int context_validation(void)
return OGS_OK;
}
static void parse_config_logger_file(ogs_yaml_iter_t *logger_iter,
const char *logger_key)
{
ogs_yaml_iter_t iter;
/* Legacy format:
* logger:
* file: /var/log/open5gs/mme.log */
if (!strcmp(logger_key, "file") && ogs_yaml_iter_has_value(logger_iter)) {
ogs_app()->logger.file = ogs_yaml_iter_value(logger_iter);
ogs_warn("Please change the configuration file as below.");
ogs_log_print(OGS_LOG_WARN, "\n<OLD Format>\n");
ogs_log_print(OGS_LOG_WARN, "logger:\n");
ogs_log_print(OGS_LOG_WARN, " file: %s\n", ogs_app()->logger.file);
ogs_log_print(OGS_LOG_WARN, "\n<NEW Format>\n");
ogs_log_print(OGS_LOG_WARN, "logger:\n");
ogs_log_print(OGS_LOG_WARN, " file:\n");
ogs_log_print(OGS_LOG_WARN, " path: %s\n", ogs_app()->logger.file);
ogs_log_print(OGS_LOG_WARN, "\n\n\n");
return;
}
/* Current format:
* logger:
* default:
* timestamp: false
* file:
* path: /var/log/open5gs/mme.log
* timestamp: true */
ogs_yaml_iter_recurse(logger_iter, &iter);
while (ogs_yaml_iter_next(&iter)) {
const char *key = ogs_yaml_iter_key(&iter);
ogs_assert(key);
if (!strcmp(key, "timestamp")) {
ogs_log_ts_e ts = ogs_yaml_iter_bool(&iter)
? OGS_LOG_TS_ENABLED
: OGS_LOG_TS_DISABLED;
if (!strcmp(logger_key, "default")) {
ogs_app()->logger_default.timestamp = ts;
} else if (!strcmp(logger_key, "file")) {
ogs_app()->logger.timestamp = ts;
}
} else if (!strcmp(key, "path")) {
if (!strcmp(logger_key, "file")) {
ogs_app()->logger.file = ogs_yaml_iter_value(&iter);
}
}
}
}
static int parse_config(void)
{
int rv;
@ -332,8 +278,9 @@ static int parse_config(void)
while (ogs_yaml_iter_next(&logger_iter)) {
const char *logger_key = ogs_yaml_iter_key(&logger_iter);
ogs_assert(logger_key);
parse_config_logger_file(&logger_iter, logger_key);
if (!strcmp(logger_key, "level")) {
if (!strcmp(logger_key, "file")) {
ogs_app()->logger.file = ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "level")) {
ogs_app()->logger.level =
ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "domain")) {

View File

@ -178,34 +178,6 @@ const char *ogs_yaml_iter_value(ogs_yaml_iter_t *iter)
return NULL;
}
int ogs_yaml_iter_has_value(ogs_yaml_iter_t *iter)
{
ogs_assert(iter);
ogs_assert(iter->document);
ogs_assert(iter->node);
if (iter->node->type == YAML_SCALAR_NODE) {
return 1;
} else if (iter->node->type == YAML_MAPPING_NODE) {
yaml_node_t *node = NULL;
ogs_assert(iter->pair);
node = yaml_document_get_node(iter->document, iter->pair->value);
ogs_assert(node);
return node->type == YAML_SCALAR_NODE;
} else if (iter->node->type == YAML_SEQUENCE_NODE) {
yaml_node_t *node = NULL;
ogs_assert(iter->item);
node = yaml_document_get_node(iter->document, *iter->item);
ogs_assert(node);
return node->type == YAML_SCALAR_NODE;
}
ogs_assert_if_reached();
return 0;
}
int ogs_yaml_iter_bool(ogs_yaml_iter_t *iter)
{
const char *v = ogs_yaml_iter_value(iter);

View File

@ -59,7 +59,6 @@ void ogs_yaml_iter_recurse(ogs_yaml_iter_t *parent, ogs_yaml_iter_t *iter);
int ogs_yaml_iter_type(ogs_yaml_iter_t *iter);
const char *ogs_yaml_iter_key(ogs_yaml_iter_t *iter);
const char *ogs_yaml_iter_value(ogs_yaml_iter_t *iter);
int ogs_yaml_iter_has_value(ogs_yaml_iter_t *iter);
int ogs_yaml_iter_bool(ogs_yaml_iter_t *iter);
#ifdef __cplusplus

View File

@ -340,28 +340,6 @@ void ogs_log_set_mask_level(const char *_mask, ogs_log_level_e level)
}
}
void ogs_log_set_timestamp(ogs_log_ts_e ts_default, ogs_log_ts_e ts_file)
{
ogs_log_t *log;
if (ts_default == OGS_LOG_TS_UNSET)
ts_default = OGS_LOG_TS_ENABLED;
if (ts_file == OGS_LOG_TS_UNSET)
ts_file = ts_default;
ogs_list_for_each(&log_list, log) {
switch (log->type) {
case OGS_LOG_FILE_TYPE:
log->print.timestamp = (ts_file == OGS_LOG_TS_ENABLED);
break;
default:
log->print.timestamp = (ts_default == OGS_LOG_TS_ENABLED);
break;
}
}
}
static ogs_log_level_e ogs_log_level_from_string(const char *string)
{
ogs_log_level_e level = OGS_ERROR;

View File

@ -64,12 +64,6 @@ typedef enum {
OGS_LOG_FULL = OGS_LOG_TRACE,
} ogs_log_level_e;
typedef enum {
OGS_LOG_TS_UNSET,
OGS_LOG_TS_ENABLED,
OGS_LOG_TS_DISABLED,
} ogs_log_ts_e;
typedef struct ogs_log_s ogs_log_t;
typedef struct ogs_log_domain_s ogs_log_domain_t;
@ -96,7 +90,6 @@ void ogs_log_install_domain(int *domain_id,
int ogs_log_config_domain(const char *domain, const char *level);
void ogs_log_set_mask_level(const char *mask, ogs_log_level_e level);
void ogs_log_set_timestamp(ogs_log_ts_e ts_default, ogs_log_ts_e ts_file);
void ogs_log_vprintf(ogs_log_level_e level, int id,
ogs_err_t err, const char *file, int line, const char *func,

View File

@ -2493,26 +2493,12 @@ ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_add(void)
return subscription_data;
}
void ogs_sbi_subscription_data_set_resource_uri(
ogs_sbi_subscription_data_t *subscription_data, char *resource_uri)
{
ogs_assert(subscription_data);
ogs_assert(resource_uri);
if (subscription_data->resource_uri)
ogs_free(subscription_data->resource_uri);
subscription_data->resource_uri = ogs_strdup(resource_uri);
ogs_assert(subscription_data->resource_uri);
}
void ogs_sbi_subscription_data_set_id(
ogs_sbi_subscription_data_t *subscription_data, char *id)
{
ogs_assert(subscription_data);
ogs_assert(id);
if (subscription_data->id)
ogs_free(subscription_data->id);
subscription_data->id = ogs_strdup(id);
ogs_assert(subscription_data->id);
}
@ -2530,9 +2516,6 @@ void ogs_sbi_subscription_data_remove(
if (subscription_data->notification_uri)
ogs_free(subscription_data->notification_uri);
if (subscription_data->resource_uri)
ogs_free(subscription_data->resource_uri);
if (subscription_data->req_nf_instance_id)
ogs_free(subscription_data->req_nf_instance_id);

View File

@ -286,7 +286,6 @@ typedef struct ogs_sbi_subscription_data_s {
OpenAPI_nf_type_e req_nf_type; /* reqNfType */
OpenAPI_nf_status_e nf_status;
char *notification_uri;
char *resource_uri;
struct {
OpenAPI_nf_type_e nf_type; /* nfType */
@ -296,7 +295,7 @@ typedef struct ogs_sbi_subscription_data_s {
uint64_t requester_features;
uint64_t nrf_supported_features;
void *client;
void *client; /* only used in SERVER */
} ogs_sbi_subscription_data_t;
typedef struct ogs_sbi_smf_info_s {
@ -516,8 +515,6 @@ void ogs_sbi_subscription_spec_remove(
void ogs_sbi_subscription_spec_remove_all(void);
ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_add(void);
void ogs_sbi_subscription_data_set_resource_uri(
ogs_sbi_subscription_data_t *subscription_data, char *resource_uri);
void ogs_sbi_subscription_data_set_id(
ogs_sbi_subscription_data_t *subscription_data, char *id);
void ogs_sbi_subscription_data_remove(

View File

@ -1712,7 +1712,11 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_update(
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PATCH;
message.h.uri = subscription_data->resource_uri;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS;
message.h.resource.component[1] = subscription_data->id;
message.http.content_type = (char *)OGS_SBI_CONTENT_PATCH_TYPE;
@ -1767,7 +1771,11 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_unsubscribe(
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.uri = subscription_data->resource_uri;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS;
message.h.resource.component[1] = subscription_data->id;
message.http.custom.callback =
(char *)OGS_SBI_CALLBACK_NNRF_NFMANAGEMENT_NF_STATUS_NOTIFY;

View File

@ -824,17 +824,6 @@ void ogs_nnrf_nfm_handle_nf_status_subscribe(
{
OpenAPI_subscription_data_t *SubscriptionData = NULL;
int rv;
ogs_sbi_message_t message;
ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
ogs_assert(recvmsg);
ogs_assert(subscription_data);
@ -844,62 +833,44 @@ void ogs_nnrf_nfm_handle_nf_status_subscribe(
return;
}
if (!recvmsg->http.location) {
ogs_error("No http.location");
return;
}
if (recvmsg->http.location) {
int rv;
ogs_sbi_message_t message;
ogs_sbi_header_t header;
memset(&header, 0, sizeof(header));
header.uri = recvmsg->http.location;
rv = ogs_sbi_parse_header(&message, &header);
if (rv != OGS_OK) {
ogs_error("Cannot parse http.location [%s]",
recvmsg->http.location);
return;
}
if (!message.h.resource.component[1]) {
ogs_error("No Subscription ID [%s]", recvmsg->http.location);
ogs_sbi_header_free(&header);
return;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("Invalid URI [%s]", header.uri);
ogs_sbi_header_free(&header);
return;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("%s: ogs_sbi_client_add()", OGS_FUNC);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("%s: ogs_sbi_client_add() failed", OGS_FUNC);
ogs_sbi_header_free(&header);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
memset(&header, 0, sizeof(header));
header.uri = recvmsg->http.location;
rv = ogs_sbi_parse_header(&message, &header);
if (rv != OGS_OK) {
ogs_error("Cannot parse http.location [%s]",
recvmsg->http.location);
return;
}
if (!message.h.resource.component[1]) {
ogs_error("No Subscription ID [%s]", recvmsg->http.location);
ogs_sbi_header_free(&header);
return;
}
ogs_sbi_subscription_data_set_id(
subscription_data, message.h.resource.component[1]);
ogs_sbi_header_free(&header);
} else if (SubscriptionData->subscription_id) {
/*
* For compatibility with v2.5.x and lower versions
*
* Deprecated : It will be removed soon.
*/
ogs_sbi_subscription_data_set_id(
subscription_data, SubscriptionData->subscription_id);
} else {
ogs_error("No Subscription ID");
return;
}
OGS_SBI_SETUP_CLIENT(subscription_data, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
ogs_sbi_subscription_data_set_resource_uri(
subscription_data, header.uri);
ogs_sbi_subscription_data_set_id(
subscription_data, message.h.resource.component[1]);
ogs_sbi_header_free(&header);
/* SBI Features */
if (SubscriptionData->nrf_supported_features) {

View File

@ -313,11 +313,6 @@ int ogs_sbi_discover_and_send(ogs_sbi_xact_t *xact)
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
if (!client) {
ogs_fatal("No Client : [%s]", request->h.uri);
ogs_assert_if_reached();
}
}
if (scp_client) {

View File

@ -16,7 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
project('open5gs', 'c', 'cpp',
version : '2.7.1',
version : '2.7.0',
license : 'AGPL-3.0-or-later',
meson_version : '>= 0.43.0',
default_options : [
@ -25,7 +25,7 @@ project('open5gs', 'c', 'cpp',
],
)
libogslib_version = '2.7.1'
libogslib_version = '2.7.0'
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))

View File

@ -1676,17 +1676,13 @@ void amf_ue_remove(amf_ue_t *amf_ue)
/* Clear SubscribedInfo */
amf_clear_subscribed_info(amf_ue);
PCF_AM_POLICY_CLEAR(amf_ue);
if (amf_ue->policy_association.client)
ogs_sbi_client_remove(amf_ue->policy_association.client);
if (amf_ue->policy_association_id)
ogs_free(amf_ue->policy_association_id);
if (amf_ue->data_change_subscription_id)
ogs_free(amf_ue->data_change_subscription_id);
UDM_SDM_CLEAR(amf_ue);
if (amf_ue->data_change_subscription.client)
ogs_sbi_client_remove(amf_ue->data_change_subscription.client);
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
if (amf_ue->confirmation_for_5g_aka.client)
ogs_sbi_client_remove(amf_ue->confirmation_for_5g_aka.client);
if (amf_ue->confirmation_url_for_5g_aka)
ogs_free(amf_ue->confirmation_url_for_5g_aka);
/* Free UeRadioCapability */
OGS_ASN_CLEAR_DATA(&amf_ue->ueRadioCapability);
@ -2253,10 +2249,8 @@ void amf_sess_remove(amf_sess_t *sess)
ogs_list_count(&sess->sbi.xact_list));
ogs_sbi_object_free(&sess->sbi);
CLEAR_SESSION_CONTEXT(sess);
if (sess->sm_context.client)
ogs_sbi_client_remove(sess->sm_context.client);
if (sess->sm_context_ref)
ogs_free(sess->sm_context_ref);
if (sess->payload_container)
ogs_pkbuf_free(sess->payload_container);

View File

@ -290,33 +290,13 @@ struct amf_ue_s {
/* PCF sends the RESPONSE
* of [POST] /npcf-am-polocy-control/v1/policies */
#define PCF_AM_POLICY_ASSOCIATED(__aMF) \
((__aMF) && ((__aMF)->policy_association.id))
((__aMF) && ((__aMF)->policy_association_id))
#define PCF_AM_POLICY_CLEAR(__aMF) \
do { \
ogs_assert((__aMF)); \
if ((__aMF)->policy_association.resource_uri) \
ogs_free((__aMF)->policy_association.resource_uri); \
(__aMF)->policy_association.resource_uri = NULL; \
if ((__aMF)->policy_association.id) \
ogs_free((__aMF)->policy_association.id); \
(__aMF)->policy_association.id = NULL; \
} while(0)
#define PCF_AM_POLICY_STORE(__aMF, __rESOURCE_URI, __iD) \
do { \
ogs_assert((__aMF)); \
ogs_assert((__rESOURCE_URI)); \
ogs_assert((__iD)); \
PCF_AM_POLICY_CLEAR(__aMF); \
(__aMF)->policy_association.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aMF)->policy_association.resource_uri); \
(__aMF)->policy_association.id = ogs_strdup(__iD); \
ogs_assert((__aMF)->policy_association.id); \
} while(0)
struct {
char *resource_uri;
char *id;
ogs_sbi_client_t *client;
} policy_association;
OGS_MEM_CLEAR((__aMF)->policy_association_id);
#define PCF_AM_POLICY_STORE(__aMF, __iD) \
OGS_STRING_DUP((__aMF)->policy_association_id, __iD);
char *policy_association_id;
/* 5GMM Capability */
struct {
@ -342,27 +322,7 @@ struct amf_ue_s {
/* Security Context */
ogs_nas_ue_security_capability_t ue_security_capability;
ogs_nas_ue_network_capability_t ue_network_capability;
#define CHECK_5G_AKA_CONFIRMATION(__aMF) \
((__aMF) && ((__aMF)->confirmation_for_5g_aka.resource_uri))
#define STORE_5G_AKA_CONFIRMATION(__aMF, __rESOURCE_URI) \
do { \
ogs_assert((__aMF)); \
CLEAR_5G_AKA_CONFIRMATION(__aMF); \
(__aMF)->confirmation_for_5g_aka.resource_uri = \
ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aMF)->confirmation_for_5g_aka.resource_uri); \
} while(0)
#define CLEAR_5G_AKA_CONFIRMATION(__aMF) \
do { \
ogs_assert((__aMF)); \
if ((__aMF)->confirmation_for_5g_aka.resource_uri) \
ogs_free((__aMF)->confirmation_for_5g_aka.resource_uri); \
(__aMF)->confirmation_for_5g_aka.resource_uri = NULL; \
} while(0)
struct {
char *resource_uri;
ogs_sbi_client_t *client;
} confirmation_for_5g_aka;
char *confirmation_url_for_5g_aka;
uint8_t rand[OGS_RAND_LEN];
uint8_t autn[OGS_AUTN_LEN];
uint8_t xres_star[OGS_MAX_RES_LEN];
@ -508,34 +468,8 @@ struct amf_ue_s {
/* SubscriptionId of Subscription to Data Change Notification to UDM */
#define UDM_SDM_SUBSCRIBED(__aMF) \
((__aMF) && ((__aMF)->data_change_subscription.id))
#define UDM_SDM_CLEAR(__aMF) \
do { \
ogs_assert((__aMF)); \
if ((__aMF)->data_change_subscription.resource_uri) \
ogs_free((__aMF)->data_change_subscription.resource_uri); \
(__aMF)->data_change_subscription.resource_uri = NULL; \
if ((__aMF)->data_change_subscription.id) \
ogs_free((__aMF)->data_change_subscription.id); \
(__aMF)->data_change_subscription.id = NULL; \
} while(0)
#define UDM_SDM_STORE(__aMF, __rESOURCE_URI, __iD) \
do { \
ogs_assert((__aMF)); \
ogs_assert((__rESOURCE_URI)); \
ogs_assert((__iD)); \
UDM_SDM_CLEAR(__aMF); \
(__aMF)->data_change_subscription.resource_uri = \
ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aMF)->data_change_subscription.resource_uri); \
(__aMF)->data_change_subscription.id = ogs_strdup(__iD); \
ogs_assert((__aMF)->data_change_subscription.id); \
} while(0)
struct {
char *resource_uri;
char *id;
ogs_sbi_client_t *client;
} data_change_subscription;
((__aMF) && ((__aMF)->data_change_subscription_id))
char *data_change_subscription_id;
struct {
/*
@ -565,37 +499,18 @@ typedef struct amf_sess_s {
uint8_t pti; /* Procedure Trasaction Identity */
#define SESSION_CONTEXT_IN_SMF(__sESS) \
((__sESS) && (__sESS)->sm_context.ref)
#define STORE_SESSION_CONTEXT(__sESS, __rESOURCE_URI, __rEF) \
((__sESS) && (__sESS)->sm_context_ref)
#define CLEAR_SM_CONTEXT_REF(__sESS) \
do { \
ogs_assert(__sESS); \
ogs_assert(__rESOURCE_URI); \
ogs_assert(__rEF); \
CLEAR_SESSION_CONTEXT(__sESS); \
(__sESS)->sm_context.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__sESS)->sm_context.resource_uri); \
(__sESS)->sm_context.ref = ogs_strdup(__rEF); \
ogs_assert((__sESS)->sm_context.ref); \
} while(0);
#define CLEAR_SESSION_CONTEXT(__sESS) \
do { \
ogs_assert(__sESS); \
if ((__sESS)->sm_context.ref) \
ogs_free((__sESS)->sm_context.ref); \
(__sESS)->sm_context.ref = NULL; \
if ((__sESS)->sm_context.resource_uri) \
ogs_free((__sESS)->sm_context.resource_uri); \
(__sESS)->sm_context.resource_uri = NULL; \
ogs_assert((__sESS)->sm_context_ref); \
ogs_free((__sESS)->sm_context_ref); \
(__sESS)->sm_context_ref = NULL; \
} while(0);
/* SMF sends the RESPONSE
* of [POST] /nsmf-pdusession/v1/sm-contexts */
struct {
char *resource_uri;
char *ref;
ogs_sbi_client_t *client;
} sm_context;
char *sm_context_ref;
bool pdu_session_release_complete_received;
bool pdu_session_resource_release_response_received;

View File

@ -1283,11 +1283,9 @@ int gmm_handle_ul_nas_transport(ran_ue_t *ran_ue, amf_ue_t *amf_ue,
sess->s_nssai.sd.v = selected_slice->s_nssai.sd.v;
ogs_info("UE SUPI[%s] DNN[%s] S_NSSAI[SST:%d SD:0x%x] "
"smContextRef[%s] smContextResourceURI[%s]",
"smContextRef [%s]",
amf_ue->supi, sess->dnn, sess->s_nssai.sst, sess->s_nssai.sd.v,
sess->sm_context.ref ? sess->sm_context.ref : "NULL",
sess->sm_context.resource_uri ?
sess->sm_context.resource_uri : "NULL");
sess->sm_context_ref ? sess->sm_context_ref : "NULL");
if (!SESSION_CONTEXT_IN_SMF(sess)) {
ogs_sbi_nf_instance_t *nf_instance = NULL;
@ -1437,7 +1435,7 @@ int gmm_handle_ul_nas_transport(ran_ue_t *ran_ue, amf_ue_t *amf_ue,
sess->pdu_session_release_complete_received = true;
if (sess->pdu_session_resource_release_response_received ==
true)
CLEAR_SESSION_CONTEXT(sess);
CLEAR_SM_CONTEXT_REF(sess);
break;
default:
break;
@ -1678,7 +1676,7 @@ static void amf_namf_comm_decode_ue_session_context_list(
sess = amf_sess_add(amf_ue, PduSessionContext->pdu_session_id);
ogs_assert(sess);
sess->sm_context.ref = PduSessionContext->sm_context_ref;
sess->sm_context_ref = PduSessionContext->sm_context_ref;
if (PduSessionContext->s_nssai) {
memset(&sess->s_nssai, 0, sizeof(sess->s_nssai));

View File

@ -274,7 +274,9 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
break;
CASE(OGS_SBI_HTTP_METHOD_DELETE)
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
if (amf_ue->confirmation_url_for_5g_aka)
ogs_free(amf_ue->confirmation_url_for_5g_aka);
amf_ue->confirmation_url_for_5g_aka = NULL;
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) {
@ -376,7 +378,10 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
*/
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) {
UDM_SDM_CLEAR(amf_ue);
if (amf_ue->data_change_subscription_id) {
ogs_free(amf_ue->data_change_subscription_id);
amf_ue->data_change_subscription_id = NULL;
}
r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL,
@ -442,7 +447,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) {
if (CHECK_5G_AKA_CONFIRMATION(amf_ue)) {
if (amf_ue->confirmation_url_for_5g_aka) {
r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH,
NULL,
@ -852,7 +857,9 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
break;
CASE(OGS_SBI_HTTP_METHOD_DELETE)
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
if (amf_ue->confirmation_url_for_5g_aka)
ogs_free(amf_ue->confirmation_url_for_5g_aka);
amf_ue->confirmation_url_for_5g_aka = NULL;
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) {
@ -960,7 +967,10 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
AMF_NETWORK_INITIATED_IMPLICIT_DE_REGISTERED ||
state ==
AMF_NETWORK_INITIATED_EXPLICIT_DE_REGISTERED) {
UDM_SDM_CLEAR(amf_ue);
if (amf_ue->data_change_subscription_id) {
ogs_free(amf_ue->data_change_subscription_id);
amf_ue->data_change_subscription_id = NULL;
}
r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL,
@ -1034,7 +1044,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
state ==
AMF_NETWORK_INITIATED_EXPLICIT_DE_REGISTERED) {
if (amf_ue->confirmation_for_5g_aka.resource_uri) {
if (amf_ue->confirmation_url_for_5g_aka) {
r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH,
NULL,

View File

@ -246,7 +246,7 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
amf_ue->supi, sess->psi,
N1N2MessageTransferReqData->
n1n2_failure_txf_notif_uri);
return OGS_ERROR;
return OGS_ERROR;;
}
client = ogs_sbi_client_find(
@ -287,7 +287,7 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
header.resource.component[1] = amf_ue->supi;
header.resource.component[2] =
(char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES;
header.resource.component[3] = sess->sm_context.ref;
header.resource.component[3] = sess->sm_context_ref;
sendmsg.http.location = ogs_sbi_server_uri(server, &header);
@ -349,12 +349,13 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
header.resource.component[1] = amf_ue->supi;
header.resource.component[2] =
(char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES;
header.resource.component[3] = sess->sm_context.ref;
header.resource.component[3] = sess->sm_context_ref;
sendmsg.http.location = ogs_sbi_server_uri(server, &header);
/* Store Paging Info */
AMF_SESS_STORE_PAGING_INFO(sess, sendmsg.http.location, NULL);
AMF_SESS_STORE_PAGING_INFO(
sess, sendmsg.http.location, NULL);
/* Store 5GSM Message */
AMF_SESS_STORE_5GSM_MESSAGE(sess,
@ -423,12 +424,13 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
header.resource.component[1] = amf_ue->supi;
header.resource.component[2] =
(char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES;
header.resource.component[3] = sess->sm_context.ref;
header.resource.component[3] = sess->sm_context_ref;
sendmsg.http.location = ogs_sbi_server_uri(server, &header);
/* Store Paging Info */
AMF_SESS_STORE_PAGING_INFO(sess, sendmsg.http.location, NULL);
AMF_SESS_STORE_PAGING_INFO(
sess, sendmsg.http.location, NULL);
/* Store 5GSM Message */
AMF_SESS_STORE_5GSM_MESSAGE(sess,
@ -1172,7 +1174,7 @@ static OpenAPI_list_t *amf_namf_comm_encode_ue_session_context_list(amf_ue_t *am
ogs_assert(sNSSAI);
PduSessionContext->pdu_session_id = sess->psi;
PduSessionContext->sm_context_ref = sess->sm_context.ref;
PduSessionContext->sm_context_ref = sess->sm_context_ref;
sNSSAI->sst = sess->s_nssai.sst;
sNSSAI->sd = ogs_s_nssai_sd_to_string(sess->s_nssai.sd);

View File

@ -87,11 +87,11 @@ ogs_sbi_request_t *amf_nausf_auth_build_authenticate_delete(
ogs_sbi_request_t *request = NULL;
ogs_assert(amf_ue);
ogs_assert(amf_ue->confirmation_for_5g_aka.resource_uri);
ogs_assert(amf_ue->confirmation_url_for_5g_aka);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.uri = amf_ue->confirmation_for_5g_aka.resource_uri;
message.h.uri = amf_ue->confirmation_url_for_5g_aka;
request = ogs_sbi_build_request(&message);
ogs_expect(request);
@ -110,11 +110,11 @@ ogs_sbi_request_t *amf_nausf_auth_build_authenticate_confirmation(
OpenAPI_confirmation_data_t *ConfirmationData = NULL;
ogs_assert(amf_ue);
ogs_assert(amf_ue->confirmation_for_5g_aka.resource_uri);
ogs_assert(amf_ue->confirmation_url_for_5g_aka);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
message.h.uri = amf_ue->confirmation_for_5g_aka.resource_uri;
message.h.uri = amf_ue->confirmation_url_for_5g_aka;
ConfirmationData = ogs_calloc(1, sizeof(*ConfirmationData));
if (!ConfirmationData) {

View File

@ -30,21 +30,9 @@ int amf_nausf_auth_handle_authenticate(
OpenAPI_map_t *LinksValueScheme = NULL;
OpenAPI_lnode_t *node = NULL;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
ogs_assert(amf_ue);
ogs_assert(message);
if (!message->http.location) {
ogs_error("[%s] No http.location", amf_ue->suci);
return OGS_ERROR;
}
UeAuthenticationCtx = message->UeAuthenticationCtx;
if (!UeAuthenticationCtx) {
ogs_error("[%s] No UeAuthenticationCtx", amf_ue->suci);
@ -104,36 +92,11 @@ int amf_nausf_auth_handle_authenticate(
return OGS_ERROR;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, message->http.location);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s] Invalid URI [%s]",
amf_ue->suci, message->http.location);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s] ogs_sbi_client_add()", amf_ue->suci);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s] ogs_sbi_client_add() failed", amf_ue->suci);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&amf_ue->confirmation_for_5g_aka, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
STORE_5G_AKA_CONFIRMATION(amf_ue, message->http.location);
if (amf_ue->confirmation_url_for_5g_aka)
ogs_free(amf_ue->confirmation_url_for_5g_aka);
amf_ue->confirmation_url_for_5g_aka =
ogs_strdup(LinksValueSchemeValue->href);
ogs_assert(amf_ue->confirmation_url_for_5g_aka);
ogs_ascii_to_hex(AV5G_AKA->rand, strlen(AV5G_AKA->rand),
amf_ue->rand, sizeof(amf_ue->rand));

View File

@ -2516,7 +2516,7 @@ void ngap_handle_pdu_session_resource_release_response(
sess->pdu_session_resource_release_response_received = true;
if (sess->pdu_session_release_complete_received == true)
CLEAR_SESSION_CONTEXT(sess);
CLEAR_SM_CONTEXT_REF(sess);
}
}

View File

@ -221,11 +221,15 @@ ogs_sbi_request_t *amf_npcf_am_policy_control_build_delete(
ogs_assert(amf_ue);
ogs_assert(amf_ue->supi);
ogs_assert(amf_ue->policy_association.resource_uri);
ogs_assert(amf_ue->policy_association_id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.uri = amf_ue->policy_association.resource_uri;
message.h.service.name =
(char *)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_POLICIES;
message.h.resource.component[1] = amf_ue->policy_association_id;
request = ogs_sbi_build_request(&message);
ogs_expect(request);

View File

@ -35,13 +35,6 @@ int amf_npcf_am_policy_control_handle_create(
ogs_sbi_message_t message;
ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_CREATED) {
ogs_error("[%s] HTTP response error [%d]",
amf_ue->supi, recvmsg->res_status);
@ -105,53 +98,12 @@ int amf_npcf_am_policy_control_handle_create(
return OGS_ERROR;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s] Invalid URI [%s]", amf_ue->supi, header.uri);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s] ogs_sbi_client_add()", amf_ue->supi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s] ogs_sbi_client_add() failed", amf_ue->supi);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&amf_ue->policy_association, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
PCF_AM_POLICY_STORE(amf_ue, header.uri, message.h.resource.component[1]);
/* SBI Features */
supported_features = ogs_uint64_from_string(PolicyAssociation->supp_feat);
amf_ue->am_policy_control_features &= supported_features;
PCF_AM_POLICY_STORE(amf_ue, message.h.resource.component[1]);
OpenAPI_list_for_each(PolicyAssociation->triggers, node) {
if (node->data) {
OpenAPI_request_trigger_e trigger = (intptr_t)node->data;

View File

@ -272,15 +272,17 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_update_sm_context(
ogs_assert(param);
ogs_assert(sess);
ogs_assert(sess->sm_context.resource_uri);
ogs_assert(sess->sm_context_ref);
amf_ue = sess->amf_ue;
ogs_assert(amf_ue);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
message.h.uri = ogs_msprintf("%s/%s",
sess->sm_context.resource_uri, OGS_SBI_RESOURCE_NAME_MODIFY);
ogs_assert(message.h.uri);
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_SM_CONTEXTS;
message.h.resource.component[1] = sess->sm_context_ref;
message.h.resource.component[2] = (char *)OGS_SBI_RESOURCE_NAME_MODIFY;
memset(&ueLocation, 0, sizeof(ueLocation));
memset(&SmContextUpdateData, 0, sizeof(SmContextUpdateData));
@ -375,8 +377,6 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_update_sm_context(
ogs_expect(request);
end:
if (message.h.uri)
ogs_free(message.h.uri);
if (ueLocation.nr_location) {
if (ueLocation.nr_location->ue_location_timestamp)
ogs_free(ueLocation.nr_location->ue_location_timestamp);
@ -405,15 +405,18 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_release_sm_context(
OpenAPI_user_location_t ueLocation;
ogs_assert(sess);
ogs_assert(sess->sm_context.resource_uri);
ogs_assert(sess->sm_context_ref);
amf_ue = sess->amf_ue;
ogs_assert(amf_ue);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
message.h.uri = ogs_msprintf("%s/%s",
sess->sm_context.resource_uri, OGS_SBI_RESOURCE_NAME_RELEASE);
ogs_assert(message.h.uri);
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_SM_CONTEXTS;
message.h.resource.component[1] = sess->sm_context_ref;
message.h.resource.component[2] = (char *)OGS_SBI_RESOURCE_NAME_RELEASE;
memset(&SmContextReleaseData, 0, sizeof(SmContextReleaseData));
@ -457,8 +460,6 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_release_sm_context(
ogs_expect(request);
end:
if (message.h.uri)
ogs_free(message.h.uri);
if (ueLocation.nr_location) {
if (ueLocation.nr_location->ue_location_timestamp)
ogs_free(ueLocation.nr_location->ue_location_timestamp);

View File

@ -56,13 +56,6 @@ int amf_nsmf_pdusession_handle_create_sm_context(
ogs_sbi_message_t message;
ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
if (!recvmsg->http.location) {
ogs_error("[%d:%d] No http.location", sess->psi, sess->pti);
r = nas_5gs_send_back_gsm_message(ran_ue, sess,
@ -104,55 +97,6 @@ int amf_nsmf_pdusession_handle_create_sm_context(
return OGS_ERROR;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s:%d] Invalid URI [%s]",
amf_ue->supi, sess->psi, header.uri);
ogs_sbi_header_free(&header);
r = nas_5gs_send_back_gsm_message(ran_ue, sess,
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
AMF_NAS_BACKOFF_TIME);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s:%d] ogs_sbi_client_add()", amf_ue->supi, sess->psi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s:%d] ogs_sbi_client_add() failed",
amf_ue->supi, sess->psi);
ogs_sbi_header_free(&header);
r = nas_5gs_send_back_gsm_message(ran_ue, sess,
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
AMF_NAS_BACKOFF_TIME);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&sess->sm_context, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
STORE_SESSION_CONTEXT(
sess, header.uri, message.h.resource.component[1]);
ogs_sbi_header_free(&header);
if (sess->pdu_session_establishment_accept) {
/*
* [1-SERVER] /namf-comm/v1/ue-contexts/{supi}/n1-n2-messages
@ -173,6 +117,7 @@ int amf_nsmf_pdusession_handle_create_sm_context(
ogs_error("[%d:%d] nas_5gs_send_to_gnb() failed",
sess->psi, sess->pti);
ogs_sbi_header_free(&header);
r = nas_5gs_send_back_gsm_message(ran_ue, sess,
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
AMF_NAS_BACKOFF_TIME);
@ -183,6 +128,13 @@ int amf_nsmf_pdusession_handle_create_sm_context(
}
}
if (sess->sm_context_ref)
ogs_free(sess->sm_context_ref);
sess->sm_context_ref = ogs_strdup(message.h.resource.component[1]);
ogs_assert(sess->sm_context_ref);
ogs_sbi_header_free(&header);
} else {
OpenAPI_sm_context_create_error_t *SmContextCreateError = NULL;
OpenAPI_ref_to_binary_data_t *n1SmMsg = NULL;

View File

@ -255,11 +255,16 @@ ogs_sbi_request_t *amf_nudm_sdm_build_subscription_delete(
ogs_assert(amf_ue);
ogs_assert(amf_ue->supi);
ogs_assert(amf_ue->data_change_subscription.resource_uri);
ogs_assert(amf_ue->data_change_subscription_id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.uri = amf_ue->data_change_subscription.resource_uri;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDM_SDM;
message.h.api.version = (char *)OGS_SBI_API_V2;
message.h.resource.component[0] = amf_ue->supi;
message.h.resource.component[1] =
(char *)OGS_SBI_RESOURCE_NAME_SDM_SUBSCRIPTIONS;
message.h.resource.component[2] = amf_ue->data_change_subscription_id;
request = ogs_sbi_build_request(&message);
ogs_expect(request);

View File

@ -246,7 +246,7 @@ int amf_nudm_sdm_handle_provisioned(
break;
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)
if (UDM_SDM_SUBSCRIBED(amf_ue)) {
if (amf_ue->data_change_subscription_id) {
/* we already have a SDM subscription to UDM; continue without
* subscribing again */
r = amf_ue_sbi_discover_and_send(
@ -272,13 +272,6 @@ int amf_nudm_sdm_handle_provisioned(
ogs_sbi_message_t message;
ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
if (!recvmsg->http.location) {
ogs_error("[%s] No http.location", amf_ue->supi);
r = nas_5gs_send_gmm_reject_from_sbi(
@ -295,12 +288,10 @@ int amf_nudm_sdm_handle_provisioned(
if (rv != OGS_OK) {
ogs_error("[%s] Cannot parse http.location [%s]",
amf_ue->supi, recvmsg->http.location);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
@ -313,52 +304,13 @@ int amf_nudm_sdm_handle_provisioned(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s] Invalid URI [%s]", amf_ue->supi, header.uri);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s] ogs_sbi_client_add()", amf_ue->supi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s] ogs_sbi_client_add() failed", amf_ue->supi);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&amf_ue->policy_association, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
UDM_SDM_STORE(amf_ue, header.uri, message.h.resource.component[2]);
if (amf_ue->data_change_subscription_id)
ogs_free(amf_ue->data_change_subscription_id);
amf_ue->data_change_subscription_id =
ogs_strdup(message.h.resource.component[2]);
ogs_sbi_header_free(&header);

View File

@ -505,7 +505,7 @@ void amf_sbi_send_release_session(
ogs_assert(r != OGS_ERROR);
/* Prevent to invoke SMF for this session */
CLEAR_SESSION_CONTEXT(sess);
CLEAR_SM_CONTEXT_REF(sess);
}
void amf_sbi_send_release_all_sessions(

View File

@ -184,9 +184,8 @@ void ausf_ue_remove(ausf_ue_t *ausf_ue)
ogs_free(ausf_ue->supi);
}
AUTH_EVENT_CLEAR(ausf_ue);
if (ausf_ue->auth_event.client)
ogs_sbi_client_remove(ausf_ue->auth_event.client);
if (ausf_ue->auth_events_url)
ogs_free(ausf_ue->auth_events_url);
if (ausf_ue->serving_network_name)
ogs_free(ausf_ue->serving_network_name);

View File

@ -52,25 +52,7 @@ struct ausf_ue_s {
char *serving_network_name;
OpenAPI_auth_type_e auth_type;
#define AUTH_EVENT_CLEAR(__aUSF) \
do { \
ogs_assert((__aUSF)); \
if ((__aUSF)->auth_event.resource_uri) \
ogs_free((__aUSF)->auth_event.resource_uri); \
(__aUSF)->auth_event.resource_uri = NULL; \
} while(0)
#define AUTH_EVENT_STORE(__aUSF, __rESOURCE_URI) \
do { \
ogs_assert((__aUSF)); \
ogs_assert((__rESOURCE_URI)); \
AUTH_EVENT_CLEAR(__aUSF); \
(__aUSF)->auth_event.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aUSF)->auth_event.resource_uri); \
} while(0)
struct {
char *resource_uri;
ogs_sbi_client_t *client;
} auth_event;
char *auth_events_url;
OpenAPI_auth_result_e auth_result;
uint8_t rand[OGS_RAND_LEN];

View File

@ -244,7 +244,8 @@ bool ausf_nudm_ueau_handle_get(ausf_ue_t *ausf_ue,
sendmsg.UeAuthenticationCtx = &UeAuthenticationCtx;
response = ogs_sbi_build_response(&sendmsg, OGS_SBI_HTTP_STATUS_CREATED);
response = ogs_sbi_build_response(&sendmsg,
OGS_SBI_HTTP_STATUS_CREATED);
ogs_assert(response);
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
@ -285,13 +286,6 @@ bool ausf_nudm_ueau_handle_result_confirmation_inform(ausf_ue_t *ausf_ue,
OpenAPI_confirmation_data_response_t ConfirmationDataResponse;
OpenAPI_auth_event_t *AuthEvent = NULL;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
ogs_assert(ausf_ue);
ogs_assert(stream);
@ -314,33 +308,10 @@ bool ausf_nudm_ueau_handle_result_confirmation_inform(ausf_ue_t *ausf_ue,
return false;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, recvmsg->http.location);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s] Invalid URI [%s]",
ausf_ue->suci, recvmsg->http.location);
ogs_assert(true ==
ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
recvmsg, "Invalid URI", ausf_ue->suci, NULL));
return false;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s] ogs_sbi_client_add()", ausf_ue->suci);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
ogs_assert(client);
}
OGS_SBI_SETUP_CLIENT(&ausf_ue->auth_event, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
AUTH_EVENT_STORE(ausf_ue, recvmsg->http.location);
if (ausf_ue->auth_events_url)
ogs_free(ausf_ue->auth_events_url);
ausf_ue->auth_events_url = ogs_strdup(recvmsg->http.location);
ogs_assert(ausf_ue->auth_events_url);
memset(&ConfirmationDataResponse, 0, sizeof(ConfirmationDataResponse));

View File

@ -495,9 +495,8 @@ void pcf_sess_remove(pcf_sess_t *sess)
ogs_assert(sess->sm_policy_id);
ogs_free(sess->sm_policy_id);
PCF_BINDING_CLEAR(sess);
if (sess->binding.client)
ogs_sbi_client_remove(sess->binding.client);
if (sess->binding_id)
ogs_free(sess->binding_id);
if (sess->dnn)
ogs_free(sess->dnn);

View File

@ -81,34 +81,7 @@ struct pcf_sess_s {
/* BSF sends the RESPONSE
* of [POST] /nbsf-management/v1/PcfBindings */
#define PCF_BINDING_ASSOCIATED(__sESS) \
((__sESS) && ((__sESS)->binding.id))
#define PCF_BINDING_CLEAR(__sESS) \
do { \
ogs_assert((__sESS)); \
if ((__sESS)->binding.resource_uri) \
ogs_free((__sESS)->binding.resource_uri); \
(__sESS)->binding.resource_uri = NULL; \
if ((__sESS)->binding.id) \
ogs_free((__sESS)->binding.id); \
(__sESS)->binding.id = NULL; \
} while(0)
#define PCF_BINDING_STORE(__sESS, __rESOURCE_URI, __iD) \
do { \
ogs_assert((__sESS)); \
ogs_assert((__rESOURCE_URI)); \
ogs_assert((__iD)); \
PCF_BINDING_CLEAR(__sESS); \
(__sESS)->binding.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__sESS)->binding.resource_uri); \
(__sESS)->binding.id = ogs_strdup(__iD); \
ogs_assert((__sESS)->binding.id); \
} while(0)
struct {
char *resource_uri;
char *id;
ogs_sbi_client_t *client;
} binding;
char *binding_id;
uint8_t psi; /* PDU Session Identity */

View File

@ -189,11 +189,15 @@ ogs_sbi_request_t *pcf_nbsf_management_build_de_register(
ogs_assert(sess);
pcf_ue = sess->pcf_ue;
ogs_assert(pcf_ue);
ogs_assert(sess->binding.resource_uri);
ogs_assert(sess->binding_id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.uri = sess->binding.resource_uri;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_PCF_BINDINGS;
message.h.resource.component[1] = sess->binding_id;
request = ogs_sbi_build_request(&message);
ogs_expect(request);

View File

@ -62,13 +62,6 @@ bool pcf_nbsf_management_handle_register(
OpenAPI_list_t *PolicyCtrlReqTriggers = NULL;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
ogs_assert(sess);
pcf_ue = sess->pcf_ue;
ogs_assert(pcf_ue);
@ -122,39 +115,10 @@ bool pcf_nbsf_management_handle_register(
goto cleanup;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
strerror = ogs_msprintf("[%s:%d] Invalid URI [%s]",
pcf_ue->supi, sess->psi, header.uri);
ogs_sbi_header_free(&header);
goto cleanup;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s:%d] ogs_sbi_client_add()", pcf_ue->supi, sess->psi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
strerror = ogs_msprintf("[%s:%d] ogs_sbi_client_add() failed",
pcf_ue->supi, sess->psi);
ogs_sbi_header_free(&header);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
goto cleanup;
}
}
OGS_SBI_SETUP_CLIENT(&sess->binding, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
PCF_BINDING_STORE(sess, header.uri, message.h.resource.component[1]);
if (sess->binding_id)
ogs_free(sess->binding_id);
sess->binding_id = ogs_strdup(message.h.resource.component[1]);
ogs_assert(sess->binding_id);
ogs_sbi_header_free(&header);
@ -360,7 +324,7 @@ bool pcf_nbsf_management_handle_register(
memset(&header, 0, sizeof(header));
header.service.name = (char *)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL;
header.api.version = (char *)OGS_SBI_API_V1;
header.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_SM_POLICIES;
header.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_POLICIES;
header.resource.component[1] = sess->sm_policy_id;
memset(&sendmsg, 0, sizeof(sendmsg));

View File

@ -1729,9 +1729,8 @@ void smf_sess_remove(smf_sess_t *sess)
if (sess->namf.client)
ogs_sbi_client_remove(sess->namf.client);
PCF_SM_POLICY_CLEAR(sess);
if (sess->policy_association.client)
ogs_sbi_client_remove(sess->policy_association.client);
if (sess->policy_association_id)
ogs_free(sess->policy_association_id);
if (sess->session.name)
ogs_free(sess->session.name);

View File

@ -284,34 +284,7 @@ typedef struct smf_sess_s {
/* PCF sends the RESPONSE
* of [POST] /npcf-smpolocycontrol/v1/policies */
#define PCF_SM_POLICY_ASSOCIATED(__sESS) \
((__sESS) && ((__sESS)->policy_association.id))
#define PCF_SM_POLICY_CLEAR(__sESS) \
do { \
ogs_assert((__sESS)); \
if ((__sESS)->policy_association.resource_uri) \
ogs_free((__sESS)->policy_association.resource_uri); \
(__sESS)->policy_association.resource_uri = NULL; \
if ((__sESS)->policy_association.id) \
ogs_free((__sESS)->policy_association.id); \
(__sESS)->policy_association.id = NULL; \
} while(0)
#define PCF_SM_POLICY_STORE(__sESS, __rESOURCE_URI, __iD) \
do { \
ogs_assert((__sESS)); \
ogs_assert((__rESOURCE_URI)); \
ogs_assert((__iD)); \
PCF_SM_POLICY_CLEAR(__sESS); \
(__sESS)->policy_association.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__sESS)->policy_association.resource_uri); \
(__sESS)->policy_association.id = ogs_strdup(__iD); \
ogs_assert((__sESS)->policy_association.id); \
} while(0)
struct {
char *resource_uri;
char *id;
ogs_sbi_client_t *client;
} policy_association;
char *policy_association_id;
OpenAPI_up_cnx_state_e up_cnx_state;

View File

@ -944,7 +944,9 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e)
} else {
SWITCH(sbi_message->h.resource.component[2])
CASE(OGS_SBI_RESOURCE_NAME_DELETE)
PCF_SM_POLICY_CLEAR(sess);
if (sess->policy_association_id)
ogs_free(sess->policy_association_id);
sess->policy_association_id = NULL;
if (sbi_message->res_status !=
OGS_SBI_HTTP_STATUS_NO_CONTENT) {
@ -1083,7 +1085,7 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e)
break;
case OGS_NAS_5GS_PDU_SESSION_RELEASE_REQUEST:
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
if (sess->policy_association_id) {
smf_npcf_smpolicycontrol_param_t param;
memset(&param, 0, sizeof(param));
@ -1820,7 +1822,7 @@ void smf_gsm_state_5gc_n1_n2_reject(ogs_fsm_t *s, smf_event_t *e)
switch (e->h.id) {
case OGS_FSM_ENTRY_SIG:
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
if (sess->policy_association_id) {
smf_npcf_smpolicycontrol_param_t param;
int r = 0;
@ -1862,7 +1864,9 @@ void smf_gsm_state_5gc_n1_n2_reject(ogs_fsm_t *s, smf_event_t *e)
} else {
SWITCH(sbi_message->h.resource.component[2])
CASE(OGS_SBI_RESOURCE_NAME_DELETE)
PCF_SM_POLICY_CLEAR(sess);
if (sess->policy_association_id)
ogs_free(sess->policy_association_id);
sess->policy_association_id = NULL;
if (sbi_message->res_status !=
OGS_SBI_HTTP_STATUS_NO_CONTENT) {

View File

@ -303,13 +303,15 @@ ogs_sbi_request_t *smf_npcf_smpolicycontrol_build_delete(
ogs_assert(sess->sm_context_ref);
smf_ue = sess->smf_ue;
ogs_assert(smf_ue);
ogs_assert(sess->policy_association.resource_uri);
ogs_assert(sess->policy_association_id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
message.h.uri = ogs_msprintf("%s/%s",
sess->policy_association.resource_uri,
OGS_SBI_RESOURCE_NAME_DELETE);
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_SM_POLICIES;
message.h.resource.component[1] = sess->policy_association_id;
message.h.resource.component[2] = (char *)OGS_SBI_RESOURCE_NAME_DELETE;
memset(&SmPolicyDeleteData, 0, sizeof(SmPolicyDeleteData));
@ -398,9 +400,6 @@ ogs_sbi_request_t *smf_npcf_smpolicycontrol_build_delete(
end:
if (message.h.uri)
ogs_free(message.h.uri);
if (ueLocation.nr_location) {
if (ueLocation.nr_location->ue_location_timestamp)
ogs_free(ueLocation.nr_location->ue_location_timestamp);

View File

@ -296,13 +296,6 @@ bool smf_npcf_smpolicycontrol_handle_create(
ogs_sbi_message_t message;
ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
ogs_assert(sess);
smf_ue = sess->smf_ue;
ogs_assert(smf_ue);
@ -338,39 +331,10 @@ bool smf_npcf_smpolicycontrol_handle_create(
return false;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s:%d] Invalid URI [%s]",
smf_ue->supi, sess->psi, header.uri);
ogs_sbi_header_free(&header);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s:%d] ogs_sbi_client_add()", smf_ue->supi, sess->psi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s:%d] ogs_sbi_client_add() failed",
smf_ue->supi, sess->psi);
ogs_sbi_header_free(&header);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&sess->policy_association, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
PCF_SM_POLICY_STORE(sess, header.uri, message.h.resource.component[1]);
if (sess->policy_association_id)
ogs_free(sess->policy_association_id);
sess->policy_association_id = ogs_strdup(message.h.resource.component[1]);
ogs_assert(sess->policy_association_id);
ogs_sbi_header_free(&header);
@ -755,7 +719,7 @@ bool smf_npcf_smpolicycontrol_handle_terminate_notify(
ogs_assert(true == ogs_sbi_send_http_status_no_content(stream));
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
if (sess->policy_association_id) {
memset(&param, 0, sizeof(param));
r = smf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL,

View File

@ -756,7 +756,7 @@ bool smf_nsmf_handle_update_sm_context(
ogs_assert(true ==
ogs_sbi_server_send_response(stream, response));
} else if (PCF_SM_POLICY_ASSOCIATED(sess)) {
} else if (sess->policy_association_id) {
smf_npcf_smpolicycontrol_param_t param;
memset(&param, 0, sizeof(param));
@ -862,7 +862,7 @@ bool smf_nsmf_handle_release_sm_context(
SmContextReleaseData->_5g_mm_cause_value;
}
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
if (sess->policy_association_id) {
r = smf_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL,
smf_npcf_smpolicycontrol_build_delete,

View File

@ -535,7 +535,7 @@ static void reselect_upf(ogs_pfcp_node_t *node)
ogs_error("[%s:%s] EPC restoration is not implemented",
smf_ue->imsi_bcd, sess->session.name);
} else {
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
if (sess->policy_association_id) {
smf_npcf_smpolicycontrol_param_t param;
ogs_info("[%s:%d] SMF-initiated Deletion",

View File

@ -27,6 +27,8 @@ static OGS_POOL(af_sess_pool, af_sess_t);
static int context_initialized = 0;
static void clear_pcf_app_session_id(af_sess_t *sess);
void af_context_init(void)
{
ogs_assert(context_initialized == 0);
@ -142,9 +144,9 @@ af_sess_t *af_sess_add_by_ue_address(ogs_ip_t *ue_address)
ogs_assert(sess);
memset(sess, 0, sizeof *sess);
sess->app_session.af.id = ogs_msprintf("%d",
sess->af_app_session_id = ogs_msprintf("%d",
(int)ogs_pool_index(&af_sess_pool, sess));
ogs_assert(sess->app_session.af.id);
ogs_assert(sess->af_app_session_id);
if (ue_address->ipv4) {
sess->ipv4addr = ogs_ipv4_to_string(ue_address->addr);
@ -180,12 +182,10 @@ void af_sess_remove(af_sess_t *sess)
/* Free SBI object memory */
ogs_sbi_object_free(&sess->sbi);
if (sess->app_session.af.id)
ogs_free(sess->app_session.af.id);
if (sess->af_app_session_id)
ogs_free(sess->af_app_session_id);
PCF_APP_SESSION_CLEAR(sess);
if (sess->app_session.pcf.client)
ogs_sbi_client_remove(sess->app_session.pcf.client);
clear_pcf_app_session_id(sess);
if (sess->ipv4addr)
ogs_free(sess->ipv4addr);
@ -227,6 +227,33 @@ void af_sess_remove_all(void)
af_sess_remove(sess);
}
static void clear_pcf_app_session_id(af_sess_t *sess)
{
ogs_assert(sess);
if (sess->pcf_app_session_id) {
ogs_hash_set(self.pcf_app_session_id_hash,
&sess->pcf_app_session_id, sizeof(sess->pcf_app_session_id), NULL);
ogs_free(sess->pcf_app_session_id);
}
}
bool af_sess_set_pcf_app_session_id(af_sess_t *sess, char *pcf_app_session_id)
{
ogs_assert(sess);
ogs_assert(pcf_app_session_id);
clear_pcf_app_session_id(sess);
sess->pcf_app_session_id = ogs_strdup(pcf_app_session_id);
ogs_assert(sess->pcf_app_session_id);
ogs_hash_set(self.pcf_app_session_id_hash,
&sess->pcf_app_session_id, strlen(sess->pcf_app_session_id), sess);
return true;
}
af_sess_t *af_sess_find(uint32_t index)
{
return ogs_pool_find(&af_sess_pool, index);
@ -238,6 +265,13 @@ af_sess_t *af_sess_find_by_af_app_session_id(char *af_app_session_id)
return af_sess_find(atoll(af_app_session_id));
}
af_sess_t *af_sess_find_by_pcf_app_session_id(char *pcf_app_session_id)
{
ogs_assert(pcf_app_session_id);
return (af_sess_t *)ogs_hash_get(self.pcf_app_session_id_hash,
pcf_app_session_id, strlen(pcf_app_session_id));
}
void af_sess_associate_pcf_client(af_sess_t *sess)
{
ogs_sbi_client_t *client = NULL;

View File

@ -52,39 +52,8 @@ typedef struct af_sess_s {
uint64_t policyauthorization_features;
#define PCF_APP_SESSION_ASSOCIATED(__sESS) \
((__sESS) && ((__sESS)->app_session.pcf_id))
#define PCF_APP_SESSION_CLEAR(__sESS) \
do { \
ogs_assert((__sESS)); \
if ((__sESS)->app_session.pcf.resource_uri) \
ogs_free((__sESS)->app_session.pcf.resource_uri); \
(__sESS)->app_session.pcf.resource_uri = NULL; \
if ((__sESS)->app_session.pcf.id) \
ogs_free((__sESS)->app_session.pcf.id); \
(__sESS)->app_session.pcf.id = NULL; \
} while(0)
#define PCF_APP_SESSION_STORE(__sESS, __rESOURCE_URI, __iD) \
do { \
ogs_assert((__sESS)); \
ogs_assert((__rESOURCE_URI)); \
ogs_assert((__iD)); \
PCF_APP_SESSION_CLEAR(__sESS); \
(__sESS)->app_session.pcf.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__sESS)->app_session.pcf.resource_uri); \
(__sESS)->app_session.pcf.id = ogs_strdup(__iD); \
ogs_assert((__sESS)->app_session.pcf.id); \
} while(0)
struct {
struct {
char *id;
} af;
struct {
char *resource_uri;
char *id;
ogs_sbi_client_t *client;
} pcf;
} app_session;
char *af_app_session_id;
char *pcf_app_session_id;
char *ipv4addr;
char *ipv6addr;
@ -122,8 +91,11 @@ af_sess_t *af_sess_add_by_ue_address(ogs_ip_t *ue_address);
void af_sess_remove(af_sess_t *sess);
void af_sess_remove_all(void);
bool af_sess_set_pcf_app_session_id(af_sess_t *sess, char *pcf_app_session_id);
af_sess_t *af_sess_find(uint32_t index);
af_sess_t *af_sess_find_by_af_app_session_id(char *af_app_session_id);
af_sess_t *af_sess_find_by_pcf_app_session_id(char *pcf_app_session_id);
void af_sess_associate_pcf_client(af_sess_t *sess);

View File

@ -54,7 +54,7 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_create(
af_npcf_policyauthorization_param_t *af_param;
ogs_assert(sess);
ogs_assert(sess->app_session.af.id);
ogs_assert(sess->af_app_session_id);
af_param = data;
ogs_assert(af_param);
@ -82,7 +82,7 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_create(
header.service.name = (char *)OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION;
header.api.version = (char *)OGS_SBI_API_V1;
header.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_APP_SESSIONS;
header.resource.component[1] = (char *)sess->app_session.af.id;
header.resource.component[1] = (char *)sess->af_app_session_id;
AscReqData.notif_uri = ogs_sbi_server_uri(server, &header);
ogs_assert(AscReqData.notif_uri);
@ -379,14 +379,19 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_update(
af_npcf_policyauthorization_param_t *af_param;
ogs_assert(sess);
ogs_assert(sess->app_session.pcf.resource_uri);
ogs_assert(sess->pcf_app_session_id);
af_param = data;
ogs_assert(af_param);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PATCH;
message.h.uri = sess->app_session.pcf.resource_uri;
message.h.service.name =
(char *)OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_APP_SESSIONS;
message.h.resource.component[1] = sess->pcf_app_session_id;
message.AppSessionContextUpdateDataPatch =
&AppSessionContextUpdateDataPatch;
@ -599,18 +604,22 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_delete(
ogs_sbi_request_t *request = NULL;
ogs_assert(sess);
ogs_assert(sess->app_session.pcf.resource_uri);
ogs_assert(sess->pcf_app_session_id);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
message.h.uri = ogs_msprintf("%s/%s",
sess->app_session.pcf.resource_uri, OGS_SBI_RESOURCE_NAME_DELETE);
message.h.service.name =
(char *)OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_APP_SESSIONS;
message.h.resource.component[1] = sess->pcf_app_session_id;
message.h.resource.component[2] =
(char *)OGS_SBI_RESOURCE_NAME_DELETE;
request = ogs_sbi_build_request(&message);
ogs_expect(request);
ogs_free(message.h.uri);
return request;
}
@ -649,7 +658,7 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_create_video(
af_npcf_policyauthorization_param_t *af_param;
ogs_assert(sess);
ogs_assert(sess->app_session.af.id);
ogs_assert(sess->af_app_session_id);
af_param = data;
ogs_assert(af_param);
@ -676,7 +685,7 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_create_video(
header.service.name = (char *)OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION;
header.api.version = (char *)OGS_SBI_API_V1;
header.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_APP_SESSIONS;
header.resource.component[1] = (char *)sess->app_session.af.id;
header.resource.component[1] = (char *)sess->af_app_session_id;
AscReqData.notif_uri = ogs_sbi_server_uri(server, &header);
ogs_assert(AscReqData.notif_uri);

View File

@ -28,13 +28,6 @@ void af_npcf_policyauthorization_handle_create(
ogs_sbi_message_t message;
ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
OpenAPI_app_session_context_t *AppSessionContext = NULL;
OpenAPI_app_session_context_req_data_t *AscReqData = NULL;
@ -90,35 +83,11 @@ void af_npcf_policyauthorization_handle_create(
goto cleanup;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s:%s] Invalid URI [%s]",
sess->ipv4addr ? sess->ipv4addr : "Unknown",
sess->ipv6addr ? sess->ipv6addr : "Unknown",
header.uri);
goto cleanup;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s:%s] ogs_sbi_client_add()",
sess->ipv4addr ? sess->ipv4addr : "Unknown",
sess->ipv6addr ? sess->ipv6addr : "Unknown");
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
ogs_assert(client);
}
OGS_SBI_SETUP_CLIENT(&sess->app_session.pcf, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
PCF_APP_SESSION_STORE(sess, header.uri, message.h.resource.component[1]);
supported_features = ogs_uint64_from_string(AscReqData->supp_feat);
sess->policyauthorization_features &= supported_features;
af_sess_set_pcf_app_session_id(sess, message.h.resource.component[1]);
cleanup:
ogs_sbi_header_free(&header);
}