Compare commits

...

8 Commits

Author SHA1 Message Date
Sukchan Lee 4c00edd839 Update document for v2.7.1 2024-04-19 21:24:08 +09:00
Sukchan Lee 426fa3f84a Release v2.7.1 2024-04-19 21:22:24 +09:00
Pau Espin c0a520f32a systemd: network: Add explicit routes towards tundev for UE pool of addresses
When running the open5gs package with systemd network config, the 1st IP address
of the UE pool configured in open5gs-upfd config file for ogstun is
being assigned to the interface through this file.
That was discussed as being a desirable default setup.

However, in the event a user wants a setup where no IP address is
assigned to the tundev, then it's not enough removing the IP address,
because then the implicit routing rules regarding the subnet of the IP
address added automatically by the kernel are also removed.

This patch adds config sections to set up the routing explicitly, with
the aim to get the routing still applied if the user decides to comment
out the IP address, so that packets are still forwarded properly in that
case.

Related: https://osmocom.org/issues/6361
2024-04-19 08:32:19 +09:00
Sukchan Lee d14304461b Oops! Fix the compile error! 2024-04-18 21:32:25 +09:00
Sukchan Lee a9b1b116b3 [SBI] Generate URI via HTTP.location as is (#3058)
A friend in the community was trying to connect an SMF made by another
manufacturer with an SBI interface and found a big problem with Open5GS.

All of the code in the part that generates the Resource URI
from HTTP.location is invalid.

For example, suppose we create a Resource URI with SMContext as below.
{apiRoot}/nsmf-pdusession/<apiVersion>/sm-contexts/{smContextRef}

In this case, Open5GS extracted the {smContextRef} part of the HTTP.location
and appended it to the beginning
{apiRoot}/nsmf-pdusession/<apiVersion>/sm-contexts/.

This implementation may not work properly if the apiRoot changes.
Consider a different port number as shown below.

<HTTP.location>
127.0.0.4:9999/nsmf-pdusession/v1/sm-contexts/1

The SMF may send an apiRoot to the AMF with a changed port number,
in which case the AMF must honor it.

Therefore, instead of extracting only the smContextRef from HTTP.location,
we modified it to use the whole thing to create a Resource URI.

We modified all NFs that use HTTP.location in the same way, not just SMFs.
2024-04-18 21:24:07 +09:00
Oliver Smith 4ab22dc98e docs: quickstart: add configure logging section
Add a section that explains how to fix duplicate timestamps in
journalctl.
2024-04-18 21:08:35 +09:00
Oliver Smith 8abd35580b configs, docs: adjust to logger config change 2024-04-18 21:08:35 +09:00
Oliver Smith 7973e45d16 [CORE] logger: add option to disable timestamps
Add an option to disable printing the timestamp. This is useful to not
have duplicate timestamps, when stderr is piped into a logging system
that adds timestamps on its own. For example with systemd's journald:

$ journalctl -u open5gs-smfd
Apr 10 13:25:18 hostname open5gs-smfd[1582]: 04/10 13:25:18.274: [app] INFO: Configuration: '/etc/open5gs/smf.yaml' (../lib/app/ogs-init.c:130)

Configuration change:
```
<OLD Format>
logger:
  file: /var/log/open5gs/smf.log

<NEW Format>
logger:
  file:
    path: /var/log/open5gs/smf.log
```

Example config, to have no timestamps on stderr:
```
logger:
  default:
    timestamp: false
  file:
    path: /var/log/open5gs/smf.log
    timestamp: true
```
2024-04-18 21:08:35 +09:00
71 changed files with 1006 additions and 299 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,6 +5,14 @@ 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,3 +1,33 @@
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,6 +428,34 @@ $ 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,7 +169,8 @@ index a70143f08..e0dba560c 100644
+++ b/configs/open5gs/amf.yaml.in
@@ -1,6 +1,6 @@
logger:
file: @localstatedir@/log/open5gs/amf.log
file:
path: @localstatedir@/log/open5gs/amf.log
-# level: info # fatal|error|warn|info(default)|debug|trace
+ level: debug

View File

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

View File

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

View File

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

View File

@ -0,0 +1,15 @@
---
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,10 +36,15 @@ 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,6 +114,9 @@ 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
*/
@ -254,6 +257,57 @@ 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;
@ -278,9 +332,8 @@ 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);
if (!strcmp(logger_key, "file")) {
ogs_app()->logger.file = ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "level")) {
parse_config_logger_file(&logger_iter, logger_key);
if (!strcmp(logger_key, "level")) {
ogs_app()->logger.level =
ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "domain")) {

View File

@ -178,6 +178,34 @@ 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,6 +59,7 @@ 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,6 +340,28 @@ 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,6 +64,12 @@ 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;
@ -90,6 +96,7 @@ 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,12 +2493,26 @@ 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);
}
@ -2516,6 +2530,9 @@ 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,6 +286,7 @@ 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 */
@ -295,7 +296,7 @@ typedef struct ogs_sbi_subscription_data_s {
uint64_t requester_features;
uint64_t nrf_supported_features;
void *client; /* only used in SERVER */
void *client;
} ogs_sbi_subscription_data_t;
typedef struct ogs_sbi_smf_info_s {
@ -515,6 +516,8 @@ 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,11 +1712,7 @@ 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.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.h.uri = subscription_data->resource_uri;
message.http.content_type = (char *)OGS_SBI_CONTENT_PATCH_TYPE;
@ -1771,11 +1767,7 @@ 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.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.h.uri = subscription_data->resource_uri;
message.http.custom.callback =
(char *)OGS_SBI_CALLBACK_NNRF_NFMANAGEMENT_NF_STATUS_NOTIFY;

View File

@ -824,6 +824,17 @@ 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);
@ -833,45 +844,63 @@ void ogs_nnrf_nfm_handle_nf_status_subscribe(
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;
}
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");
if (!recvmsg->http.location) {
ogs_error("No http.location");
return;
}
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);
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) {
subscription_data->nrf_supported_features =

View File

@ -313,6 +313,11 @@ 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.0',
version : '2.7.1',
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.0'
libogslib_version = '2.7.1'
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))

