Change Number of UEs usage [#533]

- Set the number of UEs in units of AMF/MME instead of gNB/eNB.
- See default value as shown below
    Number of UEs per AMF/MME : 4,096
    Number of gNB/eNB per AMF/MME : 32
This commit is contained in:
Sukchan Lee 2020-08-25 23:05:01 -04:00
parent ea0f024b93
commit 18c483950c
167 changed files with 930 additions and 1197 deletions

View File

@ -250,12 +250,10 @@ parameter:
#
# max:
#
# o Maximum Number of gNB per AMF
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
# o Maximum Number of UE per gNB
# ue: 128
# o Maximum Number of NF Instance
# nf: 512
#
max:
@ -280,12 +278,6 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:
#

View File

@ -126,12 +126,10 @@ parameter:
#
# max:
#
# o Maximum Number of gNB per AMF
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
# o Maximum Number of UE per gNB
# ue: 128
# o Maximum Number of NF Instance
# nf: 512
#
max:
@ -156,12 +154,6 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:
#

View File

@ -52,16 +52,10 @@ parameter:
#
# max:
#
# o Maximum Number of SGW per MME
# sgw: 32
# o Maximum Number of PGW per MME
# pgw: 32
# o Maximum Number of VLR per MME
# vlr: 32
# o Maximum Number of eNodeB per MME
# enb: 32
# o Maximum Number of UE per eNodeB
# ue: 128
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
#
max:
@ -86,10 +80,4 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:

View File

@ -354,16 +354,10 @@ parameter:
#
# max:
#
# o Maximum Number of SGW per MME
# sgw: 32
# o Maximum Number of PGW per MME
# pgw: 32
# o Maximum Number of VLR per MME
# vlr: 32
# o Maximum Number of eNodeB per MME
# enb: 32
# o Maximum Number of UE per eNodeB
# ue: 128
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
#
max:
@ -388,12 +382,6 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:
#

View File

@ -96,12 +96,10 @@ parameter:
#
# max:
#
# o Maximum Number of gNB per MME
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
# o Maximum Number of UE per gNB
# ue: 128
# o Maximum Number of NF Instance
# nf: 512
#
max:
@ -126,12 +124,6 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:
#

View File

@ -51,16 +51,10 @@ parameter:
#
# max:
#
# o Maximum Number of SGW per MME
# sgw: 32
# o Maximum Number of PGW per MME
# pgw: 32
# o Maximum Number of VLR per MME
# vlr: 32
# o Maximum Number of eNodeB per MME
# enb: 32
# o Maximum Number of UE per eNodeB
# ue: 128
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
#
max:
@ -85,10 +79,4 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:

View File

@ -128,16 +128,10 @@ parameter:
#
# max:
#
# o Maximum Number of SGW per MME
# sgw: 32
# o Maximum Number of PGW per MME
# pgw: 32
# o Maximum Number of VLR per MME
# vlr: 32
# o Maximum Number of eNodeB per MME
# enb: 32
# o Maximum Number of UE per eNodeB
# ue: 128
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
#
max:
@ -162,10 +156,4 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:

View File

@ -93,16 +93,10 @@ parameter:
#
# max:
#
# o Maximum Number of SGW per MME
# sgw: 32
# o Maximum Number of PGW per MME
# pgw: 32
# o Maximum Number of VLR per MME
# vlr: 32
# o Maximum Number of eNodeB per MME
# enb: 32
# o Maximum Number of UE per eNodeB
# ue: 128
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
#
max:

View File

@ -310,12 +310,10 @@ parameter:
#
# max:
#
# o Maximum Number of gNB per AMF
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
# o Maximum Number of UE per gNB
# ue: 128
# o Maximum Number of NF Instance
# nf: 512
#
max:
@ -340,12 +338,6 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:
#

View File

@ -126,12 +126,10 @@ parameter:
#
# max:
#
# o Maximum Number of gNB per AMF
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
# o Maximum Number of UE per gNB
# ue: 128
# o Maximum Number of NF Instance
# nf: 512
#
max:
@ -156,12 +154,6 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:
#

View File

@ -128,12 +128,10 @@ parameter:
#
# max:
#
# o Maximum Number of gNB per AMF
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
# o Maximum Number of UE per gNB
# ue: 128
# o Maximum Number of NF Instance
# nf: 512
#
max:
@ -158,12 +156,6 @@ max:
# 8192: 128
# big: 8
#
# o Memory of Packet Buffering in UPF/SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in UPF/SGW
# - UPF/SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
#
# packet: 65536
#
pool:
#

View File

@ -107,12 +107,10 @@ parameter:
#
# max:
#
# o Maximum Number of gNB per AMF
# o Maximum Number of UE per AMF/MME
# ue: 4,096
# o Maximum Number of gNB/eNB per AMF/MME
# gnb: 32
# o Maximum Number of UE per gNB
# ue: 128
# o Maximum Number of NF Instance
# nf: 512
#
max:

View File

@ -110,7 +110,8 @@ UPF-pfcp = 10.10.0.7 :8805 (authVPN) for N4
UPF-gtpu = 10.11.0.7 :2152 (userplaneVPN) for S5/8u, N3
```
You can refer to the network settings at [https://open5gs.org/open5gs/assets/Open5GS-Diagram.pdf](https://open5gs.org/open5gs/assets/Open5GS-Diagram.pdf) provided by [@kbarlee](https://github.com/kbarlee) in issue [#528](https://github.com/open5gs/open5gs/issues/528)
You can refer to the network settings at
[{{ site.url }}{{ site.baseurl }}/assets/Open5GS-Diagram.pdf]({{ site.url }}{{ site.baseurl }}/assets/Open5GS-Diagram.pdf) provided by [@kbarlee](https://github.com/kbarlee) in issue [#528](https://github.com/{{ site.github_username }}/open5gs/issues/528)
{: .notice--danger}
Modify [install/etc/open5gs/mme.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/master/configs/open5gs/mme.yaml.in) to set the S1AP IP address, PLMN ID, and TAC.

View File

@ -116,7 +116,8 @@ UPF-pfcp = 10.10.0.7 :8805 (authVPN) for N4
UPF-gtpu = 10.11.0.7 :2152 (userplaneVPN) for S5/8u, N3
```
You can refer to the network settings at [https://open5gs.org/open5gs/assets/Open5GS-Diagram.pdf](https://open5gs.org/open5gs/assets/Open5GS-Diagram.pdf) provided by [@kbarlee](https://github.com/kbarlee) in issue [#528](https://github.com/open5gs/open5gs/issues/528)
You can refer to the network settings at
[{{ site.url }}{{ site.baseurl }}/assets/Open5GS-Diagram.pdf]({{ site.url }}{{ site.baseurl }}/assets/Open5GS-Diagram.pdf) provided by [@kbarlee](https://github.com/kbarlee) in issue [#528](https://github.com/{{ site.github_username }}/open5gs/issues/528)
{: .notice--danger}
Modify [install/etc/open5gs/mme.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/master/configs/open5gs/mme.yaml.in) to set the S1AP IP address, PLMN ID, and TAC.

View File

@ -29,6 +29,15 @@ $ sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.6 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.7 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.8 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.9 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.10 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.11 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.12 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.13 netmask 255.255.255.255
```
Enable IP forwarding

View File

@ -24,8 +24,7 @@ $ brew install mongodb-community
Run MongoDB server.
```bash
$ mkdir -p ./data/db
$ mongod --dbpath ./data/db
$ mongod --config /usr/local/etc/mongod.conf
```
**Tip:** MongoDB is persistent after rebooting with the following commands:
@ -38,6 +37,7 @@ $ mongod --dbpath ./data/db
Install TUN/TAP driver
- You can download it from [http://tuntaposx.sourceforge.net/](http://tuntaposx.sourceforge.net/)
- And then, run tuntap_20150118.pkg to install TUN/TAP driver.
Configure the TUN device.
```bash
@ -45,6 +45,15 @@ $ sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.6 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.7 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.8 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.9 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.10 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.11 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.12 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.13 netmask 255.255.255.255
```
Enable IP forwarding & Masquerading
@ -81,7 +90,7 @@ To compile with meson:
```bash
$ cd open5gs
$ meson build --prefix=`pwd`/install
$ meson build --prefix=`pwd`/install -D c_std=c99
$ ninja -C build
```

View File

@ -160,7 +160,7 @@ If your device shows as connected (Includes 5G/LTE symbol) there are a few simpl
## Further Debugging
---
Problem with Open5GS can be filed as [GitHub Issues](https://github.com/open5gs/open5gs/issues). Please include the following to get help:
Problem with Open5GS can be filed as [GitHub Issues](https://github.com/{{ site.github_username }}/open5gs/issues). Please include the following to get help:
- Attach `*.pcapng` file created by wireskark.
- Attach configuration files at `/etc/open5gs/*.yaml`.

View File

@ -3,6 +3,20 @@ title: Now in the Github Issue
head_inline: "<style> .blue { color: blue; } </style>"
---
#### Wireshark cannot decode NAS-5GS
By default, wireshark cannot decode NAS-5GS message when the security header type is "Integrity protected and ciphered".
![Wireshark cannot decode]({{ site.url }}{{ site.baseurl }}/assets/images/wireshark_cannot_decode_nas_5gs.png){: height="480" width="640"}
You need to turn on "Try to detect and decode 5G-EA0 ciphered messages" in the wireshark perference menu.
![Wireshark perference]({{ site.url }}{{ site.baseurl }}/assets/images/wireshark_preference.png){: height="480" width="640"}
Now, you can see the NAS-5GS message in the wireshark.
![Wireshark can decode]({{ site.url }}{{ site.baseurl }}/assets/images/wireshark_can_decode_nas_5gs.png){: height="480" width="640"}
#### Test failed (e.g. `meson test -v`)
Sometimes you may get a message like the one below due to a problem with the freeDiameter library.
@ -662,7 +676,7 @@ By default, Open5GS is designed to support the Embedding System. To do so, we in
- We'll use Debian Docker Environment.
```bash
$ git clone https://github.com/open5gs/open5gs
$ git clone https://github.com/{{ site.github_username }}/open5gs
$ cd open5gs/docker
$ DIST=debian TAG=stretch docker-compose run dev
```
@ -675,7 +689,7 @@ $ sudo apt update
$ sudo apt install libsctp-dev:armel libyaml-dev:armel libgnutls28-dev:armel libgcrypt-dev:armel libidn11-dev:armel libssl-dev:armel libmongoc-dev:armel libbson-dev:armel
$ sudo apt install crossbuild-essential-armel
$ sudo apt install qemu
$ git clone https://github.com/acetcom/open5gs
$ git clone https://github.com/{{ site.github_username }}/open5gs
$ cd open5gs/
$ cat << EOF > cross_file.txt

View File

@ -257,7 +257,7 @@ $ diff -u /etc/open5gs/mme.yaml.old /etc/open5gs/mme.yaml
ciphering_order : [ EEA0, EEA1, EEA2 ]
```
Modify [install/etc/open5gs/sgwu.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/master/configs/open5gs/sgwu.yaml.in) to set the GTP-U and PFCP IP address.
Modify [install/etc/open5gs/sgwu.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/master/configs/open5gs/sgwu.yaml.in) to set the GTP-U IP address.
```diff
$ diff -u /etc/open5gs/sgwu.yaml.old /etc/open5gs/sgwu.yaml
--- sgwu.yaml.old 2020-08-22 12:08:44.782880778 -0400

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

View File

@ -19,11 +19,11 @@ libapp_sources = files('''
ogs-app.h
ogs-yaml.h
ogs-config.h
ogs-context.h
ogs-init.h
ogs-yaml.c
ogs-config.c
ogs-context.c
ogs-init.c
'''.split())

View File

@ -27,7 +27,7 @@
extern int __ogs_app_domain;
#include "app/ogs-yaml.h"
#include "app/ogs-config.h"
#include "app/ogs-context.h"
#include "app/ogs-init.h"
#undef OGS_APP_INSIDE

View File

@ -19,22 +19,22 @@
#include "ogs-app.h"
static ogs_config_t self;
static ogs_app_context_t self;
static int initialized = 0;
int ogs_config_init()
int ogs_app_context_init(void)
{
ogs_assert(initialized == 0);
memset(&self, 0, sizeof(ogs_config_t));
memset(&self, 0, sizeof(ogs_app_context_t));
initialized = 1;
return OGS_OK;
}
int ogs_config_final()
void ogs_app_context_final(void)
{
ogs_assert(initialized == 1);
@ -43,115 +43,59 @@ int ogs_config_final()
free(self.document);
}
initialized = 0;
if (self.pollset)
ogs_pollset_destroy(self.pollset);
if (self.timer_mgr)
ogs_timer_mgr_destroy(self.timer_mgr);
if (self.queue)
ogs_queue_destroy(self.queue);
return OGS_OK;
initialized = 0;
}
ogs_config_t *ogs_config()
ogs_app_context_t *ogs_app()
{
return &self;
}
int ogs_config_read()
{
ogs_config_t *config = &self;
FILE *file;
yaml_parser_t parser;
yaml_document_t *document = NULL;
ogs_assert(config->file);
file = fopen(config->file, "rb");
if (!file) {
ogs_fatal("cannot open file `%s`", config->file);
return OGS_ERROR;
}
ogs_assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_file(&parser, file);
document = calloc(1, sizeof(yaml_document_t));
if (!yaml_parser_load(&parser, document)) {
ogs_fatal("Failed to parse configuration file '%s'", config->file);
switch (parser.error) {
case YAML_MEMORY_ERROR:
ogs_error("Memory error: Not enough memory for parsing");
break;
case YAML_READER_ERROR:
if (parser.problem_value != -1)
ogs_error("Reader error - %s: #%X at %zd", parser.problem,
parser.problem_value, parser.problem_offset);
else
ogs_error("Reader error - %s at %zd", parser.problem,
parser.problem_offset);
break;
case YAML_SCANNER_ERROR:
if (parser.context)
ogs_error("Scanner error - %s at line %zu, column %zu"
"%s at line %zu, column %zu", parser.context,
parser.context_mark.line+1,
parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
else
ogs_error("Scanner error - %s at line %zu, column %zu",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
break;
case YAML_PARSER_ERROR:
if (parser.context)
ogs_error("Parser error - %s at line %zu, column %zu"
"%s at line %zu, column %zu", parser.context,
parser.context_mark.line+1,
parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
else
ogs_error("Parser error - %s at line %zu, column %zu",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
break;
default:
/* Couldn't happen. */
ogs_assert_if_reached();
break;
}
free(document);
yaml_parser_delete(&parser);
ogs_assert(!fclose(file));
return OGS_ERROR;
}
config->document = document;
yaml_parser_delete(&parser);
ogs_assert(!fclose(file));
return OGS_OK;
}
static void recalculate_pool_size(void)
{
#define MAX_NUM_OF_BEARER 4 /* Num of Bearer per APN(Session) */
#define MAX_NUM_OF_BEARER 4 /* Num of Bearer per Session */
#define MAX_NUM_OF_TUNNEL 3 /* Num of Tunnel per Bearer */
#define MAX_NUM_OF_PF 16 /* Num of PacketFilter per Bearer */
#define MAX_NUM_OF_NF_SERVICE 16 /* Num of NF Service per NF Instance */
#define MAX_NUM_OF_SBI_MESSAGE 8 /* Num of HTTP(s) Request/Response per NF */
#define MAX_NUM_OF_NF_SUBSCRIPTION 4 /* Num of Subscription per NF */
#define MAX_NUM_OF_AUTH 4 /* Num of Subscription per UE */
self.pool.ue = self.max.ue * self.max.gnb;
self.pool.auth = self.pool.ue * MAX_NUM_OF_AUTH;
self.pool.pfcp = ogs_max(self.max.smf, self.max.upf);
self.pool.sess = self.pool.ue * OGS_MAX_NUM_OF_SESS;
self.pool.sess = self.max.ue * OGS_MAX_NUM_OF_SESS;
self.pool.bearer = self.pool.sess * MAX_NUM_OF_BEARER;
self.pool.tunnel = self.pool.bearer * MAX_NUM_OF_TUNNEL;
self.pool.pf = self.pool.bearer * MAX_NUM_OF_PF;
self.pool.nf_service = self.max.nf * MAX_NUM_OF_NF_SERVICE;
self.pool.sbi_message = self.max.nf * MAX_NUM_OF_SBI_MESSAGE;
self.pool.nf_subscription = self.max.nf * MAX_NUM_OF_NF_SUBSCRIPTION;
#define MAX_NUM_OF_TIMER 16
self.pool.timer = self.max.ue * MAX_NUM_OF_TIMER;
self.pool.nf = self.max.gnb;
#define MAX_NUM_OF_SOCKET 4 /* Num of socket per NF */
self.pool.socket = self.pool.nf * MAX_NUM_OF_SOCKET;
#define MAX_GTP_XACT_POOL 512
self.pool.gtp_xact = MAX_GTP_XACT_POOL;
self.pool.gtp_node = self.pool.nf;
#define MAX_PFCP_XACT_POOL 512
self.pool.pfcp_xact = MAX_PFCP_XACT_POOL;
self.pool.pfcp_node = self.pool.nf;
#define MAX_NUM_OF_NF_SERVICE 16 /* Num of NF Service per NF Instance */
#define MAX_NUM_OF_SBI_MESSAGE 8 /* Num of HTTP(s) Request/Response per NF */
#define MAX_NUM_OF_NF_SUBSCRIPTION 4 /* Num of Subscription per NF */
self.pool.nf_service = self.pool.nf * MAX_NUM_OF_NF_SERVICE;
self.pool.sbi_message = self.pool.nf * MAX_NUM_OF_SBI_MESSAGE;
self.pool.nf_subscription = self.pool.nf * MAX_NUM_OF_NF_SUBSCRIPTION;
#define MAX_EVENT_POOL 32
self.pool.event = MAX_EVENT_POOL;
#define MAX_CSMAP_POOL 128
self.pool.csmap = MAX_CSMAP_POOL; /* Num of TAI-LAI Mapping Table */
}
static void regenerate_all_timer_duration(void)
@ -223,31 +167,16 @@ static void regenerate_all_timer_duration(void)
#endif
}
static int config_prepare(void)
static int app_context_prepare(void)
{
#define USRSCTP_LOCAL_UDP_PORT 9899
self.usrsctp.udp_port = USRSCTP_LOCAL_UDP_PORT;
#define MAX_NUM_OF_SGW 32 /* Num of SGW per MME */
#define MAX_NUM_OF_PGW 32 /* Num of PGW per MME */
#define MAX_NUM_OF_VLR 32 /* Num of VLR per MME */
#define MAX_NUM_OF_CSMAP 128 /* Num of TAI-LAI MAP per MME */
#define MAX_NUM_OF_UE 128 /* Num of UE per gNB */
#define MAX_NUM_OF_SMF 32 /* Num of SMF per AMF */
#define MAX_NUM_OF_UPF 32 /* Num of PGW per AMF */
#define MAX_NUM_OF_GNB 32 /* Num of gNB per AMF */
#define MAX_NUM_OF_NF 512 /* Num of NF Instance */
self.max.sgw = MAX_NUM_OF_SGW;
self.max.pgw = MAX_NUM_OF_PGW;
self.max.vlr = MAX_NUM_OF_VLR;
self.max.csmap = MAX_NUM_OF_CSMAP;
#define MAX_NUM_OF_UE 4096 /* Num of UE per AMF/MME */
#define MAX_NUM_OF_GNB 32 /* Num of gNB per AMF/MME */
self.max.gnb = MAX_NUM_OF_GNB;
self.max.ue = MAX_NUM_OF_UE;
self.max.smf = MAX_NUM_OF_SMF;
self.max.upf = MAX_NUM_OF_UPF;
self.max.nf = MAX_NUM_OF_NF;
#define MAX_NUM_OF_PACKET_POOL 65536
self.pool.packet = MAX_NUM_OF_PACKET_POOL;
@ -274,7 +203,7 @@ static int config_prepare(void)
return OGS_OK;
}
static int ogs_app_ctx_validation(void)
static int app_context_validation(void)
{
if (self.parameter.no_ipv4 == 1 &&
self.parameter.no_ipv6 == 1) {
@ -294,18 +223,17 @@ static int ogs_app_ctx_validation(void)
return OGS_OK;
}
int ogs_config_parse()
int ogs_app_context_parse_config(void)
{
int rv;
ogs_config_t *config = &self;
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
ogs_assert(config);
document = config->document;
document = self.document;
ogs_assert(document);
rv = config_prepare();
rv = app_context_prepare();
if (rv != OGS_OK) return rv;
ogs_yaml_iter_init(&root_iter, document);
@ -448,9 +376,6 @@ int ogs_config_parse()
!strcmp(max_key, "enb")) {
const char *v = ogs_yaml_iter_value(&max_iter);
if (v) self.max.gnb = atoi(v);
} else if (!strcmp(max_key, "nf")) {
const char *v = ogs_yaml_iter_value(&max_iter);
if (v) self.max.nf = atoi(v);
} else
ogs_warn("unknown key `%s`", max_key);
}
@ -564,7 +489,7 @@ int ogs_config_parse()
}
}
rv = ogs_app_ctx_validation();
rv = app_context_validation();
if (rv != OGS_OK) return rv;
return OGS_OK;

