diff --git a/configs/open5gs/amf.yaml.in b/configs/open5gs/amf.yaml.in
index 98138f909..7cad29f4c 100644
--- a/configs/open5gs/amf.yaml.in
+++ b/configs/open5gs/amf.yaml.in
@@ -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:
#
diff --git a/configs/open5gs/ausf.yaml.in b/configs/open5gs/ausf.yaml.in
index 3d5834894..e829f12b3 100644
--- a/configs/open5gs/ausf.yaml.in
+++ b/configs/open5gs/ausf.yaml.in
@@ -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:
#
diff --git a/configs/open5gs/hss.yaml.in b/configs/open5gs/hss.yaml.in
index 2c7ec4769..d4f82de35 100644
--- a/configs/open5gs/hss.yaml.in
+++ b/configs/open5gs/hss.yaml.in
@@ -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:
diff --git a/configs/open5gs/mme.yaml.in b/configs/open5gs/mme.yaml.in
index 1ac7de7df..db32706b0 100644
--- a/configs/open5gs/mme.yaml.in
+++ b/configs/open5gs/mme.yaml.in
@@ -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:
#
diff --git a/configs/open5gs/nrf.yaml.in b/configs/open5gs/nrf.yaml.in
index fd696b376..18219cd64 100644
--- a/configs/open5gs/nrf.yaml.in
+++ b/configs/open5gs/nrf.yaml.in
@@ -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:
#
diff --git a/configs/open5gs/pcrf.yaml.in b/configs/open5gs/pcrf.yaml.in
index a510a9048..a74eb66a4 100644
--- a/configs/open5gs/pcrf.yaml.in
+++ b/configs/open5gs/pcrf.yaml.in
@@ -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:
diff --git a/configs/open5gs/sgwc.yaml.in b/configs/open5gs/sgwc.yaml.in
index 72c521127..fd7ff63a2 100644
--- a/configs/open5gs/sgwc.yaml.in
+++ b/configs/open5gs/sgwc.yaml.in
@@ -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:
diff --git a/configs/open5gs/sgwu.yaml.in b/configs/open5gs/sgwu.yaml.in
index dbe36ac68..e0c6bd567 100644
--- a/configs/open5gs/sgwu.yaml.in
+++ b/configs/open5gs/sgwu.yaml.in
@@ -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:
diff --git a/configs/open5gs/smf.yaml.in b/configs/open5gs/smf.yaml.in
index 06405d8dd..d3630a233 100644
--- a/configs/open5gs/smf.yaml.in
+++ b/configs/open5gs/smf.yaml.in
@@ -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:
#
diff --git a/configs/open5gs/udm.yaml.in b/configs/open5gs/udm.yaml.in
index 4e5bab617..622b7c6d8 100644
--- a/configs/open5gs/udm.yaml.in
+++ b/configs/open5gs/udm.yaml.in
@@ -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:
#
diff --git a/configs/open5gs/udr.yaml.in b/configs/open5gs/udr.yaml.in
index 9396627dc..6de6263bc 100644
--- a/configs/open5gs/udr.yaml.in
+++ b/configs/open5gs/udr.yaml.in
@@ -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:
#
diff --git a/configs/open5gs/upf.yaml.in b/configs/open5gs/upf.yaml.in
index c270ad36a..7dfd62879 100644
--- a/configs/open5gs/upf.yaml.in
+++ b/configs/open5gs/upf.yaml.in
@@ -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:
diff --git a/docs/_docs/guide/01-quickstart.md b/docs/_docs/guide/01-quickstart.md
index c5c74236d..83cfc9f56 100644
--- a/docs/_docs/guide/01-quickstart.md
+++ b/docs/_docs/guide/01-quickstart.md
@@ -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.
diff --git a/docs/_docs/guide/02-building-open5gs-from-sources.md b/docs/_docs/guide/02-building-open5gs-from-sources.md
index bae2eb44e..3329de108 100644
--- a/docs/_docs/guide/02-building-open5gs-from-sources.md
+++ b/docs/_docs/guide/02-building-open5gs-from-sources.md
@@ -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.
diff --git a/docs/_docs/platform/04-freebsd.md b/docs/_docs/platform/04-freebsd.md
index f78f08197..b7b3bc2d1 100644
--- a/docs/_docs/platform/04-freebsd.md
+++ b/docs/_docs/platform/04-freebsd.md
@@ -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
diff --git a/docs/_docs/platform/05-macosx.md b/docs/_docs/platform/05-macosx.md
index db6e2736e..b1871c882 100644
--- a/docs/_docs/platform/05-macosx.md
+++ b/docs/_docs/platform/05-macosx.md
@@ -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
```
diff --git a/docs/_docs/troubleshoot/01-simple-issues.md b/docs/_docs/troubleshoot/01-simple-issues.md
index 5afb2efc2..fadca978a 100644
--- a/docs/_docs/troubleshoot/01-simple-issues.md
+++ b/docs/_docs/troubleshoot/01-simple-issues.md
@@ -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`.
diff --git a/docs/_docs/troubleshoot/02-now-in-github-issues.md b/docs/_docs/troubleshoot/02-now-in-github-issues.md
index f716aa3bf..7beddd1d7 100644
--- a/docs/_docs/troubleshoot/02-now-in-github-issues.md
+++ b/docs/_docs/troubleshoot/02-now-in-github-issues.md
@@ -3,6 +3,20 @@ title: Now in the Github Issue
head_inline: ""
---
+#### 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
diff --git a/docs/_docs/tutorial/01-your-first-lte.md b/docs/_docs/tutorial/01-your-first-lte.md
index 4b2729a9c..0ac06a30d 100644
--- a/docs/_docs/tutorial/01-your-first-lte.md
+++ b/docs/_docs/tutorial/01-your-first-lte.md
@@ -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
diff --git a/docs/assets/images/wireshark_can_decode_nas_5gs.png b/docs/assets/images/wireshark_can_decode_nas_5gs.png
new file mode 100644
index 000000000..1c24be9b6
Binary files /dev/null and b/docs/assets/images/wireshark_can_decode_nas_5gs.png differ
diff --git a/docs/assets/images/wireshark_cannot_decode_nas_5gs.png b/docs/assets/images/wireshark_cannot_decode_nas_5gs.png
new file mode 100644
index 000000000..477f091f9
Binary files /dev/null and b/docs/assets/images/wireshark_cannot_decode_nas_5gs.png differ
diff --git a/docs/assets/images/wireshark_preference.png b/docs/assets/images/wireshark_preference.png
new file mode 100644
index 000000000..b7786937b
Binary files /dev/null and b/docs/assets/images/wireshark_preference.png differ
diff --git a/lib/app/meson.build b/lib/app/meson.build
index 7ddf60b06..828f1146f 100644
--- a/lib/app/meson.build
+++ b/lib/app/meson.build
@@ -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())
diff --git a/lib/app/ogs-app.h b/lib/app/ogs-app.h
index c8a3f2f0f..4563c6e4d 100644
--- a/lib/app/ogs-app.h
+++ b/lib/app/ogs-app.h
@@ -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
diff --git a/lib/app/ogs-config.c b/lib/app/ogs-context.c
similarity index 80%
rename from lib/app/ogs-config.c
rename to lib/app/ogs-context.c
index 5d731b4ac..f05c8faed 100644
--- a/lib/app/ogs-config.c
+++ b/lib/app/ogs-context.c
@@ -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;
diff --git a/lib/app/ogs-config.h b/lib/app/ogs-context.h
similarity index 77%
rename from lib/app/ogs-config.h
rename to lib/app/ogs-context.h
index 1d041ed06..dd46bb641 100644
--- a/lib/app/ogs-config.h
+++ b/lib/app/ogs-context.h
@@ -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 */
diff --git a/lib/app/ogs-init.c b/lib/app/ogs-init.c
index 169bed9b1..53a436873 100644
--- a/lib/app/ogs-init.c
+++ b/lib/app/ogs-init.c
@@ -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);
diff --git a/lib/app/ogs-init.h b/lib/app/ogs-init.h
index 3c6222938..b8eccd0c4 100644
--- a/lib/app/ogs-init.h
+++ b/lib/app/ogs-init.h
@@ -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
diff --git a/lib/core/ogs-core.c b/lib/core/ogs-core.c
index 53e93cfd6..fa2e7ce9f 100644
--- a/lib/core/ogs-core.c
+++ b/lib/core/ogs-core.c
@@ -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,
};
diff --git a/lib/core/ogs-core.h b/lib/core/ogs-core.h
index c3ad7658c..77eba0944 100644
--- a/lib/core/ogs-core.h
+++ b/lib/core/ogs-core.h
@@ -86,14 +86,6 @@ typedef struct {
int config_pool;
} pkbuf;
- struct {
- int pool;
- } socket;
-
- struct {
- int pool;
- } timer;
-
struct {
int pool;
} tlv;
diff --git a/lib/core/ogs-epoll.c b/lib/core/ogs-epoll.c
index 3fd7fe610..a7859f012 100644
--- a/lib/core/ogs-epoll.c
+++ b/lib/core/ogs-epoll.c
@@ -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) {
diff --git a/lib/core/ogs-kqueue.c b/lib/core/ogs-kqueue.c
index 96babcbc2..2a9ee33ca 100644
--- a/lib/core/ogs-kqueue.c
+++ b/lib/core/ogs-kqueue.c
@@ -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);
diff --git a/lib/core/ogs-poll-private.h b/lib/core/ogs-poll-private.h
index 7c79b6722..8c7ce45a1 100644
--- a/lib/core/ogs-poll-private.h
+++ b/lib/core/ogs-poll-private.h
@@ -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
diff --git a/lib/core/ogs-poll.c b/lib/core/ogs-poll.c
index eec887e8e..d907abf00 100644
--- a/lib/core/ogs-poll.c
+++ b/lib/core/ogs-poll.c
@@ -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)
diff --git a/lib/core/ogs-poll.h b/lib/core/ogs-poll.h
index c199eff43..8fee72134 100644
--- a/lib/core/ogs-poll.h
+++ b/lib/core/ogs-poll.h
@@ -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
diff --git a/lib/core/ogs-timer.c b/lib/core/ogs-timer.c
index 34d4938ed..51cc287b5 100644
--- a/lib/core/ogs-timer.c
+++ b/lib/core/ogs-timer.c
@@ -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;
}
diff --git a/lib/core/ogs-timer.h b/lib/core/ogs-timer.h
index 7c8abd6c0..7ab14eee5 100644
--- a/lib/core/ogs-timer.h
+++ b/lib/core/ogs-timer.h
@@ -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(
diff --git a/lib/gtp/node.c b/lib/gtp/node.c
index 3801bcb8b..59b9bd348 100644
--- a/lib/gtp/node.c
+++ b/lib/gtp/node.c
@@ -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)
diff --git a/lib/gtp/node.h b/lib/gtp/node.h
index 24d53ba55..b5139b41e 100644
--- a/lib/gtp/node.h
+++ b/lib/gtp/node.h
@@ -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);
diff --git a/lib/gtp/ogs-gtp.h b/lib/gtp/ogs-gtp.h
index 4137e77dc..ebc866c5d 100644
--- a/lib/gtp/ogs-gtp.h
+++ b/lib/gtp/ogs-gtp.h
@@ -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
diff --git a/lib/gtp/xact.c b/lib/gtp/xact.c
index 37e4706cb..01d4ae52a 100644
--- a/lib/gtp/xact.c
+++ b/lib/gtp/xact.c
@@ -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",
diff --git a/lib/gtp/xact.h b/lib/gtp/xact.h
index ea4996b59..6d76dad52 100644
--- a/lib/gtp/xact.h
+++ b/lib/gtp/xact.h
@@ -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,
diff --git a/lib/pfcp/build.c b/lib/pfcp/build.c
index b4c3740ea..26a29a08a 100644
--- a/lib/pfcp/build.c
+++ b/lib/pfcp/build.c
@@ -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;
diff --git a/lib/pfcp/context.c b/lib/pfcp/context.c
index 71b52a5ef..d28a05efe 100644
--- a/lib/pfcp/context.c
+++ b/lib/pfcp/context.c
@@ -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);
diff --git a/lib/pfcp/handler.c b/lib/pfcp/handler.c
index 6936c534d..6d2eb55f5 100644
--- a/lib/pfcp/handler.c
+++ b/lib/pfcp/handler.c
@@ -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(
diff --git a/lib/pfcp/xact.c b/lib/pfcp/xact.c
index 7855e3737..99ee20be7 100644
--- a/lib/pfcp/xact.c
+++ b/lib/pfcp/xact.c
@@ -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",
diff --git a/lib/pfcp/xact.h b/lib/pfcp/xact.h
index e560f7ffb..1d14836c6 100644
--- a/lib/pfcp/xact.h
+++ b/lib/pfcp/xact.h
@@ -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,
diff --git a/lib/sbi/client.c b/lib/sbi/client.c
index a7b0f23f1..f48ef2f46 100644
--- a/lib/sbi/client.c
+++ b/lib/sbi/client.c
@@ -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 */
diff --git a/lib/sbi/context.c b/lib/sbi/context.c
index 3af349e15..f22cb739b 100644
--- a/lib/sbi/context.c
+++ b/lib/sbi/context.c
@@ -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);
diff --git a/lib/sbi/context.h b/lib/sbi/context.h
index d3f789fb3..b14292341 100644
--- a/lib/sbi/context.h
+++ b/lib/sbi/context.h
@@ -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);
diff --git a/lib/sbi/server.c b/lib/sbi/server.c
index cb6ba10da..aa029c383 100644
--- a/lib/sbi/server.c
+++ b/lib/sbi/server.c
@@ -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;
diff --git a/src/amf/app.c b/src/amf/app.c
index 44c0b1fb9..6be1d9361 100644
--- a/src/amf/app.c
+++ b/src/amf/app.c
@@ -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");
diff --git a/src/amf/context.c b/src/amf/context.c
index ba54e89f0..b09c59277 100644
--- a/src/amf/context.c
+++ b/src/amf/context.c
@@ -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;
diff --git a/src/amf/context.h b/src/amf/context.h
index 014b79887..ef5b74c13 100644
--- a/src/amf/context.h
+++ b/src/amf/context.h
@@ -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 */
diff --git a/src/amf/event.c b/src/amf/event.c
index d92c4e059..b798ad1f7 100644
--- a/src/amf/event.c
+++ b/src/amf/event.c
@@ -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);
diff --git a/src/amf/init.c b/src/amf/init.c
index e5a8e8497..f01776e60 100644
--- a/src/amf/init.c
+++ b/src/amf/init.c
@@ -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)
diff --git a/src/amf/nf-sm.c b/src/amf/nf-sm.c
index c857066f9..37c1d7451 100644
--- a/src/amf/nf-sm.c
+++ b/src/amf/nf-sm.c
@@ -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;
diff --git a/src/amf/ngap-handler.c b/src/amf/ngap-handler.c
index 6efba5d3a..4dcc460d5 100644
--- a/src/amf/ngap-handler.c
+++ b/src/amf/ngap-handler.c
@@ -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)
diff --git a/src/amf/ngap-path.c b/src/amf/ngap-path.c
index dcd8939eb..6b5a2cdd9 100644
--- a/src/amf/ngap-path.c
+++ b/src/amf/ngap-path.c
@@ -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);
diff --git a/src/amf/ngap-sctp.c b/src/amf/ngap-sctp.c
index b895c91cf..ed1773de4 100644
--- a/src/amf/ngap-sctp.c
+++ b/src/amf/ngap-sctp.c
@@ -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
diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c
index 792930cc2..5845f7b9d 100644
--- a/src/amf/nnrf-handler.c
+++ b/src/amf/nnrf-handler.c
@@ -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);
diff --git a/src/amf/sbi-path.c b/src/amf/sbi-path.c
index 4f55b105b..2f6990e33 100644
--- a/src/amf/sbi-path.c
+++ b/src/amf/sbi-path.c
@@ -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);
diff --git a/src/amf/timer.c b/src/amf/timer.c
index 7f607ed8c..9a4a0232e 100644
--- a/src/amf/timer.c
+++ b/src/amf/timer.c
@@ -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);
diff --git a/src/ausf/context.c b/src/ausf/context.c
index 048351046..f22e5384d 100644
--- a/src/ausf/context.c
+++ b/src/ausf/context.c
@@ -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();
diff --git a/src/ausf/context.h b/src/ausf/context.h
index e8819e1fd..ebd66c589 100644
--- a/src/ausf/context.h
+++ b/src/ausf/context.h
@@ -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;
diff --git a/src/ausf/event.c b/src/ausf/event.c
index 9185e068b..a55593c06 100644
--- a/src/ausf/event.c
+++ b/src/ausf/event.c
@@ -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);
}
diff --git a/src/ausf/init.c b/src/ausf/init.c
index 24f1f52be..7b4e7c5a7 100644
--- a/src/ausf/init.c
+++ b/src/ausf/init.c
@@ -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)
diff --git a/src/ausf/nf-sm.c b/src/ausf/nf-sm.c
index 88429fb2d..f4d0692e9 100644
--- a/src/ausf/nf-sm.c
+++ b/src/ausf/nf-sm.c
@@ -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;
diff --git a/src/ausf/nnrf-handler.c b/src/ausf/nnrf-handler.c
index f093c2eeb..5741b0cba 100644
--- a/src/ausf/nnrf-handler.c
+++ b/src/ausf/nnrf-handler.c
@@ -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);
diff --git a/src/ausf/sbi-path.c b/src/ausf/sbi-path.c
index e43f4e50a..f73c35d6a 100644
--- a/src/ausf/sbi-path.c
+++ b/src/ausf/sbi-path.c
@@ -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);
diff --git a/src/ausf/timer.c b/src/ausf/timer.c
index 4c95a9590..c3fbab749 100644
--- a/src/ausf/timer.c
+++ b/src/ausf/timer.c
@@ -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));
diff --git a/src/hss/hss-context.c b/src/hss/hss-context.c
index df515d5b9..919f78809 100644
--- a/src/hss/hss-context.c
+++ b/src/hss/hss-context.c
@@ -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();
diff --git a/src/hss/hss-init.c b/src/hss/hss-init.c
index 2c28beb9e..e29341a0f 100644
--- a/src/hss/hss-init.c
+++ b/src/hss/hss-init.c
@@ -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();
diff --git a/src/main.c b/src/main.c
index 3e9d11149..2ff995294 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
}
}
diff --git a/src/mme/app-init.c b/src/mme/app-init.c
index d53337383..cdd30411f 100644
--- a/src/mme/app-init.c
+++ b/src/mme/app-init.c
@@ -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");
diff --git a/src/mme/mme-context.c b/src/mme/mme-context.c
index 131b24d07..f2e223a56 100644
--- a/src/mme/mme-context.c
+++ b/src/mme/mme-context.c
@@ -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;
diff --git a/src/mme/mme-context.h b/src/mme/mme-context.h
index 7ec4a4ebd..a5ead5289 100644
--- a/src/mme/mme-context.h
+++ b/src/mme/mme-context.h
@@ -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 {
diff --git a/src/mme/mme-event.c b/src/mme/mme-event.c
index 04005d040..46c674879 100644
--- a/src/mme/mme-event.c
+++ b/src/mme/mme-event.c
@@ -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
}
diff --git a/src/mme/mme-event.h b/src/mme/mme-event.h
index e7fddbda6..6341deae3 100644
--- a/src/mme/mme-event.h
+++ b/src/mme/mme-event.h
@@ -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);
diff --git a/src/mme/mme-fd-path.c b/src/mme/mme-fd-path.c
index eb387aabf..66c5b23ac 100644
--- a/src/mme/mme-fd-path.c
+++ b/src/mme/mme-fd-path.c
@@ -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);
}
}
diff --git a/src/mme/mme-gtp-path.c b/src/mme/mme-gtp-path.c
index 74e5546f0..6dbc8c39f 100644
--- a/src/mme/mme-gtp-path.c
+++ b/src/mme/mme-gtp-path.c
@@ -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);
}
diff --git a/src/mme/mme-init.c b/src/mme/mme-init.c
index 31c641817..61cf03c4d 100644
--- a/src/mme/mme-init.c
+++ b/src/mme/mme-init.c
@@ -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)
diff --git a/src/mme/mme-timer.c b/src/mme/mme-timer.c
index b21b1c6c2..6a779e89e 100644
--- a/src/mme/mme-timer.c
+++ b/src/mme/mme-timer.c
@@ -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);
diff --git a/src/mme/s1ap-handler.c b/src/mme/s1ap-handler.c
index dae0580b0..64787f44b 100644
--- a/src/mme/s1ap-handler.c
+++ b/src/mme/s1ap-handler.c
@@ -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)
diff --git a/src/mme/s1ap-path.c b/src/mme/s1ap-path.c
index 5c5a7e599..baf3dfe0e 100644
--- a/src/mme/s1ap-path.c
+++ b/src/mme/s1ap-path.c
@@ -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);
diff --git a/src/mme/s1ap-sctp.c b/src/mme/s1ap-sctp.c
index 47ed526df..dc406e924 100644
--- a/src/mme/s1ap-sctp.c
+++ b/src/mme/s1ap-sctp.c
@@ -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
diff --git a/src/mme/sgsap-sctp.c b/src/mme/sgsap-sctp.c
index c43a8acf4..e51e47978 100644
--- a/src/mme/sgsap-sctp.c
+++ b/src/mme/sgsap-sctp.c
@@ -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",
diff --git a/src/mme/sgsap-sm.c b/src/mme/sgsap-sm.c
index 4bd4a74ff..2139edd3e 100644
--- a/src/mme/sgsap-sm.c
+++ b/src/mme/sgsap-sm.c
@@ -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);
diff --git a/src/nrf/context.h b/src/nrf/context.h
index 18b1add81..2cce05ab9 100644
--- a/src/nrf/context.h
+++ b/src/nrf/context.h
@@ -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);
diff --git a/src/nrf/event.c b/src/nrf/event.c
index 198c6eee7..80c0045ec 100644
--- a/src/nrf/event.c
+++ b/src/nrf/event.c
@@ -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);
}
diff --git a/src/nrf/init.c b/src/nrf/init.c
index 6b271571e..a9ba0d37a 100644
--- a/src/nrf/init.c
+++ b/src/nrf/init.c
@@ -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)
diff --git a/src/nrf/nf-sm.c b/src/nrf/nf-sm.c
index b4a683f0c..a364752ff 100644
--- a/src/nrf/nf-sm.c
+++ b/src/nrf/nf-sm.c
@@ -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));
}
diff --git a/src/nrf/nnrf-handler.c b/src/nrf/nnrf-handler.c
index 88aece3c5..6c964d72b 100644
--- a/src/nrf/nnrf-handler.c
+++ b/src/nrf/nnrf-handler.c
@@ -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();
diff --git a/src/nrf/sbi-path.c b/src/nrf/sbi-path.c
index b03275f9e..1aab75f25 100644
--- a/src/nrf/sbi-path.c
+++ b/src/nrf/sbi-path.c
@@ -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);
diff --git a/src/nrf/timer.c b/src/nrf/timer.c
index cb7f88eba..b79679867 100644
--- a/src/nrf/timer.c
+++ b/src/nrf/timer.c
@@ -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);
diff --git a/src/pcrf/pcrf-context.c b/src/pcrf/pcrf-context.c
index 3f49a3af0..69fcb3070 100644
--- a/src/pcrf/pcrf-context.c
+++ b/src/pcrf/pcrf-context.c
@@ -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++;
diff --git a/src/pcrf/pcrf-gx-path.c b/src/pcrf/pcrf-gx-path.c
index 18b55e3f2..40c49d6a9 100644
--- a/src/pcrf/pcrf-gx-path.c
+++ b/src/pcrf/pcrf-gx-path.c
@@ -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();
diff --git a/src/pcrf/pcrf-init.c b/src/pcrf/pcrf-init.c
index ba8dd6407..e9942904f 100644
--- a/src/pcrf/pcrf-init.c
+++ b/src/pcrf/pcrf-init.c
@@ -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();
diff --git a/src/pcrf/pcrf-rx-path.c b/src/pcrf/pcrf-rx-path.c
index cd5f8442f..000082feb 100644
--- a/src/pcrf/pcrf-rx-path.c
+++ b/src/pcrf/pcrf-rx-path.c
@@ -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();
diff --git a/src/sgwc/context.c b/src/sgwc/context.c
index 9621b522e..eadfa344a 100644
--- a/src/sgwc/context.c
+++ b/src/sgwc/context.c
@@ -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);
diff --git a/src/sgwc/context.h b/src/sgwc/context.h
index 4ea46de32..b5b098c65 100644
--- a/src/sgwc/context.h
+++ b/src/sgwc/context.h
@@ -48,10 +48,6 @@ typedef struct sgwc_context_s {
ogs_sockaddr_t *gtpc_addr; /* SGW GTPC IPv4 Address */
ogs_sockaddr_t *gtpc_addr6; /* SGW GTPC IPv6 Address */
- ogs_queue_t *queue; /* Queue for processing SGW control */
- ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
- ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
-
ogs_list_t mme_s11_list; /* MME GTPC Node List */
ogs_list_t pgw_s5c_list; /* PGW GTPC Node List */
ogs_list_t enb_s1u_list; /* eNB GTPU Node List */
diff --git a/src/sgwc/event.c b/src/sgwc/event.c
index 09aac5d35..af4cbd892 100644
--- a/src/sgwc/event.c
+++ b/src/sgwc/event.c
@@ -22,34 +22,19 @@
static OGS_POOL(pool, sgwc_event_t);
-#define EVENT_POOL 32 /* FIXME : 32 */
void sgwc_event_init(void)
{
- ogs_pool_init(&pool, EVENT_POOL);
-
- sgwc_self()->queue = ogs_queue_create(EVENT_POOL);
- ogs_assert(sgwc_self()->queue);
- sgwc_self()->timer_mgr = ogs_timer_mgr_create();
- ogs_assert(sgwc_self()->timer_mgr);
- sgwc_self()->pollset = ogs_pollset_create();
- ogs_assert(sgwc_self()->pollset);
+ ogs_pool_init(&pool, ogs_app()->pool.event);
}
void sgwc_event_term(void)
{
- ogs_queue_term(sgwc_self()->queue);
- ogs_pollset_notify(sgwc_self()->pollset);
+ ogs_queue_term(ogs_app()->queue);
+ ogs_pollset_notify(ogs_app()->pollset);
}
void sgwc_event_final(void)
{
- if (sgwc_self()->pollset)
- ogs_pollset_destroy(sgwc_self()->pollset);
- if (sgwc_self()->timer_mgr)
- ogs_timer_mgr_destroy(sgwc_self()->timer_mgr);
- if (sgwc_self()->queue)
- ogs_queue_destroy(sgwc_self()->queue);
-
ogs_pool_final(&pool);
}
diff --git a/src/sgwc/gtp-path.c b/src/sgwc/gtp-path.c
index 6acb07816..5fed24cd1 100644
--- a/src/sgwc/gtp-path.c
+++ b/src/sgwc/gtp-path.c
@@ -93,7 +93,7 @@ static void _gtpv2_c_recv_cb(short when, ogs_socket_t fd, void *data)
e->pkbuf = pkbuf;
- rv = ogs_queue_push(sgwc_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);
@@ -109,7 +109,7 @@ int sgwc_gtp_open(void)
ogs_pkbuf_config_t config;
memset(&config, 0, sizeof config);
- config.cluster_8192_pool = ogs_config()->pool.packet;
+ config.cluster_8192_pool = ogs_app()->pool.packet;
packet_pool = ogs_pkbuf_pool_create(&config);
@@ -117,14 +117,14 @@ int sgwc_gtp_open(void)
sock = ogs_gtp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(sgwc_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv2_c_recv_cb, sock);
}
ogs_list_for_each(&sgwc_self()->gtpc_list6, node) {
sock = ogs_gtp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(sgwc_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv2_c_recv_cb, sock);
}
diff --git a/src/sgwc/init.c b/src/sgwc/init.c
index 45277fe91..f9698e056 100644
--- a/src/sgwc/init.c
+++ b/src/sgwc/init.c
@@ -28,14 +28,14 @@ int sgwc_initialize()
{
int rv;
- ogs_pfcp_context_init(ogs_config()->max.upf * OGS_MAX_NUM_OF_GTPU_RESOURCE);
+ ogs_pfcp_context_init(ogs_app()->pool.nf * OGS_MAX_NUM_OF_GTPU_RESOURCE);
sgwc_context_init();
sgwc_event_init();
- rv = ogs_gtp_xact_init(sgwc_self()->timer_mgr, 512);
+ rv = ogs_gtp_xact_init();
if (rv != OGS_OK) return rv;
- rv = ogs_pfcp_xact_init(sgwc_self()->timer_mgr, 512);
+ rv = ogs_pfcp_xact_init();
if (rv != OGS_OK) return rv;
rv = ogs_pfcp_context_parse_config("sgwc", "sgwu");
@@ -45,7 +45,7 @@ int sgwc_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(sgwc_main, NULL);
@@ -82,8 +82,8 @@ static void sgwc_main(void *data)
ogs_fsm_init(&sgwc_sm, 0);
for ( ;; ) {
- ogs_pollset_poll(sgwc_self()->pollset,
- ogs_timer_mgr_next(sgwc_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.
@@ -96,12 +96,12 @@ static void sgwc_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
- ogs_timer_mgr_expire(sgwc_self()->timer_mgr);
+ ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
sgwc_event_t *e = NULL;
- rv = ogs_queue_trypop(sgwc_self()->queue, (void**)&e);
+ rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)
diff --git a/src/sgwc/pfcp-path.c b/src/sgwc/pfcp-path.c
index 6cbbfa8de..db413176c 100644
--- a/src/sgwc/pfcp-path.c
+++ b/src/sgwc/pfcp-path.c
@@ -32,7 +32,7 @@ static void pfcp_node_fsm_init(ogs_pfcp_node_t *node, bool try_to_assoicate)
e.pfcp_node = node;
if (try_to_assoicate == true) {
- node->t_association = ogs_timer_add(sgwc_self()->timer_mgr,
+ node->t_association = ogs_timer_add(ogs_app()->timer_mgr,
sgwc_timer_pfcp_association, node);
ogs_assert(node->t_association);
}
@@ -114,7 +114,7 @@ static void pfcp_recv_cb(short when, ogs_socket_t fd, void *data)
e->pfcp_node = node;
e->pkbuf = pkbuf;
- rv = ogs_queue_push(sgwc_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);
@@ -133,14 +133,14 @@ int sgwc_pfcp_open(void)
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(sgwc_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
ogs_list_for_each(&ogs_pfcp_self()->pfcp_list6, node) {
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(sgwc_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
diff --git a/src/sgwc/pfcp-sm.c b/src/sgwc/pfcp-sm.c
index c7de73255..8b3378d0d 100644
--- a/src/sgwc/pfcp-sm.c
+++ b/src/sgwc/pfcp-sm.c
@@ -39,7 +39,7 @@ void sgwc_pfcp_state_initial(ogs_fsm_t *s, sgwc_event_t *e)
ogs_pfcp_self()->pfcp_sock, ogs_pfcp_self()->pfcp_sock6, node);
ogs_assert(rv == OGS_OK);
- node->t_no_heartbeat = ogs_timer_add(sgwc_self()->timer_mgr,
+ node->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr,
sgwc_timer_pfcp_no_heartbeat, node);
ogs_assert(node->t_no_heartbeat);
@@ -84,7 +84,7 @@ void sgwc_pfcp_state_will_associate(ogs_fsm_t *s, sgwc_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (node->t_association) {
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_cp_send_association_setup_request(node, node_timeout);
}
@@ -107,7 +107,7 @@ void sgwc_pfcp_state_will_associate(ogs_fsm_t *s, sgwc_event_t *e)
ogs_assert(node->t_association);
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_cp_send_association_setup_request(node, node_timeout);
break;
@@ -171,7 +171,7 @@ void sgwc_pfcp_state_associated(ogs_fsm_t *s, sgwc_event_t *e)
case OGS_FSM_ENTRY_SIG:
ogs_info("PFCP associated");
ogs_timer_start(node->t_no_heartbeat,
- ogs_config()->time.message.pfcp.no_heartbeat_duration);
+ ogs_app()->time.message.pfcp.no_heartbeat_duration);
break;
case OGS_FSM_EXIT_SIG:
ogs_info("PFCP de-associated");
@@ -315,7 +315,7 @@ static void node_timeout(ogs_pfcp_xact_t *xact, void *data)
e = sgwc_event_new(SGWC_EVT_SXA_NO_HEARTBEAT);
e->pfcp_node = data;
- rv = ogs_queue_push(sgwc_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
sgwc_event_free(e);
diff --git a/src/sgwc/sxa-build.c b/src/sgwc/sxa-build.c
index c14a76fb6..249d426f8 100644
--- a/src/sgwc/sxa-build.c
+++ b/src/sgwc/sxa-build.c
@@ -47,7 +47,7 @@ ogs_pkbuf_t *sgwc_sxa_build_session_establishment_request(
/* Node ID */
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, &len);
req->node_id.presence = 1;
req->node_id.data = &node_id;
diff --git a/src/sgwc/sxa-handler.c b/src/sgwc/sxa-handler.c
index e6f3a3c1f..9a819ad78 100644
--- a/src/sgwc/sxa-handler.c
+++ b/src/sgwc/sxa-handler.c
@@ -176,9 +176,9 @@ void sgwc_sxa_handle_session_establishment_response(
if (!pgw) {
pgw = ogs_gtp_node_add_by_f_teid(
&sgwc_self()->pgw_s5c_list, pgw_s5c_teid, sgwc_self()->gtpc_port,
- 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);
ogs_assert(pgw);
rv = ogs_gtp_connect(
diff --git a/src/sgwc/timer.c b/src/sgwc/timer.c
index bb4f4f30b..863f8d505 100644
--- a/src/sgwc/timer.c
+++ b/src/sgwc/timer.c
@@ -55,7 +55,7 @@ static void timer_send_event(int timer_id, void *data)
break;
}
- rv = ogs_queue_push(sgwc_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, sgwc_timer_get_name(e->timer_id));
diff --git a/src/sgwu/context.c b/src/sgwu/context.c
index 0d9a7dffa..afbdadc28 100644
--- a/src/sgwu/context.c
+++ b/src/sgwu/context.c
@@ -41,13 +41,13 @@ void sgwu_context_init(void)
ogs_pfcp_self()->up_function_features.empu = 1;
ogs_pfcp_self()->up_function_features_len = 2;
- ogs_gtp_node_init(512);
+ ogs_gtp_node_init();
ogs_list_init(&self.sess_list);
ogs_list_init(&self.gtpu_list);
ogs_list_init(&self.peer_list);
- ogs_pool_init(&sgwu_sess_pool, ogs_config()->pool.sess);
+ ogs_pool_init(&sgwu_sess_pool, ogs_app()->pool.sess);
self.sess_hash = ogs_hash_make();
@@ -87,7 +87,7 @@ static int sgwu_context_prepare(void)
static int sgwu_context_validation(void)
{
if (ogs_list_first(&self.gtpu_list) == NULL) {
- ogs_error("No sgwu.gtpu in '%s'", ogs_config()->file);
+ ogs_error("No sgwu.gtpu in '%s'", ogs_app()->file);
return OGS_ERROR;
}
return OGS_OK;
@@ -99,7 +99,7 @@ int sgwu_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 = sgwu_context_prepare();
@@ -231,17 +231,17 @@ int sgwu_context_parse_config(void)
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);
}
@@ -317,8 +317,8 @@ int sgwu_context_parse_config(void)
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.gtpu_port);
ogs_assert(rv == OGS_OK);
@@ -375,7 +375,7 @@ sgwu_sess_t *sgwu_sess_add(ogs_pfcp_f_seid_t *cp_f_seid,
memset(sess, 0, sizeof *sess);
sess->index = ogs_pool_index(&sgwu_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);
sess->sgwu_sxa_seid = sess->index;
sess->sgwc_sxa_seid = cp_f_seid->seid;
diff --git a/src/sgwu/context.h b/src/sgwu/context.h
index 5b78f825f..5bc969b42 100644
--- a/src/sgwu/context.h
+++ b/src/sgwu/context.h
@@ -43,10 +43,6 @@ typedef struct sgwu_context_s {
ogs_sock_t *gtpu_sock; /* SGWU GTPU IPv4 Socket */
ogs_sock_t *gtpu_sock6; /* SGWU GTPU IPv6 Socket */
- ogs_queue_t *queue; /* Queue for processing SGWU control */
- ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
- ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
-
ogs_list_t peer_list; /* gNB/SMF Node List */
ogs_hash_t *sess_hash; /* hash table (F-SEID) */
ogs_list_t sess_list;
diff --git a/src/sgwu/event.c b/src/sgwu/event.c
index f27e21552..d087ea2e2 100644
--- a/src/sgwu/event.c
+++ b/src/sgwu/event.c
@@ -22,34 +22,19 @@
static OGS_POOL(pool, sgwu_event_t);
-#define EVENT_POOL 32 /* FIXME : 32 */
void sgwu_event_init(void)
{
- ogs_pool_init(&pool, EVENT_POOL);
-
- sgwu_self()->queue = ogs_queue_create(EVENT_POOL);
- ogs_assert(sgwu_self()->queue);
- sgwu_self()->timer_mgr = ogs_timer_mgr_create();
- ogs_assert(sgwu_self()->timer_mgr);
- sgwu_self()->pollset = ogs_pollset_create();
- ogs_assert(sgwu_self()->pollset);
+ ogs_pool_init(&pool, ogs_app()->pool.event);
}
void sgwu_event_term(void)
{
- ogs_queue_term(sgwu_self()->queue);
- ogs_pollset_notify(sgwu_self()->pollset);
+ ogs_queue_term(ogs_app()->queue);
+ ogs_pollset_notify(ogs_app()->pollset);
}
void sgwu_event_final(void)
{
- if (sgwu_self()->pollset)
- ogs_pollset_destroy(sgwu_self()->pollset);
- if (sgwu_self()->timer_mgr)
- ogs_timer_mgr_destroy(sgwu_self()->timer_mgr);
- if (sgwu_self()->queue)
- ogs_queue_destroy(sgwu_self()->queue);
-
ogs_pool_final(&pool);
}
diff --git a/src/sgwu/gtp-path.c b/src/sgwu/gtp-path.c
index dbef1d628..655a3cd6e 100644
--- a/src/sgwu/gtp-path.c
+++ b/src/sgwu/gtp-path.c
@@ -178,7 +178,7 @@ int sgwu_gtp_open(void)
ogs_pkbuf_config_t config;
memset(&config, 0, sizeof config);
- config.cluster_8192_pool = ogs_config()->pool.packet;
+ config.cluster_8192_pool = ogs_app()->pool.packet;
packet_pool = ogs_pkbuf_pool_create(&config);
@@ -191,7 +191,7 @@ int sgwu_gtp_open(void)
else if (sock->family == AF_INET6)
sgwu_self()->gtpu_sock6 = sock;
- node->poll = ogs_pollset_add(sgwu_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv1_u_recv_cb, sock);
}
diff --git a/src/sgwu/init.c b/src/sgwu/init.c
index 66dba081e..bd66d79f9 100644
--- a/src/sgwu/init.c
+++ b/src/sgwu/init.c
@@ -32,7 +32,7 @@ int sgwu_initialize()
sgwu_context_init();
sgwu_event_init();
- rv = ogs_pfcp_xact_init(sgwu_self()->timer_mgr, 512);
+ rv = ogs_pfcp_xact_init();
if (rv != OGS_OK) return rv;
rv = ogs_pfcp_context_parse_config("sgwu", "sgwc");
@@ -42,7 +42,7 @@ int sgwu_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(sgwu_main, NULL);
@@ -78,8 +78,8 @@ static void sgwu_main(void *data)
ogs_fsm_init(&sgwu_sm, 0);
for ( ;; ) {
- ogs_pollset_poll(sgwu_self()->pollset,
- ogs_timer_mgr_next(sgwu_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.
@@ -92,12 +92,12 @@ static void sgwu_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
- ogs_timer_mgr_expire(sgwu_self()->timer_mgr);
+ ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
sgwu_event_t *e = NULL;
- rv = ogs_queue_trypop(sgwu_self()->queue, (void**)&e);
+ rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)
diff --git a/src/sgwu/pfcp-path.c b/src/sgwu/pfcp-path.c
index a4b816979..32255e100 100644
--- a/src/sgwu/pfcp-path.c
+++ b/src/sgwu/pfcp-path.c
@@ -29,7 +29,7 @@ static void pfcp_node_fsm_init(ogs_pfcp_node_t *node, bool try_to_assoicate)
e.pfcp_node = node;
if (try_to_assoicate == true) {
- node->t_association = ogs_timer_add(sgwu_self()->timer_mgr,
+ node->t_association = ogs_timer_add(ogs_app()->timer_mgr,
sgwu_timer_association, node);
ogs_assert(node->t_association);
}
@@ -111,7 +111,7 @@ static void pfcp_recv_cb(short when, ogs_socket_t fd, void *data)
e->pfcp_node = node;
e->pkbuf = pkbuf;
- rv = ogs_queue_push(sgwu_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);
@@ -130,14 +130,14 @@ int sgwu_pfcp_open(void)
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(sgwu_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
ogs_list_for_each(&ogs_pfcp_self()->pfcp_list6, node) {
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(sgwu_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
diff --git a/src/sgwu/pfcp-sm.c b/src/sgwu/pfcp-sm.c
index d45a216c5..de89d821c 100644
--- a/src/sgwu/pfcp-sm.c
+++ b/src/sgwu/pfcp-sm.c
@@ -39,7 +39,7 @@ void sgwu_pfcp_state_initial(ogs_fsm_t *s, sgwu_event_t *e)
ogs_pfcp_self()->pfcp_sock, ogs_pfcp_self()->pfcp_sock6, node);
ogs_assert(rv == OGS_OK);
- node->t_no_heartbeat = ogs_timer_add(sgwu_self()->timer_mgr,
+ node->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr,
sgwu_timer_no_heartbeat, node);
ogs_assert(node->t_no_heartbeat);
@@ -80,7 +80,7 @@ void sgwu_pfcp_state_will_associate(ogs_fsm_t *s, sgwu_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (node->t_association) {
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_up_send_association_setup_request(node, node_timeout);
}
@@ -103,7 +103,7 @@ void sgwu_pfcp_state_will_associate(ogs_fsm_t *s, sgwu_event_t *e)
ogs_assert(node->t_association);
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_up_send_association_setup_request(node, node_timeout);
break;
@@ -167,7 +167,7 @@ void sgwu_pfcp_state_associated(ogs_fsm_t *s, sgwu_event_t *e)
case OGS_FSM_ENTRY_SIG:
ogs_info("PFCP associated");
ogs_timer_start(node->t_no_heartbeat,
- ogs_config()->time.message.pfcp.no_heartbeat_duration);
+ ogs_app()->time.message.pfcp.no_heartbeat_duration);
break;
case OGS_FSM_EXIT_SIG:
ogs_info("PFCP de-associated");
@@ -290,7 +290,7 @@ static void node_timeout(ogs_pfcp_xact_t *xact, void *data)
e = sgwu_event_new(SGWU_EVT_SXA_NO_HEARTBEAT);
e->pfcp_node = data;
- rv = ogs_queue_push(sgwu_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
sgwu_event_free(e);
diff --git a/src/sgwu/sxa-build.c b/src/sgwu/sxa-build.c
index 79a5ef174..b53fac283 100644
--- a/src/sgwu/sxa-build.c
+++ b/src/sgwu/sxa-build.c
@@ -39,7 +39,7 @@ ogs_pkbuf_t *sgwu_sxa_build_session_establishment_response(uint8_t type,
/* Node ID */
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, &len);
rsp->node_id.presence = 1;
rsp->node_id.data = &node_id;
diff --git a/src/sgwu/sxa-handler.c b/src/sgwu/sxa-handler.c
index a418d13ce..f2ca43114 100644
--- a/src/sgwu/sxa-handler.c
+++ b/src/sgwu/sxa-handler.c
@@ -38,9 +38,9 @@ static void setup_gtp_node(ogs_pfcp_far_t *far)
if (!gnode) {
gnode = ogs_gtp_node_add_by_ip(
&sgwu_self()->peer_list, &ip, sgwu_self()->gtpu_port,
- 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);
ogs_assert(gnode);
rv = ogs_gtp_connect(
diff --git a/src/sgwu/timer.c b/src/sgwu/timer.c
index 31b8436ce..0b05ae74a 100644
--- a/src/sgwu/timer.c
+++ b/src/sgwu/timer.c
@@ -43,7 +43,7 @@ static void timer_send_event(int timer_id, void *data)
e->timer_id = timer_id;
e->pfcp_node = data;
- rv = ogs_queue_push(sgwu_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
sgwu_event_free(e);
diff --git a/src/smf/context.c b/src/smf/context.c
index ac23dcf1b..7030fa9f8 100644
--- a/src/smf/context.c
+++ b/src/smf/context.c
@@ -51,7 +51,7 @@ void smf_context_init(void)
ogs_log_install_domain(&__smf_log_domain, "smf", ogs_core()->log.level);
ogs_log_install_domain(&__gsm_log_domain, "gsm", ogs_core()->log.level);
- ogs_gtp_node_init(512);
+ ogs_gtp_node_init();
ogs_list_init(&self.smf_ue_list);
@@ -60,11 +60,11 @@ void smf_context_init(void)
ogs_list_init(&self.sgw_s5c_list);
- ogs_pool_init(&smf_ue_pool, ogs_config()->pool.ue);
- ogs_pool_init(&smf_sess_pool, ogs_config()->pool.sess);
- ogs_pool_init(&smf_bearer_pool, ogs_config()->pool.bearer);
+ ogs_pool_init(&smf_ue_pool, ogs_app()->max.ue);
+ ogs_pool_init(&smf_sess_pool, ogs_app()->pool.sess);
+ ogs_pool_init(&smf_bearer_pool, ogs_app()->pool.bearer);
- ogs_pool_init(&smf_pf_pool, ogs_config()->pool.pf);
+ ogs_pool_init(&smf_pf_pool, ogs_app()->pool.pf);
self.supi_hash = ogs_hash_make();
self.imsi_hash = ogs_hash_make();
@@ -123,20 +123,20 @@ static int smf_context_validation(void)
(self.diam_config->cnf_diamid == NULL ||
self.diam_config->cnf_diamrlm == NULL ||
self.diam_config->cnf_addr == NULL)) {
- ogs_error("No smf.freeDiameter in '%s'", ogs_config()->file);
+ ogs_error("No smf.freeDiameter in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (ogs_list_first(&self.gtpc_list) == NULL &&
ogs_list_first(&self.gtpc_list6) == NULL) {
- ogs_error("No smf.gtpc in '%s'", ogs_config()->file);
+ ogs_error("No smf.gtpc in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (self.dns[0] == NULL && self.dns6[0] == NULL) {
- ogs_error("No smf.dns in '%s'", ogs_config()->file);
+ ogs_error("No smf.dns in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (ogs_list_first(&ogs_pfcp_self()->subnet_list) == NULL) {
- ogs_error("No smf.pdn: in '%s'", ogs_config()->file);
+ ogs_error("No smf.pdn: in '%s'", ogs_app()->file);
return OGS_ERROR;
}
return OGS_OK;
@@ -148,7 +148,7 @@ int smf_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 = smf_context_prepare();
@@ -384,10 +384,10 @@ int smf_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);
@@ -395,9 +395,9 @@ int smf_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);
@@ -409,9 +409,9 @@ int smf_context_parse_config(void)
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);
@@ -683,14 +683,14 @@ smf_sess_t *smf_sess_add_by_apn(smf_ue_t *smf_ue, char *apn)
ogs_pool_alloc(&smf_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(&smf_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->smf_n4_teid = sess->index;
@@ -701,7 +701,7 @@ smf_sess_t *smf_sess_add_by_apn(smf_ue_t *smf_ue, char *apn)
/* Setup Timer */
sess->t_release_holding = ogs_timer_add(
- self.timer_mgr, smf_timer_release_holding_expire, sess);
+ ogs_app()->timer_mgr, smf_timer_release_holding_expire, sess);
memset(&e, 0, sizeof(e));
e.sess = sess;
@@ -784,14 +784,14 @@ smf_sess_t *smf_sess_add_by_psi(smf_ue_t *smf_ue, uint8_t psi)
ogs_pool_alloc(&smf_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(&smf_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);
sess->sm_context_ref = ogs_msprintf("%d",
(int)ogs_pool_index(&smf_sess_pool, sess));
@@ -812,7 +812,7 @@ smf_sess_t *smf_sess_add_by_psi(smf_ue_t *smf_ue, uint8_t psi)
/* Setup Timer */
sess->t_release_holding = ogs_timer_add(
- self.timer_mgr, smf_timer_release_holding_expire, sess);
+ ogs_app()->timer_mgr, smf_timer_release_holding_expire, sess);
memset(&e, 0, sizeof(e));
e.sess = sess;
@@ -1095,7 +1095,7 @@ smf_bearer_t *smf_qos_flow_add(smf_sess_t *sess)
qos_flow->index = ogs_pool_index(&smf_bearer_pool, qos_flow);
ogs_assert(qos_flow->index > 0 && qos_flow->index <=
- ogs_config()->pool.bearer);
+ ogs_app()->pool.bearer);
ogs_list_init(&qos_flow->pf_list);
@@ -1189,7 +1189,7 @@ smf_bearer_t *smf_bearer_add(smf_sess_t *sess)
bearer->index = ogs_pool_index(&smf_bearer_pool, bearer);
ogs_assert(bearer->index > 0 && bearer->index <=
- ogs_config()->pool.bearer);
+ ogs_app()->pool.bearer);
ogs_list_init(&bearer->pf_list);
diff --git a/src/smf/context.h b/src/smf/context.h
index 67f27f348..134eb2d00 100644
--- a/src/smf/context.h
+++ b/src/smf/context.h
@@ -22,10 +22,6 @@
#include "smf-config.h"
-#if HAVE_NET_IF_H
-#include
-#endif
-
#include "ogs-gtp.h"
#include "ogs-diameter-gx.h"
#include "ogs-pfcp.h"
@@ -38,6 +34,10 @@
#include "timer.h"
#include "smf-sm.h"
+#if HAVE_NET_IF_H
+#include
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -63,10 +63,6 @@ typedef struct smf_context_s {
ogs_sockaddr_t *gtpc_addr; /* SMF GTPC IPv4 Address */
ogs_sockaddr_t *gtpc_addr6; /* SMF GTPC IPv6 Address */
- ogs_queue_t *queue; /* Queue for processing SMF control */
- ogs_timer_mgr_t *timer_mgr; /* Timer Manager */
- ogs_pollset_t *pollset; /* Poll Set for I/O Multiplexing */
-
#define MAX_NUM_OF_DNS 2
const char *dns[MAX_NUM_OF_DNS];
const char *dns6[MAX_NUM_OF_DNS];
diff --git a/src/smf/event.c b/src/smf/event.c
index 51154e36c..6360eabd4 100644
--- a/src/smf/event.c
+++ b/src/smf/event.c
@@ -20,30 +20,15 @@
#include "event.h"
#include "context.h"
-#define EVENT_POOL 32 /* FIXME : 32 */
static OGS_POOL(pool, smf_event_t);
void smf_event_init(void)
{
- ogs_pool_init(&pool, EVENT_POOL);
-
- smf_self()->queue = ogs_queue_create(EVENT_POOL);
- ogs_assert(smf_self()->queue);
- smf_self()->timer_mgr = ogs_timer_mgr_create();
- ogs_assert(smf_self()->timer_mgr);
- smf_self()->pollset = ogs_pollset_create();
- ogs_assert(smf_self()->pollset);
+ ogs_pool_init(&pool, ogs_app()->pool.event);
}
void smf_event_final(void)
{
- if (smf_self()->pollset)
- ogs_pollset_destroy(smf_self()->pollset);
- if (smf_self()->timer_mgr)
- ogs_timer_mgr_destroy(smf_self()->timer_mgr);
- if (smf_self()->queue)
- ogs_queue_destroy(smf_self()->queue);
-
ogs_pool_final(&pool);
}
diff --git a/src/smf/fd-path.c b/src/smf/fd-path.c
index 9a4900174..02fb74e30 100644
--- a/src/smf/fd-path.c
+++ b/src/smf/fd-path.c
@@ -747,14 +747,14 @@ out:
e->sess = sess;
e->pkbuf = gxbuf;
e->gtp_xact = xact;
- rv = ogs_queue_push(smf_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_diam_gx_message_free(gx_message);
ogs_pkbuf_free(e->pkbuf);
smf_event_free(e);
} else {
- ogs_pollset_notify(smf_self()->pollset);
+ ogs_pollset_notify(ogs_app()->pollset);
}
} else {
ogs_diam_gx_message_free(gx_message);
@@ -972,14 +972,14 @@ static int smf_gx_rar_cb( struct msg **msg, struct avp *avp,
e->sess = sess;
e->pkbuf = gxbuf;
- rv = ogs_queue_push(smf_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_diam_gx_message_free(gx_message);
ogs_pkbuf_free(e->pkbuf);
smf_event_free(e);
} else {
- ogs_pollset_notify(smf_self()->pollset);
+ ogs_pollset_notify(ogs_app()->pollset);
}
/* Set the Auth-Application-Id AVP */
@@ -1043,7 +1043,7 @@ int smf_fd_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);
ret = ogs_diam_init(FD_MODE_CLIENT|FD_MODE_SERVER,
smf_self()->diam_conf_path, smf_self()->diam_config);
diff --git a/src/smf/gtp-path.c b/src/smf/gtp-path.c
index d386724fc..4648eba1f 100644
--- a/src/smf/gtp-path.c
+++ b/src/smf/gtp-path.c
@@ -60,7 +60,7 @@ static void _gtpv2_c_recv_cb(short when, ogs_socket_t fd, void *data)
e->gnode = gnode;
e->pkbuf = pkbuf;
- rv = ogs_queue_push(smf_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);
@@ -77,14 +77,14 @@ int smf_gtp_open(void)
sock = ogs_gtp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(smf_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv2_c_recv_cb, sock);
}
ogs_list_for_each(&smf_self()->gtpc_list6, node) {
sock = ogs_gtp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(smf_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv2_c_recv_cb, sock);
}
diff --git a/src/smf/init.c b/src/smf/init.c
index 80a100710..da07fc824 100644
--- a/src/smf/init.c
+++ b/src/smf/init.c
@@ -29,15 +29,15 @@ int smf_initialize()
{
int rv;
- ogs_pfcp_context_init(ogs_config()->max.upf * OGS_MAX_NUM_OF_GTPU_RESOURCE);
+ ogs_pfcp_context_init(ogs_app()->pool.nf * OGS_MAX_NUM_OF_GTPU_RESOURCE);
smf_context_init();
- smf_event_init(); /* Create event with poll, timer */
- ogs_sbi_context_init(smf_self()->pollset, smf_self()->timer_mgr);
+ smf_event_init();
+ ogs_sbi_context_init();
- rv = ogs_gtp_xact_init(smf_self()->timer_mgr, 512);
+ rv = ogs_gtp_xact_init();
if (rv != OGS_OK) return rv;
- rv = ogs_pfcp_xact_init(smf_self()->timer_mgr, 512);
+ rv = ogs_pfcp_xact_init();
if (rv != OGS_OK) return rv;
rv = ogs_pfcp_context_parse_config("smf", "upf");
@@ -50,7 +50,7 @@ int smf_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;
rv = ogs_pfcp_ue_pool_generate();
@@ -78,14 +78,14 @@ static void event_termination(void)
smf_nf_fsm_fini(nf_instance);
/* Starting holding timer */
- t_termination_holding = ogs_timer_add(smf_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(smf_self()->queue);
- ogs_pollset_notify(smf_self()->pollset);
+ ogs_queue_term(ogs_app()->queue);
+ ogs_pollset_notify(ogs_app()->pollset);
}
void smf_terminate(void)
@@ -118,8 +118,8 @@ static void smf_main(void *data)
ogs_fsm_init(&smf_sm, 0);
for ( ;; ) {
- ogs_pollset_poll(smf_self()->pollset,
- ogs_timer_mgr_next(smf_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.
@@ -132,12 +132,12 @@ static void smf_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
- ogs_timer_mgr_expire(smf_self()->timer_mgr);
+ ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
smf_event_t *e = NULL;
- rv = ogs_queue_trypop(smf_self()->queue, (void**)&e);
+ rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)
diff --git a/src/smf/n4-build.c b/src/smf/n4-build.c
index 048f5631b..da8a3c29a 100644
--- a/src/smf/n4-build.c
+++ b/src/smf/n4-build.c
@@ -48,7 +48,7 @@ ogs_pkbuf_t *smf_n4_build_session_establishment_request(
/* Node ID */
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, &len);
req->node_id.presence = 1;
req->node_id.data = &node_id;
diff --git a/src/smf/nas-path.c b/src/smf/nas-path.c
index e7f3ec099..1ec87fa88 100644
--- a/src/smf/nas-path.c
+++ b/src/smf/nas-path.c
@@ -33,7 +33,7 @@ void nas_5gs_send_to_gsm(
e->sess = sess;
e->sbi.session = session;
e->pkbuf = pkbuf;
- rv = ogs_queue_push(smf_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);
diff --git a/src/smf/nf-sm.c b/src/smf/nf-sm.c
index 3d36a9f84..29dc57269 100644
--- a/src/smf/nf-sm.c
+++ b/src/smf/nf-sm.c
@@ -107,7 +107,7 @@ void smf_nf_state_will_register(ogs_fsm_t *s, smf_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 smf_nf_state_will_register(ogs_fsm_t *s, smf_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;
@@ -207,7 +207,7 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_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,
@@ -247,7 +247,7 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_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]",
@@ -351,7 +351,7 @@ void smf_nf_state_exception(ogs_fsm_t *s, smf_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;
diff --git a/src/smf/ngap-path.c b/src/smf/ngap-path.c
index 3373394fd..c97fe7801 100644
--- a/src/smf/ngap-path.c
+++ b/src/smf/ngap-path.c
@@ -34,7 +34,7 @@ void ngap_send_to_n2sm(smf_sess_t *sess,
e->sbi.session = session;
e->pkbuf = pkbuf;
e->ngap.type = type;
- rv = ogs_queue_push(smf_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);
diff --git a/src/smf/nnrf-handler.c b/src/smf/nnrf-handler.c
index 607f37b48..7f03283f0 100644
--- a/src/smf/nnrf-handler.c
+++ b/src/smf/nnrf-handler.c
@@ -77,7 +77,7 @@ void smf_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(smf_self()->timer_mgr,
+ subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr,
smf_timer_subscription_validity, subscription);
ogs_assert(subscription->t_validity);
ogs_timer_start(subscription->t_validity, duration);
diff --git a/src/smf/pfcp-path.c b/src/smf/pfcp-path.c
index 75027dce6..9d2ceda0f 100644
--- a/src/smf/pfcp-path.c
+++ b/src/smf/pfcp-path.c
@@ -31,7 +31,7 @@ static void pfcp_node_fsm_init(ogs_pfcp_node_t *node, bool try_to_assoicate)
e.pfcp_node = node;
if (try_to_assoicate == true) {
- node->t_association = ogs_timer_add(smf_self()->timer_mgr,
+ node->t_association = ogs_timer_add(ogs_app()->timer_mgr,
smf_timer_pfcp_association, node);
ogs_assert(node->t_association);
}
@@ -113,7 +113,7 @@ static void pfcp_recv_cb(short when, ogs_socket_t fd, void *data)
e->pfcp_node = node;
e->pkbuf = pkbuf;
- rv = ogs_queue_push(smf_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);
@@ -132,14 +132,14 @@ int smf_pfcp_open(void)
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(smf_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
ogs_list_for_each(&ogs_pfcp_self()->pfcp_list6, node) {
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(smf_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
diff --git a/src/smf/pfcp-sm.c b/src/smf/pfcp-sm.c
index 1500be637..aa4e4aa03 100644
--- a/src/smf/pfcp-sm.c
+++ b/src/smf/pfcp-sm.c
@@ -41,7 +41,7 @@ void smf_pfcp_state_initial(ogs_fsm_t *s, smf_event_t *e)
ogs_pfcp_self()->pfcp_sock, ogs_pfcp_self()->pfcp_sock6, node);
ogs_assert(rv == OGS_OK);
- node->t_no_heartbeat = ogs_timer_add(smf_self()->timer_mgr,
+ node->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr,
smf_timer_pfcp_no_heartbeat, node);
ogs_assert(node->t_no_heartbeat);
@@ -86,7 +86,7 @@ void smf_pfcp_state_will_associate(ogs_fsm_t *s, smf_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (node->t_association) {
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_cp_send_association_setup_request(node, node_timeout);
}
@@ -109,7 +109,7 @@ void smf_pfcp_state_will_associate(ogs_fsm_t *s, smf_event_t *e)
ogs_assert(node->t_association);
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_cp_send_association_setup_request(node, node_timeout);
break;
@@ -173,7 +173,7 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
case OGS_FSM_ENTRY_SIG:
ogs_info("PFCP associated");
ogs_timer_start(node->t_no_heartbeat,
- ogs_config()->time.message.pfcp.no_heartbeat_duration);
+ ogs_app()->time.message.pfcp.no_heartbeat_duration);
break;
case OGS_FSM_EXIT_SIG:
ogs_info("PFCP de-associated");
@@ -316,7 +316,7 @@ static void node_timeout(ogs_pfcp_xact_t *xact, void *data)
e = smf_event_new(SMF_EVT_N4_NO_HEARTBEAT);
e->pfcp_node = data;
- rv = ogs_queue_push(smf_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
smf_event_free(e);
diff --git a/src/smf/sbi-path.c b/src/smf/sbi-path.c
index f05459acf..4a646af2e 100644
--- a/src/smf/sbi-path.c
+++ b/src/smf/sbi-path.c
@@ -37,7 +37,7 @@ static int server_cb(ogs_sbi_server_t *server,
e->sbi.session = session;
e->sbi.request = request;
- rv = ogs_queue_push(smf_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
smf_event_free(e);
@@ -59,7 +59,7 @@ static int client_cb(ogs_sbi_response_t *response, void *data)
e->sbi.response = response;
e->sbi.data = data;
- rv = ogs_queue_push(smf_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
smf_event_free(e);
diff --git a/src/smf/timer.c b/src/smf/timer.c
index 62e854e9e..901c1f9de 100644
--- a/src/smf/timer.c
+++ b/src/smf/timer.c
@@ -81,7 +81,7 @@ static void timer_send_event(int timer_id, void *data)
break;
}
- rv = ogs_queue_push(smf_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, smf_timer_get_name(e->timer_id));
diff --git a/src/udm/context.c b/src/udm/context.c
index eb73970f2..5226e1d76 100644
--- a/src/udm/context.c
+++ b/src/udm/context.c
@@ -37,7 +37,7 @@ void udm_context_init(void)
ogs_log_install_domain(&__udm_log_domain, "udm", ogs_core()->log.level);
/* Allocate TWICE the pool to check if maximum number of gNBs is reached */
- ogs_pool_init(&udm_ue_pool, ogs_config()->pool.ue);
+ ogs_pool_init(&udm_ue_pool, ogs_app()->max.ue);
ogs_list_init(&self.udm_ue_list);
self.suci_hash = ogs_hash_make();
@@ -85,7 +85,7 @@ int udm_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 = udm_context_prepare();
diff --git a/src/udm/context.h b/src/udm/context.h
index 9f4425b2f..6647ec08a 100644
--- a/src/udm/context.h
+++ b/src/udm/context.h
@@ -39,10 +39,6 @@ extern int __udm_log_domain;
#define OGS_LOG_DOMAIN __udm_log_domain
typedef struct udm_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 udm_ue_list;
diff --git a/src/udm/event.c b/src/udm/event.c
index d87ff1775..ad2376683 100644
--- a/src/udm/event.c
+++ b/src/udm/event.c
@@ -20,30 +20,15 @@
#include "event.h"
#include "context.h"
-#define EVENT_POOL 32 /* FIXME : 32 */
static OGS_POOL(pool, udm_event_t);
void udm_event_init(void)
{
- ogs_pool_init(&pool, EVENT_POOL);
-
- udm_self()->queue = ogs_queue_create(EVENT_POOL);
- ogs_assert(udm_self()->queue);
- udm_self()->timer_mgr = ogs_timer_mgr_create();
- ogs_assert(udm_self()->timer_mgr);
- udm_self()->pollset = ogs_pollset_create();
- ogs_assert(udm_self()->pollset);
+ ogs_pool_init(&pool, ogs_app()->pool.event);
}
void udm_event_final(void)
{
- if (udm_self()->pollset)
- ogs_pollset_destroy(udm_self()->pollset);
- if (udm_self()->timer_mgr)
- ogs_timer_mgr_destroy(udm_self()->timer_mgr);
- if (udm_self()->queue)
- ogs_queue_destroy(udm_self()->queue);
-
ogs_pool_final(&pool);
}
diff --git a/src/udm/init.c b/src/udm/init.c
index 2362c4f1e..34160d275 100644
--- a/src/udm/init.c
+++ b/src/udm/init.c
@@ -28,8 +28,8 @@ int udm_initialize()
int rv;
udm_context_init();
- udm_event_init(); /* Create event with poll, timer */
- ogs_sbi_context_init(udm_self()->pollset, udm_self()->timer_mgr);
+ udm_event_init();
+ ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("udm", "nrf");
if (rv != OGS_OK) return rv;
@@ -38,7 +38,7 @@ int udm_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(udm_main, NULL);
@@ -60,14 +60,14 @@ static void event_termination(void)
udm_nf_fsm_fini(nf_instance);
/* Starting holding timer */
- t_termination_holding = ogs_timer_add(udm_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(udm_self()->queue);
- ogs_pollset_notify(udm_self()->pollset);
+ ogs_queue_term(ogs_app()->queue);
+ ogs_pollset_notify(ogs_app()->pollset);
}
void udm_terminate(void)
@@ -94,8 +94,8 @@ static void udm_main(void *data)
ogs_fsm_init(&udm_sm, 0);
for ( ;; ) {
- ogs_pollset_poll(udm_self()->pollset,
- ogs_timer_mgr_next(udm_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 udm_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
- ogs_timer_mgr_expire(udm_self()->timer_mgr);
+ ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
udm_event_t *e = NULL;
- rv = ogs_queue_trypop(udm_self()->queue, (void**)&e);
+ rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)
diff --git a/src/udm/nf-sm.c b/src/udm/nf-sm.c
index 6874f9201..67663a722 100644
--- a/src/udm/nf-sm.c
+++ b/src/udm/nf-sm.c
@@ -107,7 +107,7 @@ void udm_nf_state_will_register(ogs_fsm_t *s, udm_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 udm_nf_state_will_register(ogs_fsm_t *s, udm_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 udm_nf_state_registered(ogs_fsm_t *s, udm_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 udm_nf_state_registered(ogs_fsm_t *s, udm_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 udm_nf_state_exception(ogs_fsm_t *s, udm_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;
diff --git a/src/udm/nnrf-handler.c b/src/udm/nnrf-handler.c
index 8828193bc..5910f16f2 100644
--- a/src/udm/nnrf-handler.c
+++ b/src/udm/nnrf-handler.c
@@ -77,7 +77,7 @@ void udm_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(udm_self()->timer_mgr,
+ subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr,
udm_timer_subscription_validity, subscription);
ogs_assert(subscription->t_validity);
ogs_timer_start(subscription->t_validity, duration);
diff --git a/src/udm/sbi-path.c b/src/udm/sbi-path.c
index bd5d2f9c2..ea3e2cfb4 100644
--- a/src/udm/sbi-path.c
+++ b/src/udm/sbi-path.c
@@ -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(udm_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
udm_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(udm_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
udm_event_free(e);
diff --git a/src/udm/timer.c b/src/udm/timer.c
index 68a947fc6..00e605097 100644
--- a/src/udm/timer.c
+++ b/src/udm/timer.c
@@ -65,7 +65,7 @@ static void sbi_timer_send_event(int timer_id, void *data)
break;
}
- rv = ogs_queue_push(udm_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, udm_timer_get_name(e->timer_id));
diff --git a/src/udr/context.c b/src/udr/context.c
index da001f849..98b2501d3 100644
--- a/src/udr/context.c
+++ b/src/udr/context.c
@@ -68,7 +68,7 @@ int udr_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 = udr_context_prepare();
diff --git a/src/udr/context.h b/src/udr/context.h
index 2bf3f0213..4bd5bc86a 100644
--- a/src/udr/context.h
+++ b/src/udr/context.h
@@ -39,10 +39,6 @@ extern int __udr_log_domain;
#define OGS_LOG_DOMAIN __udr_log_domain
typedef struct udr_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;
} udr_context_t;
diff --git a/src/udr/event.c b/src/udr/event.c
index e566140de..3cd6ae195 100644
--- a/src/udr/event.c
+++ b/src/udr/event.c
@@ -20,30 +20,15 @@
#include "event.h"
#include "context.h"
-#define EVENT_POOL 32 /* FIXME : 32 */
static OGS_POOL(pool, udr_event_t);
void udr_event_init(void)
{
- ogs_pool_init(&pool, EVENT_POOL);
-
- udr_self()->queue = ogs_queue_create(EVENT_POOL);
- ogs_assert(udr_self()->queue);
- udr_self()->timer_mgr = ogs_timer_mgr_create();
- ogs_assert(udr_self()->timer_mgr);
- udr_self()->pollset = ogs_pollset_create();
- ogs_assert(udr_self()->pollset);
+ ogs_pool_init(&pool, ogs_app()->pool.event);
}
void udr_event_final(void)
{
- if (udr_self()->pollset)
- ogs_pollset_destroy(udr_self()->pollset);
- if (udr_self()->timer_mgr)
- ogs_timer_mgr_destroy(udr_self()->timer_mgr);
- if (udr_self()->queue)
- ogs_queue_destroy(udr_self()->queue);
-
ogs_pool_final(&pool);
}
diff --git a/src/udr/init.c b/src/udr/init.c
index c6afc8754..c47626eec 100644
--- a/src/udr/init.c
+++ b/src/udr/init.c
@@ -28,8 +28,8 @@ int udr_initialize()
int rv;
udr_context_init();
- udr_event_init(); /* Create event with poll, timer */
- ogs_sbi_context_init(udr_self()->pollset, udr_self()->timer_mgr);
+ udr_event_init();
+ ogs_sbi_context_init();
rv = ogs_sbi_context_parse_config("udr", "nrf");
if (rv != OGS_OK) return rv;
@@ -38,10 +38,10 @@ int udr_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;
- rv = ogs_dbi_init(ogs_config()->db_uri);
+ rv = ogs_dbi_init(ogs_app()->db_uri);
if (rv != OGS_OK) return rv;
thread = ogs_thread_create(udr_main, NULL);
@@ -63,14 +63,14 @@ static void event_termination(void)
udr_nf_fsm_fini(nf_instance);
/* Starting holding timer */
- t_termination_holding = ogs_timer_add(udr_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(udr_self()->queue);
- ogs_pollset_notify(udr_self()->pollset);
+ ogs_queue_term(ogs_app()->queue);
+ ogs_pollset_notify(ogs_app()->pollset);
}
void udr_terminate(void)
@@ -99,8 +99,8 @@ static void udr_main(void *data)
ogs_fsm_init(&udr_sm, 0);
for ( ;; ) {
- ogs_pollset_poll(udr_self()->pollset,
- ogs_timer_mgr_next(udr_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.
@@ -113,12 +113,12 @@ static void udr_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
- ogs_timer_mgr_expire(udr_self()->timer_mgr);
+ ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
udr_event_t *e = NULL;
- rv = ogs_queue_trypop(udr_self()->queue, (void**)&e);
+ rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)
diff --git a/src/udr/nf-sm.c b/src/udr/nf-sm.c
index 78fca0194..8d180e341 100644
--- a/src/udr/nf-sm.c
+++ b/src/udr/nf-sm.c
@@ -107,7 +107,7 @@ void udr_nf_state_will_register(ogs_fsm_t *s, udr_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 udr_nf_state_will_register(ogs_fsm_t *s, udr_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 udr_nf_state_registered(ogs_fsm_t *s, udr_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 udr_nf_state_registered(ogs_fsm_t *s, udr_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 udr_nf_state_exception(ogs_fsm_t *s, udr_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;
diff --git a/src/udr/nnrf-handler.c b/src/udr/nnrf-handler.c
index 1ff12b56f..fee1aa4e7 100644
--- a/src/udr/nnrf-handler.c
+++ b/src/udr/nnrf-handler.c
@@ -77,7 +77,7 @@ void udr_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(udr_self()->timer_mgr,
+ subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr,
udr_timer_subscription_validity, subscription);
ogs_assert(subscription->t_validity);
ogs_timer_start(subscription->t_validity, duration);
diff --git a/src/udr/sbi-path.c b/src/udr/sbi-path.c
index 4fd2f611c..2e8c55cc8 100644
--- a/src/udr/sbi-path.c
+++ b/src/udr/sbi-path.c
@@ -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(udr_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
udr_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(udr_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
udr_event_free(e);
diff --git a/src/udr/timer.c b/src/udr/timer.c
index e5af873a2..1a1d802a9 100644
--- a/src/udr/timer.c
+++ b/src/udr/timer.c
@@ -62,7 +62,7 @@ static void sbi_timer_send_event(int timer_id, void *data)
break;
}
- rv = ogs_queue_push(udr_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, udr_timer_get_name(e->timer_id));
diff --git a/src/upf/context.c b/src/upf/context.c
index 615008054..2328bd89f 100644
--- a/src/upf/context.c
+++ b/src/upf/context.c
@@ -41,13 +41,13 @@ void upf_context_init(void)
ogs_pfcp_self()->up_function_features.empu = 1;
ogs_pfcp_self()->up_function_features_len = 2;
- ogs_gtp_node_init(512);
+ ogs_gtp_node_init();
ogs_list_init(&self.sess_list);
ogs_list_init(&self.gtpu_list);
ogs_list_init(&self.peer_list);
- ogs_pool_init(&upf_sess_pool, ogs_config()->pool.sess);
+ ogs_pool_init(&upf_sess_pool, ogs_app()->pool.sess);
self.sess_hash = ogs_hash_make();
self.ipv4_hash = ogs_hash_make();
@@ -93,11 +93,11 @@ static int upf_context_prepare(void)
static int upf_context_validation(void)
{
if (ogs_list_first(&self.gtpu_list) == NULL) {
- ogs_error("No upf.gtpu in '%s'", ogs_config()->file);
+ ogs_error("No upf.gtpu in '%s'", ogs_app()->file);
return OGS_ERROR;
}
if (ogs_list_first(&ogs_pfcp_self()->subnet_list) == NULL) {
- ogs_error("No upf.pdn: in '%s'", ogs_config()->file);
+ ogs_error("No upf.pdn: in '%s'", ogs_app()->file);
return OGS_ERROR;
}
return OGS_OK;
@@ -109,7 +109,7 @@ int upf_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 = upf_context_prepare();
@@ -241,17 +241,17 @@ int upf_context_parse_config(void)
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);
}
@@ -327,8 +327,8 @@ int upf_context_parse_config(void)
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.gtpu_port);
ogs_assert(rv == OGS_OK);
@@ -389,7 +389,7 @@ upf_sess_t *upf_sess_add(ogs_pfcp_f_seid_t *cp_f_seid,
memset(sess, 0, sizeof *sess);
sess->index = ogs_pool_index(&upf_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);
sess->upf_n4_seid = sess->index;
sess->smf_n4_seid = cp_f_seid->seid;
diff --git a/src/upf/context.h b/src/upf/context.h
index af2e874ad..13f23a082 100644
--- a/src/upf/context.h
+++ b/src/upf/context.h
@@ -52,10 +52,6 @@ typedef struct upf_context_s {
ogs_sock_t *gtpu_sock; /* UPF GTPU IPv4 Socket */
ogs_sock_t *gtpu_sock6; /* UPF GTPU IPv6 Socket */
- 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 */
-
ogs_list_t peer_list; /* gNB N3 Node List */
ogs_hash_t *sess_hash; /* hash table (F-SEID) */
diff --git a/src/upf/event.c b/src/upf/event.c
index c29bde4d7..29cc85684 100644
--- a/src/upf/event.c
+++ b/src/upf/event.c
@@ -37,40 +37,25 @@ static void pollset_action_setup(void)
}
#endif
-#define EVENT_POOL 32 /* FIXME : 32 */
static OGS_POOL(pool, upf_event_t);
void upf_event_init(void)
{
- ogs_pool_init(&pool, EVENT_POOL);
+ ogs_pool_init(&pool, ogs_app()->pool.event);
#if defined(HAVE_KQUEUE)
pollset_action_setup();
#endif
-
- upf_self()->queue = ogs_queue_create(EVENT_POOL);
- ogs_assert(upf_self()->queue);
- upf_self()->timer_mgr = ogs_timer_mgr_create();
- ogs_assert(upf_self()->timer_mgr);
- upf_self()->pollset = ogs_pollset_create();
- ogs_assert(upf_self()->pollset);
}
void upf_event_term(void)
{
- ogs_queue_term(upf_self()->queue);
- ogs_pollset_notify(upf_self()->pollset);
+ ogs_queue_term(ogs_app()->queue);
+ ogs_pollset_notify(ogs_app()->pollset);
}
void upf_event_final(void)
{
- if (upf_self()->pollset)
- ogs_pollset_destroy(upf_self()->pollset);
- if (upf_self()->timer_mgr)
- ogs_timer_mgr_destroy(upf_self()->timer_mgr);
- if (upf_self()->queue)
- ogs_queue_destroy(upf_self()->queue);
-
ogs_pool_final(&pool);
}
diff --git a/src/upf/gtp-path.c b/src/upf/gtp-path.c
index e2f7b1926..ac9812b82 100644
--- a/src/upf/gtp-path.c
+++ b/src/upf/gtp-path.c
@@ -72,7 +72,7 @@ static void _gtpv1_tun_recv_cb(short when, ogs_socket_t fd, void *data)
/* Unicast */
ogs_pfcp_up_handle_pdr(pdr, recvbuf, &report);
} else {
- if (ogs_config()->parameter.multicast) {
+ if (ogs_app()->parameter.multicast) {
upf_gtp_handle_multicast(recvbuf);
}
}
@@ -225,7 +225,7 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
}
/* Check IPv6 */
- if (ogs_config()->parameter.no_slaac == 0 && ip_h->ip_v == 6) {
+ if (ogs_app()->parameter.no_slaac == 0 && ip_h->ip_v == 6) {
rv = upf_gtp_handle_slaac(sess, pkbuf);
if (rv == UPF_GTP_HANDLED) {
goto cleanup;
@@ -259,7 +259,7 @@ int upf_gtp_open(void)
else if (sock->family == AF_INET6)
upf_self()->gtpu_sock6 = sock;
- node->poll = ogs_pollset_add(upf_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, _gtpv1_u_recv_cb, sock);
}
@@ -284,7 +284,7 @@ int upf_gtp_open(void)
return OGS_ERROR;
}
- dev->poll = ogs_pollset_add(upf_self()->pollset,
+ dev->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, dev->fd, _gtpv1_tun_recv_cb, NULL);
ogs_assert(dev->poll);
}
diff --git a/src/upf/init.c b/src/upf/init.c
index e604de139..23477e850 100644
--- a/src/upf/init.c
+++ b/src/upf/init.c
@@ -34,7 +34,7 @@ int upf_initialize()
upf_context_init();
upf_event_init();
- rv = ogs_pfcp_xact_init(upf_self()->timer_mgr, 512);
+ rv = ogs_pfcp_xact_init();
if (rv != OGS_OK) return rv;
rv = ogs_pfcp_context_parse_config("upf", "smf");
@@ -44,7 +44,7 @@ int upf_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;
rv = ogs_pfcp_ue_pool_generate();
@@ -83,8 +83,8 @@ static void upf_main(void *data)
ogs_fsm_init(&upf_sm, 0);
for ( ;; ) {
- ogs_pollset_poll(upf_self()->pollset,
- ogs_timer_mgr_next(upf_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.
@@ -97,12 +97,12 @@ static void upf_main(void *data)
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
- ogs_timer_mgr_expire(upf_self()->timer_mgr);
+ ogs_timer_mgr_expire(ogs_app()->timer_mgr);
for ( ;; ) {
upf_event_t *e = NULL;
- rv = ogs_queue_trypop(upf_self()->queue, (void**)&e);
+ rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)
diff --git a/src/upf/n4-build.c b/src/upf/n4-build.c
index 04e8b8412..f7d766072 100644
--- a/src/upf/n4-build.c
+++ b/src/upf/n4-build.c
@@ -40,7 +40,7 @@ ogs_pkbuf_t *upf_n4_build_session_establishment_response(uint8_t type,
/* Node ID */
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, &len);
rsp->node_id.presence = 1;
rsp->node_id.data = &node_id;
diff --git a/src/upf/n4-handler.c b/src/upf/n4-handler.c
index 9e869737e..e5c3a77df 100644
--- a/src/upf/n4-handler.c
+++ b/src/upf/n4-handler.c
@@ -39,9 +39,9 @@ static void setup_gtp_node(ogs_pfcp_far_t *far)
if (!gnode) {
gnode = ogs_gtp_node_add_by_ip(
&upf_self()->peer_list, &ip, upf_self()->gtpu_port,
- 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);
ogs_assert(gnode);
rv = ogs_gtp_connect(
diff --git a/src/upf/pfcp-path.c b/src/upf/pfcp-path.c
index d72f560bc..19ba5b3d3 100644
--- a/src/upf/pfcp-path.c
+++ b/src/upf/pfcp-path.c
@@ -32,7 +32,7 @@ static void pfcp_node_fsm_init(ogs_pfcp_node_t *node, bool try_to_assoicate)
e.pfcp_node = node;
if (try_to_assoicate == true) {
- node->t_association = ogs_timer_add(upf_self()->timer_mgr,
+ node->t_association = ogs_timer_add(ogs_app()->timer_mgr,
upf_timer_association, node);
ogs_assert(node->t_association);
}
@@ -114,7 +114,7 @@ static void pfcp_recv_cb(short when, ogs_socket_t fd, void *data)
e->pfcp_node = node;
e->pkbuf = pkbuf;
- rv = ogs_queue_push(upf_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);
@@ -133,14 +133,14 @@ int upf_pfcp_open(void)
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(upf_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
ogs_list_for_each(&ogs_pfcp_self()->pfcp_list6, node) {
sock = ogs_pfcp_server(node);
ogs_assert(sock);
- node->poll = ogs_pollset_add(upf_self()->pollset,
+ node->poll = ogs_pollset_add(ogs_app()->pollset,
OGS_POLLIN, sock->fd, pfcp_recv_cb, sock);
}
diff --git a/src/upf/pfcp-sm.c b/src/upf/pfcp-sm.c
index b737a0be9..6f3656836 100644
--- a/src/upf/pfcp-sm.c
+++ b/src/upf/pfcp-sm.c
@@ -44,7 +44,7 @@ void upf_pfcp_state_initial(ogs_fsm_t *s, upf_event_t *e)
ogs_pfcp_self()->pfcp_sock, ogs_pfcp_self()->pfcp_sock6, node);
ogs_assert(rv == OGS_OK);
- node->t_no_heartbeat = ogs_timer_add(upf_self()->timer_mgr,
+ node->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr,
upf_timer_no_heartbeat, node);
ogs_assert(node->t_no_heartbeat);
@@ -85,7 +85,7 @@ void upf_pfcp_state_will_associate(ogs_fsm_t *s, upf_event_t *e)
case OGS_FSM_ENTRY_SIG:
if (node->t_association) {
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_up_send_association_setup_request(node, node_timeout);
}
@@ -108,7 +108,7 @@ void upf_pfcp_state_will_associate(ogs_fsm_t *s, upf_event_t *e)
ogs_assert(node->t_association);
ogs_timer_start(node->t_association,
- ogs_config()->time.message.pfcp.association_interval);
+ ogs_app()->time.message.pfcp.association_interval);
ogs_pfcp_up_send_association_setup_request(node, node_timeout);
break;
@@ -172,7 +172,7 @@ void upf_pfcp_state_associated(ogs_fsm_t *s, upf_event_t *e)
case OGS_FSM_ENTRY_SIG:
ogs_info("PFCP associated");
ogs_timer_start(node->t_no_heartbeat,
- ogs_config()->time.message.pfcp.no_heartbeat_duration);
+ ogs_app()->time.message.pfcp.no_heartbeat_duration);
break;
case OGS_FSM_EXIT_SIG:
ogs_info("PFCP de-associated");
@@ -291,7 +291,7 @@ static void node_timeout(ogs_pfcp_xact_t *xact, void *data)
e = upf_event_new(UPF_EVT_N4_NO_HEARTBEAT);
e->pfcp_node = data;
- rv = ogs_queue_push(upf_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
upf_event_free(e);
diff --git a/src/upf/timer.c b/src/upf/timer.c
index edc7e90f2..9ebcee565 100644
--- a/src/upf/timer.c
+++ b/src/upf/timer.c
@@ -45,7 +45,7 @@ static void timer_send_event(int timer_id, void *data)
e->timer_id = timer_id;
e->pfcp_node = data;
- rv = ogs_queue_push(upf_self()->queue, e);
+ rv = ogs_queue_push(ogs_app()->queue, e);
if (rv != OGS_OK) {
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
upf_event_free(e);
diff --git a/tests/app/5gc-init.c b/tests/app/5gc-init.c
index 914297903..9bb27e41f 100644
--- a/tests/app/5gc-init.c
+++ b/tests/app/5gc-init.c
@@ -47,19 +47,19 @@ int app_initialize(const char *const argv[])
argv_out[i] = NULL;
}
- if (ogs_config()->parameter.no_nrf == 0)
+ if (ogs_app()->parameter.no_nrf == 0)
nrf_thread = test_child_create("nrf", argv_out);
- if (ogs_config()->parameter.no_amf == 0)
+ if (ogs_app()->parameter.no_amf == 0)
amf_thread = test_child_create("amf", argv_out);
- if (ogs_config()->parameter.no_ausf == 0)
+ if (ogs_app()->parameter.no_ausf == 0)
ausf_thread = test_child_create("ausf", argv_out);
- if (ogs_config()->parameter.no_udm == 0)
+ if (ogs_app()->parameter.no_udm == 0)
udm_thread = test_child_create("udm", argv_out);
- if (ogs_config()->parameter.no_smf == 0)
+ if (ogs_app()->parameter.no_smf == 0)
smf_thread = test_child_create("smf", argv_out);
- if (ogs_config()->parameter.no_upf == 0)
+ if (ogs_app()->parameter.no_upf == 0)
upf_thread = test_child_create("upf", argv_out);
- if (ogs_config()->parameter.no_udr == 0)
+ if (ogs_app()->parameter.no_udr == 0)
udr_thread = test_child_create("udr", argv_out);
return OGS_OK;;
@@ -83,8 +83,8 @@ void test_5gc_init(void)
ogs_log_install_domain(&__ogs_dbi_domain, "dbi", OGS_LOG_ERROR);
ogs_log_install_domain(&__ogs_nas_domain, "nas", OGS_LOG_ERROR);
- ogs_sctp_init(ogs_config()->usrsctp.udp_port);
- ogs_assert(ogs_dbi_init(ogs_config()->db_uri) == OGS_OK);
+ ogs_sctp_init(ogs_app()->usrsctp.udp_port);
+ ogs_assert(ogs_dbi_init(ogs_app()->db_uri) == OGS_OK);
}
void test_5gc_final(void)
diff --git a/tests/app/app-init.c b/tests/app/app-init.c
index 3053acdd1..b2cb4c1bc 100644
--- a/tests/app/app-init.c
+++ b/tests/app/app-init.c
@@ -51,11 +51,11 @@ int app_initialize(const char *const argv[])
argv_out[i] = NULL;
}
- if (ogs_config()->parameter.no_nrf == 0)
+ if (ogs_app()->parameter.no_nrf == 0)
nrf_thread = test_child_create("nrf", argv_out);
- if (ogs_config()->parameter.no_pcrf == 0)
+ if (ogs_app()->parameter.no_pcrf == 0)
pcrf_thread = test_child_create("pcrf", argv_out);
- if (ogs_config()->parameter.no_hss == 0)
+ if (ogs_app()->parameter.no_hss == 0)
hss_thread = test_child_create("hss", argv_out);
/*
@@ -66,11 +66,11 @@ int app_initialize(const char *const argv[])
*/
ogs_msleep(500);
- if (ogs_config()->parameter.no_upf == 0)
+ if (ogs_app()->parameter.no_upf == 0)
upf_thread = test_child_create("upf", argv_out);
- if (ogs_config()->parameter.no_sgwu == 0)
+ if (ogs_app()->parameter.no_sgwu == 0)
sgwu_thread = test_child_create("sgwu", argv_out);
- if (ogs_config()->parameter.no_sgwc == 0)
+ if (ogs_app()->parameter.no_sgwc == 0)
sgwc_thread = test_child_create("sgwc", argv_out);
/*
@@ -81,16 +81,16 @@ int app_initialize(const char *const argv[])
*/
ogs_msleep(500);
- if (ogs_config()->parameter.no_smf == 0)
+ if (ogs_app()->parameter.no_smf == 0)
smf_thread = test_child_create("smf", argv_out);
- if (ogs_config()->parameter.no_mme == 0)
+ if (ogs_app()->parameter.no_mme == 0)
mme_thread = test_child_create("mme", argv_out);
- if (ogs_config()->parameter.no_ausf == 0)
+ if (ogs_app()->parameter.no_ausf == 0)
ausf_thread = test_child_create("ausf", argv_out);
- if (ogs_config()->parameter.no_udm == 0)
+ if (ogs_app()->parameter.no_udm == 0)
udm_thread = test_child_create("udm", argv_out);
- if (ogs_config()->parameter.no_udr == 0)
+ if (ogs_app()->parameter.no_udr == 0)
udr_thread = test_child_create("udr", argv_out);
return OGS_OK;;
@@ -123,8 +123,8 @@ void test_app_init(void)
ogs_log_install_domain(&__ogs_dbi_domain, "dbi", OGS_LOG_ERROR);
ogs_log_install_domain(&__ogs_nas_domain, "nas", OGS_LOG_ERROR);
- ogs_sctp_init(ogs_config()->usrsctp.udp_port);
- ogs_assert(ogs_dbi_init(ogs_config()->db_uri) == OGS_OK);
+ ogs_sctp_init(ogs_app()->usrsctp.udp_port);
+ ogs_assert(ogs_dbi_init(ogs_app()->db_uri) == OGS_OK);
}
void test_app_final(void)
diff --git a/tests/app/epc-init.c b/tests/app/epc-init.c
index 2a1d0ac4d..9c5fb6dc3 100644
--- a/tests/app/epc-init.c
+++ b/tests/app/epc-init.c
@@ -48,11 +48,11 @@ int app_initialize(const char *const argv[])
argv_out[i] = NULL;
}
- if (ogs_config()->parameter.no_nrf == 0)
+ if (ogs_app()->parameter.no_nrf == 0)
nrf_thread = test_child_create("nrf", argv_out);
- if (ogs_config()->parameter.no_pcrf == 0)
+ if (ogs_app()->parameter.no_pcrf == 0)
pcrf_thread = test_child_create("pcrf", argv_out);
- if (ogs_config()->parameter.no_hss == 0)
+ if (ogs_app()->parameter.no_hss == 0)
hss_thread = test_child_create("hss", argv_out);
/*
@@ -63,11 +63,11 @@ int app_initialize(const char *const argv[])
*/
ogs_msleep(500);
- if (ogs_config()->parameter.no_upf == 0)
+ if (ogs_app()->parameter.no_upf == 0)
upf_thread = test_child_create("upf", argv_out);
- if (ogs_config()->parameter.no_sgwu == 0)
+ if (ogs_app()->parameter.no_sgwu == 0)
sgwu_thread = test_child_create("sgwu", argv_out);
- if (ogs_config()->parameter.no_sgwc == 0)
+ if (ogs_app()->parameter.no_sgwc == 0)
sgwc_thread = test_child_create("sgwc", argv_out);
/*
@@ -78,9 +78,9 @@ int app_initialize(const char *const argv[])
*/
ogs_msleep(500);
- if (ogs_config()->parameter.no_smf == 0)
+ if (ogs_app()->parameter.no_smf == 0)
smf_thread = test_child_create("smf", argv_out);
- if (ogs_config()->parameter.no_mme == 0)
+ if (ogs_app()->parameter.no_mme == 0)
mme_thread = test_child_create("mme", argv_out);
return OGS_OK;;
@@ -106,8 +106,8 @@ void test_epc_init(void)
ogs_log_install_domain(&__ogs_dbi_domain, "dbi", OGS_LOG_ERROR);
ogs_log_install_domain(&__ogs_nas_domain, "nas", OGS_LOG_ERROR);
- ogs_sctp_init(ogs_config()->usrsctp.udp_port);
- ogs_assert(ogs_dbi_init(ogs_config()->db_uri) == OGS_OK);
+ ogs_sctp_init(ogs_app()->usrsctp.udp_port);
+ ogs_assert(ogs_dbi_init(ogs_app()->db_uri) == OGS_OK);
}
void test_epc_final(void)
diff --git a/tests/common/context.c b/tests/common/context.c
index 37e1f9064..8b7d8e215 100644
--- a/tests/common/context.c
+++ b/tests/common/context.c
@@ -37,9 +37,9 @@ void test_context_init(void)
/* Initialize AMF context */
memset(&self, 0, sizeof(test_context_t));
- ogs_pool_init(&test_ue_pool, ogs_config()->pool.ue);
- ogs_pool_init(&test_sess_pool, ogs_config()->pool.sess);
- ogs_pool_init(&test_bearer_pool, ogs_config()->pool.bearer);
+ ogs_pool_init(&test_ue_pool, ogs_app()->max.ue);
+ ogs_pool_init(&test_sess_pool, ogs_app()->pool.sess);
+ ogs_pool_init(&test_bearer_pool, ogs_app()->pool.bearer);
rv = ogs_getaddrinfo(&test_self()->gnb1_addr, AF_UNSPEC,
"127.0.0.2", OGS_GTPV1_U_UDP_PORT, 0);
@@ -134,7 +134,7 @@ int test_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 = test_context_prepare();
@@ -229,10 +229,10 @@ int test_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);
@@ -240,9 +240,9 @@ int test_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);
@@ -254,9 +254,9 @@ int test_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);
@@ -617,10 +617,10 @@ int test_context_parse_config(void)
}
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);
@@ -628,9 +628,9 @@ int test_context_parse_config(void)
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);
@@ -642,9 +642,9 @@ int test_context_parse_config(void)
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);
diff --git a/tests/core/poll-test.c b/tests/core/poll-test.c
index 269c6580c..676d3255a 100644
--- a/tests/core/poll-test.c
+++ b/tests/core/poll-test.c
@@ -54,7 +54,7 @@ static void test1_func(abts_case *tc, void *data)
ogs_poll_t *poll[NUM];
ogs_sockaddr_t *addr;
ogs_socknode_t *server[NUM], *client[NUM];
- ogs_pollset_t *pollset = ogs_pollset_create();
+ ogs_pollset_t *pollset = ogs_pollset_create(512);
ABTS_PTR_NOTNULL(tc, pollset);
for (i = 0; i < NUM; i++) {
@@ -158,7 +158,7 @@ static void test2_func(abts_case *tc, void *data)
int rv;
ogs_poll_t *poll;
ogs_sockaddr_t *addr;
- ogs_pollset_t *pollset = ogs_pollset_create();
+ ogs_pollset_t *pollset = ogs_pollset_create(512);
ABTS_PTR_NOTNULL(tc, pollset);
rv = ogs_getaddrinfo(&addr, AF_INET, "127.0.0.1", PORT, AI_PASSIVE);
@@ -218,7 +218,7 @@ static void test3_func(abts_case *tc, void *data)
{
int rv;
ogs_poll_t *poll = NULL;
- ogs_pollset_t *pollset = ogs_pollset_create();
+ ogs_pollset_t *pollset = ogs_pollset_create(512);
ABTS_PTR_NOTNULL(tc, pollset);
rv = ogs_socketpair(AF_SOCKPAIR, SOCK_STREAM, 0, test3_fd);
@@ -286,7 +286,7 @@ static void test4_func(abts_case *tc, void *data)
ogs_sockaddr_t *addr;
ogs_socknode_t *node;
ogs_poll_t *poll;
- ogs_pollset_t *pollset = ogs_pollset_create();
+ ogs_pollset_t *pollset = ogs_pollset_create(512);
ABTS_PTR_NOTNULL(tc, pollset);
rv = ogs_getaddrinfo(&addr, AF_INET, NULL, PORT, AI_PASSIVE);
@@ -314,7 +314,7 @@ static void test4_func(abts_case *tc, void *data)
static void test5_func(abts_case *tc, void *data)
{
int rv;
- ogs_pollset_t *pollset = ogs_pollset_create();
+ ogs_pollset_t *pollset = ogs_pollset_create(512);
ABTS_PTR_NOTNULL(tc, pollset);
rv = ogs_pollset_poll(pollset, ogs_time_from_msec(100));
@@ -353,7 +353,7 @@ static void test6_func(abts_case *tc, void *data)
int rv;
ogs_socket_t fd[2];
ogs_poll_t *poll = NULL;
- ogs_pollset_t *pollset = ogs_pollset_create();
+ ogs_pollset_t *pollset = ogs_pollset_create(512);
ABTS_PTR_NOTNULL(tc, pollset);
rv = ogs_socketpair(AF_SOCKPAIR, SOCK_STREAM, 0, fd);
@@ -403,7 +403,7 @@ static void test7_func(abts_case *tc, void *data)
{
/*
int rv;
- ogs_pollset_t *pollset = ogs_pollset_create();
+ ogs_pollset_t *pollset = ogs_pollset_create(512);
ogs_poll_t *poll = NULL;
poll = ogs_poll_new(pollset, test7_handler, tc);
diff --git a/tests/core/timer-test.c b/tests/core/timer-test.c
index 125254e4e..455e000bf 100644
--- a/tests/core/timer-test.c
+++ b/tests/core/timer-test.c
@@ -51,8 +51,8 @@ static void test1_func(abts_case *tc, void *data)
memset(expire_check, 0, TEST_DURATION/TEST_TIMER_PRECISION);
- timer = ogs_timer_mgr_create();
- pollset = ogs_pollset_create();
+ timer = ogs_timer_mgr_create(512);
+ pollset = ogs_pollset_create(512);
ogs_assert(timer);
for(n = 0; n < sizeof(timer_duration)/sizeof(ogs_time_t); n++) {
timer_array[n] = ogs_timer_add(
@@ -126,7 +126,7 @@ static void test2_func(abts_case *tc, void *data)
memset(expire_check, 0, TEST_DURATION/TEST_TIMER_PRECISION);
memset(tm_num, 0, sizeof(int)*(TEST_DURATION/TEST_TIMER_PRECISION));
- timer = ogs_timer_mgr_create();
+ timer = ogs_timer_mgr_create(512);
ogs_assert(timer);
for(n = 0; n < TEST_TIMER_NUM; n++) {
@@ -168,7 +168,7 @@ static void test3_func(abts_case *tc, void *data)
memset(expire_check, 0, TEST_DURATION/TEST_TIMER_PRECISION);
memset(tm_num, 0, sizeof(int)*(TEST_DURATION/TEST_TIMER_PRECISION));
- timer = ogs_timer_mgr_create();
+ timer = ogs_timer_mgr_create(512);
ogs_assert(timer);
for(n = 0; n < TEST_TIMER_NUM; n++) {
diff --git a/tests/unit/abts-main.c b/tests/unit/abts-main.c
index ef1f7e5ef..9fa18e61e 100644
--- a/tests/unit/abts-main.c
+++ b/tests/unit/abts-main.c
@@ -88,7 +88,7 @@ int main(int argc, const char *const argv[])
ogs_pkbuf_default_init(&config);
ogs_pkbuf_default_create(&config);
- ogs_config_init();
+ ogs_app_context_init();
mme_context_init();
atexit(terminate);