View File

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

View File

@ -290,13 +290,33 @@ 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) \
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;
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;
/* 5GMM Capability */
struct {
@ -322,7 +342,27 @@ struct amf_ue_s {
/* Security Context */
ogs_nas_ue_security_capability_t ue_security_capability;
ogs_nas_ue_network_capability_t ue_network_capability;
char *confirmation_url_for_5g_aka;
#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;
uint8_t rand[OGS_RAND_LEN];
uint8_t autn[OGS_AUTN_LEN];
uint8_t xres_star[OGS_MAX_RES_LEN];
@ -468,8 +508,34 @@ struct amf_ue_s {
/* SubscriptionId of Subscription to Data Change Notification to UDM */
#define UDM_SDM_SUBSCRIBED(__aMF) \
((__aMF) && ((__aMF)->data_change_subscription_id))
char *data_change_subscription_id;
((__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;
struct {
/*
@ -499,18 +565,37 @@ typedef struct amf_sess_s {
uint8_t pti; /* Procedure Trasaction Identity */
#define SESSION_CONTEXT_IN_SMF(__sESS) \
((__sESS) && (__sESS)->sm_context_ref)
#define CLEAR_SM_CONTEXT_REF(__sESS) \
((__sESS) && (__sESS)->sm_context.ref)
#define STORE_SESSION_CONTEXT(__sESS, __rESOURCE_URI, __rEF) \
do { \
ogs_assert(__sESS); \
ogs_assert((__sESS)->sm_context_ref); \
ogs_free((__sESS)->sm_context_ref); \
(__sESS)->sm_context_ref = NULL; \
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; \
} while(0);
/* SMF sends the RESPONSE
* of [POST] /nsmf-pdusession/v1/sm-contexts */
char *sm_context_ref;
struct {
char *resource_uri;
char *ref;
ogs_sbi_client_t *client;
} sm_context;
bool pdu_session_release_complete_received;
bool pdu_session_resource_release_response_received;

View File

@ -1283,9 +1283,11 @@ 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]",
"smContextRef[%s] smContextResourceURI[%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.ref ? sess->sm_context.ref : "NULL",
sess->sm_context.resource_uri ?
sess->sm_context.resource_uri : "NULL");
if (!SESSION_CONTEXT_IN_SMF(sess)) {
ogs_sbi_nf_instance_t *nf_instance = NULL;
@ -1435,7 +1437,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_SM_CONTEXT_REF(sess);
CLEAR_SESSION_CONTEXT(sess);
break;
default:
break;
@ -1676,7 +1678,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,9 +274,7 @@ 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)
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;
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) {
@ -378,10 +376,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 (amf_ue->data_change_subscription_id) {
ogs_free(amf_ue->data_change_subscription_id);
amf_ue->data_change_subscription_id = NULL;
}
UDM_SDM_CLEAR(amf_ue);
r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL,
@ -447,7 +442,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 (amf_ue->confirmation_url_for_5g_aka) {
if (CHECK_5G_AKA_CONFIRMATION(amf_ue)) {
r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH,
NULL,
@ -857,9 +852,7 @@ 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)
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;
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) {
@ -967,10 +960,7 @@ 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) {
if (amf_ue->data_change_subscription_id) {
ogs_free(amf_ue->data_change_subscription_id);
amf_ue->data_change_subscription_id = NULL;
}
UDM_SDM_CLEAR(amf_ue);
r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL,
@ -1044,7 +1034,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
state ==
AMF_NETWORK_INITIATED_EXPLICIT_DE_REGISTERED) {
if (amf_ue->confirmation_url_for_5g_aka) {
if (amf_ue->confirmation_for_5g_aka.resource_uri) {
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,13 +349,12 @@ 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,
@ -424,13 +423,12 @@ 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,
@ -1174,7 +1172,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_url_for_5g_aka);
ogs_assert(amf_ue->confirmation_for_5g_aka.resource_uri);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.uri = amf_ue->confirmation_url_for_5g_aka;
message.h.uri = amf_ue->confirmation_for_5g_aka.resource_uri;
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_url_for_5g_aka);
ogs_assert(amf_ue->confirmation_for_5g_aka.resource_uri);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
message.h.uri = amf_ue->confirmation_url_for_5g_aka;
message.h.uri = amf_ue->confirmation_for_5g_aka.resource_uri;
ConfirmationData = ogs_calloc(1, sizeof(*ConfirmationData));
if (!ConfirmationData) {

View File

@ -30,9 +30,21 @@ 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);
@ -92,11 +104,36 @@ int amf_nausf_auth_handle_authenticate(
return OGS_ERROR;
}
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);
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);
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_SM_CONTEXT_REF(sess);
CLEAR_SESSION_CONTEXT(sess);
}
}

View File

@ -221,15 +221,11 @@ 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_id);
ogs_assert(amf_ue->policy_association.resource_uri);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
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;
message.h.uri = amf_ue->policy_association.resource_uri;
request = ogs_sbi_build_request(&message);
ogs_expect(request);