View File

@ -21,8 +21,8 @@
#error "This header cannot be included directly."
#endif
#ifndef OGS_APP_CONFIG_H
#define OGS_APP_CONFIG_H
#ifndef OGS_APP_CONTEXT_H
#define OGS_APP_CONTEXT_H
#include "ogs-app.h"
@ -30,7 +30,7 @@
extern "C" {
#endif
typedef struct ogs_config_s {
typedef struct ogs_app_context_s {
const char *file;
void *document;
@ -41,6 +41,10 @@ typedef struct ogs_config_s {
const char *domain;
} logger;
ogs_queue_t *queue;
ogs_timer_mgr_t *timer_mgr;
ogs_pollset_t *pollset;
struct {
/* Element */
int no_mme;
@ -73,32 +77,33 @@ typedef struct ogs_config_s {
} usrsctp;
struct {
int sgw;
int pgw;
int vlr;
int csmap;
int ue;
int smf;
int upf;
int gnb;
int nf;
uint64_t ue;
uint64_t gnb;
} max;
struct {
ogs_pkbuf_config_t defconfig;
int packet;
uint64_t packet;
int ue;
int auth;
int pfcp;
int sess;
int bearer;
int tunnel;
int pf;
int nf_service;
int nf_subscription;
int sbi_message;
uint64_t nf;
uint64_t sess;
uint64_t bearer;
uint64_t tunnel;
uint64_t pf;
uint64_t nf_service;
uint64_t nf_subscription;
uint64_t sbi_message;
uint64_t csmap;
uint64_t event;
uint64_t timer;
uint64_t socket;
uint64_t gtp_xact;
uint64_t gtp_node;
uint64_t pfcp_xact;
uint64_t pfcp_node;
} pool;
struct {
@ -137,17 +142,16 @@ typedef struct ogs_config_s {
} pfcp;
} message;
} time;
} ogs_config_t;
} ogs_app_context_t;
int ogs_config_init(void);
int ogs_config_final(void);
ogs_config_t *ogs_config(void);
int ogs_app_context_init(void);
void ogs_app_context_final(void);
ogs_app_context_t *ogs_app(void);
int ogs_config_read(void);
int ogs_config_parse(void);
int ogs_app_context_parse_config(void);
#ifdef __cplusplus
}
#endif
#endif /* OGS_APP_CONFIG_H */
#endif /* OGS_APP_CONTEXT_H */

View File

@ -38,7 +38,7 @@ int ogs_app_initialize(const char *default_config, const char *const argv[])
ogs_core_initialize();
ogs_app_setup_log();
ogs_config_init();
ogs_app_context_init();
/**************************************************************************
* Stage 1 : Command Line Options
@ -71,63 +71,151 @@ int ogs_app_initialize(const char *default_config, const char *const argv[])
* Stage 2 : Load Configuration File
*/
if (optarg.config_file)
ogs_config()->file = optarg.config_file;
ogs_app()->file = optarg.config_file;
else
ogs_config()->file = default_config;
ogs_app()->file = default_config;
rv = ogs_config_read();
rv = ogs_app_config_read();
if (rv != OGS_OK) return rv;
rv = ogs_config_parse();
rv = ogs_app_context_parse_config();
if (rv != OGS_OK) return rv;
/**************************************************************************
* Stage 3 : Initialize Default Memory Pool
*/
ogs_pkbuf_default_create(&ogs_config()->pool.defconfig);
ogs_pkbuf_default_create(&ogs_app()->pool.defconfig);
/**************************************************************************
* Stage 4 : Setup LOG Module
*/
if (optarg.log_file)
ogs_config()->logger.file = optarg.log_file;
ogs_app()->logger.file = optarg.log_file;
if (ogs_config()->logger.file) {
if (ogs_log_add_file(ogs_config()->logger.file) == NULL) {
if (ogs_app()->logger.file) {
if (ogs_log_add_file(ogs_app()->logger.file) == NULL) {
ogs_fatal("cannot open log file : %s",
ogs_config()->logger.file);
ogs_app()->logger.file);
return OGS_ERROR;
}
}
if (optarg.domain_mask)
ogs_config()->logger.domain = optarg.domain_mask;
ogs_app()->logger.domain = optarg.domain_mask;
if (optarg.log_level)
ogs_config()->logger.level = optarg.log_level;
ogs_app()->logger.level = optarg.log_level;
rv = ogs_log_config_domain(
ogs_config()->logger.domain, ogs_config()->logger.level);
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
/**************************************************************************
* Stage 5 : Setup Database Module
*/
if (ogs_env_get("DB_URI"))
ogs_config()->db_uri = ogs_env_get("DB_URI");
ogs_app()->db_uri = ogs_env_get("DB_URI");
/**************************************************************************
* Stage 6 : Queue, Timer and Poll
*/
ogs_app()->queue = ogs_queue_create(ogs_app()->pool.event);
ogs_assert(ogs_app()->queue);
ogs_app()->timer_mgr = ogs_timer_mgr_create(ogs_app()->pool.timer);
ogs_assert(ogs_app()->timer_mgr);
ogs_app()->pollset = ogs_pollset_create(ogs_app()->pool.socket);
ogs_assert(ogs_app()->pollset);
return rv;
}
void ogs_app_terminate(void)
{
ogs_config_final();
ogs_app_context_final();
ogs_pkbuf_default_destroy();
ogs_core_terminate();
}
int ogs_app_config_read(void)
{
FILE *file;
yaml_parser_t parser;
yaml_document_t *document = NULL;
ogs_assert(ogs_app()->file);
file = fopen(ogs_app()->file, "rb");
if (!file) {
ogs_fatal("cannot open file `%s`", ogs_app()->file);
return OGS_ERROR;
}
ogs_assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_file(&parser, file);
document = calloc(1, sizeof(yaml_document_t));
if (!yaml_parser_load(&parser, document)) {
ogs_fatal("Failed to parse configuration file '%s'", ogs_app()->file);
switch (parser.error) {
case YAML_MEMORY_ERROR:
ogs_error("Memory error: Not enough memory for parsing");
break;
case YAML_READER_ERROR:
if (parser.problem_value != -1)
ogs_error("Reader error - %s: #%X at %zd", parser.problem,
parser.problem_value, parser.problem_offset);
else
ogs_error("Reader error - %s at %zd", parser.problem,
parser.problem_offset);
break;
case YAML_SCANNER_ERROR:
if (parser.context)
ogs_error("Scanner error - %s at line %zu, column %zu"
"%s at line %zu, column %zu", parser.context,
parser.context_mark.line+1,
parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
else
ogs_error("Scanner error - %s at line %zu, column %zu",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
break;
case YAML_PARSER_ERROR:
if (parser.context)
ogs_error("Parser error - %s at line %zu, column %zu"
"%s at line %zu, column %zu", parser.context,
parser.context_mark.line+1,
parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
else
ogs_error("Parser error - %s at line %zu, column %zu",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
break;
default:
/* Couldn't happen. */
ogs_assert_if_reached();
break;
}
free(document);
yaml_parser_delete(&parser);
ogs_assert(!fclose(file));
return OGS_ERROR;
}
ogs_app()->document = document;
yaml_parser_delete(&parser);
ogs_assert(!fclose(file));
return OGS_OK;
}
void ogs_app_setup_log(void)
{
ogs_log_install_domain(&__ogs_app_domain, "app", ogs_core()->log.level);

View File

@ -31,6 +31,7 @@ extern "C" {
int ogs_app_initialize(const char *default_config, const char *const argv[]);
void ogs_app_terminate(void);
int ogs_app_config_read(void);
void ogs_app_setup_log(void);
#ifdef __cplusplus

View File

@ -33,9 +33,6 @@ static ogs_core_context_t self = {
.pkbuf.pool = 8,
.pkbuf.config_pool = 8,
.socket.pool = 128,
.timer.pool = 512,
.tlv.pool = 512,
};

View File

@ -86,14 +86,6 @@ typedef struct {
int config_pool;
} pkbuf;
struct {
int pool;
} socket;
struct {
int pool;
} timer;
struct {
int pool;
} tlv;

View File

@ -67,13 +67,13 @@ static void epoll_init(ogs_pollset_t *pollset)
pollset->context = context;
context->event_list = ogs_calloc(
ogs_core()->socket.pool, sizeof(struct epoll_event));
pollset->capacity, sizeof(struct epoll_event));
ogs_assert(context->event_list);
context->map_hash = ogs_hash_make();
ogs_assert(context->map_hash);
context->epfd = epoll_create(ogs_core()->socket.pool);
context->epfd = epoll_create(pollset->capacity);
ogs_assert(context->epfd >= 0);
ogs_notify_init(pollset);
@ -202,7 +202,7 @@ static int epoll_process(ogs_pollset_t *pollset, ogs_time_t timeout)
ogs_assert(context);
num_of_poll = epoll_wait(context->epfd, context->event_list,
ogs_core()->socket.pool,
pollset->capacity,
timeout == OGS_INFINITE_TIME ? OGS_INFINITE_TIME :
ogs_time_to_msec(timeout));
if (num_of_poll < 0) {

View File

@ -67,12 +67,12 @@ static void kqueue_init(ogs_pollset_t *pollset)
pollset->context = context;
context->change_list = ogs_calloc(
ogs_core()->socket.pool, sizeof(struct kevent));
pollset->capacity, sizeof(struct kevent));
context->event_list = ogs_calloc(
ogs_core()->socket.pool, sizeof(struct kevent));
pollset->capacity, sizeof(struct kevent));
ogs_assert(context->change_list);
context->nchanges = 0;
context->nevents = ogs_core()->socket.pool;
context->nevents = pollset->capacity;
context->kqueue = kqueue();
ogs_assert(context->kqueue != -1);
@ -108,7 +108,7 @@ static int kqueue_set(ogs_poll_t *poll, int filter, int flags)
context = pollset->context;
ogs_assert(context);
ogs_assert(context->nchanges < ogs_core()->socket.pool);
ogs_assert(context->nchanges < pollset->capacity);
kev = &context->change_list[context->nchanges];
memset(kev, 0, sizeof *kev);

View File

@ -48,6 +48,8 @@ typedef struct ogs_pollset_s {
ogs_socket_t fd[2];
ogs_poll_t *poll;
} notify;
unsigned int capacity;
} ogs_pollset_t;
#ifdef __cplusplus

View File

@ -30,12 +30,14 @@ extern const ogs_pollset_actions_t ogs_select_actions;
ogs_pollset_actions_t ogs_pollset_actions;
bool ogs_pollset_actions_initialized = false;
ogs_pollset_t *ogs_pollset_create(void)
ogs_pollset_t *ogs_pollset_create(unsigned int capacity)
{
ogs_pollset_t *pollset = ogs_calloc(1, sizeof *pollset);
ogs_assert(pollset);
ogs_pool_init(&pollset->pool, ogs_core()->socket.pool);
pollset->capacity = capacity;
ogs_pool_init(&pollset->pool, capacity);
if (ogs_pollset_actions_initialized == false) {
#if defined(HAVE_KQUEUE)

View File

@ -30,7 +30,7 @@ extern "C" {
typedef void (*ogs_poll_handler_f)(short when, ogs_socket_t fd, void *data);
ogs_pollset_t *ogs_pollset_create(void);
ogs_pollset_t *ogs_pollset_create(unsigned int capacity);
void ogs_pollset_destroy(ogs_pollset_t *pollset);
#define OGS_POLLIN 0x01

View File

@ -52,12 +52,12 @@ static void add_timer_node(
ogs_rbtree_insert_color(tree, timer);
}
ogs_timer_mgr_t *ogs_timer_mgr_create(void)
ogs_timer_mgr_t *ogs_timer_mgr_create(unsigned int capacity)
{
ogs_timer_mgr_t *manager = ogs_calloc(1, sizeof *manager);
ogs_assert(manager);
ogs_pool_init(&manager->pool, ogs_core()->timer.pool);
ogs_pool_init(&manager->pool, capacity);
return manager;
}

View File

@ -41,7 +41,7 @@ typedef struct ogs_timer_s {
ogs_time_t timeout;
} ogs_timer_t;
ogs_timer_mgr_t *ogs_timer_mgr_create(void);
ogs_timer_mgr_t *ogs_timer_mgr_create(unsigned int capacity);
void ogs_timer_mgr_destroy(ogs_timer_mgr_t *manager);
ogs_timer_t *ogs_timer_add(

View File

@ -21,17 +21,16 @@
static OGS_POOL(pool, ogs_gtp_node_t);
int ogs_gtp_node_init(int size)
int ogs_gtp_node_init(void)
{
ogs_pool_init(&pool, size);
ogs_pool_init(&pool, ogs_app()->pool.gtp_node);
return OGS_OK;
}
int ogs_gtp_node_final(void)
void ogs_gtp_node_final(void)
{
ogs_pool_final(&pool);
return OGS_OK;
}
ogs_gtp_node_t *ogs_gtp_node_new(ogs_sockaddr_t *sa_list)

View File

@ -52,8 +52,8 @@ typedef struct ogs_gtp_node_s {
ogs_list_t remote_list;
} ogs_gtp_node_t;
int ogs_gtp_node_init(int size);
int ogs_gtp_node_final(void);
int ogs_gtp_node_init(void);
void ogs_gtp_node_final(void);
ogs_gtp_node_t *ogs_gtp_node_new(ogs_sockaddr_t *sa_list);
void ogs_gtp_node_free(ogs_gtp_node_t *node);

View File

@ -21,6 +21,7 @@
#define OGS_GTP_H
#include "ogs-core.h"
#include "ogs-app.h"
#define OGS_GTPV1_U_UDP_PORT 2152
#define OGS_GTPV2_C_UDP_PORT 2123

View File

@ -28,7 +28,6 @@ typedef enum {
} ogs_gtp_xact_stage_t;
static int ogs_gtp_xact_initialized = 0;
static ogs_timer_mgr_t *g_timer_mgr = NULL;
static uint32_t g_xact_id = 0;
static OGS_POOL(pool, ogs_gtp_xact_t);
@ -39,29 +38,26 @@ static int ogs_gtp_xact_delete(ogs_gtp_xact_t *xact);
static void response_timeout(void *data);
static void holding_timeout(void *data);
int ogs_gtp_xact_init(ogs_timer_mgr_t *timer_mgr, int size)
int ogs_gtp_xact_init(void)
{
ogs_assert(ogs_gtp_xact_initialized == 0);
ogs_pool_init(&pool, size);
ogs_pool_init(&pool, ogs_app()->pool.gtp_xact);
g_xact_id = 0;
g_timer_mgr = timer_mgr;
ogs_gtp_xact_initialized = 1;
return OGS_OK;
}
int ogs_gtp_xact_final(void)
void ogs_gtp_xact_final(void)
{
ogs_assert(ogs_gtp_xact_initialized == 1);
ogs_pool_final(&pool);
ogs_gtp_xact_initialized = 0;
return OGS_OK;
}
ogs_gtp_xact_t *ogs_gtp_xact_local_create(ogs_gtp_node_t *gnode,
@ -92,13 +88,15 @@ ogs_gtp_xact_t *ogs_gtp_xact_local_create(ogs_gtp_node_t *gnode,
xact->cb = cb;
xact->data = data;
xact->tm_response = ogs_timer_add(g_timer_mgr, response_timeout, xact);
xact->tm_response = ogs_timer_add(
ogs_app()->timer_mgr, response_timeout, xact);
ogs_assert(xact->tm_response);
xact->response_rcount = ogs_config()->time.message.gtp.n3_response_rcount,
xact->response_rcount = ogs_app()->time.message.gtp.n3_response_rcount,
xact->tm_holding = ogs_timer_add(g_timer_mgr, holding_timeout, xact);
xact->tm_holding = ogs_timer_add(
ogs_app()->timer_mgr, holding_timeout, xact);
ogs_assert(xact->tm_holding);
xact->holding_rcount = ogs_config()->time.message.gtp.n3_holding_rcount,
xact->holding_rcount = ogs_app()->time.message.gtp.n3_holding_rcount,
ogs_list_add(xact->org == OGS_GTP_LOCAL_ORIGINATOR ?
&xact->gnode->local_list : &xact->gnode->remote_list, xact);
@ -135,13 +133,15 @@ ogs_gtp_xact_t *ogs_gtp_xact_remote_create(ogs_gtp_node_t *gnode, uint32_t sqn)
xact->xid = OGS_GTP_SQN_TO_XID(sqn);
xact->gnode = gnode;
xact->tm_response = ogs_timer_add(g_timer_mgr, response_timeout, xact);
xact->tm_response = ogs_timer_add(
ogs_app()->timer_mgr, response_timeout, xact);
ogs_assert(xact->tm_response);
xact->response_rcount = ogs_config()->time.message.gtp.n3_response_rcount,
xact->response_rcount = ogs_app()->time.message.gtp.n3_response_rcount,
xact->tm_holding = ogs_timer_add(g_timer_mgr, holding_timeout, xact);
xact->tm_holding = ogs_timer_add(
ogs_app()->timer_mgr, holding_timeout, xact);
ogs_assert(xact->tm_holding);
xact->holding_rcount = ogs_config()->time.message.gtp.n3_holding_rcount,
xact->holding_rcount = ogs_app()->time.message.gtp.n3_holding_rcount,
ogs_list_add(xact->org == OGS_GTP_LOCAL_ORIGINATOR ?
&xact->gnode->local_list : &xact->gnode->remote_list, xact);
@ -307,7 +307,7 @@ int ogs_gtp_xact_update_rx(ogs_gtp_xact_t *xact, uint8_t type)
if (pkbuf) {
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.
ogs_app()->time.message.
gtp.t3_holding_duration);
ogs_warn("[%d] %s Request Duplicated. Retransmit!"
@ -343,7 +343,7 @@ int ogs_gtp_xact_update_rx(ogs_gtp_xact_t *xact, uint8_t type)
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.gtp.t3_holding_duration);
ogs_app()->time.message.gtp.t3_holding_duration);
break;
@ -373,7 +373,7 @@ int ogs_gtp_xact_update_rx(ogs_gtp_xact_t *xact, uint8_t type)
if (pkbuf) {
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.
ogs_app()->time.message.
gtp.t3_holding_duration);
ogs_warn("[%d] %s Request Duplicated. Retransmit!"
@ -408,7 +408,7 @@ int ogs_gtp_xact_update_rx(ogs_gtp_xact_t *xact, uint8_t type)
}
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.gtp.t3_holding_duration);
ogs_app()->time.message.gtp.t3_holding_duration);
break;
@ -479,7 +479,7 @@ int ogs_gtp_xact_commit(ogs_gtp_xact_t *xact)
if (xact->tm_response)
ogs_timer_start(xact->tm_response,
ogs_config()->time.message.gtp.t3_response_duration);
ogs_app()->time.message.gtp.t3_response_duration);
break;
@ -521,7 +521,7 @@ int ogs_gtp_xact_commit(ogs_gtp_xact_t *xact)
}
if (xact->tm_response)
ogs_timer_start(xact->tm_response,
ogs_config()->time.message.gtp.t3_response_duration);
ogs_app()->time.message.gtp.t3_response_duration);
break;
@ -579,7 +579,7 @@ static void response_timeout(void *data)
if (xact->tm_response)
ogs_timer_start(xact->tm_response,
ogs_config()->time.message.gtp.t3_response_duration);
ogs_app()->time.message.gtp.t3_response_duration);
pkbuf = xact->seq[xact->step-1].pkbuf;
ogs_assert(pkbuf);
@ -628,7 +628,7 @@ static void holding_timeout(void *data)
if (--xact->holding_rcount > 0) {
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.gtp.t3_holding_duration);
ogs_app()->time.message.gtp.t3_holding_duration);
} else {
ogs_debug("[%d] %s Delete Transaction "
"for step %d type %d peer [%s]:%d",

View File

@ -88,8 +88,8 @@ typedef struct ogs_gtp_xact_s {
uint64_t update_flags;
} ogs_gtp_xact_t;
int ogs_gtp_xact_init(ogs_timer_mgr_t *timer_mgr, int size);
int ogs_gtp_xact_final(void);
int ogs_gtp_xact_init(void);
void ogs_gtp_xact_final(void);
ogs_gtp_xact_t *ogs_gtp_xact_local_create(ogs_gtp_node_t *gnode,
ogs_gtp_header_t *hdesc, ogs_pkbuf_t *pkbuf,

View File

@ -68,7 +68,7 @@ ogs_pkbuf_t *ogs_pfcp_cp_build_association_setup_request(uint8_t type)
ogs_pfcp_sockaddr_to_node_id(
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
ogs_config()->parameter.prefer_ipv4,
ogs_app()->parameter.prefer_ipv4,
&node_id, &node_id_len);
req->node_id.presence = 1;
req->node_id.data = &node_id;
@ -100,7 +100,7 @@ ogs_pkbuf_t *ogs_pfcp_cp_build_association_setup_response(uint8_t type,
ogs_pfcp_sockaddr_to_node_id(
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
ogs_config()->parameter.prefer_ipv4,
ogs_app()->parameter.prefer_ipv4,
&node_id, &node_id_len);
rsp->node_id.presence = 1;
rsp->node_id.data = &node_id;
@ -139,7 +139,7 @@ ogs_pkbuf_t *ogs_pfcp_up_build_association_setup_request(uint8_t type)
ogs_pfcp_sockaddr_to_node_id(
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
ogs_config()->parameter.prefer_ipv4,
ogs_app()->parameter.prefer_ipv4,
&node_id, &node_id_len);
req->node_id.presence = 1;
req->node_id.data = &node_id;
@ -192,7 +192,7 @@ ogs_pkbuf_t *ogs_pfcp_up_build_association_setup_response(uint8_t type,
ogs_pfcp_sockaddr_to_node_id(
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
ogs_config()->parameter.prefer_ipv4,
ogs_app()->parameter.prefer_ipv4,
&node_id, &node_id_len);
rsp->node_id.presence = 1;
rsp->node_id.data = &node_id;

View File

@ -64,26 +64,26 @@ void ogs_pfcp_context_init(int num_of_gtpu_resource)
ogs_log_install_domain(&__ogs_pfcp_domain, "pfcp", ogs_core()->log.level);
ogs_pool_init(&ogs_pfcp_node_pool, ogs_config()->pool.pfcp);
ogs_pool_init(&ogs_pfcp_node_pool, ogs_app()->pool.pfcp_node);
ogs_pool_init(&ogs_pfcp_gtpu_resource_pool, num_of_gtpu_resource);
ogs_list_init(&self.peer_list);
ogs_list_init(&self.gtpu_resource_list);
ogs_pool_init(&ogs_pfcp_sess_pool, ogs_config()->pool.sess);
ogs_pool_init(&ogs_pfcp_sess_pool, ogs_app()->pool.sess);
ogs_pool_init(&ogs_pfcp_pdr_pool,
ogs_config()->pool.sess * OGS_MAX_NUM_OF_PDR);
ogs_app()->pool.sess * OGS_MAX_NUM_OF_PDR);
ogs_pool_init(&ogs_pfcp_far_pool,
ogs_config()->pool.sess * OGS_MAX_NUM_OF_FAR);
ogs_app()->pool.sess * OGS_MAX_NUM_OF_FAR);
ogs_pool_init(&ogs_pfcp_urr_pool,
ogs_config()->pool.sess * OGS_MAX_NUM_OF_URR);
ogs_app()->pool.sess * OGS_MAX_NUM_OF_URR);
ogs_pool_init(&ogs_pfcp_qer_pool,
ogs_config()->pool.sess * OGS_MAX_NUM_OF_QER);
ogs_app()->pool.sess * OGS_MAX_NUM_OF_QER);
ogs_pool_init(&ogs_pfcp_bar_pool,
ogs_config()->pool.sess * OGS_MAX_NUM_OF_BAR);
ogs_app()->pool.sess * OGS_MAX_NUM_OF_BAR);
ogs_pool_init(&ogs_pfcp_rule_pool,
ogs_config()->pool.sess * OGS_MAX_NUM_OF_RULE);
ogs_app()->pool.sess * OGS_MAX_NUM_OF_RULE);
ogs_list_init(&self.dev_list);
ogs_pool_init(&ogs_pfcp_dev_pool, OGS_MAX_NUM_OF_DEV);
@ -142,7 +142,7 @@ static int ogs_pfcp_context_validation(const char *local)
{
if (ogs_list_first(&self.pfcp_list) == NULL &&
ogs_list_first(&self.pfcp_list6) == NULL) {
ogs_error("No %s.pfcp: in '%s'", local, ogs_config()->file);
ogs_error("No %s.pfcp: in '%s'", local, ogs_app()->file);
return OGS_ERROR;
}
return OGS_OK;
@ -154,7 +154,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = ogs_pfcp_context_prepare();
@ -255,10 +255,10 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
}
if (addr) {
if (ogs_config()->parameter.no_ipv4 == 0)
if (ogs_app()->parameter.no_ipv4 == 0)
ogs_socknode_add(
&self.pfcp_list, AF_INET, addr);
if (ogs_config()->parameter.no_ipv6 == 0)
if (ogs_app()->parameter.no_ipv6 == 0)
ogs_socknode_add(
&self.pfcp_list6, AF_INET6, addr);
ogs_freeaddrinfo(addr);
@ -266,9 +266,9 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
if (dev) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.pfcp_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.pfcp_list6,
dev, self.pfcp_port);
ogs_assert(rv == OGS_OK);
@ -280,9 +280,9 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
if (ogs_list_first(&self.pfcp_list) == NULL &&
ogs_list_first(&self.pfcp_list6) == NULL) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.pfcp_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.pfcp_list6,
NULL, self.pfcp_port);
ogs_assert(rv == OGS_OK);
@ -618,9 +618,9 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
}
ogs_filter_ip_version(&addr,
ogs_config()->parameter.no_ipv4,
ogs_config()->parameter.no_ipv6,
ogs_config()->parameter.prefer_ipv4);
ogs_app()->parameter.no_ipv4,
ogs_app()->parameter.no_ipv6,
ogs_app()->parameter.prefer_ipv4);
if (addr == NULL) continue;
@ -1315,7 +1315,7 @@ int ogs_pfcp_ue_pool_generate(void)
}
inc = 0;
while(poolindex < ogs_config()->pool.sess) {
while(poolindex < ogs_app()->pool.sess) {
ogs_pfcp_ue_ip_t *ue_ip = NULL;
ue_ip = &subnet->pool.array[poolindex];
@ -1522,7 +1522,7 @@ ogs_pfcp_subnet_t *ogs_pfcp_subnet_add(
if (apn)
strcpy(subnet->apn, apn);
ogs_pool_init(&subnet->pool, ogs_config()->pool.sess);
ogs_pool_init(&subnet->pool, ogs_app()->pool.sess);
ogs_list_add(&self.subnet_list, subnet);

View File

@ -35,7 +35,7 @@ void ogs_pfcp_handle_heartbeat_response(
ogs_pfcp_xact_commit(xact);
ogs_timer_start(node->t_no_heartbeat,
ogs_config()->time.message.pfcp.no_heartbeat_duration);
ogs_app()->time.message.pfcp.no_heartbeat_duration);
}
void ogs_pfcp_cp_handle_association_setup_request(

View File

@ -31,40 +31,37 @@ typedef enum {
} ogs_pfcp_xact_stage_t;
static int ogs_pfcp_xact_initialized = 0;
static ogs_timer_mgr_t *g_timer_mgr = NULL;
static uint32_t g_xact_id = 0;
static OGS_POOL(pool, ogs_pfcp_xact_t);
static ogs_pfcp_xact_stage_t ogs_pfcp_xact_get_stage(uint8_t type, uint32_t sqn);
static ogs_pfcp_xact_stage_t ogs_pfcp_xact_get_stage(
uint8_t type, uint32_t sqn);
static int ogs_pfcp_xact_delete(ogs_pfcp_xact_t *xact);
static void response_timeout(void *data);
static void holding_timeout(void *data);
int ogs_pfcp_xact_init(ogs_timer_mgr_t *timer_mgr, int size)
int ogs_pfcp_xact_init(void)
{
ogs_assert(ogs_pfcp_xact_initialized == 0);
ogs_pool_init(&pool, size);
ogs_pool_init(&pool, ogs_app()->pool.pfcp_xact);
g_xact_id = 0;
g_timer_mgr = timer_mgr;
ogs_pfcp_xact_initialized = 1;
return OGS_OK;
}
int ogs_pfcp_xact_final(void)
void ogs_pfcp_xact_final(void)
{
ogs_assert(ogs_pfcp_xact_initialized == 1);
ogs_pool_final(&pool);
ogs_pfcp_xact_initialized = 0;
return OGS_OK;
}
ogs_pfcp_xact_t *ogs_pfcp_xact_local_create(ogs_pfcp_node_t *node,
@ -88,13 +85,15 @@ ogs_pfcp_xact_t *ogs_pfcp_xact_local_create(ogs_pfcp_node_t *node,
xact->cb = cb;
xact->data = data;
xact->tm_response = ogs_timer_add(g_timer_mgr, response_timeout, xact);
xact->tm_response = ogs_timer_add(
ogs_app()->timer_mgr, response_timeout, xact);
ogs_assert(xact->tm_response);
xact->response_rcount = ogs_config()->time.message.pfcp.n1_response_rcount,
xact->response_rcount = ogs_app()->time.message.pfcp.n1_response_rcount,
xact->tm_holding = ogs_timer_add(g_timer_mgr, holding_timeout, xact);
xact->tm_holding = ogs_timer_add(
ogs_app()->timer_mgr, holding_timeout, xact);
ogs_assert(xact->tm_holding);
xact->holding_rcount = ogs_config()->time.message.pfcp.n1_holding_rcount,
xact->holding_rcount = ogs_app()->time.message.pfcp.n1_holding_rcount,
ogs_list_add(xact->org == OGS_PFCP_LOCAL_ORIGINATOR ?
&xact->node->local_list : &xact->node->remote_list, xact);
@ -132,13 +131,15 @@ ogs_pfcp_xact_t *ogs_pfcp_xact_remote_create(
xact->xid = OGS_PFCP_SQN_TO_XID(sqn);
xact->node = node;
xact->tm_response = ogs_timer_add(g_timer_mgr, response_timeout, xact);
xact->tm_response = ogs_timer_add(
ogs_app()->timer_mgr, response_timeout, xact);
ogs_assert(xact->tm_response);
xact->response_rcount = ogs_config()->time.message.pfcp.n1_response_rcount,
xact->response_rcount = ogs_app()->time.message.pfcp.n1_response_rcount,
xact->tm_holding = ogs_timer_add(g_timer_mgr, holding_timeout, xact);
xact->tm_holding = ogs_timer_add(
ogs_app()->timer_mgr, holding_timeout, xact);
ogs_assert(xact->tm_holding);
xact->holding_rcount = ogs_config()->time.message.pfcp.n1_holding_rcount,
xact->holding_rcount = ogs_app()->time.message.pfcp.n1_holding_rcount,
ogs_list_add(xact->org == OGS_PFCP_LOCAL_ORIGINATOR ?
&xact->node->local_list : &xact->node->remote_list, xact);
@ -304,7 +305,7 @@ int ogs_pfcp_xact_update_rx(ogs_pfcp_xact_t *xact, uint8_t type)
if (pkbuf) {
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.
ogs_app()->time.message.
pfcp.t1_holding_duration);
ogs_warn("[%d] %s Request Duplicated. Retransmit!"
@ -340,7 +341,7 @@ int ogs_pfcp_xact_update_rx(ogs_pfcp_xact_t *xact, uint8_t type)
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.pfcp.t1_holding_duration);
ogs_app()->time.message.pfcp.t1_holding_duration);
break;
@ -370,7 +371,7 @@ int ogs_pfcp_xact_update_rx(ogs_pfcp_xact_t *xact, uint8_t type)
if (pkbuf) {
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.
ogs_app()->time.message.
pfcp.t1_holding_duration);
ogs_warn("[%d] %s Request Duplicated. Retransmit!"
@ -405,7 +406,7 @@ int ogs_pfcp_xact_update_rx(ogs_pfcp_xact_t *xact, uint8_t type)
}
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.pfcp.t1_holding_duration);
ogs_app()->time.message.pfcp.t1_holding_duration);
break;
@ -476,7 +477,7 @@ int ogs_pfcp_xact_commit(ogs_pfcp_xact_t *xact)
if (xact->tm_response)
ogs_timer_start(xact->tm_response,
ogs_config()->time.message.pfcp.t1_response_duration);
ogs_app()->time.message.pfcp.t1_response_duration);
break;
@ -518,7 +519,7 @@ int ogs_pfcp_xact_commit(ogs_pfcp_xact_t *xact)
}
if (xact->tm_response)
ogs_timer_start(xact->tm_response,
ogs_config()->time.message.pfcp.t1_response_duration);
ogs_app()->time.message.pfcp.t1_response_duration);
break;
@ -576,7 +577,7 @@ static void response_timeout(void *data)
if (xact->tm_response)
ogs_timer_start(xact->tm_response,
ogs_config()->time.message.pfcp.t1_response_duration);
ogs_app()->time.message.pfcp.t1_response_duration);
pkbuf = xact->seq[xact->step-1].pkbuf;
ogs_assert(pkbuf);
@ -625,7 +626,7 @@ static void holding_timeout(void *data)
if (--xact->holding_rcount > 0) {
if (xact->tm_holding)
ogs_timer_start(xact->tm_holding,
ogs_config()->time.message.pfcp.t1_holding_duration);
ogs_app()->time.message.pfcp.t1_holding_duration);
} else {
ogs_debug("[%d] %s Delete Transaction "
"for step %d type %d peer [%s]:%d",

View File

@ -90,8 +90,8 @@ typedef struct ogs_pfcp_xact_s {
int delete_trigger;
} ogs_pfcp_xact_t;
int ogs_pfcp_xact_init(ogs_timer_mgr_t *timer_mgr, int size);
int ogs_pfcp_xact_final(void);
int ogs_pfcp_xact_init(void);
void ogs_pfcp_xact_final(void);
ogs_pfcp_xact_t *ogs_pfcp_xact_local_create(ogs_pfcp_node_t *node,
ogs_pfcp_header_t *hdesc, ogs_pkbuf_t *pkbuf,

View File

@ -72,7 +72,7 @@ void ogs_sbi_client_init(int num_of_sockinfo_pool, int num_of_connection_pool)
curl_global_init(CURL_GLOBAL_DEFAULT);
ogs_list_init(&ogs_sbi_self()->client_list);
ogs_pool_init(&client_pool, ogs_config()->max.nf);
ogs_pool_init(&client_pool, ogs_app()->pool.nf);
ogs_pool_init(&sockinfo_pool, num_of_sockinfo_pool);
ogs_pool_init(&connection_pool, num_of_connection_pool);
@ -105,7 +105,7 @@ ogs_sbi_client_t *ogs_sbi_client_add(ogs_sockaddr_t *addr)
ogs_list_init(&client->connection_list);
client->t_curl = ogs_timer_add(
ogs_sbi_self()->timer_mgr, multi_timer_expired, client);
ogs_app()->timer_mgr, multi_timer_expired, client);
multi = client->multi = curl_multi_init();
ogs_assert(multi);
@ -273,7 +273,7 @@ static connection_t *connection_add(
}
conn->timer = ogs_timer_add(
ogs_sbi_self()->timer_mgr, connection_timer_expired, conn);
ogs_app()->timer_mgr, connection_timer_expired, conn);
ogs_assert(conn->timer);
ogs_list_add(&client->connection_list, conn);
@ -281,7 +281,7 @@ static connection_t *connection_add(
/* If http response is not received within deadline,
* Open5GS will discard this request. */
ogs_timer_start(conn->timer,
ogs_config()->time.message.sbi.connection_deadline);
ogs_app()->time.message.sbi.connection_deadline);
conn->easy = curl_easy_init();
ogs_assert(conn->easy);
@ -569,7 +569,7 @@ static void sock_set(sockinfo_t *sockinfo, curl_socket_t s,
sockinfo->easy = e;
sockinfo->poll = ogs_pollset_add(
ogs_sbi_self()->pollset, kind, s, event_cb, sockinfo);
ogs_app()->pollset, kind, s, event_cb, sockinfo);
}
/* Initialize a new sockinfo_t structure */