View File

@ -35,6 +35,13 @@ 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);
@ -98,12 +105,53 @@ 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,17 +272,15 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_update_sm_context(
ogs_assert(param);
ogs_assert(sess);
ogs_assert(sess->sm_context_ref);
ogs_assert(sess->sm_context.resource_uri);
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.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;
message.h.uri = ogs_msprintf("%s/%s",
sess->sm_context.resource_uri, OGS_SBI_RESOURCE_NAME_MODIFY);
ogs_assert(message.h.uri);
memset(&ueLocation, 0, sizeof(ueLocation));
memset(&SmContextUpdateData, 0, sizeof(SmContextUpdateData));
@ -377,6 +375,8 @@ 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,18 +405,15 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_release_sm_context(
OpenAPI_user_location_t ueLocation;
ogs_assert(sess);
ogs_assert(sess->sm_context_ref);
ogs_assert(sess->sm_context.resource_uri);
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.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;
message.h.uri = ogs_msprintf("%s/%s",
sess->sm_context.resource_uri, OGS_SBI_RESOURCE_NAME_RELEASE);
ogs_assert(message.h.uri);
memset(&SmContextReleaseData, 0, sizeof(SmContextReleaseData));
@ -460,6 +457,8 @@ 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,6 +56,13 @@ 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,
@ -97,6 +104,55 @@ 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
@ -117,7 +173,6 @@ 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);
@ -128,13 +183,6 @@ 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,16 +255,11 @@ 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_id);
ogs_assert(amf_ue->data_change_subscription.resource_uri);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
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;
message.h.uri = amf_ue->data_change_subscription.resource_uri;
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 (amf_ue->data_change_subscription_id) {
if (UDM_SDM_SUBSCRIBED(amf_ue)) {
/* we already have a SDM subscription to UDM; continue without
* subscribing again */
r = amf_ue_sbi_discover_and_send(
@ -272,6 +272,13 @@ 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(
@ -288,10 +295,12 @@ 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;
}
@ -304,13 +313,52 @@ 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;
}
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]);
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]);
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_SM_CONTEXT_REF(sess);
CLEAR_SESSION_CONTEXT(sess);
}
void amf_sbi_send_release_all_sessions(

View File

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

View File

@ -52,7 +52,25 @@ struct ausf_ue_s {
char *serving_network_name;
OpenAPI_auth_type_e auth_type;
char *auth_events_url;
#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;
OpenAPI_auth_result_e auth_result;
uint8_t rand[OGS_RAND_LEN];

View File

@ -244,8 +244,7 @@ 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));
@ -286,6 +285,13 @@ 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);
@ -308,10 +314,33 @@ bool ausf_nudm_ueau_handle_result_confirmation_inform(ausf_ue_t *ausf_ue,
return false;
}
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);
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);
memset(&ConfirmationDataResponse, 0, sizeof(ConfirmationDataResponse));