View File

@ -31,33 +31,28 @@ static ogs_sbi_context_t self;
static int context_initialized = 0;
void ogs_sbi_context_init(ogs_pollset_t *pollset, ogs_timer_mgr_t *timer_mgr)
void ogs_sbi_context_init(void)
{
ogs_assert(context_initialized == 0);
/* Initialize SMF context */
memset(&self, 0, sizeof(ogs_sbi_context_t));
ogs_assert(pollset);
self.pollset = pollset;
ogs_assert(timer_mgr);
self.timer_mgr = timer_mgr;
ogs_log_install_domain(&__ogs_sbi_domain, "sbi", ogs_core()->log.level);
ogs_sbi_message_init(
ogs_config()->pool.sbi_message, ogs_config()->pool.sbi_message);
ogs_sbi_server_init(ogs_config()->max.nf);
ogs_sbi_client_init(ogs_config()->max.nf, ogs_config()->max.nf);
ogs_app()->pool.sbi_message, ogs_app()->pool.sbi_message);
ogs_sbi_server_init(ogs_app()->pool.nf);
ogs_sbi_client_init(ogs_app()->pool.nf, ogs_app()->pool.nf);
ogs_list_init(&self.nf_instance_list);
ogs_pool_init(&nf_instance_pool, ogs_config()->max.nf);
ogs_pool_init(&nf_service_pool, ogs_config()->pool.nf_service);
ogs_pool_init(&nf_instance_pool, ogs_app()->pool.nf);
ogs_pool_init(&nf_service_pool, ogs_app()->pool.nf_service);
ogs_pool_init(&xact_pool, ogs_config()->pool.sbi_message);
ogs_pool_init(&xact_pool, ogs_app()->pool.sbi_message);
ogs_list_init(&self.subscription_list);
ogs_pool_init(&subscription_pool, ogs_config()->pool.nf_subscription);
ogs_pool_init(&subscription_pool, ogs_app()->pool.nf_subscription);
ogs_uuid_get(&self.uuid);
ogs_uuid_format(self.nf_instance_id, &self.uuid);
@ -103,7 +98,7 @@ static int ogs_sbi_context_prepare(void)
static int ogs_sbi_context_validation(const char *local)
{
if (ogs_list_first(&self.server_list) == NULL) {
ogs_error("No %s.sbi: in '%s'", local, ogs_config()->file);
ogs_error("No %s.sbi: in '%s'", local, ogs_app()->file);
return OGS_ERROR;
}
@ -116,7 +111,7 @@ int ogs_sbi_context_parse_config(const char *local, const char *remote)
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = ogs_sbi_context_prepare();
@ -239,17 +234,17 @@ int ogs_sbi_context_parse_config(const char *local, const char *remote)
ogs_list_init(&list6);
if (addr) {
if (ogs_config()->parameter.no_ipv4 == 0)
if (ogs_app()->parameter.no_ipv4 == 0)
ogs_socknode_add(&list, AF_INET, addr);
if (ogs_config()->parameter.no_ipv6 == 0)
if (ogs_app()->parameter.no_ipv6 == 0)
ogs_socknode_add(&list6, AF_INET6, addr);
ogs_freeaddrinfo(addr);
}
if (dev) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ? NULL : &list,
ogs_config()->parameter.no_ipv6 ? NULL : &list6,
ogs_app()->parameter.no_ipv4 ? NULL : &list,
ogs_app()->parameter.no_ipv6 ? NULL : &list6,
dev, port);
ogs_assert(rv == OGS_OK);
}
@ -283,8 +278,8 @@ int ogs_sbi_context_parse_config(const char *local, const char *remote)
ogs_list_init(&list6);
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ? NULL : &list,
ogs_config()->parameter.no_ipv6 ? NULL : &list6,
ogs_app()->parameter.no_ipv4 ? NULL : &list,
ogs_app()->parameter.no_ipv6 ? NULL : &list6,
NULL, self.http_port);
ogs_assert(rv == OGS_OK);
@ -400,9 +395,9 @@ int ogs_sbi_context_parse_config(const char *local, const char *remote)
}
ogs_filter_ip_version(&addr,
ogs_config()->parameter.no_ipv4,
ogs_config()->parameter.no_ipv6,
ogs_config()->parameter.prefer_ipv4);
ogs_app()->parameter.no_ipv4,
ogs_app()->parameter.no_ipv6,
ogs_app()->parameter.prefer_ipv4);
if (addr == NULL) continue;
@ -450,19 +445,19 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id)
ogs_assert(nf_instance->id);
nf_instance->time.heartbeat_interval =
ogs_config()->time.nf_instance.heartbeat_interval;
ogs_app()->time.nf_instance.heartbeat_interval;
nf_instance->t_registration_interval = ogs_timer_add(
ogs_sbi_self()->timer_mgr, NULL, nf_instance);
ogs_app()->timer_mgr, NULL, nf_instance);
ogs_assert(nf_instance->t_registration_interval);
nf_instance->t_heartbeat_interval = ogs_timer_add(
ogs_sbi_self()->timer_mgr, NULL, nf_instance);
ogs_app()->timer_mgr, NULL, nf_instance);
ogs_assert(nf_instance->t_heartbeat_interval);
nf_instance->t_no_heartbeat = ogs_timer_add(
ogs_sbi_self()->timer_mgr, NULL, nf_instance);
ogs_app()->timer_mgr, NULL, nf_instance);
ogs_assert(nf_instance->t_no_heartbeat);
nf_instance->t_validity = ogs_timer_add(
ogs_sbi_self()->timer_mgr, NULL, nf_instance);
ogs_app()->timer_mgr, NULL, nf_instance);
ogs_assert(nf_instance->t_validity);
ogs_list_add(&ogs_sbi_self()->nf_instance_list, nf_instance);
@ -1015,11 +1010,11 @@ ogs_sbi_xact_t *ogs_sbi_xact_add(OpenAPI_nf_type_e target_nf_type,
ogs_assert(xact->request);
xact->t_response = ogs_timer_add(
ogs_sbi_self()->timer_mgr, timer_cb, xact);
ogs_app()->timer_mgr, timer_cb, xact);
ogs_assert(xact->t_response);
ogs_timer_start(xact->t_response,
ogs_config()->time.message.sbi.client_wait_duration);
ogs_app()->time.message.sbi.client_wait_duration);
ogs_list_add(&sbi_object->xact_list, xact);
@ -1064,7 +1059,7 @@ ogs_sbi_subscription_t *ogs_sbi_subscription_add(void)
memset(subscription, 0, sizeof(ogs_sbi_subscription_t));
subscription->time.validity_duration =
ogs_config()->time.subscription.validity_duration;
ogs_app()->time.subscription.validity_duration;
ogs_list_add(&ogs_sbi_self()->subscription_list, subscription);

View File

@ -32,9 +32,6 @@ extern "C" {
typedef struct ogs_sbi_client_s ogs_sbi_client_t;
typedef struct ogs_sbi_context_s {
ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
uint32_t http_port; /* SBI HTTP local port */
uint32_t https_port; /* SBI HTTPS local port */
@ -179,7 +176,7 @@ typedef struct ogs_sbi_subscription_s {
void *client; /* only used in SERVER */
} ogs_sbi_subscription_t;
void ogs_sbi_context_init(ogs_pollset_t *pollset, ogs_timer_mgr_t *timer_mgr);
void ogs_sbi_context_init(void);
void ogs_sbi_context_final(void);
ogs_sbi_context_t *ogs_sbi_self(void);
int ogs_sbi_context_parse_config(const char *local, const char *remote);

View File

@ -82,7 +82,7 @@ static void session_timer_expired(void *data);
void ogs_sbi_server_init(int num_of_session_pool)
{
ogs_list_init(&ogs_sbi_self()->server_list);
ogs_pool_init(&server_pool, ogs_config()->max.nf);
ogs_pool_init(&server_pool, ogs_app()->pool.nf);
ogs_pool_init(&session_pool, num_of_session_pool);
}
@ -112,13 +112,13 @@ static ogs_sbi_session_t *session_add(ogs_sbi_server_t *server,
session->connection = connection;
session->timer = ogs_timer_add(
ogs_sbi_self()->timer_mgr, session_timer_expired, session);
ogs_app()->timer_mgr, session_timer_expired, session);
ogs_assert(session->timer);
/* If User does not send http response within deadline,
* Open5GS will assert this program. */
ogs_timer_start(session->timer,
ogs_config()->time.message.sbi.connection_deadline);
ogs_app()->time.message.sbi.connection_deadline);
ogs_list_add(&server->suspended_session_list, session);
@ -284,7 +284,7 @@ void ogs_sbi_server_start(ogs_sbi_server_t *server, int (*cb)(
mhd_info = MHD_get_daemon_info(server->mhd, MHD_DAEMON_INFO_LISTEN_FD);
ogs_assert(mhd_info);
server->poll = ogs_pollset_add(ogs_sbi_self()->pollset,
server->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, mhd_info->listen_fd, run, server->mhd);
ogs_assert(server->poll);
@ -393,7 +393,7 @@ void ogs_sbi_server_send_response(
ogs_sbi_response_free(response);
session_remove(session);
request->poll = ogs_pollset_add(ogs_sbi_self()->pollset,
request->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLOUT, mhd_socket, run, mhd_daemon);
ogs_assert(request->poll);
@ -491,7 +491,7 @@ static void notify_connection(void *cls,
mhd_socket = mhd_info->connect_fd;
ogs_assert(mhd_socket != INVALID_SOCKET);
poll = ogs_pollset_add(ogs_sbi_self()->pollset,
poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, mhd_socket, run, mhd_daemon);
ogs_assert(poll);
*socket_context = poll;

View File

@ -24,7 +24,7 @@ int app_initialize(const char *const argv[])
{
int rv;
ogs_sctp_init(ogs_config()->usrsctp.udp_port);
ogs_sctp_init(ogs_app()->usrsctp.udp_port);
rv = amf_initialize();
if (rv != OGS_OK) {
ogs_error("Failed to intialize AMF");

View File

@ -48,11 +48,11 @@ void amf_context_init(void)
ogs_list_init(&self.ngap_list6);
/* Allocate TWICE the pool to check if maximum number of gNBs is reached */
ogs_pool_init(&amf_gnb_pool, ogs_config()->max.gnb*2);
ogs_pool_init(&amf_ue_pool, ogs_config()->pool.ue);
ogs_pool_init(&ran_ue_pool, ogs_config()->pool.ue);
ogs_pool_init(&amf_sess_pool, ogs_config()->pool.sess);
ogs_pool_init(&self.m_tmsi, ogs_config()->pool.ue);
ogs_pool_init(&amf_gnb_pool, ogs_app()->max.gnb*2);
ogs_pool_init(&amf_ue_pool, ogs_app()->max.ue);
ogs_pool_init(&ran_ue_pool, ogs_app()->max.ue);
ogs_pool_init(&amf_sess_pool, ogs_app()->pool.sess);
ogs_pool_init(&self.m_tmsi, ogs_app()->max.ue);
ogs_list_init(&self.gnb_list);
ogs_list_init(&self.amf_ue_list);
@ -117,50 +117,50 @@ static int amf_context_validation(void)
{
if (ogs_list_first(&self.ngap_list) == NULL &&
ogs_list_first(&self.ngap_list6) == NULL) {
ogs_error("No amf.ngap in '%s'", ogs_config()->file);
ogs_error("No amf.ngap in '%s'", ogs_app()->file);
return OGS_RETRY;
}
if (self.num_of_served_guami == 0) {
ogs_error("No amf.guami in '%s'", ogs_config()->file);
ogs_error("No amf.guami in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.num_of_served_tai == 0) {
ogs_error("No amf.tai in '%s'", ogs_config()->file);
ogs_error("No amf.tai in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.num_of_plmn_support == 0) {
ogs_error("No amf.plmn in '%s'", ogs_config()->file);
ogs_error("No amf.plmn in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.plmn_support[0].num_of_s_nssai == 0) {
ogs_error("No amf.plmn.s_nssai in '%s'", ogs_config()->file);
ogs_error("No amf.plmn.s_nssai in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.served_tai[0].list0.tai[0].num == 0 &&
self.served_tai[0].list2.num == 0) {
ogs_error("No amf.tai.plmn_id|tac in '%s'", ogs_config()->file);
ogs_error("No amf.tai.plmn_id|tac in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.amf_name == NULL) {
ogs_error("No amf.amf_name in '%s'", ogs_config()->file);
ogs_error("No amf.amf_name in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.num_of_integrity_order == 0) {
ogs_error("No amf.security.integrity_order in '%s'",
ogs_config()->file);
ogs_app()->file);
return OGS_ERROR;
}
if (self.num_of_ciphering_order == 0) {
ogs_error("no amf.security.ciphering_order in '%s'",
ogs_config()->file);
ogs_app()->file);
return OGS_ERROR;
}
@ -173,7 +173,7 @@ int amf_context_parse_config(void)
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = amf_context_prepare();
@ -271,10 +271,10 @@ int amf_context_parse_config(void)
}
if (addr) {
if (ogs_config()->parameter.no_ipv4 == 0)
if (ogs_app()->parameter.no_ipv4 == 0)
ogs_socknode_add(
&self.ngap_list, AF_INET, addr);
if (ogs_config()->parameter.no_ipv6 == 0)
if (ogs_app()->parameter.no_ipv6 == 0)
ogs_socknode_add(
&self.ngap_list6, AF_INET6, addr);
ogs_freeaddrinfo(addr);
@ -282,9 +282,9 @@ int amf_context_parse_config(void)
if (dev) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.ngap_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.ngap_list6,
dev, port);
ogs_assert(rv == OGS_OK);
@ -296,9 +296,9 @@ int amf_context_parse_config(void)
if (ogs_list_first(&self.ngap_list) == NULL &&
ogs_list_first(&self.ngap_list6) == NULL) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.ngap_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.ngap_list6,
NULL, self.ngap_port);
ogs_assert(rv == OGS_OK);
@ -834,16 +834,16 @@ amf_gnb_t *amf_gnb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr)
gnb->max_num_of_ostreams = DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
gnb->ostream_id = 0;
if (ogs_config()->sockopt.sctp.max_num_of_ostreams) {
if (ogs_app()->sockopt.sctp.max_num_of_ostreams) {
gnb->max_num_of_ostreams =
ogs_config()->sockopt.sctp.max_num_of_ostreams;
ogs_app()->sockopt.sctp.max_num_of_ostreams;
ogs_info("[GNB] max_num_of_ostreams : %d", gnb->max_num_of_ostreams);
}
ogs_list_init(&gnb->ran_ue_list);
if (gnb->sock_type == SOCK_STREAM) {
gnb->poll = ogs_pollset_add(amf_self()->pollset,
gnb->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, ngap_recv_upcall, sock);
ogs_assert(gnb->poll);
}
@ -957,7 +957,7 @@ ran_ue_t *ran_ue_add(amf_gnb_t *gnb, uint32_t ran_ue_ngap_id)
/*
* SCTP output stream identification
* Default ogs_config()->parameter.sctp_streams : 30
* Default ogs_app()->parameter.sctp_streams : 30
* 0 : Non UE signalling
* 1-29 : UE specific association
*/
@ -1109,22 +1109,22 @@ amf_ue_t *amf_ue_add(ran_ue_t *ran_ue)
/* Add All Timers */
amf_ue->t3513.timer = ogs_timer_add(
self.timer_mgr, amf_timer_t3513_expire, amf_ue);
ogs_app()->timer_mgr, amf_timer_t3513_expire, amf_ue);
amf_ue->t3513.pkbuf = NULL;
amf_ue->t3522.timer = ogs_timer_add(
self.timer_mgr, amf_timer_t3522_expire, amf_ue);
ogs_app()->timer_mgr, amf_timer_t3522_expire, amf_ue);
amf_ue->t3522.pkbuf = NULL;
amf_ue->t3550.timer = ogs_timer_add(
self.timer_mgr, amf_timer_t3550_expire, amf_ue);
ogs_app()->timer_mgr, amf_timer_t3550_expire, amf_ue);
amf_ue->t3550.pkbuf = NULL;
amf_ue->t3555.timer = ogs_timer_add(
self.timer_mgr, amf_timer_t3555_expire, amf_ue);
ogs_app()->timer_mgr, amf_timer_t3555_expire, amf_ue);
amf_ue->t3555.pkbuf = NULL;
amf_ue->t3560.timer = ogs_timer_add(
self.timer_mgr, amf_timer_t3560_expire, amf_ue);
ogs_app()->timer_mgr, amf_timer_t3560_expire, amf_ue);
amf_ue->t3560.pkbuf = NULL;
amf_ue->t3570.timer = ogs_timer_add(
self.timer_mgr, amf_timer_t3570_expire, amf_ue);
ogs_app()->timer_mgr, amf_timer_t3570_expire, amf_ue);
amf_ue->t3570.pkbuf = NULL;
/* Create FSM */
@ -1635,7 +1635,7 @@ int amf_m_tmsi_pool_generate()
int index = 0;
ogs_trace("M-TMSI Pool try to generate...");
for (i = 0; index < ogs_config()->pool.ue; i++) {
for (i = 0; index < ogs_app()->max.ue; i++) {
amf_m_tmsi_t *m_tmsi = NULL;
int conflict = 0;

View File

@ -47,10 +47,6 @@ typedef struct amf_ue_s amf_ue_t;
typedef uint32_t amf_m_tmsi_t;
typedef struct amf_context_s {
ogs_queue_t *queue; /* Queue for processing UPF control */
ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
OpenAPI_nf_type_e nf_type;
/* Served GUAMI */

View File

@ -25,25 +25,11 @@ static OGS_POOL(pool, amf_event_t);
void amf_event_init(void)
{
ogs_pool_init(&pool, EVENT_POOL);
amf_self()->queue = ogs_queue_create(EVENT_POOL);
ogs_assert(amf_self()->queue);
amf_self()->timer_mgr = ogs_timer_mgr_create();
ogs_assert(amf_self()->timer_mgr);
amf_self()->pollset = ogs_pollset_create();
ogs_assert(amf_self()->pollset);
ogs_pool_init(&pool, ogs_app()->pool.event);
}
void amf_event_final(void)
{
if (amf_self()->pollset)
ogs_pollset_destroy(amf_self()->pollset);
if (amf_self()->timer_mgr)
ogs_timer_mgr_destroy(amf_self()->timer_mgr);
if (amf_self()->queue)
ogs_queue_destroy(amf_self()->queue);
ogs_pool_final(&pool);
}
@ -132,7 +118,7 @@ void amf_sctp_event_push(amf_event_e id,
e->ngap.max_num_of_istreams = max_num_of_istreams;
e->ngap.max_num_of_ostreams = max_num_of_ostreams;
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_free(e->ngap.addr);

View File

@ -28,8 +28,8 @@ int amf_initialize()
int rv;
amf_context_init();
amf_event_init(); /* Create event with poll, timer */
ogs_sbi_context_init(amf_self()->pollset, amf_self()->timer_mgr);
amf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("amf", "nrf");
if (rv != OGS_OK) return rv;
@ -41,7 +41,7 @@ int amf_initialize()
if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_config()->logger.domain, ogs_config()->logger.level);
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
thread = ogs_thread_create(amf_main, NULL);
@ -63,14 +63,14 @@ static void event_termination(void)
amf_nf_fsm_fini(nf_instance);
/* Starting holding timer */
t_termination_holding = ogs_timer_add(amf_self()->timer_mgr, NULL, NULL);
t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL);
ogs_assert(t_termination_holding);
#define TERMINATION_HOLDING_TIME ogs_time_from_msec(300)
ogs_timer_start(t_termination_holding, TERMINATION_HOLDING_TIME);
/* Sending termination event to the queue */
ogs_queue_term(amf_self()->queue);
ogs_pollset_notify(amf_self()->pollset);
ogs_queue_term(ogs_app()->queue);
ogs_pollset_notify(ogs_app()->pollset);
}
void amf_terminate(void)
@ -97,8 +97,8 @@ static void amf_main(void *data)
ogs_fsm_init(&amf_sm, 0);
for ( ;; ) {
ogs_pollset_poll(amf_self()->pollset,
ogs_timer_mgr_next(amf_self()->timer_mgr));
ogs_pollset_poll(ogs_app()->pollset,
ogs_timer_mgr_next(ogs_app()->timer_mgr));
/*
* After ogs_pollset_poll(), ogs_timer_mgr_expire() must be called.
@ -111,12 +111,12 @@ static void amf_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
ogs_timer_mgr_expire(amf_self()->timer_mgr);
ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
amf_event_t *e = NULL;
rv = ogs_queue_trypop(amf_self()->queue, (void**)&e);
rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)

View File

@ -107,7 +107,7 @@ void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_config()->time.message.sbi.nf_register_interval);
ogs_app()->time.message.sbi.nf_register_interval);
ogs_nnrf_nfm_send_nf_register(nf_instance);
break;
@ -162,7 +162,7 @@ void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e)
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_config()->time.message.sbi.nf_register_interval);
ogs_app()->time.message.sbi.nf_register_interval);
ogs_nnrf_nfm_send_nf_register(nf_instance);
break;
@ -206,7 +206,7 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e)
ogs_timer_start(nf_instance->t_no_heartbeat,
ogs_time_from_sec(
nf_instance->time.heartbeat_interval +
ogs_config()->time.nf_instance.no_heartbeat_margin));
ogs_app()->time.nf_instance.no_heartbeat_margin));
}
ogs_nnrf_nfm_send_nf_status_subscribe(client,
@ -246,7 +246,7 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e)
ogs_timer_start(nf_instance->t_no_heartbeat,
ogs_time_from_sec(
nf_instance->time.heartbeat_interval +
ogs_config()->time.nf_instance.
ogs_app()->time.nf_instance.
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
@ -348,7 +348,7 @@ void amf_nf_state_exception(ogs_fsm_t *s, amf_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_config()->time.message.sbi.
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
break;

View File

@ -93,7 +93,7 @@ static bool maximum_number_of_gnbs_is_reached(void)
}
}
return number_of_gnbs_online >= ogs_config()->max.gnb;
return number_of_gnbs_online >= ogs_app()->max.gnb;
}
void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message)

View File

@ -114,7 +114,7 @@ int ngap_delayed_send_to_ran_ue(
e = amf_event_new(AMF_EVT_NGAP_TIMER);
ogs_assert(e);
e->timer = ogs_timer_add(
amf_self()->timer_mgr, amf_timer_ng_delayed_send, e);
ogs_app()->timer_mgr, amf_timer_ng_delayed_send, e);
ogs_assert(e->timer);
e->pkbuf = pkbuf;
e->ran_ue = ran_ue;
@ -143,7 +143,7 @@ int ngap_send_to_5gsm(amf_ue_t *amf_ue, ogs_pkbuf_t *esmbuf)
ogs_assert(e);
e->amf_ue = amf_ue;
e->pkbuf = esmbuf;
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_pkbuf_free(e->pkbuf);
@ -224,7 +224,7 @@ int ngap_send_to_nas(ran_ue_t *ran_ue,
e->ngap.code = procedureCode;
e->nas.type = security_header_type.type;
e->pkbuf = nasbuf;
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_pkbuf_free(e->pkbuf);

View File

@ -37,7 +37,7 @@ ogs_sock_t *ngap_server(ogs_socknode_t *node)
ogs_assert(node);
ogs_socknode_sctp_option(node, &ogs_config()->sockopt);
ogs_socknode_sctp_option(node, &ogs_app()->sockopt);
ogs_socknode_nodelay(node, true);
#if HAVE_USRSCTP
@ -48,7 +48,7 @@ ogs_sock_t *ngap_server(ogs_socknode_t *node)
#else
sock = ogs_sctp_server(SOCK_STREAM, node);
ogs_assert(sock);
node->poll = ogs_pollset_add(amf_self()->pollset,
node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, lksctp_accept_handler, sock);
#endif

View File

@ -79,7 +79,7 @@ void amf_nnrf_handle_nf_status_subscribe(
ogs_warn("[%s] Forced to %lld seconds", subscription->id,
(long long)ogs_time_sec(VALIDITY_MINIMUM));
}
subscription->t_validity = ogs_timer_add(amf_self()->timer_mgr,
subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr,
amf_timer_subscription_validity, subscription);
ogs_assert(subscription->t_validity);
ogs_timer_start(subscription->t_validity, duration);

View File

@ -38,7 +38,7 @@ static int server_cb(ogs_sbi_server_t *server,
e->sbi.session = session;
e->sbi.request = request;
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
amf_event_free(e);
@ -60,7 +60,7 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
e->sbi.response = response;
e->sbi.data = data;
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
amf_event_free(e);

View File

@ -105,7 +105,7 @@ void amf_timer_ng_delayed_send(void *data)
e->timer_id = AMF_TIMER_NG_DELAYED_SEND;
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_timer_delete(e->timer);
@ -142,7 +142,7 @@ static void sbi_timer_send_event(int timer_id, void *data)
break;
}
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed [%d] in %s",
(int)rv, amf_timer_get_name(e->timer_id));
@ -191,7 +191,7 @@ static void gmm_timer_event_send(
e->timer_id = timer_id;
e->amf_ue = amf_ue;
rv = ogs_queue_push(amf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
amf_event_free(e);

View File

@ -37,7 +37,7 @@ void ausf_context_init(void)
ogs_log_install_domain(&__ausf_log_domain, "ausf", ogs_core()->log.level);
/* Allocate TWICE the pool to check if maximum number of gNBs is reached */
ogs_pool_init(&ausf_ue_pool, ogs_config()->pool.ue);
ogs_pool_init(&ausf_ue_pool, ogs_app()->max.ue);
ogs_list_init(&self.ausf_ue_list);
self.suci_hash = ogs_hash_make();
@ -85,7 +85,7 @@ int ausf_context_parse_config(void)
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = ausf_context_prepare();

View File

@ -39,10 +39,6 @@ extern int __ausf_log_domain;
#define OGS_LOG_DOMAIN __ausf_log_domain
typedef struct ausf_context_s {
ogs_queue_t *queue; /* Queue for processing UPF control */
ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
OpenAPI_nf_type_e nf_type;
ogs_list_t ausf_ue_list;

View File

@ -20,30 +20,15 @@
#include "event.h"
#include "context.h"
#define EVENT_POOL 32 /* FIXME : 32 */
static OGS_POOL(pool, ausf_event_t);
void ausf_event_init(void)
{
ogs_pool_init(&pool, EVENT_POOL);
ausf_self()->queue = ogs_queue_create(EVENT_POOL);
ogs_assert(ausf_self()->queue);
ausf_self()->timer_mgr = ogs_timer_mgr_create();
ogs_assert(ausf_self()->timer_mgr);
ausf_self()->pollset = ogs_pollset_create();
ogs_assert(ausf_self()->pollset);
ogs_pool_init(&pool, ogs_app()->pool.event);
}
void ausf_event_final(void)
{
if (ausf_self()->pollset)
ogs_pollset_destroy(ausf_self()->pollset);
if (ausf_self()->timer_mgr)
ogs_timer_mgr_destroy(ausf_self()->timer_mgr);
if (ausf_self()->queue)
ogs_queue_destroy(ausf_self()->queue);
ogs_pool_final(&pool);
}

View File

@ -28,8 +28,8 @@ int ausf_initialize()
int rv;
ausf_context_init();
ausf_event_init(); /* Create event with poll, timer */
ogs_sbi_context_init(ausf_self()->pollset, ausf_self()->timer_mgr);
ausf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("ausf", "nrf");
if (rv != OGS_OK) return rv;
@ -38,7 +38,7 @@ int ausf_initialize()
if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_config()->logger.domain, ogs_config()->logger.level);
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
thread = ogs_thread_create(ausf_main, NULL);
@ -60,14 +60,14 @@ static void event_termination(void)
ausf_nf_fsm_fini(nf_instance);
/* Starting holding timer */
t_termination_holding = ogs_timer_add(ausf_self()->timer_mgr, NULL, NULL);
t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL);
ogs_assert(t_termination_holding);
#define TERMINATION_HOLDING_TIME ogs_time_from_msec(300)
ogs_timer_start(t_termination_holding, TERMINATION_HOLDING_TIME);
/* Sending termination event to the queue */
ogs_queue_term(ausf_self()->queue);
ogs_pollset_notify(ausf_self()->pollset);
ogs_queue_term(ogs_app()->queue);
ogs_pollset_notify(ogs_app()->pollset);
}
void ausf_terminate(void)
@ -94,8 +94,8 @@ static void ausf_main(void *data)
ogs_fsm_init(&ausf_sm, 0);
for ( ;; ) {
ogs_pollset_poll(ausf_self()->pollset,
ogs_timer_mgr_next(ausf_self()->timer_mgr));
ogs_pollset_poll(ogs_app()->pollset,
ogs_timer_mgr_next(ogs_app()->timer_mgr));
/*
* After ogs_pollset_poll(), ogs_timer_mgr_expire() must be called.
@ -108,12 +108,12 @@ static void ausf_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
ogs_timer_mgr_expire(ausf_self()->timer_mgr);
ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
ausf_event_t *e = NULL;
rv = ogs_queue_trypop(ausf_self()->queue, (void**)&e);
rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)

View File

@ -107,7 +107,7 @@ void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_config()->time.message.sbi.nf_register_interval);
ogs_app()->time.message.sbi.nf_register_interval);
ogs_nnrf_nfm_send_nf_register(nf_instance);
break;
@ -162,7 +162,7 @@ void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e)
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_config()->time.message.sbi.nf_register_interval);
ogs_app()->time.message.sbi.nf_register_interval);
ogs_nnrf_nfm_send_nf_register(nf_instance);
break;
@ -206,7 +206,7 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e)
ogs_timer_start(nf_instance->t_no_heartbeat,
ogs_time_from_sec(
nf_instance->time.heartbeat_interval +
ogs_config()->time.nf_instance.no_heartbeat_margin));
ogs_app()->time.nf_instance.no_heartbeat_margin));
}
ogs_nnrf_nfm_send_nf_status_subscribe(client,
@ -246,7 +246,7 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e)
ogs_timer_start(nf_instance->t_no_heartbeat,
ogs_time_from_sec(
nf_instance->time.heartbeat_interval +
ogs_config()->time.nf_instance.
ogs_app()->time.nf_instance.
no_heartbeat_margin));
} else {
ogs_warn("[%s] HTTP response error [%d]",
@ -350,7 +350,7 @@ void ausf_nf_state_exception(ogs_fsm_t *s, ausf_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_IS_SELF(nf_instance->id))
ogs_timer_start(nf_instance->t_registration_interval,
ogs_config()->time.message.sbi.
ogs_app()->time.message.sbi.
nf_register_interval_in_exception);
break;

View File

@ -77,7 +77,7 @@ void ausf_nnrf_handle_nf_status_subscribe(
ogs_warn("[%s] Forced to %lld seconds", subscription->id,
(long long)ogs_time_sec(VALIDITY_MINIMUM));
}
subscription->t_validity = ogs_timer_add(ausf_self()->timer_mgr,
subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr,
ausf_timer_subscription_validity, subscription);
ogs_assert(subscription->t_validity);
ogs_timer_start(subscription->t_validity, duration);

View File

@ -35,7 +35,7 @@ static int server_cb(ogs_sbi_server_t *server,
e->sbi.session = session;
e->sbi.request = request;
rv = ogs_queue_push(ausf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ausf_event_free(e);
@ -57,7 +57,7 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
e->sbi.response = response;
e->sbi.data = data;
rv = ogs_queue_push(ausf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ausf_event_free(e);

View File

@ -65,7 +65,7 @@ static void sbi_timer_send_event(int timer_id, void *data)
break;
}
rv = ogs_queue_push(ausf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed [%d] in %s",
(int)rv, ausf_timer_get_name(e->timer_id));

View File

@ -75,7 +75,7 @@ static int hss_context_validation(void)
(self.diam_config->cnf_diamid == NULL ||
self.diam_config->cnf_diamrlm == NULL ||
self.diam_config->cnf_addr == NULL)) {
ogs_error("No hss.freeDiameter in '%s'", ogs_config()->file);
ogs_error("No hss.freeDiameter in '%s'", ogs_app()->file);
return OGS_ERROR;
}
@ -88,7 +88,7 @@ int hss_context_parse_config(void)
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = hss_context_prepare();

View File

@ -32,10 +32,10 @@ int hss_initialize(void)
if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_config()->logger.domain, ogs_config()->logger.level);
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
rv = ogs_dbi_init(ogs_config()->db_uri);
rv = ogs_dbi_init(ogs_app()->db_uri);
if (rv != OGS_OK) return rv;
rv = hss_fd_init();

View File

@ -51,16 +51,16 @@ static void show_running_config(void)
{
ogs_log_print(OGS_LOG_INFO, "%s\n\n", version);
ogs_info("Configuration: '%s'", ogs_config()->file);
ogs_info("Configuration: '%s'", ogs_app()->file);
if (ogs_config()->logger.file) {
ogs_info("File Logging: '%s'", ogs_config()->logger.file);
if (ogs_app()->logger.file) {
ogs_info("File Logging: '%s'", ogs_app()->logger.file);
if (ogs_config()->logger.level)
ogs_info("LOG-LEVEL: '%s'", ogs_config()->logger.level);
if (ogs_app()->logger.level)
ogs_info("LOG-LEVEL: '%s'", ogs_app()->logger.level);
if (ogs_config()->logger.domain)
ogs_info("LOG-DOMAIN: '%s'", ogs_config()->logger.domain);
if (ogs_app()->logger.domain)
ogs_info("LOG-DOMAIN: '%s'", ogs_app()->logger.domain);
}
}

View File

@ -24,7 +24,7 @@ int app_initialize(const char *const argv[])
{
int rv;
ogs_sctp_init(ogs_config()->usrsctp.udp_port);
ogs_sctp_init(ogs_app()->usrsctp.udp_port);
rv = mme_initialize();
if (rv != OGS_OK) {
ogs_error("Failed to intialize MME");

View File

@ -112,26 +112,26 @@ void mme_context_init()
ogs_list_init(&self.gtpc_list);
ogs_list_init(&self.gtpc_list6);
ogs_gtp_node_init(512);
ogs_gtp_node_init();
ogs_list_init(&self.sgw_list);
ogs_list_init(&self.pgw_list);
ogs_list_init(&self.enb_list);
ogs_list_init(&self.vlr_list);
ogs_list_init(&self.csmap_list);
ogs_pool_init(&mme_sgw_pool, ogs_config()->max.sgw);
ogs_pool_init(&mme_pgw_pool, ogs_config()->max.pgw);
ogs_pool_init(&mme_vlr_pool, ogs_config()->max.vlr);
ogs_pool_init(&mme_csmap_pool, ogs_config()->max.csmap);
ogs_pool_init(&mme_sgw_pool, ogs_app()->pool.nf);
ogs_pool_init(&mme_pgw_pool, ogs_app()->pool.nf);
ogs_pool_init(&mme_vlr_pool, ogs_app()->pool.nf);
ogs_pool_init(&mme_csmap_pool, ogs_app()->pool.csmap);
/* Allocate TWICE the pool to check if maximum number of eNBs is reached */
ogs_pool_init(&mme_enb_pool, ogs_config()->max.gnb*2);
ogs_pool_init(&mme_enb_pool, ogs_app()->max.gnb*2);
ogs_pool_init(&mme_ue_pool, ogs_config()->pool.ue);
ogs_pool_init(&enb_ue_pool, ogs_config()->pool.ue);
ogs_pool_init(&mme_sess_pool, ogs_config()->pool.sess);
ogs_pool_init(&mme_bearer_pool, ogs_config()->pool.bearer);
ogs_pool_init(&self.m_tmsi, ogs_config()->pool.ue);
ogs_pool_init(&mme_ue_pool, ogs_app()->max.ue);
ogs_pool_init(&enb_ue_pool, ogs_app()->max.ue);
ogs_pool_init(&mme_sess_pool, ogs_app()->pool.sess);
ogs_pool_init(&mme_bearer_pool, ogs_app()->pool.bearer);
ogs_pool_init(&self.m_tmsi, ogs_app()->max.ue);
self.enb_addr_hash = ogs_hash_make();
self.enb_id_hash = ogs_hash_make();
@ -210,71 +210,71 @@ static int mme_context_validation(void)
(self.diam_config->cnf_diamid == NULL ||
self.diam_config->cnf_diamrlm == NULL ||
self.diam_config->cnf_addr == NULL)) {
ogs_error("No mme.freeDiameter in '%s'", ogs_config()->file);
ogs_error("No mme.freeDiameter in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (ogs_list_first(&self.s1ap_list) == NULL &&
ogs_list_first(&self.s1ap_list6) == NULL) {
ogs_error("No mme.s1ap in '%s'", ogs_config()->file);
ogs_error("No mme.s1ap in '%s'", ogs_app()->file);
return OGS_RETRY;
}
if (ogs_list_first(&self.gtpc_list) == NULL &&
ogs_list_first(&self.gtpc_list6) == NULL) {
ogs_error("No mme.gtpc in '%s'", ogs_config()->file);
ogs_error("No mme.gtpc in '%s'", ogs_app()->file);
return OGS_RETRY;
}
if (ogs_list_first(&self.sgw_list) == NULL) {
ogs_error("No sgw.gtpc in '%s'", ogs_config()->file);
ogs_error("No sgw.gtpc in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (ogs_list_first(&self.pgw_list) == NULL) {
ogs_error("No pgw.gtpc in '%s'", ogs_config()->file);
ogs_error("No pgw.gtpc in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.max_num_of_served_gummei == 0) {
ogs_error("No mme.gummei in '%s'", ogs_config()->file);
ogs_error("No mme.gummei in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.served_gummei[0].num_of_plmn_id == 0) {
ogs_error("No mme.gummei.plmn_id in '%s'", ogs_config()->file);
ogs_error("No mme.gummei.plmn_id in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.served_gummei[0].num_of_mme_gid == 0) {
ogs_error("No mme.gummei.mme_gid in '%s'", ogs_config()->file);
ogs_error("No mme.gummei.mme_gid in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.served_gummei[0].num_of_mme_code == 0) {
ogs_error("No mme.gummei.mme_code in '%s'", ogs_config()->file);
ogs_error("No mme.gummei.mme_code in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.num_of_served_tai == 0) {
ogs_error("No mme.tai in '%s'", ogs_config()->file);
ogs_error("No mme.tai in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.served_tai[0].list0.tai[0].num == 0 &&
self.served_tai[0].list2.num == 0) {
ogs_error("No mme.tai.plmn_id|tac in '%s'", ogs_config()->file);
ogs_error("No mme.tai.plmn_id|tac in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.num_of_integrity_order == 0) {
ogs_error("No mme.security.integrity_order in '%s'",
ogs_config()->file);
ogs_app()->file);
return OGS_ERROR;
}
if (self.num_of_ciphering_order == 0) {
ogs_error("no mme.security.ciphering_order in '%s'",
ogs_config()->file);
ogs_app()->file);
return OGS_ERROR;
}
@ -287,7 +287,7 @@ int mme_context_parse_config()
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = mme_context_prepare();
@ -523,10 +523,10 @@ int mme_context_parse_config()
}
if (addr) {
if (ogs_config()->parameter.no_ipv4 == 0)
if (ogs_app()->parameter.no_ipv4 == 0)
ogs_socknode_add(
&self.s1ap_list, AF_INET, addr);
if (ogs_config()->parameter.no_ipv6 == 0)
if (ogs_app()->parameter.no_ipv6 == 0)
ogs_socknode_add(
&self.s1ap_list6, AF_INET6, addr);
ogs_freeaddrinfo(addr);
@ -534,9 +534,9 @@ int mme_context_parse_config()
if (dev) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.s1ap_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.s1ap_list6,
dev, port);
ogs_assert(rv == OGS_OK);
@ -548,9 +548,9 @@ int mme_context_parse_config()
if (ogs_list_first(&self.s1ap_list) == NULL &&
ogs_list_first(&self.s1ap_list6) == NULL) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.s1ap_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.s1ap_list6,
NULL, self.s1ap_port);
ogs_assert(rv == OGS_OK);
@ -634,10 +634,10 @@ int mme_context_parse_config()
}
if (addr) {
if (ogs_config()->parameter.no_ipv4 == 0)
if (ogs_app()->parameter.no_ipv4 == 0)
ogs_socknode_add(
&self.gtpc_list, AF_INET, addr);
if (ogs_config()->parameter.no_ipv6 == 0)
if (ogs_app()->parameter.no_ipv6 == 0)
ogs_socknode_add(
&self.gtpc_list6, AF_INET6, addr);
ogs_freeaddrinfo(addr);
@ -645,9 +645,9 @@ int mme_context_parse_config()
if (dev) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.gtpc_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.gtpc_list6,
dev, port);
ogs_assert(rv == OGS_OK);
@ -658,9 +658,9 @@ int mme_context_parse_config()
if (ogs_list_first(&self.gtpc_list) == NULL &&
ogs_list_first(&self.gtpc_list6) == NULL) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.gtpc_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.gtpc_list6,
NULL, self.gtpc_port);
ogs_assert(rv == OGS_OK);
@ -1361,9 +1361,9 @@ int mme_context_parse_config()
}
ogs_filter_ip_version(&addr,
ogs_config()->parameter.no_ipv4,
ogs_config()->parameter.no_ipv6,
ogs_config()->parameter.prefer_ipv4);
ogs_app()->parameter.no_ipv4,
ogs_app()->parameter.no_ipv6,
ogs_app()->parameter.prefer_ipv4);
if (addr == NULL) continue;
@ -1531,9 +1531,9 @@ int mme_context_parse_config()
}
ogs_filter_ip_version(&addr,
ogs_config()->parameter.no_ipv4,
ogs_config()->parameter.no_ipv6,
ogs_config()->parameter.prefer_ipv4);
ogs_app()->parameter.no_ipv4,
ogs_app()->parameter.no_ipv6,
ogs_app()->parameter.prefer_ipv4);
if (addr == NULL) continue;
@ -1639,9 +1639,9 @@ int mme_context_parse_config()
}
ogs_filter_ip_version(&addr,
ogs_config()->parameter.no_ipv4,
ogs_config()->parameter.no_ipv6,
ogs_config()->parameter.prefer_ipv4);
ogs_app()->parameter.no_ipv4,
ogs_app()->parameter.no_ipv6,
ogs_app()->parameter.prefer_ipv4);
if (addr == NULL) continue;
@ -1917,16 +1917,16 @@ mme_enb_t *mme_enb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr)
enb->max_num_of_ostreams = DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
enb->ostream_id = 0;
if (ogs_config()->sockopt.sctp.max_num_of_ostreams) {
if (ogs_app()->sockopt.sctp.max_num_of_ostreams) {
enb->max_num_of_ostreams =
ogs_config()->sockopt.sctp.max_num_of_ostreams;
ogs_app()->sockopt.sctp.max_num_of_ostreams;
ogs_info("[ENB] max_num_of_ostreams : %d", enb->max_num_of_ostreams);
}
ogs_list_init(&enb->enb_ue_list);
if (enb->sock_type == SOCK_STREAM) {
enb->poll = ogs_pollset_add(mme_self()->pollset,
enb->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, s1ap_recv_upcall, sock);
ogs_assert(enb->poll);
}
@ -2044,7 +2044,7 @@ enb_ue_t *enb_ue_add(mme_enb_t *enb, uint32_t enb_ue_s1ap_id)
/*
* SCTP output stream identification
* Default ogs_config()->parameter.sctp_streams : 30
* Default ogs_app()->parameter.sctp_streams : 30
* 0 : Non UE signalling
* 1-29 : UE specific association
*/
@ -2242,7 +2242,7 @@ mme_ue_t *mme_ue_add(enb_ue_t *enb_ue)
mme_ue->mme_s11_teid = ogs_pool_index(&mme_ue_pool, mme_ue);
ogs_assert(mme_ue->mme_s11_teid > 0 &&
mme_ue->mme_s11_teid <= ogs_config()->pool.ue);
mme_ue->mme_s11_teid <= ogs_app()->max.ue);
/* Create New GUTI */
mme_ue_new_guti(mme_ue);
@ -2266,19 +2266,19 @@ mme_ue_t *mme_ue_add(enb_ue_t *enb_ue)
/* Add All Timers */
mme_ue->t3413.timer = ogs_timer_add(
self.timer_mgr, mme_timer_t3413_expire, mme_ue);
ogs_app()->timer_mgr, mme_timer_t3413_expire, mme_ue);
mme_ue->t3413.pkbuf = NULL;
mme_ue->t3422.timer = ogs_timer_add(
self.timer_mgr, mme_timer_t3422_expire, mme_ue);
ogs_app()->timer_mgr, mme_timer_t3422_expire, mme_ue);
mme_ue->t3422.pkbuf = NULL;
mme_ue->t3450.timer = ogs_timer_add(
self.timer_mgr, mme_timer_t3450_expire, mme_ue);
ogs_app()->timer_mgr, mme_timer_t3450_expire, mme_ue);
mme_ue->t3450.pkbuf = NULL;
mme_ue->t3460.timer = ogs_timer_add(
self.timer_mgr, mme_timer_t3460_expire, mme_ue);
ogs_app()->timer_mgr, mme_timer_t3460_expire, mme_ue);
mme_ue->t3460.pkbuf = NULL;
mme_ue->t3470.timer = ogs_timer_add(
self.timer_mgr, mme_timer_t3470_expire, mme_ue);
ogs_app()->timer_mgr, mme_timer_t3470_expire, mme_ue);
mme_ue->t3470.pkbuf = NULL;
/* Create FSM */
@ -2795,7 +2795,7 @@ mme_bearer_t *mme_bearer_add(mme_sess_t *sess)
ogs_list_add(&sess->bearer_list, bearer);
bearer->t3489.timer = ogs_timer_add(
self.timer_mgr, mme_timer_t3489_expire, bearer);
ogs_app()->timer_mgr, mme_timer_t3489_expire, bearer);
bearer->t3489.pkbuf = NULL;
memset(&e, 0, sizeof(e));
@ -3179,7 +3179,7 @@ int mme_m_tmsi_pool_generate()
int index = 0;
ogs_trace("M-TMSI Pool try to generate...");
for (i = 0; index < ogs_config()->pool.ue; i++) {
for (i = 0; index < ogs_app()->max.ue; i++) {
mme_m_tmsi_t *m_tmsi = NULL;
int conflict = 0;

View File

@ -150,11 +150,6 @@ typedef struct mme_context_s {
ogs_hash_t *imsi_ue_hash; /* hash table (IMSI : MME_UE) */
ogs_hash_t *guti_ue_hash; /* hash table (GUTI : MME_UE) */
/* System */
ogs_queue_t *queue; /* Queue for processing MME control */
ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
} mme_context_t;
typedef struct mme_sgw_s {

View File

@ -24,31 +24,10 @@
#include "s1ap-path.h"
#define EVENT_POOL 32 /* FIXME : 32 */
void mme_event_init(void)
{
mme_self()->queue = ogs_queue_create(EVENT_POOL);
ogs_assert(mme_self()->queue);
mme_self()->timer_mgr = ogs_timer_mgr_create();
ogs_assert(mme_self()->timer_mgr);
mme_self()->pollset = ogs_pollset_create();
ogs_assert(mme_self()->pollset);
}
void mme_event_term(void)
{
ogs_queue_term(mme_self()->queue);
ogs_pollset_notify(mme_self()->pollset);
}
void mme_event_final(void)
{
if (mme_self()->pollset)
ogs_pollset_destroy(mme_self()->pollset);
if (mme_self()->timer_mgr)
ogs_timer_mgr_destroy(mme_self()->timer_mgr);
if (mme_self()->queue)
ogs_queue_destroy(mme_self()->queue);
ogs_queue_term(ogs_app()->queue);
ogs_pollset_notify(ogs_app()->pollset);
}
mme_event_t *mme_event_new(mme_event_e id)
@ -144,7 +123,7 @@ void mme_sctp_event_push(mme_event_e id,
e->max_num_of_istreams = max_num_of_istreams;
e->max_num_of_ostreams = max_num_of_ostreams;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_free(e->addr);
@ -154,7 +133,7 @@ void mme_sctp_event_push(mme_event_e id,
}
#if HAVE_USRSCTP
else {
ogs_pollset_notify(mme_self()->pollset);
ogs_pollset_notify(ogs_app()->pollset);
}
#endif
}

View File

@ -94,9 +94,7 @@ typedef struct mme_event_s {
ogs_timer_t *timer;
} mme_event_t;
void mme_event_init(void);
void mme_event_term(void);
void mme_event_final(void);
mme_event_t *mme_event_new(mme_event_e id);
void mme_event_free(mme_event_t *e);

View File

@ -373,13 +373,13 @@ out:
ogs_assert(e);
e->mme_ue = mme_ue;
e->pkbuf = s6abuf;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_error("ogs_queue_push() failed:%d", (int)rv);
ogs_pkbuf_free(e->pkbuf);
mme_event_free(e);
} else {
ogs_pollset_notify(mme_self()->pollset);
ogs_pollset_notify(ogs_app()->pollset);
}
}
@ -1069,13 +1069,13 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg)
ogs_assert(e);
e->mme_ue = mme_ue;
e->pkbuf = s6abuf;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_error("ogs_queue_push() failed:%d", (int)rv);
ogs_pkbuf_free(e->pkbuf);
mme_event_free(e);
} else {
ogs_pollset_notify(mme_self()->pollset);
ogs_pollset_notify(ogs_app()->pollset);
}
}