View File

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

View File

@ -81,7 +81,34 @@ struct pcf_sess_s {
/* BSF sends the RESPONSE
* of [POST] /nbsf-management/v1/PcfBindings */
char *binding_id;
#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;
uint8_t psi; /* PDU Session Identity */

View File

@ -189,15 +189,11 @@ 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_id);
ogs_assert(sess->binding.resource_uri);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
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;
message.h.uri = sess->binding.resource_uri;
request = ogs_sbi_build_request(&message);
ogs_expect(request);

View File

@ -62,6 +62,13 @@ 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);
@ -115,10 +122,39 @@ bool pcf_nbsf_management_handle_register(
goto cleanup;
}
if (sess->binding_id)
ogs_free(sess->binding_id);
sess->binding_id = ogs_strdup(message.h.resource.component[1]);
ogs_assert(sess->binding_id);
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]);
ogs_sbi_header_free(&header);
@ -324,7 +360,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_POLICIES;
header.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_SM_POLICIES;
header.resource.component[1] = sess->sm_policy_id;
memset(&sendmsg, 0, sizeof(sendmsg));

View File

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

View File

@ -284,7 +284,34 @@ typedef struct smf_sess_s {
/* PCF sends the RESPONSE
* of [POST] /npcf-smpolocycontrol/v1/policies */
char *policy_association_id;
#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;
OpenAPI_up_cnx_state_e up_cnx_state;

View File

@ -944,9 +944,7 @@ 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)
if (sess->policy_association_id)
ogs_free(sess->policy_association_id);
sess->policy_association_id = NULL;
PCF_SM_POLICY_CLEAR(sess);
if (sbi_message->res_status !=
OGS_SBI_HTTP_STATUS_NO_CONTENT) {
@ -1085,7 +1083,7 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e)
break;
case OGS_NAS_5GS_PDU_SESSION_RELEASE_REQUEST:
if (sess->policy_association_id) {
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
smf_npcf_smpolicycontrol_param_t param;
memset(&param, 0, sizeof(param));
@ -1822,7 +1820,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 (sess->policy_association_id) {
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
smf_npcf_smpolicycontrol_param_t param;
int r = 0;
@ -1864,9 +1862,7 @@ 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)
if (sess->policy_association_id)
ogs_free(sess->policy_association_id);
sess->policy_association_id = NULL;
PCF_SM_POLICY_CLEAR(sess);
if (sbi_message->res_status !=
OGS_SBI_HTTP_STATUS_NO_CONTENT) {

View File

@ -303,15 +303,13 @@ 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_id);
ogs_assert(sess->policy_association.resource_uri);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
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;
message.h.uri = ogs_msprintf("%s/%s",
sess->policy_association.resource_uri,
OGS_SBI_RESOURCE_NAME_DELETE);
memset(&SmPolicyDeleteData, 0, sizeof(SmPolicyDeleteData));
@ -400,6 +398,9 @@ 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,6 +296,13 @@ 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);
@ -331,10 +338,39 @@ bool smf_npcf_smpolicycontrol_handle_create(
return false;
}
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);
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]);
ogs_sbi_header_free(&header);
@ -719,7 +755,7 @@ bool smf_npcf_smpolicycontrol_handle_terminate_notify(
ogs_assert(true == ogs_sbi_send_http_status_no_content(stream));
if (sess->policy_association_id) {
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
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 (sess->policy_association_id) {
} else if (PCF_SM_POLICY_ASSOCIATED(sess)) {
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 (sess->policy_association_id) {
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
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 (sess->policy_association_id) {
if (PCF_SM_POLICY_ASSOCIATED(sess)) {
smf_npcf_smpolicycontrol_param_t param;
ogs_info("[%s:%d] SMF-initiated Deletion",

View File

@ -27,8 +27,6 @@ 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);
@ -144,9 +142,9 @@ af_sess_t *af_sess_add_by_ue_address(ogs_ip_t *ue_address)
ogs_assert(sess);
memset(sess, 0, sizeof *sess);
sess->af_app_session_id = ogs_msprintf("%d",
sess->app_session.af.id = ogs_msprintf("%d",
(int)ogs_pool_index(&af_sess_pool, sess));
ogs_assert(sess->af_app_session_id);
ogs_assert(sess->app_session.af.id);
if (ue_address->ipv4) {
sess->ipv4addr = ogs_ipv4_to_string(ue_address->addr);
@ -182,10 +180,12 @@ void af_sess_remove(af_sess_t *sess)
/* Free SBI object memory */
ogs_sbi_object_free(&sess->sbi);
if (sess->af_app_session_id)
ogs_free(sess->af_app_session_id);
if (sess->app_session.af.id)
ogs_free(sess->app_session.af.id);
clear_pcf_app_session_id(sess);
PCF_APP_SESSION_CLEAR(sess);
if (sess->app_session.pcf.client)
ogs_sbi_client_remove(sess->app_session.pcf.client);
if (sess->ipv4addr)
ogs_free(sess->ipv4addr);
@ -227,33 +227,6 @@ 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);
@ -265,13 +238,6 @@ 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,8 +52,39 @@ typedef struct af_sess_s {
uint64_t policyauthorization_features;
char *af_app_session_id;
char *pcf_app_session_id;
#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 *ipv4addr;
char *ipv6addr;
@ -91,11 +122,8 @@ 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->af_app_session_id);
ogs_assert(sess->app_session.af.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->af_app_session_id;
header.resource.component[1] = (char *)sess->app_session.af.id;
AscReqData.notif_uri = ogs_sbi_server_uri(server, &header);
ogs_assert(AscReqData.notif_uri);
@ -379,19 +379,14 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_update(
af_npcf_policyauthorization_param_t *af_param;
ogs_assert(sess);
ogs_assert(sess->pcf_app_session_id);
ogs_assert(sess->app_session.pcf.resource_uri);
af_param = data;
ogs_assert(af_param);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PATCH;
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.uri = sess->app_session.pcf.resource_uri;
message.AppSessionContextUpdateDataPatch =
&AppSessionContextUpdateDataPatch;
@ -604,22 +599,18 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_delete(
ogs_sbi_request_t *request = NULL;
ogs_assert(sess);
ogs_assert(sess->pcf_app_session_id);
ogs_assert(sess->app_session.pcf.resource_uri);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
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;
message.h.uri = ogs_msprintf("%s/%s",
sess->app_session.pcf.resource_uri, OGS_SBI_RESOURCE_NAME_DELETE);
request = ogs_sbi_build_request(&message);
ogs_expect(request);
ogs_free(message.h.uri);
return request;
}
@ -658,7 +649,7 @@ ogs_sbi_request_t *af_npcf_policyauthorization_build_create_video(
af_npcf_policyauthorization_param_t *af_param;
ogs_assert(sess);
ogs_assert(sess->af_app_session_id);
ogs_assert(sess->app_session.af.id);
af_param = data;
ogs_assert(af_param);
@ -685,7 +676,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->af_app_session_id;
header.resource.component[1] = (char *)sess->app_session.af.id;
AscReqData.notif_uri = ogs_sbi_server_uri(server, &header);
ogs_assert(AscReqData.notif_uri);

View File

@ -28,6 +28,13 @@ 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;
@ -83,11 +90,35 @@ 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);
}