View File

@ -65,7 +65,7 @@ static void _gtpv2_c_recv_cb(short when, ogs_socket_t fd, void *data)
e->gnode = sgw->gnode;
e->pkbuf = pkbuf;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_error("ogs_queue_push() failed:%d", (int)rv);
ogs_pkbuf_free(e->pkbuf);
@ -121,14 +121,14 @@ int mme_gtp_open(void)
sock = ogs_gtp_server(node);
ogs_assert(sock);
node->poll = ogs_pollset_add(mme_self()->pollset,
node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv2_c_recv_cb, sock);
}
ogs_list_for_each(&mme_self()->gtpc_list6, node) {
sock = ogs_gtp_server(node);
ogs_assert(sock);
node->poll = ogs_pollset_add(mme_self()->pollset,
node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv2_c_recv_cb, sock);
}

View File

@ -37,16 +37,15 @@ int mme_initialize()
int rv;
mme_context_init();
mme_event_init();
rv = ogs_gtp_xact_init(mme_self()->timer_mgr, 512);
rv = ogs_gtp_xact_init();
if (rv != OGS_OK) return rv;
rv = mme_context_parse_config();
if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_config()->logger.domain, ogs_config()->logger.level);
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
rv = mme_m_tmsi_pool_generate();
@ -76,8 +75,6 @@ void mme_terminate(void)
mme_context_final();
ogs_gtp_xact_final();
mme_event_final();
}
static void mme_main(void *data)
@ -89,8 +86,8 @@ static void mme_main(void *data)
ogs_fsm_init(&mme_sm, 0);
for ( ;; ) {
ogs_pollset_poll(mme_self()->pollset,
ogs_timer_mgr_next(mme_self()->timer_mgr));
ogs_pollset_poll(ogs_app()->pollset,
ogs_timer_mgr_next(ogs_app()->timer_mgr));
/*
* After ogs_pollset_poll(), ogs_timer_mgr_expire() must be called.
@ -103,12 +100,12 @@ static void mme_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
ogs_timer_mgr_expire(mme_self()->timer_mgr);
ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
mme_event_t *e = NULL;
rv = ogs_queue_trypop(mme_self()->queue, (void**)&e);
rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)

View File

@ -99,7 +99,7 @@ void mme_timer_s1_delayed_send(void *data)
e->timer_id = MME_TIMER_S1_DELAYED_SEND;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_timer_delete(e->timer);
@ -119,7 +119,7 @@ static void emm_timer_event_send(
e->timer_id = timer_id;
e->mme_ue = mme_ue;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
mme_event_free(e);
@ -162,7 +162,7 @@ static void esm_timer_event_send(
e->mme_ue = mme_ue;
e->bearer = bearer;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
mme_event_free(e);
@ -184,7 +184,7 @@ void mme_timer_sgs_cli_conn_to_srv(void *data)
e->timer_id = MME_TIMER_SGS_CLI_CONN_TO_SRV;
e->vlr = data;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
mme_event_free(e);

View File

@ -60,7 +60,7 @@ static bool maximum_number_of_enbs_is_reached(void)
}
}
return number_of_enbs_online >= ogs_config()->max.gnb;
return number_of_enbs_online >= ogs_app()->max.gnb;
}
void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message)

View File

@ -115,7 +115,7 @@ int s1ap_delayed_send_to_enb_ue(
e = mme_event_new(MME_EVT_S1AP_TIMER);
ogs_assert(e);
e->timer = ogs_timer_add(
mme_self()->timer_mgr, mme_timer_s1_delayed_send, e);
ogs_app()->timer_mgr, mme_timer_s1_delayed_send, e);
ogs_assert(e->timer);
e->pkbuf = pkbuf;
e->enb_ue = enb_ue;
@ -144,7 +144,7 @@ int s1ap_send_to_esm(mme_ue_t *mme_ue, ogs_pkbuf_t *esmbuf)
ogs_assert(e);
e->mme_ue = mme_ue;
e->pkbuf = esmbuf;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_pkbuf_free(e->pkbuf);
@ -227,7 +227,7 @@ int s1ap_send_to_nas(enb_ue_t *enb_ue,
e->s1ap_code = procedureCode;
e->nas_type = security_header_type.type;
e->pkbuf = nasbuf;
rv = ogs_queue_push(mme_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_pkbuf_free(e->pkbuf);

View File

@ -38,7 +38,7 @@ ogs_sock_t *s1ap_server(ogs_socknode_t *node)
ogs_assert(node);
ogs_socknode_sctp_option(node, &ogs_config()->sockopt);
ogs_socknode_sctp_option(node, &ogs_app()->sockopt);
ogs_socknode_nodelay(node, true);
#if HAVE_USRSCTP
@ -49,7 +49,7 @@ ogs_sock_t *s1ap_server(ogs_socknode_t *node)
#else
sock = ogs_sctp_server(SOCK_STREAM, node);
ogs_assert(sock);
node->poll = ogs_pollset_add(mme_self()->pollset,
node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, lksctp_accept_handler, sock);
#endif

View File

@ -43,7 +43,7 @@ ogs_sock_t *sgsap_client(mme_vlr_t *vlr)
memset(&node, 0, sizeof node);
node.addr = vlr->sa_list;
ogs_socknode_sctp_option(&node, &ogs_config()->sockopt);
ogs_socknode_sctp_option(&node, &ogs_app()->sockopt);
ogs_socknode_nodelay(&node, true);
#if 0 /* Try to remove LINGER in usrsctp */
#if HAVE_USRSCTP
@ -60,7 +60,7 @@ ogs_sock_t *sgsap_client(mme_vlr_t *vlr)
usrsctp_set_upcall((struct socket *)sock, usrsctp_recv_handler, NULL);
#else
vlr->addr = &sock->remote_addr;
vlr->poll = ogs_pollset_add(mme_self()->pollset,
vlr->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, lksctp_recv_handler, sock);
#endif
ogs_info("sgsap client() [%s]:%d",

View File

@ -38,7 +38,7 @@ void sgsap_state_initial(ogs_fsm_t *s, mme_event_t *e)
vlr = e->vlr;
ogs_assert(vlr);
vlr->t_conn = ogs_timer_add(mme_self()->timer_mgr,
vlr->t_conn = ogs_timer_add(ogs_app()->timer_mgr,
mme_timer_sgs_cli_conn_to_srv, vlr);
ogs_expect_or_return(vlr->t_conn);

View File

@ -36,9 +36,7 @@ extern int __nrf_log_domain;
#define OGS_LOG_DOMAIN __nrf_log_domain
typedef struct nrf_context_s {
ogs_queue_t *queue; /* Queue for processing UPF control */
ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
int dummy;
} nrf_context_t;
void nrf_context_init(void);

View File

@ -20,30 +20,15 @@
#include "event.h"
#include "context.h"
#define EVENT_POOL 32 /* FIXME : 32 */
static OGS_POOL(pool, nrf_event_t);
void nrf_event_init(void)
{
ogs_pool_init(&pool, EVENT_POOL);
nrf_self()->queue = ogs_queue_create(EVENT_POOL);
ogs_assert(nrf_self()->queue);
nrf_self()->timer_mgr = ogs_timer_mgr_create();
ogs_assert(nrf_self()->timer_mgr);
nrf_self()->pollset = ogs_pollset_create();
ogs_assert(nrf_self()->pollset);
ogs_pool_init(&pool, ogs_app()->pool.event);
}
void nrf_event_final(void)
{
if (nrf_self()->pollset)
ogs_pollset_destroy(nrf_self()->pollset);
if (nrf_self()->timer_mgr)
ogs_timer_mgr_destroy(nrf_self()->timer_mgr);
if (nrf_self()->queue)
ogs_queue_destroy(nrf_self()->queue);
ogs_pool_final(&pool);
}

View File

@ -28,8 +28,8 @@ int nrf_initialize()
int rv;
nrf_context_init();
nrf_event_init(); /* Create event with poll, timer */
ogs_sbi_context_init(nrf_self()->pollset, nrf_self()->timer_mgr);
nrf_event_init();
ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("nrf", NULL);
if (rv != OGS_OK) return rv;
@ -38,7 +38,7 @@ int nrf_initialize()
if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_config()->logger.domain, ogs_config()->logger.level);
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
thread = ogs_thread_create(nrf_main, NULL);
@ -58,14 +58,14 @@ static void event_termination(void)
*/
/* Start holding timer */
t_termination_holding = ogs_timer_add(nrf_self()->timer_mgr, NULL, NULL);
t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL);
ogs_assert(t_termination_holding);
#define TERMINATION_HOLDING_TIME ogs_time_from_msec(300)
ogs_timer_start(t_termination_holding, TERMINATION_HOLDING_TIME);
/* Sending termination event to the queue */
ogs_queue_term(nrf_self()->queue);
ogs_pollset_notify(nrf_self()->pollset);
ogs_queue_term(ogs_app()->queue);
ogs_pollset_notify(ogs_app()->pollset);
}
void nrf_terminate(void)
@ -92,8 +92,8 @@ static void nrf_main(void *data)
ogs_fsm_init(&nrf_sm, 0);
for ( ;; ) {
ogs_pollset_poll(nrf_self()->pollset,
ogs_timer_mgr_next(nrf_self()->timer_mgr));
ogs_pollset_poll(ogs_app()->pollset,
ogs_timer_mgr_next(ogs_app()->timer_mgr));
/*
* After ogs_pollset_poll(), ogs_timer_mgr_expire() must be called.
@ -106,12 +106,12 @@ static void nrf_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
ogs_timer_mgr_expire(nrf_self()->timer_mgr);
ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
nrf_event_t *e = NULL;
rv = ogs_queue_trypop(nrf_self()->queue, (void**)&e);
rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)

View File

@ -59,7 +59,7 @@ void nrf_nf_state_initial(ogs_fsm_t *s, nrf_event_t *e)
nf_instance = e->nf_instance;
ogs_assert(nf_instance);
nf_instance->t_no_heartbeat = ogs_timer_add(nrf_self()->timer_mgr,
nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr,
nrf_timer_nf_instance_no_heartbeat, nf_instance);
ogs_assert(nf_instance->t_no_heartbeat);
@ -190,7 +190,7 @@ void nrf_nf_state_registered(ogs_fsm_t *s, nrf_event_t *e)
ogs_timer_start(nf_instance->t_no_heartbeat,
ogs_time_from_sec(
nf_instance->time.heartbeat_interval +
ogs_config()->time.nf_instance.no_heartbeat_margin));
ogs_app()->time.nf_instance.no_heartbeat_margin));
}
nrf_nnrf_nfm_send_nf_status_notify_all(
@ -226,7 +226,7 @@ void nrf_nf_state_registered(ogs_fsm_t *s, nrf_event_t *e)
ogs_timer_start(nf_instance->t_no_heartbeat,
ogs_time_from_sec(
nf_instance->time.heartbeat_interval +
ogs_config()->time.nf_instance.
ogs_app()->time.nf_instance.
no_heartbeat_margin));
}

View File

@ -183,7 +183,7 @@ bool nrf_nnrf_handle_nf_status_subscribe(
ogs_time_now() + ogs_time_from_sec(
subscription->time.validity_duration));
subscription->t_validity = ogs_timer_add(nrf_self()->timer_mgr,
subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr,
nrf_timer_subscription_validity, subscription);
ogs_assert(subscription->t_validity);
ogs_timer_start(subscription->t_validity,
@ -359,7 +359,7 @@ bool nrf_nnrf_handle_nf_discover(
ogs_assert(SearchResult);
SearchResult->validity_period =
ogs_config()->time.nf_instance.validity_duration;
ogs_app()->time.nf_instance.validity_duration;
ogs_assert(SearchResult->validity_period);
SearchResult->nf_instances = OpenAPI_list_create();

View File

@ -35,7 +35,7 @@ static int server_cb(ogs_sbi_server_t *server,
e->sbi.session = session;
e->sbi.request = request;
rv = ogs_queue_push(nrf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
nrf_event_free(e);

View File

@ -66,7 +66,7 @@ static void timer_send_event(int timer_id, void *data)
break;
}
rv = ogs_queue_push(nrf_self()->queue, e);
rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
nrf_event_free(e);

View File

@ -82,7 +82,7 @@ static int pcrf_context_validation(void)
self.diam_config->cnf_diamrlm == NULL ||
self.diam_config->cnf_addr == NULL)) {
ogs_error("No pcrf.freeDiameter in '%s'",
ogs_config()->file);
ogs_app()->file);
return OGS_ERROR;
}
@ -95,7 +95,7 @@ int pcrf_context_parse_config(void)
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = pcrf_context_prepare();
@ -266,7 +266,7 @@ int pcrf_db_init()
{
int rv;
rv = ogs_mongoc_init(ogs_config()->db_uri);
rv = ogs_mongoc_init(ogs_app()->db_uri);
if (rv != OGS_OK) return rv;
if (ogs_mongoc()->client && ogs_mongoc()->name) {
@ -601,11 +601,9 @@ int pcrf_db_qos_data(char *imsi_bcd, char *apn,
"been defined");
ogs_free(pcc_rule->name);
}
pcc_rule->name = ogs_calloc(
1, OGS_MAX_PCC_RULE_NAME_LEN);
ogs_assert(pcc_rule->name);
snprintf(pcc_rule->name, OGS_MAX_PCC_RULE_NAME_LEN,
pcc_rule->name = ogs_msprintf(
"%s%d", apn, pcc_rule_index+1);
ogs_assert(pcc_rule->name);
pcc_rule->precedence = pcc_rule_index+1;
pcc_rule->flow_status = OGS_FLOW_STATUS_ENABLED;
pcc_rule_index++;

View File

@ -1131,8 +1131,8 @@ int pcrf_gx_init(void)
struct disp_when data;
ogs_thread_mutex_init(&sess_state_mutex);
ogs_pool_init(&sess_state_pool, ogs_config()->pool.sess);
ogs_pool_init(&rx_sess_state_pool, ogs_config()->pool.sess);
ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess);
ogs_pool_init(&rx_sess_state_pool, ogs_app()->pool.sess);
/* Install objects definitions for this application */
ret = ogs_diam_gx_init();

View File

@ -32,7 +32,7 @@ int pcrf_initialize(void)
if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_config()->logger.domain, ogs_config()->logger.level);
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
rv = pcrf_db_init();

View File

@ -729,7 +729,7 @@ int pcrf_rx_init(void)
struct disp_when data;
ogs_thread_mutex_init(&sess_state_mutex);
ogs_pool_init(&sess_state_pool, ogs_config()->pool.sess);
ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess);
/* Install objects definitions for this application */
ret = ogs_diam_rx_init();

View File

@ -44,16 +44,16 @@ void sgwc_context_init(void)
ogs_list_init(&self.gtpc_list);
ogs_list_init(&self.gtpc_list6);
ogs_gtp_node_init(512);
ogs_gtp_node_init();
ogs_list_init(&self.mme_s11_list);
ogs_list_init(&self.pgw_s5c_list);
ogs_list_init(&self.enb_s1u_list);
ogs_list_init(&self.pgw_s5u_list);
ogs_pool_init(&sgwc_ue_pool, ogs_config()->pool.ue);
ogs_pool_init(&sgwc_sess_pool, ogs_config()->pool.sess);
ogs_pool_init(&sgwc_bearer_pool, ogs_config()->pool.bearer);
ogs_pool_init(&sgwc_tunnel_pool, ogs_config()->pool.tunnel);
ogs_pool_init(&sgwc_ue_pool, ogs_app()->max.ue);
ogs_pool_init(&sgwc_sess_pool, ogs_app()->pool.sess);
ogs_pool_init(&sgwc_bearer_pool, ogs_app()->pool.bearer);
ogs_pool_init(&sgwc_tunnel_pool, ogs_app()->pool.tunnel);
self.imsi_ue_hash = ogs_hash_make();
@ -101,7 +101,7 @@ static int sgwc_context_validation(void)
{
if (ogs_list_empty(&self.gtpc_list) &&
ogs_list_empty(&self.gtpc_list6)) {
ogs_error("No sgwc.gtpc in '%s'", ogs_config()->file);
ogs_error("No sgwc.gtpc in '%s'", ogs_app()->file);
return OGS_ERROR;
}
return OGS_OK;
@ -113,7 +113,7 @@ int sgwc_context_parse_config(void)
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
document = ogs_config()->document;
document = ogs_app()->document;
ogs_assert(document);
rv = sgwc_context_prepare();
@ -208,10 +208,10 @@ int sgwc_context_parse_config(void)
}
if (addr) {
if (ogs_config()->parameter.no_ipv4 == 0)
if (ogs_app()->parameter.no_ipv4 == 0)
ogs_socknode_add(
&self.gtpc_list, AF_INET, addr);
if (ogs_config()->parameter.no_ipv6 == 0)
if (ogs_app()->parameter.no_ipv6 == 0)
ogs_socknode_add(
&self.gtpc_list6, AF_INET6, addr);
ogs_freeaddrinfo(addr);
@ -219,9 +219,9 @@ int sgwc_context_parse_config(void)
if (dev) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.gtpc_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.gtpc_list6,
dev, port);
ogs_assert(rv == OGS_OK);
@ -233,9 +233,9 @@ int sgwc_context_parse_config(void)
if (ogs_list_empty(&self.gtpc_list) &&
ogs_list_empty(&self.gtpc_list6)) {
rv = ogs_socknode_probe(
ogs_config()->parameter.no_ipv4 ?
ogs_app()->parameter.no_ipv4 ?
NULL : &self.gtpc_list,
ogs_config()->parameter.no_ipv6 ?
ogs_app()->parameter.no_ipv6 ?
NULL : &self.gtpc_list6,
NULL, self.gtpc_port);
ogs_assert(rv == OGS_OK);
@ -312,7 +312,7 @@ sgwc_ue_t *sgwc_ue_add(uint8_t *imsi, int imsi_len)
sgwc_ue->sgw_s11_teid = ogs_pool_index(&sgwc_ue_pool, sgwc_ue);
ogs_assert(sgwc_ue->sgw_s11_teid > 0 &&
sgwc_ue->sgw_s11_teid <= ogs_config()->pool.ue);
sgwc_ue->sgw_s11_teid <= ogs_app()->max.ue);
/* Set IMSI */
sgwc_ue->imsi_len = imsi_len;
@ -383,14 +383,14 @@ sgwc_sess_t *sgwc_sess_add(sgwc_ue_t *sgwc_ue, char *apn)
ogs_pool_alloc(&sgwc_sess_pool, &sess);
if (!sess) {
ogs_error("Maximum number of session[%d] reached",
ogs_config()->pool.sess);
ogs_error("Maximum number of session[%lld] reached",
(long long)ogs_app()->pool.sess);
return NULL;
}
memset(sess, 0, sizeof *sess);
sess->index = ogs_pool_index(&sgwc_sess_pool, sess);
ogs_assert(sess->index > 0 && sess->index <= ogs_config()->pool.sess);
ogs_assert(sess->index > 0 && sess->index <= ogs_app()->pool.sess);
/* Set TEID & SEID */
sess->sgw_s5c_teid = sess->index;
@ -691,7 +691,7 @@ sgwc_tunnel_t *sgwc_tunnel_add(
tunnel->interface_type = interface_type;
tunnel->index = ogs_pool_index(&sgwc_tunnel_pool, tunnel);
ogs_assert(tunnel->index > 0 && tunnel->index <= ogs_config()->pool.tunnel);
ogs_assert(tunnel->index > 0 && tunnel->index <= ogs_app()->pool.tunnel);
pdr = ogs_pfcp_pdr_add(&bearer->pfcp);
ogs_assert(pdr);

Some files were not shown because too many files have changed in this diff Show More