diff --git a/configs/310014.yaml.in b/configs/310014.yaml.in index e95ba0565..e7844453d 100644 --- a/configs/310014.yaml.in +++ b/configs/310014.yaml.in @@ -194,7 +194,12 @@ udm: - addr: 127.0.0.12 port: 7777 -udr: +pcf: sbi: - addr: 127.0.0.13 port: 7777 + +udr: + sbi: + - addr: 127.0.0.20 + port: 7777 diff --git a/configs/csfb.yaml.in b/configs/csfb.yaml.in index 1f1d36604..0e8d1a976 100644 --- a/configs/csfb.yaml.in +++ b/configs/csfb.yaml.in @@ -228,7 +228,12 @@ udm: - addr: 127.0.0.12 port: 7777 -udr: +pcf: sbi: - addr: 127.0.0.13 port: 7777 + +udr: + sbi: + - addr: 127.0.0.20 + port: 7777 diff --git a/configs/minimal.yaml.in b/configs/minimal.yaml.in index 5b5cdc633..4c5caafd0 100644 --- a/configs/minimal.yaml.in +++ b/configs/minimal.yaml.in @@ -197,7 +197,12 @@ udm: - addr: 127.0.0.12 port: 7777 -udr: +pcf: sbi: - addr: 127.0.0.13 port: 7777 + +udr: + sbi: + - addr: 127.0.0.20 + port: 7777 diff --git a/configs/open5gs/meson.build b/configs/open5gs/meson.build index 71e9f0640..a4fe54978 100644 --- a/configs/open5gs/meson.build +++ b/configs/open5gs/meson.build @@ -32,6 +32,7 @@ open5gs_conf = ''' ausf.yaml udm.yaml udr.yaml + pcf.yaml '''.split() foreach file : open5gs_conf diff --git a/configs/open5gs/nrf.yaml.in b/configs/open5gs/nrf.yaml.in index 4e320da8c..8b8537666 100644 --- a/configs/open5gs/nrf.yaml.in +++ b/configs/open5gs/nrf.yaml.in @@ -1,3 +1,5 @@ +db_uri: mongodb://localhost/open5gs + # # logger: # diff --git a/configs/open5gs/pcf.yaml.in b/configs/open5gs/pcf.yaml.in new file mode 100644 index 000000000..6cc8b6ef6 --- /dev/null +++ b/configs/open5gs/pcf.yaml.in @@ -0,0 +1,179 @@ +db_uri: mongodb://localhost/open5gs + +# +# logger: +# +# o Set OGS_LOG_INFO to all domain level +# - If `level` is omitted, the default level is OGS_LOG_INFO) +# - If `domain` is omitted, the all domain level is set from 'level' +# (Nothing is needed) +# +# o Set OGS_LOG_ERROR to all domain level +# - `level` can be set with none, fatal, error, warn, info, debug, trace +# level: error +# +# o Set OGS_LOG_DEBUG to mme/emm domain level +# level: debug +# domain: mme,emm +# +# o Set OGS_LOG_TRACE to all domain level +# level: trace +# domain: core,sbi,pcf,event,tlv,mem,sock +# +logger: + file: @localstatedir@/log/open5gs/pcf.log +# +# pcf: +# +# +# +# o SBI Server(http://:80) +# sbi: +# +# o SBI Server(http://:80) +# sbi: +# - addr: +# - 0.0.0.0 +# - ::0 +# port: 7777 +# +# o SBI Server(https://:443) +# sbi: +# tls: +# key: pcf.key +# pem: pcf.pem +# +# o SBI Server(https://127.0.0.13:443, http://[::1]:80) +# sbi: +# - addr: 127.0.0.13 +# tls: +# key: pcf.key +# pem: pcf.pem +# - addr: ::1 +# +# o SBI Server(http://pcf.open5gs.org:80) +# sbi: +# name: pcf.open5gs.org +# +# o SBI Server(http://127.0.0.13:7777) +# sbi: +# - addr: 127.0.0.13 +# port: 7777 +# +# o SBI Server(http://:80) +# sbi: +# dev: eth0 +# +pcf: + sbi: + - addr: 127.0.0.13 + port: 7777 + +# +# nrf: +# +# > +# +# o SBI Client(http://127.0.0.10:7777) +# sbi: +# addr: 127.0.0.10 +# port: 7777 +# +# o SBI Client(https://127.0.0.10:443, http://nrf.open5gs.org:80) +# sbi: +# - addr: 127.0.0.10 +# tls: +# key: nrf.key +# pem: nrf.pem +# - name: nrf.open5gs.org +# +# o SBI Client(http://[fe80::1%@loopback_devname@]:80) +# If prefer_ipv4 is true, http://127.0.0.10:80 is selected. +# +# sbi: +# addr: +# - 127.0.0.10 +# - fe80::1%@loopback_devname@ +# +nrf: + sbi: + - addr: + - 127.0.0.10 + - ::1 + port: 7777 + +# +# parameter: +# +# o Number of output streams per SCTP associations. +# sctp_streams: 30 +# +# o Disable use of IPv4 addresses (only IPv6) +# no_ipv4: true +# +# o Disable use of IPv6 addresses (only IPv4) +# no_ipv6: true +# +# o Prefer IPv4 instead of IPv6 for estabishing new GTP connections. +# prefer_ipv4: true +# +# o Enable Multicast traffic to the UE +# multicast: true +# +# o Disable Stateless Address Autoconfiguration for IPv6 +# no_slaac: true +# +parameter: + +# +# max: +# +# o Maximum Number of UE per AMF/MME +# ue: 1024 +# o Maximum Number of gNB/eNB per AMF/MME +# gnb: 32 +# +max: + +# +# pool: +# +# o The Number of Default Memory Pool Size +# +# - Pool-size 128 => 32768 Number +# - Pool-size 256 => 4096 Number +# - Pool-size 512 => 2048 Number +# - Pool-size 1024 => 1024 Number +# - Pool-size 2048 => 512 Number +# - Pool-size 8192 => 128 Number +# - Pool-size 1024*1024 => 8 Number +# +# 128: 32768 +# 256: 4096 +# 512: 2048 +# 1024: 1024 +# 2048: 512 +# 8192: 128 +# big: 8 +# +pool: + +# +# time: +# +# o NF Instance Heartbeat (Default : 10 seconds) +# +# o NF Instance Heartbeat (Disabled) +# nf_instance: +# heartbeat: 0 +# +# o NF Instance Heartbeat (10 seconds) +# nf_instance: +# heartbeat: 10 +# +# o Message Wait Duration (Default : 10,000 ms = 10 seconds) +# +# o Message Wait Duration (3000 ms) +# message: +# duration: 3000 +time: diff --git a/configs/open5gs/udr.yaml.in b/configs/open5gs/udr.yaml.in index 53d258b88..4780b1073 100644 --- a/configs/open5gs/udr.yaml.in +++ b/configs/open5gs/udr.yaml.in @@ -43,9 +43,9 @@ logger: # key: udr.key # pem: udr.pem # -# o SBI Server(https://127.0.0.13:443, http://[::1]:80) +# o SBI Server(https://127.0.0.20:443, http://[::1]:80) # sbi: -# - addr: 127.0.0.13 +# - addr: 127.0.0.20 # tls: # key: udr.key # pem: udr.pem @@ -55,9 +55,9 @@ logger: # sbi: # name: udr.open5gs.org # -# o SBI Server(http://127.0.0.13:7777) +# o SBI Server(http://127.0.0.20:7777) # sbi: -# - addr: 127.0.0.13 +# - addr: 127.0.0.20 # port: 7777 # # o SBI Server(http://:80) @@ -66,7 +66,7 @@ logger: # udr: sbi: - - addr: 127.0.0.13 + - addr: 127.0.0.20 port: 7777 # diff --git a/configs/sample.yaml.in b/configs/sample.yaml.in index aeb85f072..a69fe8f6d 100644 --- a/configs/sample.yaml.in +++ b/configs/sample.yaml.in @@ -194,7 +194,12 @@ udm: - addr: 127.0.0.12 port: 7777 -udr: +pcf: sbi: - addr: 127.0.0.13 port: 7777 + +udr: + sbi: + - addr: 127.0.0.20 + port: 7777 diff --git a/configs/srslte.yaml.in b/configs/srslte.yaml.in index 798f25b3e..c7530a808 100644 --- a/configs/srslte.yaml.in +++ b/configs/srslte.yaml.in @@ -194,7 +194,12 @@ udm: - addr: 127.0.0.12 port: 7777 -udr: +pcf: sbi: - addr: 127.0.0.13 port: 7777 + +udr: + sbi: + - addr: 127.0.0.20 + port: 7777 diff --git a/configs/systemd/meson.build b/configs/systemd/meson.build index e228b601e..1650c3ca3 100644 --- a/configs/systemd/meson.build +++ b/configs/systemd/meson.build @@ -27,6 +27,7 @@ systemd_conf_in = ''' open5gs-nrfd.service open5gs-ausfd.service open5gs-udmd.service + open5gs-pcfd.service open5gs-udrd.service '''.split() diff --git a/configs/systemd/open5gs-pcfd.service.in b/configs/systemd/open5gs-pcfd.service.in new file mode 100644 index 000000000..0e15ba9ca --- /dev/null +++ b/configs/systemd/open5gs-pcfd.service.in @@ -0,0 +1,18 @@ +[Unit] +Description=Open5GS PCF Daemon +After=networking.service + +[Service] +Type=simple + +User=open5gs +Group=open5gs + +Restart=always +ExecStart=@bindir@/open5gs-pcfd -c @sysconfdir@/open5gs/pcf.yaml +RestartSec=2 +RestartPreventExitStatus=1 +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/configs/volte.yaml.in b/configs/volte.yaml.in index 547959c77..58a7532f3 100644 --- a/configs/volte.yaml.in +++ b/configs/volte.yaml.in @@ -199,7 +199,12 @@ udm: - addr: 127.0.0.12 port: 7777 -udr: +pcf: sbi: - addr: 127.0.0.13 port: 7777 + +udr: + sbi: + - addr: 127.0.0.20 + port: 7777 diff --git a/debian/control b/debian/control index f7f90d433..5e2be55ad 100644 --- a/debian/control +++ b/debian/control @@ -187,6 +187,18 @@ Description: UDM (Unified Data Management) . This package provides the UDM (Unified Data Managemement) +Package: open5gs-pcf +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, + ${misc:Depends}, + open5gs-common (= ${binary:Version}) +Description: PCF (Policy Control Function) + Open5GS is a C-language implementation of 5G Core and EPC + Packet Core, i.e. the core network of an NR/LTE network (Release-16) + . + This package provides the PCF (Policy Control Function) + Package: open5gs-udr Architecture: any Multi-Arch: same @@ -215,6 +227,7 @@ Depends: ${misc:Depends}, open5gs-nrf (= ${binary:Version}), open5gs-ausf (= ${binary:Version}), open5gs-udm (= ${binary:Version}), + open5gs-pcf (= ${binary:Version}), open5gs-udr (= ${binary:Version}) Description: 5G Core and EPC (metapackage) Open5GS is a C-language implementation of 5G Core and EPC diff --git a/debian/open5gs-pcf.install b/debian/open5gs-pcf.install new file mode 100644 index 000000000..34cd94ba0 --- /dev/null +++ b/debian/open5gs-pcf.install @@ -0,0 +1,3 @@ +usr/bin/open5gs-pcfd +configs/open5gs/pcf.yaml etc/open5gs +configs/systemd/open5gs-pcfd.service lib/systemd/system diff --git a/docs/_docs/guide/02-building-open5gs-from-sources.md b/docs/_docs/guide/02-building-open5gs-from-sources.md index b07ed0cc0..6a6a69215 100644 --- a/docs/_docs/guide/02-building-open5gs-from-sources.md +++ b/docs/_docs/guide/02-building-open5gs-from-sources.md @@ -13,7 +13,7 @@ This post explains how to compile and install the source code on **Debian/Ubuntu ### Getting MongoDB --- -Install MongoDB with package manager. It is used as database for the HSS and PCRF. +Install MongoDB with package manager. It is used as database for NRF/PCF/UDR and PCRF/HSS. ```bash $ sudo apt update @@ -212,7 +212,7 @@ If you modify the config files while Open5GS daemons are running, please restart ```bash $ cd install/bin/ $ ./install/bin/open5gs-mmed -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:53:47.328: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/mme.yaml' (../src/main.c:54) 08/21 22:53:47.328: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/mme.log' (../src/main.c:57) @@ -222,7 +222,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:53:47.366: [mme] INFO: s1ap_server() [127.0.0.2]:36412 (../src/mme/s1ap-sctp.c:57) $ ./install/bin/open5gs-sgwcd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:54:43.059: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/sgwc.yaml' (../src/main.c:54) 08/21 22:54:43.059: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sgwc.log' (../src/main.c:57) @@ -232,7 +232,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:54:43.066: [pfcp] INFO: ogs_pfcp_connect() [127.0.0.6]:8805 (../lib/pfcp/path.c:60) $ ./install/bin/open5gs-smfd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:54:56.000: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/smf.yaml' (../src/main.c:54) 08/21 22:54:56.000: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/smf.log' (../src/main.c:57) @@ -245,7 +245,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:54:56.051: [sbi] INFO: sbi_server() [127.0.0.4]:7777 (../lib/sbi/server.c:298) $ ./install/bin/open5gs-amfd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:55:14.015: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/amf.yaml' (../src/main.c:54) 08/21 22:55:14.015: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/amf.log' (../src/main.c:57) @@ -254,7 +254,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:55:14.040: [amf] INFO: ngap_server() [127.0.0.5]:38412 (../src/amf/ngap-sctp.c:56) $ ./install/bin/open5gs-sgwud -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:54:10.357: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/sgwu.yaml' (../src/main.c:54) 08/21 22:54:10.357: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/sgwu.log' (../src/main.c:57) @@ -263,7 +263,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:54:10.361: [gtp] INFO: gtp_server() [127.0.0.6]:2152 (../lib/gtp/path.c:32) $ ./install/bin/open5gs-upfd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:54:21.596: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/upf.yaml' (../src/main.c:54) 08/21 22:54:21.596: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/upf.log' (../src/main.c:57) @@ -273,7 +273,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:54:21.601: [gtp] INFO: gtp_server() [::1]:2152 (../lib/gtp/path.c:32) $ ./install/bin/open5gs-hssd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:57:17.450: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/hss.yaml' (../src/main.c:54) 08/21 22:57:17.450: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/hss.log' (../src/main.c:57) @@ -281,7 +281,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:57:17.519: [app] INFO: HSS initialize...done (../src/hss/app-init.c:31) $ ./install/bin/open5gs-pcrfd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:57:45.894: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/pcrf.yaml' (../src/main.c:54) 08/21 22:57:45.894: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/pcrf.log' (../src/main.c:57) @@ -289,7 +289,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:57:45.997: [app] INFO: PCRF initialize...done (../src/pcrf/app-init.c:31) $ ./install/bin/open5gs-nrfd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:56:35.472: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/nrf.yaml' (../src/main.c:54) 08/21 22:56:35.472: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/nrf.log' (../src/main.c:57) @@ -298,7 +298,7 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:56:35.473: [sbi] INFO: sbi_server() [::1]:7777 (../lib/sbi/server.c:298 $ ./install/bin/open5gs-ausfd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:55:41.899: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/ausf.yaml' (../src/main.c:54) 08/21 22:55:41.899: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/ausf.log' (../src/main.c:57) @@ -306,15 +306,23 @@ Open5GS daemon v1.3.0-213-gd190548+ 08/21 22:55:41.900: [sbi] INFO: sbi_server() [127.0.0.11]:7777 (../lib/sbi/server.c:298) $ ./install/bin/open5gs-udmd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:56:02.154: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/udm.yaml' (../src/main.c:54) 08/21 22:56:02.154: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/udm.log' (../src/main.c:57) 08/21 22:56:02.155: [app] INFO: UDM initialize...done (../src/udm/app.c:31) 08/21 22:56:02.155: [sbi] INFO: sbi_server() [127.0.0.12]:7777 (../lib/sbi/server.c:298) +$ ./install/bin/open5gs-pcfd +Open5GS daemon v2.1.0 + +08/21 22:56:02.154: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/pcf.yaml' (../src/main.c:54) +08/21 22:56:02.154: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/pcf.log' (../src/main.c:57) +08/21 22:56:02.155: [app] INFO: PCF initialize...done (../src/pcf/app.c:31) +08/21 22:56:02.155: [sbi] INFO: sbi_server() [127.0.0.12]:7777 (../lib/sbi/server.c:298) + $ ./install/bin/open5gs-udrd -Open5GS daemon v1.3.0-213-gd190548+ +Open5GS daemon v2.1.0 08/21 22:56:15.810: [app] INFO: Configuration: '/home/acetcom/Documents/git/open5gs/install/etc/open5gs/udr.yaml' (../src/main.c:54) 08/21 22:56:15.810: [app] INFO: File Logging: '/home/acetcom/Documents/git/open5gs/install/var/log/open5gs/udr.log' (../src/main.c:57) diff --git a/docs/_docs/guide/03-splitting-network-functions.md b/docs/_docs/guide/03-splitting-network-functions.md index 292edb6c5..ff502249d 100644 --- a/docs/_docs/guide/03-splitting-network-functions.md +++ b/docs/_docs/guide/03-splitting-network-functions.md @@ -33,7 +33,8 @@ PCRF-frDi = 127.0.0.9 :3868 for Gx auth NRF-sbi = 127.0.0.10:7777 for 5G SBI AUSF-sbi = 127.0.0.11:7777 for 5G SBI UDM-sbi = 127.0.0.12:7777 for 5G SBI -UDR-sbi = 127.0.0.13:7777 for 5G SBI +PCF-sbi = 127.0.0.12:7777 for 5G SBI +UDR-sbi = 127.0.0.20:7777 for 5G SBI ``` _Cloud Userplane Server (to host IMS etc)_ diff --git a/docs/_docs/platform/02-centos.md b/docs/_docs/platform/02-centos.md index 686d5bb18..afaa5aa28 100644 --- a/docs/_docs/platform/02-centos.md +++ b/docs/_docs/platform/02-centos.md @@ -324,7 +324,8 @@ $ ninja install $ cd ../ $ ls install/bin open5gs-amfd open5gs-hssd open5gs-nrfd open5gs-sgwcd open5gs-smfd open5gs-udrd -open5gs-ausfd open5gs-mmed open5gs-pcrfd open5gs-sgwud open5gs-udmd open5gs-upfd +open5gs-ausfd open5gs-mmed open5gs-pcrfd open5gs-sgwud open5gs-udmd open5gs-pcfd +open5gs-upfd ``` ## Building WebUI of Open5GS diff --git a/docs/_docs/troubleshoot/01-simple-issues.md b/docs/_docs/troubleshoot/01-simple-issues.md index fadca978a..eecfd6bf9 100644 --- a/docs/_docs/troubleshoot/01-simple-issues.md +++ b/docs/_docs/troubleshoot/01-simple-issues.md @@ -23,10 +23,11 @@ open5gs 27366 0.0 0.0 2890772 14380 ? Ssl 12:13 0:00 /usr/bin/open5g open5gs 27485 0.0 0.0 243816 15064 ? Ssl 12:13 0:00 /usr/bin/open5gs-nrfd -c /etc/open5gs/nrf.yaml open5gs 27543 0.0 0.0 222416 9672 ? Ssl 12:13 0:00 /usr/bin/open5gs-ausfd -c /etc/open5gs/ausf.yaml open5gs 27600 0.0 0.0 222328 9668 ? Ssl 12:13 0:00 /usr/bin/open5gs-udmd -c /etc/open5gs/udm.yaml +open5gs 27600 0.0 0.0 222329 9669 ? Ssl 12:13 0:00 /usr/bin/open5gs-pcfd -c /etc/open5gs/pcf.yaml open5gs 27697 0.0 0.0 243976 13716 ? Ssl 12:13 0:00 /usr/bin/open5gs-udrd -c /etc/open5gs/udr.yaml ``` -You should see each of the above services, MME, SGW-C, SMF, AMF, SGW-U, UPF, HSS, PCRF, NRF, AUSF, UDM & UDR are all running. +You should see each of the above services, MME, SGW-C, SMF, AMF, SGW-U, UPF, HSS, PCRF, NRF, AUSF, UDM, PCF & UDR are all running. If your instance doesn't show this make sure you're started each service: ```bash @@ -41,6 +42,7 @@ $ systemctl start open5gs-pcrfd.service $ systemctl start open5gs-nrfd.service $ systemctl start open5gs-ausfd.service $ systemctl start open5gs-udmd.service +$ systemctl start open5gs-pcfd.service $ systemctl start open5gs-udrd.service ``` diff --git a/docs/_docs/troubleshoot/02-now-in-github-issues.md b/docs/_docs/troubleshoot/02-now-in-github-issues.md index 3a3dd294d..371810388 100644 --- a/docs/_docs/troubleshoot/02-now-in-github-issues.md +++ b/docs/_docs/troubleshoot/02-now-in-github-issues.md @@ -56,6 +56,7 @@ $ open5gs-nrfd $ open5gs-amfd $ open5gs-ausfd $ open5gs-udmd +$ open5gs-pcfd $ open5gs-udrd ``` @@ -254,6 +255,7 @@ $ sudo pkill -9 open5gs-pcrfd $ sudo pkill -9 open5gs-nrfd $ sudo pkill -9 open5gs-ausfd $ sudo pkill -9 open5gs-udmd +$ sudo pkill -9 open5gs-pcfd $ sudo pkill -9 open5gs-udrd ``` @@ -721,7 +723,8 @@ Currently, the number of UE is limited to `128*128`. * NRF : 127.0.0.10 * AUSF : 127.0.0.11 * UDM : 127.0.0.12 -* UDR : 127.0.0.13 +* PCF : 127.0.0.13 +* UDR : 127.0.0.20 ``` - AMF_ID, TAC and S_NSSAI diff --git a/lib/app/ogs-app.h b/lib/app/ogs-app.h index 4563c6e4d..a034f7272 100644 --- a/lib/app/ogs-app.h +++ b/lib/app/ogs-app.h @@ -75,6 +75,9 @@ void udm_terminate(void); int ausf_initialize(void); void ausf_terminate(void); +int pcf_initialize(void); +void pcf_terminate(void); + int upf_initialize(void); void upf_terminate(void); diff --git a/lib/app/ogs-context.c b/lib/app/ogs-context.c index 48a751a45..bd6ad9857 100644 --- a/lib/app/ogs-context.c +++ b/lib/app/ogs-context.c @@ -303,6 +303,9 @@ int ogs_app_context_parse_config(void) } else if (!strcmp(parameter_key, "no_udm")) { self.parameter.no_udm = ogs_yaml_iter_bool(¶meter_iter); + } else if (!strcmp(parameter_key, "no_pcf")) { + self.parameter.no_pcf = + ogs_yaml_iter_bool(¶meter_iter); } else if (!strcmp(parameter_key, "no_udr")) { self.parameter.no_udr = ogs_yaml_iter_bool(¶meter_iter); diff --git a/lib/app/ogs-context.h b/lib/app/ogs-context.h index 7ec4b3228..bb1ea315f 100644 --- a/lib/app/ogs-context.h +++ b/lib/app/ogs-context.h @@ -62,6 +62,7 @@ typedef struct ogs_app_context_s { int no_upf; int no_ausf; int no_udm; + int no_pcf; int no_udr; int no_nrf; diff --git a/lib/core/ogs-socket.c b/lib/core/ogs-socket.c index ccf044e0a..e3354ffab 100644 --- a/lib/core/ogs-socket.c +++ b/lib/core/ogs-socket.c @@ -189,32 +189,16 @@ ogs_sock_t *ogs_sock_accept(ogs_sock_t *sock) ssize_t ogs_write(ogs_socket_t fd, const void *buf, size_t len) { - ssize_t size; - ogs_assert(fd != INVALID_SOCKET); - size = write(fd, buf, len); - if (size < 0) { - ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, - "ogs_write(len:%d) failed", (int)size); - } - - return size; + return write(fd, buf, len); } ssize_t ogs_read(ogs_socket_t fd, void *buf, size_t len) { - ssize_t size; - ogs_assert(fd != INVALID_SOCKET); - size = read(fd, buf, len); - if (size < 0) { - ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, - "ogs_read(len:%d) failed", (int)size); - } - - return size; + return read(fd, buf, len); } ssize_t ogs_send(ogs_socket_t fd, const void *buf, size_t len, int flags) diff --git a/lib/sbi/context.h b/lib/sbi/context.h index b97ecc8be..9b62e45df 100644 --- a/lib/sbi/context.h +++ b/lib/sbi/context.h @@ -102,9 +102,20 @@ typedef struct ogs_sbi_nf_type_array_s { ogs_sbi_nf_instance_t *nf_instance; } ogs_sbi_nf_type_array_t[OGS_SBI_MAX_NF_TYPE]; +typedef enum { + OGS_SBI_OBJ_BASE = 0, + + OGS_SBI_OBJ_UE_TYPE, + OGS_SBI_OBJ_SESS_TYPE, + + OGS_SBI_OBJ_TOP, +} ogs_sbi_obj_type_e; + typedef struct ogs_sbi_object_s { ogs_lnode_t lnode; + ogs_sbi_obj_type_e type; + ogs_sbi_nf_type_array_t nf_type_array; ogs_list_t xact_list; diff --git a/lib/sbi/conv.c b/lib/sbi/conv.c index 815d31874..509ff1644 100644 --- a/lib/sbi/conv.c +++ b/lib/sbi/conv.c @@ -316,6 +316,54 @@ bool ogs_sbi_time_from_string(ogs_time_t *timestamp, char *str) return true; } +char *ogs_sbi_s_nssai_to_string(ogs_s_nssai_t *s_nssai) +{ + cJSON *item = NULL; + OpenAPI_snssai_t sNSSAI; + + char *v = NULL; + + ogs_assert(s_nssai); + + sNSSAI.sst = s_nssai->sst; + sNSSAI.sd = ogs_s_nssai_sd_to_string(s_nssai->sd); + + item = OpenAPI_snssai_convertToJSON(&sNSSAI); + ogs_assert(item); + if (sNSSAI.sd) ogs_free(sNSSAI.sd); + + v = cJSON_Print(item); + ogs_assert(v); + cJSON_Delete(item); + + return v; +} + +bool ogs_sbi_s_nssai_from_string(ogs_s_nssai_t *s_nssai, char *str) +{ + bool rc = false; + + cJSON *item = NULL; + OpenAPI_snssai_t *sNSSAI = NULL; + + ogs_assert(s_nssai); + ogs_assert(str); + + item = cJSON_Parse(str); + if (item) { + sNSSAI = OpenAPI_snssai_parseFromJSON(item); + if (sNSSAI) { + s_nssai->sst = sNSSAI->sst; + s_nssai->sd = ogs_s_nssai_sd_from_string(sNSSAI->sd); + OpenAPI_snssai_free(sNSSAI); + rc = true; + } + cJSON_Delete(item); + } + + return rc; +} + OpenAPI_plmn_id_t *ogs_sbi_build_plmn_id(ogs_plmn_id_t *plmn_id) { OpenAPI_plmn_id_t *PlmnId = NULL; diff --git a/lib/sbi/conv.h b/lib/sbi/conv.h index f730a2022..fc488e954 100644 --- a/lib/sbi/conv.h +++ b/lib/sbi/conv.h @@ -51,6 +51,9 @@ char *ogs_sbi_gmtime_string(ogs_time_t time); char *ogs_sbi_timezone_string(int tm_offset); bool ogs_sbi_time_from_string(ogs_time_t *time, char *str); +char *ogs_sbi_s_nssai_to_string(ogs_s_nssai_t *s_nssai); +bool ogs_sbi_s_nssai_from_string(ogs_s_nssai_t *s_nssai, char *str); + OpenAPI_plmn_id_t *ogs_sbi_build_plmn_id(ogs_plmn_id_t *plmn_id); bool ogs_sbi_parse_plmn_id( ogs_plmn_id_t *plmn_id, OpenAPI_plmn_id_t *PlmnId); diff --git a/lib/sbi/message.c b/lib/sbi/message.c index 1b4062cb9..b4637c113 100644 --- a/lib/sbi/message.c +++ b/lib/sbi/message.c @@ -136,6 +136,19 @@ void ogs_sbi_message_free(ogs_sbi_message_t *message) if (message->SmContextStatusNotification) OpenAPI_sm_context_status_notification_free( message->SmContextStatusNotification); + if (message->PolicyAssociationRequest) + OpenAPI_policy_association_request_free( + message->PolicyAssociationRequest); + if (message->PolicyAssociation) + OpenAPI_policy_association_free(message->PolicyAssociation); + if (message->AmPolicyData) + OpenAPI_am_policy_data_free(message->AmPolicyData); + if (message->SmPolicyContextData) + OpenAPI_sm_policy_context_data_free(message->SmPolicyContextData); + if (message->SmPolicyDecision) + OpenAPI_sm_policy_decision_free(message->SmPolicyDecision); + if (message->SmPolicyData) + OpenAPI_sm_policy_data_free(message->SmPolicyData); for (i = 0; i < message->num_of_part; i++) { if (message->part[i].pkbuf) @@ -279,23 +292,14 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message) ogs_free(v); } } - if (message->param.s_nssai_presence) { - char *v = NULL; - cJSON *item = NULL; - OpenAPI_snssai_t s_nssai; - - s_nssai.sst = message->param.s_nssai.sst; - s_nssai.sd = ogs_s_nssai_sd_to_string(message->param.s_nssai.sd); - - item = OpenAPI_snssai_convertToJSON(&s_nssai); - ogs_assert(item); - if (s_nssai.sd) ogs_free(s_nssai.sd); - - v = cJSON_Print(item); - ogs_assert(v); - cJSON_Delete(item); - - ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_S_NSSAI, v); + if (message->param.single_nssai_presence) { + char *v = ogs_sbi_s_nssai_to_string(&message->param.single_nssai); + ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_SINGLE_NSSAI, v); + ogs_free(v); + } + if (message->param.snssai_presence) { + char *v = ogs_sbi_s_nssai_to_string(&message->param.snssai); + ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_SNSSAI, v); ogs_free(v); } @@ -403,25 +407,21 @@ int ogs_sbi_parse_request( cJSON_Delete(item); } } - } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_S_NSSAI)) { - char *v = NULL; - cJSON *item = NULL; - OpenAPI_snssai_t *s_nssai = NULL; - - v = ogs_hash_this_val(hi); + } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_SINGLE_NSSAI)) { + char *v = ogs_hash_this_val(hi); if (v) { - item = cJSON_Parse(v); - if (item) { - s_nssai = OpenAPI_snssai_parseFromJSON(item); - if (s_nssai) { - message->param.s_nssai_presence = true; - message->param.s_nssai.sst = s_nssai->sst; - message->param.s_nssai.sd = - ogs_s_nssai_sd_from_string(s_nssai->sd); - OpenAPI_snssai_free(s_nssai); - } - cJSON_Delete(item); - } + bool rc = ogs_sbi_s_nssai_from_string( + &message->param.single_nssai, v); + if (rc == true) + message->param.single_nssai_presence = true; + } + } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_SNSSAI)) { + char *v = ogs_hash_this_val(hi); + if (v) { + bool rc = ogs_sbi_s_nssai_from_string( + &message->param.snssai, v); + if (rc == true) + message->param.snssai_presence = true; } } } @@ -719,6 +719,28 @@ static char *build_json(ogs_sbi_message_t *message) item = OpenAPI_sm_context_status_notification_convertToJSON( message->SmContextStatusNotification); ogs_assert(item); + } else if (message->PolicyAssociationRequest) { + item = OpenAPI_policy_association_request_convertToJSON( + message->PolicyAssociationRequest); + ogs_assert(item); + } else if (message->PolicyAssociation) { + item = OpenAPI_policy_association_convertToJSON( + message->PolicyAssociation); + ogs_assert(item); + } else if (message->AmPolicyData) { + item = OpenAPI_am_policy_data_convertToJSON(message->AmPolicyData); + ogs_assert(item); + } else if (message->SmPolicyContextData) { + item = OpenAPI_sm_policy_context_data_convertToJSON( + message->SmPolicyContextData); + ogs_assert(item); + } else if (message->SmPolicyDecision) { + item = OpenAPI_sm_policy_decision_convertToJSON( + message->SmPolicyDecision); + ogs_assert(item); + } else if (message->SmPolicyData) { + item = OpenAPI_sm_policy_data_convertToJSON(message->SmPolicyData); + ogs_assert(item); } if (item) { @@ -1102,6 +1124,44 @@ static int parse_json(ogs_sbi_message_t *message, END break; + CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA) + SWITCH(message->h.resource.component[1]) + CASE(OGS_SBI_RESOURCE_NAME_UES) + SWITCH(message->h.resource.component[3]) + CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) + + message->AmPolicyData = + OpenAPI_am_policy_data_parseFromJSON(item); + if (!message->AmPolicyData) { + rv = OGS_ERROR; + ogs_error("JSON parse error"); + } + break; + + CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) + + message->SmPolicyData = + OpenAPI_sm_policy_data_parseFromJSON(item); + if (!message->SmPolicyData) { + rv = OGS_ERROR; + ogs_error("JSON parse error"); + } + break; + + DEFAULT + rv = OGS_ERROR; + ogs_error("Unknown resource name [%s]", + message->h.resource.component[3]); + END + break; + + DEFAULT + rv = OGS_ERROR; + ogs_error("Unknown resource name [%s]", + message->h.resource.component[1]); + END + break; + DEFAULT rv = OGS_ERROR; ogs_error("Unknown resource name [%s]", @@ -1251,6 +1311,61 @@ static int parse_json(ogs_sbi_message_t *message, message->h.resource.component[0]); END break; + CASE(OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL) + SWITCH(message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_POLICIES) + if (message->res_status == 0) { + message->PolicyAssociationRequest = + OpenAPI_policy_association_request_parseFromJSON( + item); + if (!message->PolicyAssociationRequest) { + rv = OGS_ERROR; + ogs_error("JSON parse error"); + } + } else if (message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { + message->PolicyAssociation = + OpenAPI_policy_association_parseFromJSON(item); + if (!message->PolicyAssociation) { + rv = OGS_ERROR; + ogs_error("JSON parse error"); + } + } + break; + + DEFAULT + rv = OGS_ERROR; + ogs_error("Unknown resource name [%s]", + message->h.resource.component[0]); + END + break; + + CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) + SWITCH(message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_SM_POLICIES) + if (message->res_status == 0) { + message->SmPolicyContextData = + OpenAPI_sm_policy_context_data_parseFromJSON(item); + if (!message->SmPolicyContextData) { + rv = OGS_ERROR; + ogs_error("JSON parse error"); + } + } else if (message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { + message->SmPolicyDecision = + OpenAPI_sm_policy_decision_parseFromJSON(item); + if (!message->SmPolicyDecision) { + rv = OGS_ERROR; + ogs_error("JSON parse error"); + } + } + break; + + DEFAULT + rv = OGS_ERROR; + ogs_error("Unknown resource name [%s]", + message->h.resource.component[0]); + END + break; + CASE(OGS_SBI_SERVICE_NAME_NAMF_CALLBACK) SWITCH(message->h.resource.component[1]) CASE(OGS_SBI_RESOURCE_NAME_SM_CONTEXT_STATUS) diff --git a/lib/sbi/message.h b/lib/sbi/message.h index 1e08e2e4f..c4e026077 100644 --- a/lib/sbi/message.h +++ b/lib/sbi/message.h @@ -104,7 +104,6 @@ extern "C" { #define OGS_SBI_SERVICE_NAME_NUDM_UECM "nudm-uecm" #define OGS_SBI_RESOURCE_NAME_REGISTRATIONS "registrations" #define OGS_SBI_RESOURCE_NAME_AMF_3GPP_ACCESS "amf-3gpp-access" -#define OGS_SBI_RESOURCE_NAME_DEREG_NOTIFY "dereg-notify" #define OGS_SBI_SERVICE_NAME_NUDR_DR "nudr-dr" #define OGS_SBI_RESOURCE_NAME_SUBSCRIPTION_DATA "subscription-data" @@ -114,6 +113,9 @@ extern "C" { #define OGS_SBI_RESOURCE_NAME_AUTHENTICATION_STATUS "authentication-status" #define OGS_SBI_RESOURCE_NAME_CONTEXT_DATA "context-data" #define OGS_SBI_RESOURCE_NAME_PROVISIONED_DATA "provisioned-data" +#define OGS_SBI_RESOURCE_NAME_POLICY_DATA "policy-data" +#define OGS_SBI_RESOURCE_NAME_UES "ues" +#define OGS_SBI_RESOURCE_NAME_AM_DATA "am-data" #define OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION "nsmf-pdusession" #define OGS_SBI_RESOURCE_NAME_SM_CONTEXTS "sm-contexts" @@ -121,11 +123,22 @@ extern "C" { #define OGS_SBI_RESOURCE_NAME_MODIFY "modify" #define OGS_SBI_RESOURCE_NAME_RELEASE "release" +#define OGS_SBI_SERVICE_NAME_NSMF_CALLBACK "nsmf-callback" +#define OGS_SBI_RESOURCE_NAME_SM_POLICY_NOTIFY "sm-policy-notify" + #define OGS_SBI_SERVICE_NAME_NAMF_COMM "namf-comm" -#define OGS_SBI_SERVICE_NAME_NAMF_CALLBACK "namf-callback" #define OGS_SBI_RESOURCE_NAME_UE_CONTEXTS "ue-contexts" #define OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES "n1-n2-messages" + +#define OGS_SBI_SERVICE_NAME_NAMF_CALLBACK "namf-callback" #define OGS_SBI_RESOURCE_NAME_SM_CONTEXT_STATUS "sm-context-status" +#define OGS_SBI_RESOURCE_NAME_AM_POLICY_NOTIFY "am-policy-notify" +#define OGS_SBI_RESOURCE_NAME_DEREG_NOTIFY "dereg-notify" + +#define OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL "npcf-am-policy-control" +#define OGS_SBI_RESOURCE_NAME_POLICIES "policies" +#define OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL "npcf-smpolicycontrol" +#define OGS_SBI_RESOURCE_NAME_SM_POLICIES "sm-policies" #define OGS_SBI_PARAM_NF_TYPE "nf-type" #define OGS_SBI_PARAM_TARGET_NF_TYPE "target-nf-type" @@ -133,7 +146,8 @@ extern "C" { #define OGS_SBI_PARAM_LIMIT "limit" #define OGS_SBI_PARAM_DNN "dnn" #define OGS_SBI_PARAM_PLMN_ID "plmn-id" -#define OGS_SBI_PARAM_S_NSSAI "single-nssai" +#define OGS_SBI_PARAM_SINGLE_NSSAI "single-nssai" +#define OGS_SBI_PARAM_SNSSAI "snssai" #define OGS_SBI_ACCEPT "Accept" #define OGS_SBI_ACCEPT_ENCODING "Accept-Encoding" @@ -215,8 +229,11 @@ typedef struct ogs_sbi_message_s { char *dnn; bool plmn_id_presence; ogs_plmn_id_t plmn_id; - bool s_nssai_presence; - ogs_s_nssai_t s_nssai; + + bool single_nssai_presence; + ogs_s_nssai_t single_nssai; + bool snssai_presence; + ogs_s_nssai_t snssai; } param; int res_status; @@ -254,6 +271,12 @@ typedef struct ogs_sbi_message_s { OpenAPI_n1_n2_message_transfer_req_data_t *N1N2MessageTransferReqData; OpenAPI_n1_n2_message_transfer_rsp_data_t *N1N2MessageTransferRspData; OpenAPI_sm_context_status_notification_t *SmContextStatusNotification; + OpenAPI_policy_association_request_t *PolicyAssociationRequest; + OpenAPI_policy_association_t *PolicyAssociation; + OpenAPI_am_policy_data_t *AmPolicyData; + OpenAPI_sm_policy_context_data_t *SmPolicyContextData; + OpenAPI_sm_policy_decision_t *SmPolicyDecision; + OpenAPI_sm_policy_data_t *SmPolicyData; ogs_sbi_links_t *links; diff --git a/lib/sbi/ogs-sbi.h b/lib/sbi/ogs-sbi.h index 339a943c7..ca9ef7554 100644 --- a/lib/sbi/ogs-sbi.h +++ b/lib/sbi/ogs-sbi.h @@ -59,6 +59,11 @@ #include "model/n1_n2_message_transfer_req_data.h" #include "model/n1_n2_message_transfer_rsp_data.h" #include "model/sm_context_status_notification.h" +#include "model/policy_association.h" +#include "model/am_policy_data.h" +#include "model/sm_policy_context_data.h" +#include "model/sm_policy_decision.h" +#include "model/sm_policy_data.h" #include "custom/links.h" diff --git a/lib/sbi/openapi/.openapi-generator/uncrustify.cfg b/lib/sbi/openapi/.openapi-generator/uncrustify-0.66.1.cfg similarity index 100% rename from lib/sbi/openapi/.openapi-generator/uncrustify.cfg rename to lib/sbi/openapi/.openapi-generator/uncrustify-0.66.1.cfg diff --git a/lib/sbi/openapi/meson.build b/lib/sbi/openapi/meson.build index 613282afc..a6a733d20 100644 --- a/lib/sbi/openapi/meson.build +++ b/lib/sbi/openapi/meson.build @@ -643,6 +643,89 @@ libsbi_openapi_sources = files(''' model/ue_reg_status_update_rsp_data.c model/v2x_context.c + model/acc_net_ch_id.c + model/acc_net_charging_address.c + model/accu_usage_report.c + model/additional_access_info.c + model/af_sig_protocol.c + model/an_gw_address.c + model/app_detection_info.c + model/authorized_default_qos.c + model/candidate_for_replacement.c + model/charging_data.c + model/condition_data.c + model/credit_management_status.c + model/error_report.c + model/failure_cause.c + model/failure_code.c + model/final_unit_action.c + model/flow_direction_rm.c + model/flow_information.c + model/flow_status.c + model/ip_multicast_address_info.c + model/ma_pdu_indication.c + model/mapping_of_snssai.c + model/metering_method.c + model/packet_filter_info.c + model/partial_success_report.c + model/pcc_rule.c + model/pdu_session_rel_cause.c + model/policy_association.c + model/policy_association_release_cause.c + model/policy_association_request.c + model/policy_association_update_request.c + model/policy_control_request_trigger.c + model/policy_update.c + model/port_management_container.c + model/presence_info_rm.c + model/qos_characteristics.c + model/qos_data.c + model/qos_flow_usage.c + model/qos_monitoring_data.c + model/qos_monitoring_report.c + model/qos_notif_type.c + model/qos_notification_control_info.c + model/ran_nas_rel_cause.c + model/redirect_address_type.c + model/redirect_information.c + model/reporting_frequency.c + model/reporting_level.c + model/request_trigger.c + model/requested_qos.c + model/requested_qos_monitoring_parameter.c + model/requested_rule_data.c + model/requested_rule_data_type.c + model/requested_usage_data.c + model/rule_operation.c + model/rule_report.c + model/rule_status.c + model/serving_nf_identity.c + model/session_rule.c + model/session_rule_failure_code.c + model/session_rule_report.c + model/sm_policy_association_release_cause.c + model/sm_policy_context_data.c + model/sm_policy_control.c + model/sm_policy_decision.c + model/sm_policy_delete_data.c + model/sm_policy_notification.c + model/sm_policy_update_context_data.c + model/smf_selection_data.c + model/steer_mode_value.c + model/steering_functionality.c + model/steering_mode.c + model/termination_notification.c + model/traffic_control_data.c + model/tscai_input_container.c + model/tsn_bridge_info.c + model/tsn_port_identifier.c + model/ue_camping_rep.c + model/ue_initiated_resource_request.c + model/up_path_chg_event.c + model/usage_monitoring_data.c + model/wireline_area.c + model/wireline_service_area_restriction.c + '''.split()) libsbi_openapi_inc = include_directories('.') diff --git a/lib/sbi/openapi/model/acc_net_ch_id.c b/lib/sbi/openapi/model/acc_net_ch_id.c new file mode 100644 index 000000000..0a2c0ea69 --- /dev/null +++ b/lib/sbi/openapi/model/acc_net_ch_id.c @@ -0,0 +1,171 @@ + +#include +#include +#include +#include "acc_net_ch_id.h" + +OpenAPI_acc_net_ch_id_t *OpenAPI_acc_net_ch_id_create( + int acc_net_cha_id_value, + OpenAPI_list_t *ref_pcc_rule_ids, + int session_ch_scope + ) +{ + OpenAPI_acc_net_ch_id_t *acc_net_ch_id_local_var = OpenAPI_malloc(sizeof(OpenAPI_acc_net_ch_id_t)); + if (!acc_net_ch_id_local_var) { + return NULL; + } + acc_net_ch_id_local_var->acc_net_cha_id_value = acc_net_cha_id_value; + acc_net_ch_id_local_var->ref_pcc_rule_ids = ref_pcc_rule_ids; + acc_net_ch_id_local_var->session_ch_scope = session_ch_scope; + + return acc_net_ch_id_local_var; +} + +void OpenAPI_acc_net_ch_id_free(OpenAPI_acc_net_ch_id_t *acc_net_ch_id) +{ + if (NULL == acc_net_ch_id) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(acc_net_ch_id->ref_pcc_rule_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(acc_net_ch_id->ref_pcc_rule_ids); + ogs_free(acc_net_ch_id); +} + +cJSON *OpenAPI_acc_net_ch_id_convertToJSON(OpenAPI_acc_net_ch_id_t *acc_net_ch_id) +{ + cJSON *item = NULL; + + if (acc_net_ch_id == NULL) { + ogs_error("OpenAPI_acc_net_ch_id_convertToJSON() failed [AccNetChId]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!acc_net_ch_id->acc_net_cha_id_value) { + ogs_error("OpenAPI_acc_net_ch_id_convertToJSON() failed [acc_net_cha_id_value]"); + goto end; + } + if (cJSON_AddNumberToObject(item, "accNetChaIdValue", acc_net_ch_id->acc_net_cha_id_value) == NULL) { + ogs_error("OpenAPI_acc_net_ch_id_convertToJSON() failed [acc_net_cha_id_value]"); + goto end; + } + + if (acc_net_ch_id->ref_pcc_rule_ids) { + cJSON *ref_pcc_rule_ids = cJSON_AddArrayToObject(item, "refPccRuleIds"); + if (ref_pcc_rule_ids == NULL) { + ogs_error("OpenAPI_acc_net_ch_id_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + + OpenAPI_lnode_t *ref_pcc_rule_ids_node; + OpenAPI_list_for_each(acc_net_ch_id->ref_pcc_rule_ids, ref_pcc_rule_ids_node) { + if (cJSON_AddStringToObject(ref_pcc_rule_ids, "", (char*)ref_pcc_rule_ids_node->data) == NULL) { + ogs_error("OpenAPI_acc_net_ch_id_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + } + } + + if (acc_net_ch_id->session_ch_scope) { + if (cJSON_AddBoolToObject(item, "sessionChScope", acc_net_ch_id->session_ch_scope) == NULL) { + ogs_error("OpenAPI_acc_net_ch_id_convertToJSON() failed [session_ch_scope]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_acc_net_ch_id_t *OpenAPI_acc_net_ch_id_parseFromJSON(cJSON *acc_net_ch_idJSON) +{ + OpenAPI_acc_net_ch_id_t *acc_net_ch_id_local_var = NULL; + cJSON *acc_net_cha_id_value = cJSON_GetObjectItemCaseSensitive(acc_net_ch_idJSON, "accNetChaIdValue"); + if (!acc_net_cha_id_value) { + ogs_error("OpenAPI_acc_net_ch_id_parseFromJSON() failed [acc_net_cha_id_value]"); + goto end; + } + + + if (!cJSON_IsNumber(acc_net_cha_id_value)) { + ogs_error("OpenAPI_acc_net_ch_id_parseFromJSON() failed [acc_net_cha_id_value]"); + goto end; + } + + cJSON *ref_pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(acc_net_ch_idJSON, "refPccRuleIds"); + + OpenAPI_list_t *ref_pcc_rule_idsList; + if (ref_pcc_rule_ids) { + cJSON *ref_pcc_rule_ids_local; + if (!cJSON_IsArray(ref_pcc_rule_ids)) { + ogs_error("OpenAPI_acc_net_ch_id_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + ref_pcc_rule_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_pcc_rule_ids_local, ref_pcc_rule_ids) { + if (!cJSON_IsString(ref_pcc_rule_ids_local)) { + ogs_error("OpenAPI_acc_net_ch_id_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup(ref_pcc_rule_ids_local->valuestring)); + } + } + + cJSON *session_ch_scope = cJSON_GetObjectItemCaseSensitive(acc_net_ch_idJSON, "sessionChScope"); + + if (session_ch_scope) { + if (!cJSON_IsBool(session_ch_scope)) { + ogs_error("OpenAPI_acc_net_ch_id_parseFromJSON() failed [session_ch_scope]"); + goto end; + } + } + + acc_net_ch_id_local_var = OpenAPI_acc_net_ch_id_create ( + acc_net_cha_id_value->valuedouble, + ref_pcc_rule_ids ? ref_pcc_rule_idsList : NULL, + session_ch_scope ? session_ch_scope->valueint : 0 + ); + + return acc_net_ch_id_local_var; +end: + return NULL; +} + +OpenAPI_acc_net_ch_id_t *OpenAPI_acc_net_ch_id_copy(OpenAPI_acc_net_ch_id_t *dst, OpenAPI_acc_net_ch_id_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_acc_net_ch_id_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_acc_net_ch_id_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_acc_net_ch_id_free(dst); + dst = OpenAPI_acc_net_ch_id_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/acc_net_ch_id.h b/lib/sbi/openapi/model/acc_net_ch_id.h new file mode 100644 index 000000000..7cb5693e0 --- /dev/null +++ b/lib/sbi/openapi/model/acc_net_ch_id.h @@ -0,0 +1,42 @@ +/* + * acc_net_ch_id.h + * + * + */ + +#ifndef _OpenAPI_acc_net_ch_id_H_ +#define _OpenAPI_acc_net_ch_id_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_acc_net_ch_id_s OpenAPI_acc_net_ch_id_t; +typedef struct OpenAPI_acc_net_ch_id_s { + int acc_net_cha_id_value; + OpenAPI_list_t *ref_pcc_rule_ids; + int session_ch_scope; +} OpenAPI_acc_net_ch_id_t; + +OpenAPI_acc_net_ch_id_t *OpenAPI_acc_net_ch_id_create( + int acc_net_cha_id_value, + OpenAPI_list_t *ref_pcc_rule_ids, + int session_ch_scope + ); +void OpenAPI_acc_net_ch_id_free(OpenAPI_acc_net_ch_id_t *acc_net_ch_id); +OpenAPI_acc_net_ch_id_t *OpenAPI_acc_net_ch_id_parseFromJSON(cJSON *acc_net_ch_idJSON); +cJSON *OpenAPI_acc_net_ch_id_convertToJSON(OpenAPI_acc_net_ch_id_t *acc_net_ch_id); +OpenAPI_acc_net_ch_id_t *OpenAPI_acc_net_ch_id_copy(OpenAPI_acc_net_ch_id_t *dst, OpenAPI_acc_net_ch_id_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_acc_net_ch_id_H_ */ + diff --git a/lib/sbi/openapi/model/acc_net_charging_address.c b/lib/sbi/openapi/model/acc_net_charging_address.c new file mode 100644 index 000000000..1f1dc1763 --- /dev/null +++ b/lib/sbi/openapi/model/acc_net_charging_address.c @@ -0,0 +1,125 @@ + +#include +#include +#include +#include "acc_net_charging_address.h" + +OpenAPI_acc_net_charging_address_t *OpenAPI_acc_net_charging_address_create( + char *an_charg_ipv4_addr, + char *an_charg_ipv6_addr + ) +{ + OpenAPI_acc_net_charging_address_t *acc_net_charging_address_local_var = OpenAPI_malloc(sizeof(OpenAPI_acc_net_charging_address_t)); + if (!acc_net_charging_address_local_var) { + return NULL; + } + acc_net_charging_address_local_var->an_charg_ipv4_addr = an_charg_ipv4_addr; + acc_net_charging_address_local_var->an_charg_ipv6_addr = an_charg_ipv6_addr; + + return acc_net_charging_address_local_var; +} + +void OpenAPI_acc_net_charging_address_free(OpenAPI_acc_net_charging_address_t *acc_net_charging_address) +{ + if (NULL == acc_net_charging_address) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(acc_net_charging_address->an_charg_ipv4_addr); + ogs_free(acc_net_charging_address->an_charg_ipv6_addr); + ogs_free(acc_net_charging_address); +} + +cJSON *OpenAPI_acc_net_charging_address_convertToJSON(OpenAPI_acc_net_charging_address_t *acc_net_charging_address) +{ + cJSON *item = NULL; + + if (acc_net_charging_address == NULL) { + ogs_error("OpenAPI_acc_net_charging_address_convertToJSON() failed [AccNetChargingAddress]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (acc_net_charging_address->an_charg_ipv4_addr) { + if (cJSON_AddStringToObject(item, "anChargIpv4Addr", acc_net_charging_address->an_charg_ipv4_addr) == NULL) { + ogs_error("OpenAPI_acc_net_charging_address_convertToJSON() failed [an_charg_ipv4_addr]"); + goto end; + } + } + + if (acc_net_charging_address->an_charg_ipv6_addr) { + if (cJSON_AddStringToObject(item, "anChargIpv6Addr", acc_net_charging_address->an_charg_ipv6_addr) == NULL) { + ogs_error("OpenAPI_acc_net_charging_address_convertToJSON() failed [an_charg_ipv6_addr]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_acc_net_charging_address_t *OpenAPI_acc_net_charging_address_parseFromJSON(cJSON *acc_net_charging_addressJSON) +{ + OpenAPI_acc_net_charging_address_t *acc_net_charging_address_local_var = NULL; + cJSON *an_charg_ipv4_addr = cJSON_GetObjectItemCaseSensitive(acc_net_charging_addressJSON, "anChargIpv4Addr"); + + if (an_charg_ipv4_addr) { + if (!cJSON_IsString(an_charg_ipv4_addr)) { + ogs_error("OpenAPI_acc_net_charging_address_parseFromJSON() failed [an_charg_ipv4_addr]"); + goto end; + } + } + + cJSON *an_charg_ipv6_addr = cJSON_GetObjectItemCaseSensitive(acc_net_charging_addressJSON, "anChargIpv6Addr"); + + if (an_charg_ipv6_addr) { + if (!cJSON_IsString(an_charg_ipv6_addr)) { + ogs_error("OpenAPI_acc_net_charging_address_parseFromJSON() failed [an_charg_ipv6_addr]"); + goto end; + } + } + + acc_net_charging_address_local_var = OpenAPI_acc_net_charging_address_create ( + an_charg_ipv4_addr ? ogs_strdup(an_charg_ipv4_addr->valuestring) : NULL, + an_charg_ipv6_addr ? ogs_strdup(an_charg_ipv6_addr->valuestring) : NULL + ); + + return acc_net_charging_address_local_var; +end: + return NULL; +} + +OpenAPI_acc_net_charging_address_t *OpenAPI_acc_net_charging_address_copy(OpenAPI_acc_net_charging_address_t *dst, OpenAPI_acc_net_charging_address_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_acc_net_charging_address_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_acc_net_charging_address_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_acc_net_charging_address_free(dst); + dst = OpenAPI_acc_net_charging_address_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/acc_net_charging_address.h b/lib/sbi/openapi/model/acc_net_charging_address.h new file mode 100644 index 000000000..2f26eec4d --- /dev/null +++ b/lib/sbi/openapi/model/acc_net_charging_address.h @@ -0,0 +1,40 @@ +/* + * acc_net_charging_address.h + * + * Describes the network entity within the access network performing charging + */ + +#ifndef _OpenAPI_acc_net_charging_address_H_ +#define _OpenAPI_acc_net_charging_address_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_acc_net_charging_address_s OpenAPI_acc_net_charging_address_t; +typedef struct OpenAPI_acc_net_charging_address_s { + char *an_charg_ipv4_addr; + char *an_charg_ipv6_addr; +} OpenAPI_acc_net_charging_address_t; + +OpenAPI_acc_net_charging_address_t *OpenAPI_acc_net_charging_address_create( + char *an_charg_ipv4_addr, + char *an_charg_ipv6_addr + ); +void OpenAPI_acc_net_charging_address_free(OpenAPI_acc_net_charging_address_t *acc_net_charging_address); +OpenAPI_acc_net_charging_address_t *OpenAPI_acc_net_charging_address_parseFromJSON(cJSON *acc_net_charging_addressJSON); +cJSON *OpenAPI_acc_net_charging_address_convertToJSON(OpenAPI_acc_net_charging_address_t *acc_net_charging_address); +OpenAPI_acc_net_charging_address_t *OpenAPI_acc_net_charging_address_copy(OpenAPI_acc_net_charging_address_t *dst, OpenAPI_acc_net_charging_address_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_acc_net_charging_address_H_ */ + diff --git a/lib/sbi/openapi/model/access_and_mobility_subscription_data.c b/lib/sbi/openapi/model/access_and_mobility_subscription_data.c index d87a1c4c5..1dd835ed3 100644 --- a/lib/sbi/openapi/model/access_and_mobility_subscription_data.c +++ b/lib/sbi/openapi/model/access_and_mobility_subscription_data.c @@ -148,9 +148,6 @@ void OpenAPI_access_and_mobility_subscription_data_free(OpenAPI_access_and_mobil } OpenAPI_list_free(access_and_mobility_subscription_data->forbidden_areas); OpenAPI_service_area_restriction_free(access_and_mobility_subscription_data->service_area_restriction); - OpenAPI_list_for_each(access_and_mobility_subscription_data->core_network_type_restrictions, node) { - OpenAPI_core_network_type_free(node->data); - } OpenAPI_list_free(access_and_mobility_subscription_data->core_network_type_restrictions); OpenAPI_sor_info_free(access_and_mobility_subscription_data->sor_info); OpenAPI_list_free(access_and_mobility_subscription_data->sor_update_indicator_list); @@ -356,21 +353,16 @@ cJSON *OpenAPI_access_and_mobility_subscription_data_convertToJSON(OpenAPI_acces } if (access_and_mobility_subscription_data->core_network_type_restrictions) { - cJSON *core_network_type_restrictionsList = cJSON_AddArrayToObject(item, "coreNetworkTypeRestrictions"); - if (core_network_type_restrictionsList == NULL) { + cJSON *core_network_type_restrictions = cJSON_AddArrayToObject(item, "coreNetworkTypeRestrictions"); + if (core_network_type_restrictions == NULL) { ogs_error("OpenAPI_access_and_mobility_subscription_data_convertToJSON() failed [core_network_type_restrictions]"); goto end; } - OpenAPI_lnode_t *core_network_type_restrictions_node; - if (access_and_mobility_subscription_data->core_network_type_restrictions) { - OpenAPI_list_for_each(access_and_mobility_subscription_data->core_network_type_restrictions, core_network_type_restrictions_node) { - cJSON *itemLocal = OpenAPI_core_network_type_convertToJSON(core_network_type_restrictions_node->data); - if (itemLocal == NULL) { - ogs_error("OpenAPI_access_and_mobility_subscription_data_convertToJSON() failed [core_network_type_restrictions]"); - goto end; - } - cJSON_AddItemToArray(core_network_type_restrictionsList, itemLocal); + OpenAPI_list_for_each(access_and_mobility_subscription_data->core_network_type_restrictions, core_network_type_restrictions_node) { + if (cJSON_AddStringToObject(core_network_type_restrictions, "", OpenAPI_core_network_type_ToString((OpenAPI_core_network_type_e)core_network_type_restrictions_node->data)) == NULL) { + ogs_error("OpenAPI_access_and_mobility_subscription_data_convertToJSON() failed [core_network_type_restrictions]"); + goto end; } } } @@ -970,13 +962,12 @@ OpenAPI_access_and_mobility_subscription_data_t *OpenAPI_access_and_mobility_sub core_network_type_restrictionsList = OpenAPI_list_create(); cJSON_ArrayForEach(core_network_type_restrictions_local_nonprimitive, core_network_type_restrictions ) { - if (!cJSON_IsObject(core_network_type_restrictions_local_nonprimitive)) { + if (!cJSON_IsString(core_network_type_restrictions_local_nonprimitive)) { ogs_error("OpenAPI_access_and_mobility_subscription_data_parseFromJSON() failed [core_network_type_restrictions]"); goto end; } - OpenAPI_core_network_type_t *core_network_type_restrictionsItem = OpenAPI_core_network_type_parseFromJSON(core_network_type_restrictions_local_nonprimitive); - OpenAPI_list_add(core_network_type_restrictionsList, core_network_type_restrictionsItem); + OpenAPI_list_add(core_network_type_restrictionsList, (void *)OpenAPI_core_network_type_FromString(core_network_type_restrictions_local_nonprimitive->valuestring)); } } diff --git a/lib/sbi/openapi/model/accu_usage_report.c b/lib/sbi/openapi/model/accu_usage_report.c new file mode 100644 index 000000000..8e4030a90 --- /dev/null +++ b/lib/sbi/openapi/model/accu_usage_report.c @@ -0,0 +1,262 @@ + +#include +#include +#include +#include "accu_usage_report.h" + +OpenAPI_accu_usage_report_t *OpenAPI_accu_usage_report_create( + char *ref_um_ids, + long vol_usage, + long vol_usage_uplink, + long vol_usage_downlink, + int time_usage, + long next_vol_usage, + long next_vol_usage_uplink, + long next_vol_usage_downlink, + int next_time_usage + ) +{ + OpenAPI_accu_usage_report_t *accu_usage_report_local_var = OpenAPI_malloc(sizeof(OpenAPI_accu_usage_report_t)); + if (!accu_usage_report_local_var) { + return NULL; + } + accu_usage_report_local_var->ref_um_ids = ref_um_ids; + accu_usage_report_local_var->vol_usage = vol_usage; + accu_usage_report_local_var->vol_usage_uplink = vol_usage_uplink; + accu_usage_report_local_var->vol_usage_downlink = vol_usage_downlink; + accu_usage_report_local_var->time_usage = time_usage; + accu_usage_report_local_var->next_vol_usage = next_vol_usage; + accu_usage_report_local_var->next_vol_usage_uplink = next_vol_usage_uplink; + accu_usage_report_local_var->next_vol_usage_downlink = next_vol_usage_downlink; + accu_usage_report_local_var->next_time_usage = next_time_usage; + + return accu_usage_report_local_var; +} + +void OpenAPI_accu_usage_report_free(OpenAPI_accu_usage_report_t *accu_usage_report) +{ + if (NULL == accu_usage_report) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(accu_usage_report->ref_um_ids); + ogs_free(accu_usage_report); +} + +cJSON *OpenAPI_accu_usage_report_convertToJSON(OpenAPI_accu_usage_report_t *accu_usage_report) +{ + cJSON *item = NULL; + + if (accu_usage_report == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [AccuUsageReport]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!accu_usage_report->ref_um_ids) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [ref_um_ids]"); + goto end; + } + if (cJSON_AddStringToObject(item, "refUmIds", accu_usage_report->ref_um_ids) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [ref_um_ids]"); + goto end; + } + + if (accu_usage_report->vol_usage) { + if (cJSON_AddNumberToObject(item, "volUsage", accu_usage_report->vol_usage) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [vol_usage]"); + goto end; + } + } + + if (accu_usage_report->vol_usage_uplink) { + if (cJSON_AddNumberToObject(item, "volUsageUplink", accu_usage_report->vol_usage_uplink) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [vol_usage_uplink]"); + goto end; + } + } + + if (accu_usage_report->vol_usage_downlink) { + if (cJSON_AddNumberToObject(item, "volUsageDownlink", accu_usage_report->vol_usage_downlink) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [vol_usage_downlink]"); + goto end; + } + } + + if (accu_usage_report->time_usage) { + if (cJSON_AddNumberToObject(item, "timeUsage", accu_usage_report->time_usage) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [time_usage]"); + goto end; + } + } + + if (accu_usage_report->next_vol_usage) { + if (cJSON_AddNumberToObject(item, "nextVolUsage", accu_usage_report->next_vol_usage) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [next_vol_usage]"); + goto end; + } + } + + if (accu_usage_report->next_vol_usage_uplink) { + if (cJSON_AddNumberToObject(item, "nextVolUsageUplink", accu_usage_report->next_vol_usage_uplink) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [next_vol_usage_uplink]"); + goto end; + } + } + + if (accu_usage_report->next_vol_usage_downlink) { + if (cJSON_AddNumberToObject(item, "nextVolUsageDownlink", accu_usage_report->next_vol_usage_downlink) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [next_vol_usage_downlink]"); + goto end; + } + } + + if (accu_usage_report->next_time_usage) { + if (cJSON_AddNumberToObject(item, "nextTimeUsage", accu_usage_report->next_time_usage) == NULL) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed [next_time_usage]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_accu_usage_report_t *OpenAPI_accu_usage_report_parseFromJSON(cJSON *accu_usage_reportJSON) +{ + OpenAPI_accu_usage_report_t *accu_usage_report_local_var = NULL; + cJSON *ref_um_ids = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "refUmIds"); + if (!ref_um_ids) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [ref_um_ids]"); + goto end; + } + + + if (!cJSON_IsString(ref_um_ids)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [ref_um_ids]"); + goto end; + } + + cJSON *vol_usage = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "volUsage"); + + if (vol_usage) { + if (!cJSON_IsNumber(vol_usage)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [vol_usage]"); + goto end; + } + } + + cJSON *vol_usage_uplink = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "volUsageUplink"); + + if (vol_usage_uplink) { + if (!cJSON_IsNumber(vol_usage_uplink)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [vol_usage_uplink]"); + goto end; + } + } + + cJSON *vol_usage_downlink = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "volUsageDownlink"); + + if (vol_usage_downlink) { + if (!cJSON_IsNumber(vol_usage_downlink)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [vol_usage_downlink]"); + goto end; + } + } + + cJSON *time_usage = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "timeUsage"); + + if (time_usage) { + if (!cJSON_IsNumber(time_usage)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [time_usage]"); + goto end; + } + } + + cJSON *next_vol_usage = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "nextVolUsage"); + + if (next_vol_usage) { + if (!cJSON_IsNumber(next_vol_usage)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [next_vol_usage]"); + goto end; + } + } + + cJSON *next_vol_usage_uplink = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "nextVolUsageUplink"); + + if (next_vol_usage_uplink) { + if (!cJSON_IsNumber(next_vol_usage_uplink)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [next_vol_usage_uplink]"); + goto end; + } + } + + cJSON *next_vol_usage_downlink = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "nextVolUsageDownlink"); + + if (next_vol_usage_downlink) { + if (!cJSON_IsNumber(next_vol_usage_downlink)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [next_vol_usage_downlink]"); + goto end; + } + } + + cJSON *next_time_usage = cJSON_GetObjectItemCaseSensitive(accu_usage_reportJSON, "nextTimeUsage"); + + if (next_time_usage) { + if (!cJSON_IsNumber(next_time_usage)) { + ogs_error("OpenAPI_accu_usage_report_parseFromJSON() failed [next_time_usage]"); + goto end; + } + } + + accu_usage_report_local_var = OpenAPI_accu_usage_report_create ( + ogs_strdup(ref_um_ids->valuestring), + vol_usage ? vol_usage->valuedouble : 0, + vol_usage_uplink ? vol_usage_uplink->valuedouble : 0, + vol_usage_downlink ? vol_usage_downlink->valuedouble : 0, + time_usage ? time_usage->valuedouble : 0, + next_vol_usage ? next_vol_usage->valuedouble : 0, + next_vol_usage_uplink ? next_vol_usage_uplink->valuedouble : 0, + next_vol_usage_downlink ? next_vol_usage_downlink->valuedouble : 0, + next_time_usage ? next_time_usage->valuedouble : 0 + ); + + return accu_usage_report_local_var; +end: + return NULL; +} + +OpenAPI_accu_usage_report_t *OpenAPI_accu_usage_report_copy(OpenAPI_accu_usage_report_t *dst, OpenAPI_accu_usage_report_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_accu_usage_report_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_accu_usage_report_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_accu_usage_report_free(dst); + dst = OpenAPI_accu_usage_report_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/accu_usage_report.h b/lib/sbi/openapi/model/accu_usage_report.h new file mode 100644 index 000000000..c2dca6679 --- /dev/null +++ b/lib/sbi/openapi/model/accu_usage_report.h @@ -0,0 +1,54 @@ +/* + * accu_usage_report.h + * + * + */ + +#ifndef _OpenAPI_accu_usage_report_H_ +#define _OpenAPI_accu_usage_report_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_accu_usage_report_s OpenAPI_accu_usage_report_t; +typedef struct OpenAPI_accu_usage_report_s { + char *ref_um_ids; + long vol_usage; + long vol_usage_uplink; + long vol_usage_downlink; + int time_usage; + long next_vol_usage; + long next_vol_usage_uplink; + long next_vol_usage_downlink; + int next_time_usage; +} OpenAPI_accu_usage_report_t; + +OpenAPI_accu_usage_report_t *OpenAPI_accu_usage_report_create( + char *ref_um_ids, + long vol_usage, + long vol_usage_uplink, + long vol_usage_downlink, + int time_usage, + long next_vol_usage, + long next_vol_usage_uplink, + long next_vol_usage_downlink, + int next_time_usage + ); +void OpenAPI_accu_usage_report_free(OpenAPI_accu_usage_report_t *accu_usage_report); +OpenAPI_accu_usage_report_t *OpenAPI_accu_usage_report_parseFromJSON(cJSON *accu_usage_reportJSON); +cJSON *OpenAPI_accu_usage_report_convertToJSON(OpenAPI_accu_usage_report_t *accu_usage_report); +OpenAPI_accu_usage_report_t *OpenAPI_accu_usage_report_copy(OpenAPI_accu_usage_report_t *dst, OpenAPI_accu_usage_report_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_accu_usage_report_H_ */ + diff --git a/lib/sbi/openapi/model/additional_access_info.c b/lib/sbi/openapi/model/additional_access_info.c new file mode 100644 index 000000000..5eb03d133 --- /dev/null +++ b/lib/sbi/openapi/model/additional_access_info.c @@ -0,0 +1,132 @@ + +#include +#include +#include +#include "additional_access_info.h" + +OpenAPI_additional_access_info_t *OpenAPI_additional_access_info_create( + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type + ) +{ + OpenAPI_additional_access_info_t *additional_access_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_additional_access_info_t)); + if (!additional_access_info_local_var) { + return NULL; + } + additional_access_info_local_var->access_type = access_type; + additional_access_info_local_var->rat_type = rat_type; + + return additional_access_info_local_var; +} + +void OpenAPI_additional_access_info_free(OpenAPI_additional_access_info_t *additional_access_info) +{ + if (NULL == additional_access_info) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(additional_access_info); +} + +cJSON *OpenAPI_additional_access_info_convertToJSON(OpenAPI_additional_access_info_t *additional_access_info) +{ + cJSON *item = NULL; + + if (additional_access_info == NULL) { + ogs_error("OpenAPI_additional_access_info_convertToJSON() failed [AdditionalAccessInfo]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!additional_access_info->access_type) { + ogs_error("OpenAPI_additional_access_info_convertToJSON() failed [access_type]"); + goto end; + } + if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(additional_access_info->access_type)) == NULL) { + ogs_error("OpenAPI_additional_access_info_convertToJSON() failed [access_type]"); + goto end; + } + + if (additional_access_info->rat_type) { + if (cJSON_AddStringToObject(item, "ratType", OpenAPI_rat_type_ToString(additional_access_info->rat_type)) == NULL) { + ogs_error("OpenAPI_additional_access_info_convertToJSON() failed [rat_type]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_additional_access_info_t *OpenAPI_additional_access_info_parseFromJSON(cJSON *additional_access_infoJSON) +{ + OpenAPI_additional_access_info_t *additional_access_info_local_var = NULL; + cJSON *access_type = cJSON_GetObjectItemCaseSensitive(additional_access_infoJSON, "accessType"); + if (!access_type) { + ogs_error("OpenAPI_additional_access_info_parseFromJSON() failed [access_type]"); + goto end; + } + + OpenAPI_access_type_e access_typeVariable; + + if (!cJSON_IsString(access_type)) { + ogs_error("OpenAPI_additional_access_info_parseFromJSON() failed [access_type]"); + goto end; + } + access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring); + + cJSON *rat_type = cJSON_GetObjectItemCaseSensitive(additional_access_infoJSON, "ratType"); + + OpenAPI_rat_type_e rat_typeVariable; + if (rat_type) { + if (!cJSON_IsString(rat_type)) { + ogs_error("OpenAPI_additional_access_info_parseFromJSON() failed [rat_type]"); + goto end; + } + rat_typeVariable = OpenAPI_rat_type_FromString(rat_type->valuestring); + } + + additional_access_info_local_var = OpenAPI_additional_access_info_create ( + access_typeVariable, + rat_type ? rat_typeVariable : 0 + ); + + return additional_access_info_local_var; +end: + return NULL; +} + +OpenAPI_additional_access_info_t *OpenAPI_additional_access_info_copy(OpenAPI_additional_access_info_t *dst, OpenAPI_additional_access_info_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_additional_access_info_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_additional_access_info_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_additional_access_info_free(dst); + dst = OpenAPI_additional_access_info_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/additional_access_info.h b/lib/sbi/openapi/model/additional_access_info.h new file mode 100644 index 000000000..7bc2610d4 --- /dev/null +++ b/lib/sbi/openapi/model/additional_access_info.h @@ -0,0 +1,42 @@ +/* + * additional_access_info.h + * + * + */ + +#ifndef _OpenAPI_additional_access_info_H_ +#define _OpenAPI_additional_access_info_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "access_type.h" +#include "rat_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_additional_access_info_s OpenAPI_additional_access_info_t; +typedef struct OpenAPI_additional_access_info_s { + OpenAPI_access_type_e access_type; + OpenAPI_rat_type_e rat_type; +} OpenAPI_additional_access_info_t; + +OpenAPI_additional_access_info_t *OpenAPI_additional_access_info_create( + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type + ); +void OpenAPI_additional_access_info_free(OpenAPI_additional_access_info_t *additional_access_info); +OpenAPI_additional_access_info_t *OpenAPI_additional_access_info_parseFromJSON(cJSON *additional_access_infoJSON); +cJSON *OpenAPI_additional_access_info_convertToJSON(OpenAPI_additional_access_info_t *additional_access_info); +OpenAPI_additional_access_info_t *OpenAPI_additional_access_info_copy(OpenAPI_additional_access_info_t *dst, OpenAPI_additional_access_info_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_additional_access_info_H_ */ + diff --git a/lib/sbi/openapi/model/af_sig_protocol.c b/lib/sbi/openapi/model/af_sig_protocol.c new file mode 100644 index 000000000..4ca143354 --- /dev/null +++ b/lib/sbi/openapi/model/af_sig_protocol.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "af_sig_protocol.h" + +OpenAPI_af_sig_protocol_t *OpenAPI_af_sig_protocol_create( + ) +{ + OpenAPI_af_sig_protocol_t *af_sig_protocol_local_var = OpenAPI_malloc(sizeof(OpenAPI_af_sig_protocol_t)); + if (!af_sig_protocol_local_var) { + return NULL; + } + + return af_sig_protocol_local_var; +} + +void OpenAPI_af_sig_protocol_free(OpenAPI_af_sig_protocol_t *af_sig_protocol) +{ + if (NULL == af_sig_protocol) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(af_sig_protocol); +} + +cJSON *OpenAPI_af_sig_protocol_convertToJSON(OpenAPI_af_sig_protocol_t *af_sig_protocol) +{ + cJSON *item = NULL; + + if (af_sig_protocol == NULL) { + ogs_error("OpenAPI_af_sig_protocol_convertToJSON() failed [AfSigProtocol]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_af_sig_protocol_t *OpenAPI_af_sig_protocol_parseFromJSON(cJSON *af_sig_protocolJSON) +{ + OpenAPI_af_sig_protocol_t *af_sig_protocol_local_var = NULL; + af_sig_protocol_local_var = OpenAPI_af_sig_protocol_create ( + ); + + return af_sig_protocol_local_var; +end: + return NULL; +} + +OpenAPI_af_sig_protocol_t *OpenAPI_af_sig_protocol_copy(OpenAPI_af_sig_protocol_t *dst, OpenAPI_af_sig_protocol_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_af_sig_protocol_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_af_sig_protocol_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_af_sig_protocol_free(dst); + dst = OpenAPI_af_sig_protocol_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/af_sig_protocol.h b/lib/sbi/openapi/model/af_sig_protocol.h new file mode 100644 index 000000000..27d09d3af --- /dev/null +++ b/lib/sbi/openapi/model/af_sig_protocol.h @@ -0,0 +1,37 @@ +/* + * af_sig_protocol.h + * + * Possible values are - NO_INFORMATION: Indicate that no information about the AF signalling protocol is being provided. - SIP: Indicate that the signalling protocol is Session Initiation Protocol. + */ + +#ifndef _OpenAPI_af_sig_protocol_H_ +#define _OpenAPI_af_sig_protocol_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "null_value.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_af_sig_protocol_s OpenAPI_af_sig_protocol_t; +typedef struct OpenAPI_af_sig_protocol_s { +} OpenAPI_af_sig_protocol_t; + +OpenAPI_af_sig_protocol_t *OpenAPI_af_sig_protocol_create( + ); +void OpenAPI_af_sig_protocol_free(OpenAPI_af_sig_protocol_t *af_sig_protocol); +OpenAPI_af_sig_protocol_t *OpenAPI_af_sig_protocol_parseFromJSON(cJSON *af_sig_protocolJSON); +cJSON *OpenAPI_af_sig_protocol_convertToJSON(OpenAPI_af_sig_protocol_t *af_sig_protocol); +OpenAPI_af_sig_protocol_t *OpenAPI_af_sig_protocol_copy(OpenAPI_af_sig_protocol_t *dst, OpenAPI_af_sig_protocol_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_af_sig_protocol_H_ */ + diff --git a/lib/sbi/openapi/model/an_gw_address.c b/lib/sbi/openapi/model/an_gw_address.c new file mode 100644 index 000000000..9f130125b --- /dev/null +++ b/lib/sbi/openapi/model/an_gw_address.c @@ -0,0 +1,125 @@ + +#include +#include +#include +#include "an_gw_address.h" + +OpenAPI_an_gw_address_t *OpenAPI_an_gw_address_create( + char *an_gw_ipv4_addr, + char *an_gw_ipv6_addr + ) +{ + OpenAPI_an_gw_address_t *an_gw_address_local_var = OpenAPI_malloc(sizeof(OpenAPI_an_gw_address_t)); + if (!an_gw_address_local_var) { + return NULL; + } + an_gw_address_local_var->an_gw_ipv4_addr = an_gw_ipv4_addr; + an_gw_address_local_var->an_gw_ipv6_addr = an_gw_ipv6_addr; + + return an_gw_address_local_var; +} + +void OpenAPI_an_gw_address_free(OpenAPI_an_gw_address_t *an_gw_address) +{ + if (NULL == an_gw_address) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(an_gw_address->an_gw_ipv4_addr); + ogs_free(an_gw_address->an_gw_ipv6_addr); + ogs_free(an_gw_address); +} + +cJSON *OpenAPI_an_gw_address_convertToJSON(OpenAPI_an_gw_address_t *an_gw_address) +{ + cJSON *item = NULL; + + if (an_gw_address == NULL) { + ogs_error("OpenAPI_an_gw_address_convertToJSON() failed [AnGwAddress]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (an_gw_address->an_gw_ipv4_addr) { + if (cJSON_AddStringToObject(item, "anGwIpv4Addr", an_gw_address->an_gw_ipv4_addr) == NULL) { + ogs_error("OpenAPI_an_gw_address_convertToJSON() failed [an_gw_ipv4_addr]"); + goto end; + } + } + + if (an_gw_address->an_gw_ipv6_addr) { + if (cJSON_AddStringToObject(item, "anGwIpv6Addr", an_gw_address->an_gw_ipv6_addr) == NULL) { + ogs_error("OpenAPI_an_gw_address_convertToJSON() failed [an_gw_ipv6_addr]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_an_gw_address_t *OpenAPI_an_gw_address_parseFromJSON(cJSON *an_gw_addressJSON) +{ + OpenAPI_an_gw_address_t *an_gw_address_local_var = NULL; + cJSON *an_gw_ipv4_addr = cJSON_GetObjectItemCaseSensitive(an_gw_addressJSON, "anGwIpv4Addr"); + + if (an_gw_ipv4_addr) { + if (!cJSON_IsString(an_gw_ipv4_addr)) { + ogs_error("OpenAPI_an_gw_address_parseFromJSON() failed [an_gw_ipv4_addr]"); + goto end; + } + } + + cJSON *an_gw_ipv6_addr = cJSON_GetObjectItemCaseSensitive(an_gw_addressJSON, "anGwIpv6Addr"); + + if (an_gw_ipv6_addr) { + if (!cJSON_IsString(an_gw_ipv6_addr)) { + ogs_error("OpenAPI_an_gw_address_parseFromJSON() failed [an_gw_ipv6_addr]"); + goto end; + } + } + + an_gw_address_local_var = OpenAPI_an_gw_address_create ( + an_gw_ipv4_addr ? ogs_strdup(an_gw_ipv4_addr->valuestring) : NULL, + an_gw_ipv6_addr ? ogs_strdup(an_gw_ipv6_addr->valuestring) : NULL + ); + + return an_gw_address_local_var; +end: + return NULL; +} + +OpenAPI_an_gw_address_t *OpenAPI_an_gw_address_copy(OpenAPI_an_gw_address_t *dst, OpenAPI_an_gw_address_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_an_gw_address_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_an_gw_address_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_an_gw_address_free(dst); + dst = OpenAPI_an_gw_address_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/an_gw_address.h b/lib/sbi/openapi/model/an_gw_address.h new file mode 100644 index 000000000..fe557e787 --- /dev/null +++ b/lib/sbi/openapi/model/an_gw_address.h @@ -0,0 +1,40 @@ +/* + * an_gw_address.h + * + * describes the address of the access network gateway control node + */ + +#ifndef _OpenAPI_an_gw_address_H_ +#define _OpenAPI_an_gw_address_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_an_gw_address_s OpenAPI_an_gw_address_t; +typedef struct OpenAPI_an_gw_address_s { + char *an_gw_ipv4_addr; + char *an_gw_ipv6_addr; +} OpenAPI_an_gw_address_t; + +OpenAPI_an_gw_address_t *OpenAPI_an_gw_address_create( + char *an_gw_ipv4_addr, + char *an_gw_ipv6_addr + ); +void OpenAPI_an_gw_address_free(OpenAPI_an_gw_address_t *an_gw_address); +OpenAPI_an_gw_address_t *OpenAPI_an_gw_address_parseFromJSON(cJSON *an_gw_addressJSON); +cJSON *OpenAPI_an_gw_address_convertToJSON(OpenAPI_an_gw_address_t *an_gw_address); +OpenAPI_an_gw_address_t *OpenAPI_an_gw_address_copy(OpenAPI_an_gw_address_t *dst, OpenAPI_an_gw_address_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_an_gw_address_H_ */ + diff --git a/lib/sbi/openapi/model/app_detection_info.c b/lib/sbi/openapi/model/app_detection_info.c new file mode 100644 index 000000000..74c5e7941 --- /dev/null +++ b/lib/sbi/openapi/model/app_detection_info.c @@ -0,0 +1,180 @@ + +#include +#include +#include +#include "app_detection_info.h" + +OpenAPI_app_detection_info_t *OpenAPI_app_detection_info_create( + char *app_id, + char *instance_id, + OpenAPI_list_t *sdf_descriptions + ) +{ + OpenAPI_app_detection_info_t *app_detection_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_app_detection_info_t)); + if (!app_detection_info_local_var) { + return NULL; + } + app_detection_info_local_var->app_id = app_id; + app_detection_info_local_var->instance_id = instance_id; + app_detection_info_local_var->sdf_descriptions = sdf_descriptions; + + return app_detection_info_local_var; +} + +void OpenAPI_app_detection_info_free(OpenAPI_app_detection_info_t *app_detection_info) +{ + if (NULL == app_detection_info) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(app_detection_info->app_id); + ogs_free(app_detection_info->instance_id); + OpenAPI_list_for_each(app_detection_info->sdf_descriptions, node) { + OpenAPI_flow_information_free(node->data); + } + OpenAPI_list_free(app_detection_info->sdf_descriptions); + ogs_free(app_detection_info); +} + +cJSON *OpenAPI_app_detection_info_convertToJSON(OpenAPI_app_detection_info_t *app_detection_info) +{ + cJSON *item = NULL; + + if (app_detection_info == NULL) { + ogs_error("OpenAPI_app_detection_info_convertToJSON() failed [AppDetectionInfo]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!app_detection_info->app_id) { + ogs_error("OpenAPI_app_detection_info_convertToJSON() failed [app_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "appId", app_detection_info->app_id) == NULL) { + ogs_error("OpenAPI_app_detection_info_convertToJSON() failed [app_id]"); + goto end; + } + + if (app_detection_info->instance_id) { + if (cJSON_AddStringToObject(item, "instanceId", app_detection_info->instance_id) == NULL) { + ogs_error("OpenAPI_app_detection_info_convertToJSON() failed [instance_id]"); + goto end; + } + } + + if (app_detection_info->sdf_descriptions) { + cJSON *sdf_descriptionsList = cJSON_AddArrayToObject(item, "sdfDescriptions"); + if (sdf_descriptionsList == NULL) { + ogs_error("OpenAPI_app_detection_info_convertToJSON() failed [sdf_descriptions]"); + goto end; + } + + OpenAPI_lnode_t *sdf_descriptions_node; + if (app_detection_info->sdf_descriptions) { + OpenAPI_list_for_each(app_detection_info->sdf_descriptions, sdf_descriptions_node) { + cJSON *itemLocal = OpenAPI_flow_information_convertToJSON(sdf_descriptions_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_app_detection_info_convertToJSON() failed [sdf_descriptions]"); + goto end; + } + cJSON_AddItemToArray(sdf_descriptionsList, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_app_detection_info_t *OpenAPI_app_detection_info_parseFromJSON(cJSON *app_detection_infoJSON) +{ + OpenAPI_app_detection_info_t *app_detection_info_local_var = NULL; + cJSON *app_id = cJSON_GetObjectItemCaseSensitive(app_detection_infoJSON, "appId"); + if (!app_id) { + ogs_error("OpenAPI_app_detection_info_parseFromJSON() failed [app_id]"); + goto end; + } + + + if (!cJSON_IsString(app_id)) { + ogs_error("OpenAPI_app_detection_info_parseFromJSON() failed [app_id]"); + goto end; + } + + cJSON *instance_id = cJSON_GetObjectItemCaseSensitive(app_detection_infoJSON, "instanceId"); + + if (instance_id) { + if (!cJSON_IsString(instance_id)) { + ogs_error("OpenAPI_app_detection_info_parseFromJSON() failed [instance_id]"); + goto end; + } + } + + cJSON *sdf_descriptions = cJSON_GetObjectItemCaseSensitive(app_detection_infoJSON, "sdfDescriptions"); + + OpenAPI_list_t *sdf_descriptionsList; + if (sdf_descriptions) { + cJSON *sdf_descriptions_local_nonprimitive; + if (!cJSON_IsArray(sdf_descriptions)) { + ogs_error("OpenAPI_app_detection_info_parseFromJSON() failed [sdf_descriptions]"); + goto end; + } + + sdf_descriptionsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(sdf_descriptions_local_nonprimitive, sdf_descriptions ) { + if (!cJSON_IsObject(sdf_descriptions_local_nonprimitive)) { + ogs_error("OpenAPI_app_detection_info_parseFromJSON() failed [sdf_descriptions]"); + goto end; + } + OpenAPI_flow_information_t *sdf_descriptionsItem = OpenAPI_flow_information_parseFromJSON(sdf_descriptions_local_nonprimitive); + + OpenAPI_list_add(sdf_descriptionsList, sdf_descriptionsItem); + } + } + + app_detection_info_local_var = OpenAPI_app_detection_info_create ( + ogs_strdup(app_id->valuestring), + instance_id ? ogs_strdup(instance_id->valuestring) : NULL, + sdf_descriptions ? sdf_descriptionsList : NULL + ); + + return app_detection_info_local_var; +end: + return NULL; +} + +OpenAPI_app_detection_info_t *OpenAPI_app_detection_info_copy(OpenAPI_app_detection_info_t *dst, OpenAPI_app_detection_info_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_app_detection_info_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_app_detection_info_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_app_detection_info_free(dst); + dst = OpenAPI_app_detection_info_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/app_detection_info.h b/lib/sbi/openapi/model/app_detection_info.h new file mode 100644 index 000000000..e0911706f --- /dev/null +++ b/lib/sbi/openapi/model/app_detection_info.h @@ -0,0 +1,43 @@ +/* + * app_detection_info.h + * + * + */ + +#ifndef _OpenAPI_app_detection_info_H_ +#define _OpenAPI_app_detection_info_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "flow_information.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_app_detection_info_s OpenAPI_app_detection_info_t; +typedef struct OpenAPI_app_detection_info_s { + char *app_id; + char *instance_id; + OpenAPI_list_t *sdf_descriptions; +} OpenAPI_app_detection_info_t; + +OpenAPI_app_detection_info_t *OpenAPI_app_detection_info_create( + char *app_id, + char *instance_id, + OpenAPI_list_t *sdf_descriptions + ); +void OpenAPI_app_detection_info_free(OpenAPI_app_detection_info_t *app_detection_info); +OpenAPI_app_detection_info_t *OpenAPI_app_detection_info_parseFromJSON(cJSON *app_detection_infoJSON); +cJSON *OpenAPI_app_detection_info_convertToJSON(OpenAPI_app_detection_info_t *app_detection_info); +OpenAPI_app_detection_info_t *OpenAPI_app_detection_info_copy(OpenAPI_app_detection_info_t *dst, OpenAPI_app_detection_info_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_app_detection_info_H_ */ + diff --git a/lib/sbi/openapi/model/authorized_default_qos.c b/lib/sbi/openapi/model/authorized_default_qos.c new file mode 100644 index 000000000..af0e49070 --- /dev/null +++ b/lib/sbi/openapi/model/authorized_default_qos.c @@ -0,0 +1,303 @@ + +#include +#include +#include +#include "authorized_default_qos.h" + +OpenAPI_authorized_default_qos_t *OpenAPI_authorized_default_qos_create( + int _5qi, + OpenAPI_arp_t *arp, + int priority_level, + int aver_window, + int max_data_burst_vol, + char *maxbr_ul, + char *maxbr_dl, + char *gbr_ul, + char *gbr_dl, + int qnc, + int ext_max_data_burst_vol + ) +{ + OpenAPI_authorized_default_qos_t *authorized_default_qos_local_var = OpenAPI_malloc(sizeof(OpenAPI_authorized_default_qos_t)); + if (!authorized_default_qos_local_var) { + return NULL; + } + authorized_default_qos_local_var->_5qi = _5qi; + authorized_default_qos_local_var->arp = arp; + authorized_default_qos_local_var->priority_level = priority_level; + authorized_default_qos_local_var->aver_window = aver_window; + authorized_default_qos_local_var->max_data_burst_vol = max_data_burst_vol; + authorized_default_qos_local_var->maxbr_ul = maxbr_ul; + authorized_default_qos_local_var->maxbr_dl = maxbr_dl; + authorized_default_qos_local_var->gbr_ul = gbr_ul; + authorized_default_qos_local_var->gbr_dl = gbr_dl; + authorized_default_qos_local_var->qnc = qnc; + authorized_default_qos_local_var->ext_max_data_burst_vol = ext_max_data_burst_vol; + + return authorized_default_qos_local_var; +} + +void OpenAPI_authorized_default_qos_free(OpenAPI_authorized_default_qos_t *authorized_default_qos) +{ + if (NULL == authorized_default_qos) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_arp_free(authorized_default_qos->arp); + ogs_free(authorized_default_qos->maxbr_ul); + ogs_free(authorized_default_qos->maxbr_dl); + ogs_free(authorized_default_qos->gbr_ul); + ogs_free(authorized_default_qos->gbr_dl); + ogs_free(authorized_default_qos); +} + +cJSON *OpenAPI_authorized_default_qos_convertToJSON(OpenAPI_authorized_default_qos_t *authorized_default_qos) +{ + cJSON *item = NULL; + + if (authorized_default_qos == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [AuthorizedDefaultQos]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (authorized_default_qos->_5qi) { + if (cJSON_AddNumberToObject(item, "5qi", authorized_default_qos->_5qi) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [_5qi]"); + goto end; + } + } + + if (authorized_default_qos->arp) { + cJSON *arp_local_JSON = OpenAPI_arp_convertToJSON(authorized_default_qos->arp); + if (arp_local_JSON == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [arp]"); + goto end; + } + cJSON_AddItemToObject(item, "arp", arp_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [arp]"); + goto end; + } + } + + if (authorized_default_qos->priority_level) { + if (cJSON_AddNumberToObject(item, "priorityLevel", authorized_default_qos->priority_level) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [priority_level]"); + goto end; + } + } + + if (authorized_default_qos->aver_window) { + if (cJSON_AddNumberToObject(item, "averWindow", authorized_default_qos->aver_window) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [aver_window]"); + goto end; + } + } + + if (authorized_default_qos->max_data_burst_vol) { + if (cJSON_AddNumberToObject(item, "maxDataBurstVol", authorized_default_qos->max_data_burst_vol) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [max_data_burst_vol]"); + goto end; + } + } + + if (authorized_default_qos->maxbr_ul) { + if (cJSON_AddStringToObject(item, "maxbrUl", authorized_default_qos->maxbr_ul) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [maxbr_ul]"); + goto end; + } + } + + if (authorized_default_qos->maxbr_dl) { + if (cJSON_AddStringToObject(item, "maxbrDl", authorized_default_qos->maxbr_dl) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [maxbr_dl]"); + goto end; + } + } + + if (authorized_default_qos->gbr_ul) { + if (cJSON_AddStringToObject(item, "gbrUl", authorized_default_qos->gbr_ul) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [gbr_ul]"); + goto end; + } + } + + if (authorized_default_qos->gbr_dl) { + if (cJSON_AddStringToObject(item, "gbrDl", authorized_default_qos->gbr_dl) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [gbr_dl]"); + goto end; + } + } + + if (authorized_default_qos->qnc) { + if (cJSON_AddBoolToObject(item, "qnc", authorized_default_qos->qnc) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [qnc]"); + goto end; + } + } + + if (authorized_default_qos->ext_max_data_burst_vol) { + if (cJSON_AddNumberToObject(item, "extMaxDataBurstVol", authorized_default_qos->ext_max_data_burst_vol) == NULL) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed [ext_max_data_burst_vol]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_authorized_default_qos_t *OpenAPI_authorized_default_qos_parseFromJSON(cJSON *authorized_default_qosJSON) +{ + OpenAPI_authorized_default_qos_t *authorized_default_qos_local_var = NULL; + cJSON *_5qi = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "5qi"); + + if (_5qi) { + if (!cJSON_IsNumber(_5qi)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [_5qi]"); + goto end; + } + } + + cJSON *arp = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "arp"); + + OpenAPI_arp_t *arp_local_nonprim = NULL; + if (arp) { + arp_local_nonprim = OpenAPI_arp_parseFromJSON(arp); + } + + cJSON *priority_level = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "priorityLevel"); + + if (priority_level) { + if (!cJSON_IsNumber(priority_level)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [priority_level]"); + goto end; + } + } + + cJSON *aver_window = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "averWindow"); + + if (aver_window) { + if (!cJSON_IsNumber(aver_window)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [aver_window]"); + goto end; + } + } + + cJSON *max_data_burst_vol = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "maxDataBurstVol"); + + if (max_data_burst_vol) { + if (!cJSON_IsNumber(max_data_burst_vol)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [max_data_burst_vol]"); + goto end; + } + } + + cJSON *maxbr_ul = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "maxbrUl"); + + if (maxbr_ul) { + if (!cJSON_IsString(maxbr_ul)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [maxbr_ul]"); + goto end; + } + } + + cJSON *maxbr_dl = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "maxbrDl"); + + if (maxbr_dl) { + if (!cJSON_IsString(maxbr_dl)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [maxbr_dl]"); + goto end; + } + } + + cJSON *gbr_ul = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "gbrUl"); + + if (gbr_ul) { + if (!cJSON_IsString(gbr_ul)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [gbr_ul]"); + goto end; + } + } + + cJSON *gbr_dl = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "gbrDl"); + + if (gbr_dl) { + if (!cJSON_IsString(gbr_dl)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [gbr_dl]"); + goto end; + } + } + + cJSON *qnc = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "qnc"); + + if (qnc) { + if (!cJSON_IsBool(qnc)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [qnc]"); + goto end; + } + } + + cJSON *ext_max_data_burst_vol = cJSON_GetObjectItemCaseSensitive(authorized_default_qosJSON, "extMaxDataBurstVol"); + + if (ext_max_data_burst_vol) { + if (!cJSON_IsNumber(ext_max_data_burst_vol)) { + ogs_error("OpenAPI_authorized_default_qos_parseFromJSON() failed [ext_max_data_burst_vol]"); + goto end; + } + } + + authorized_default_qos_local_var = OpenAPI_authorized_default_qos_create ( + _5qi ? _5qi->valuedouble : 0, + arp ? arp_local_nonprim : NULL, + priority_level ? priority_level->valuedouble : 0, + aver_window ? aver_window->valuedouble : 0, + max_data_burst_vol ? max_data_burst_vol->valuedouble : 0, + maxbr_ul ? ogs_strdup(maxbr_ul->valuestring) : NULL, + maxbr_dl ? ogs_strdup(maxbr_dl->valuestring) : NULL, + gbr_ul ? ogs_strdup(gbr_ul->valuestring) : NULL, + gbr_dl ? ogs_strdup(gbr_dl->valuestring) : NULL, + qnc ? qnc->valueint : 0, + ext_max_data_burst_vol ? ext_max_data_burst_vol->valuedouble : 0 + ); + + return authorized_default_qos_local_var; +end: + return NULL; +} + +OpenAPI_authorized_default_qos_t *OpenAPI_authorized_default_qos_copy(OpenAPI_authorized_default_qos_t *dst, OpenAPI_authorized_default_qos_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_authorized_default_qos_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_authorized_default_qos_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_authorized_default_qos_free(dst); + dst = OpenAPI_authorized_default_qos_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/authorized_default_qos.h b/lib/sbi/openapi/model/authorized_default_qos.h new file mode 100644 index 000000000..f5088a7ec --- /dev/null +++ b/lib/sbi/openapi/model/authorized_default_qos.h @@ -0,0 +1,59 @@ +/* + * authorized_default_qos.h + * + * + */ + +#ifndef _OpenAPI_authorized_default_qos_H_ +#define _OpenAPI_authorized_default_qos_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "arp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_authorized_default_qos_s OpenAPI_authorized_default_qos_t; +typedef struct OpenAPI_authorized_default_qos_s { + int _5qi; + struct OpenAPI_arp_s *arp; + int priority_level; + int aver_window; + int max_data_burst_vol; + char *maxbr_ul; + char *maxbr_dl; + char *gbr_ul; + char *gbr_dl; + int qnc; + int ext_max_data_burst_vol; +} OpenAPI_authorized_default_qos_t; + +OpenAPI_authorized_default_qos_t *OpenAPI_authorized_default_qos_create( + int _5qi, + OpenAPI_arp_t *arp, + int priority_level, + int aver_window, + int max_data_burst_vol, + char *maxbr_ul, + char *maxbr_dl, + char *gbr_ul, + char *gbr_dl, + int qnc, + int ext_max_data_burst_vol + ); +void OpenAPI_authorized_default_qos_free(OpenAPI_authorized_default_qos_t *authorized_default_qos); +OpenAPI_authorized_default_qos_t *OpenAPI_authorized_default_qos_parseFromJSON(cJSON *authorized_default_qosJSON); +cJSON *OpenAPI_authorized_default_qos_convertToJSON(OpenAPI_authorized_default_qos_t *authorized_default_qos); +OpenAPI_authorized_default_qos_t *OpenAPI_authorized_default_qos_copy(OpenAPI_authorized_default_qos_t *dst, OpenAPI_authorized_default_qos_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_authorized_default_qos_H_ */ + diff --git a/lib/sbi/openapi/model/candidate_for_replacement.c b/lib/sbi/openapi/model/candidate_for_replacement.c new file mode 100644 index 000000000..9d69c5d0b --- /dev/null +++ b/lib/sbi/openapi/model/candidate_for_replacement.c @@ -0,0 +1,157 @@ + +#include +#include +#include +#include "candidate_for_replacement.h" + +OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_create( + OpenAPI_snssai_t *snssai, + OpenAPI_list_t *dnns + ) +{ + OpenAPI_candidate_for_replacement_t *candidate_for_replacement_local_var = OpenAPI_malloc(sizeof(OpenAPI_candidate_for_replacement_t)); + if (!candidate_for_replacement_local_var) { + return NULL; + } + candidate_for_replacement_local_var->snssai = snssai; + candidate_for_replacement_local_var->dnns = dnns; + + return candidate_for_replacement_local_var; +} + +void OpenAPI_candidate_for_replacement_free(OpenAPI_candidate_for_replacement_t *candidate_for_replacement) +{ + if (NULL == candidate_for_replacement) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_snssai_free(candidate_for_replacement->snssai); + OpenAPI_list_for_each(candidate_for_replacement->dnns, node) { + ogs_free(node->data); + } + OpenAPI_list_free(candidate_for_replacement->dnns); + ogs_free(candidate_for_replacement); +} + +cJSON *OpenAPI_candidate_for_replacement_convertToJSON(OpenAPI_candidate_for_replacement_t *candidate_for_replacement) +{ + cJSON *item = NULL; + + if (candidate_for_replacement == NULL) { + ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [CandidateForReplacement]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!candidate_for_replacement->snssai) { + ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [snssai]"); + goto end; + } + cJSON *snssai_local_JSON = OpenAPI_snssai_convertToJSON(candidate_for_replacement->snssai); + if (snssai_local_JSON == NULL) { + ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [snssai]"); + goto end; + } + cJSON_AddItemToObject(item, "snssai", snssai_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [snssai]"); + goto end; + } + + if (candidate_for_replacement->dnns) { + cJSON *dnns = cJSON_AddArrayToObject(item, "dnns"); + if (dnns == NULL) { + ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [dnns]"); + goto end; + } + + OpenAPI_lnode_t *dnns_node; + OpenAPI_list_for_each(candidate_for_replacement->dnns, dnns_node) { + if (cJSON_AddStringToObject(dnns, "", (char*)dnns_node->data) == NULL) { + ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [dnns]"); + goto end; + } + } + } + +end: + return item; +} + +OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_parseFromJSON(cJSON *candidate_for_replacementJSON) +{ + OpenAPI_candidate_for_replacement_t *candidate_for_replacement_local_var = NULL; + cJSON *snssai = cJSON_GetObjectItemCaseSensitive(candidate_for_replacementJSON, "snssai"); + if (!snssai) { + ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [snssai]"); + goto end; + } + + OpenAPI_snssai_t *snssai_local_nonprim = NULL; + + snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(snssai); + + cJSON *dnns = cJSON_GetObjectItemCaseSensitive(candidate_for_replacementJSON, "dnns"); + + OpenAPI_list_t *dnnsList; + if (dnns) { + cJSON *dnns_local; + if (!cJSON_IsArray(dnns)) { + ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [dnns]"); + goto end; + } + dnnsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(dnns_local, dnns) { + if (!cJSON_IsString(dnns_local)) { + ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [dnns]"); + goto end; + } + OpenAPI_list_add(dnnsList, ogs_strdup(dnns_local->valuestring)); + } + } + + candidate_for_replacement_local_var = OpenAPI_candidate_for_replacement_create ( + snssai_local_nonprim, + dnns ? dnnsList : NULL + ); + + return candidate_for_replacement_local_var; +end: + return NULL; +} + +OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_copy(OpenAPI_candidate_for_replacement_t *dst, OpenAPI_candidate_for_replacement_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_candidate_for_replacement_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_candidate_for_replacement_free(dst); + dst = OpenAPI_candidate_for_replacement_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/candidate_for_replacement.h b/lib/sbi/openapi/model/candidate_for_replacement.h new file mode 100644 index 000000000..b558b5501 --- /dev/null +++ b/lib/sbi/openapi/model/candidate_for_replacement.h @@ -0,0 +1,41 @@ +/* + * candidate_for_replacement.h + * + * + */ + +#ifndef _OpenAPI_candidate_for_replacement_H_ +#define _OpenAPI_candidate_for_replacement_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "snssai.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_candidate_for_replacement_s OpenAPI_candidate_for_replacement_t; +typedef struct OpenAPI_candidate_for_replacement_s { + struct OpenAPI_snssai_s *snssai; + OpenAPI_list_t *dnns; +} OpenAPI_candidate_for_replacement_t; + +OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_create( + OpenAPI_snssai_t *snssai, + OpenAPI_list_t *dnns + ); +void OpenAPI_candidate_for_replacement_free(OpenAPI_candidate_for_replacement_t *candidate_for_replacement); +OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_parseFromJSON(cJSON *candidate_for_replacementJSON); +cJSON *OpenAPI_candidate_for_replacement_convertToJSON(OpenAPI_candidate_for_replacement_t *candidate_for_replacement); +OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_copy(OpenAPI_candidate_for_replacement_t *dst, OpenAPI_candidate_for_replacement_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_candidate_for_replacement_H_ */ + diff --git a/lib/sbi/openapi/model/charging_data.c b/lib/sbi/openapi/model/charging_data.c new file mode 100644 index 000000000..ff0be6aae --- /dev/null +++ b/lib/sbi/openapi/model/charging_data.c @@ -0,0 +1,332 @@ + +#include +#include +#include +#include "charging_data.h" + +OpenAPI_charging_data_t *OpenAPI_charging_data_create( + char *chg_id, + OpenAPI_metering_method_t *metering_method, + int offline, + int online, + int sdf_handl, + int rating_group, + OpenAPI_reporting_level_t *reporting_level, + int service_id, + char *sponsor_id, + char *app_svc_prov_id, + int af_charging_identifier, + char *af_charg_id + ) +{ + OpenAPI_charging_data_t *charging_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_charging_data_t)); + if (!charging_data_local_var) { + return NULL; + } + charging_data_local_var->chg_id = chg_id; + charging_data_local_var->metering_method = metering_method; + charging_data_local_var->offline = offline; + charging_data_local_var->online = online; + charging_data_local_var->sdf_handl = sdf_handl; + charging_data_local_var->rating_group = rating_group; + charging_data_local_var->reporting_level = reporting_level; + charging_data_local_var->service_id = service_id; + charging_data_local_var->sponsor_id = sponsor_id; + charging_data_local_var->app_svc_prov_id = app_svc_prov_id; + charging_data_local_var->af_charging_identifier = af_charging_identifier; + charging_data_local_var->af_charg_id = af_charg_id; + + return charging_data_local_var; +} + +void OpenAPI_charging_data_free(OpenAPI_charging_data_t *charging_data) +{ + if (NULL == charging_data) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(charging_data->chg_id); + OpenAPI_metering_method_free(charging_data->metering_method); + OpenAPI_reporting_level_free(charging_data->reporting_level); + ogs_free(charging_data->sponsor_id); + ogs_free(charging_data->app_svc_prov_id); + ogs_free(charging_data->af_charg_id); + ogs_free(charging_data); +} + +cJSON *OpenAPI_charging_data_convertToJSON(OpenAPI_charging_data_t *charging_data) +{ + cJSON *item = NULL; + + if (charging_data == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [ChargingData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!charging_data->chg_id) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [chg_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "chgId", charging_data->chg_id) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [chg_id]"); + goto end; + } + + if (charging_data->metering_method) { + cJSON *metering_method_local_JSON = OpenAPI_metering_method_convertToJSON(charging_data->metering_method); + if (metering_method_local_JSON == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [metering_method]"); + goto end; + } + cJSON_AddItemToObject(item, "meteringMethod", metering_method_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [metering_method]"); + goto end; + } + } + + if (charging_data->offline) { + if (cJSON_AddBoolToObject(item, "offline", charging_data->offline) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [offline]"); + goto end; + } + } + + if (charging_data->online) { + if (cJSON_AddBoolToObject(item, "online", charging_data->online) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [online]"); + goto end; + } + } + + if (charging_data->sdf_handl) { + if (cJSON_AddBoolToObject(item, "sdfHandl", charging_data->sdf_handl) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [sdf_handl]"); + goto end; + } + } + + if (charging_data->rating_group) { + if (cJSON_AddNumberToObject(item, "ratingGroup", charging_data->rating_group) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [rating_group]"); + goto end; + } + } + + if (charging_data->reporting_level) { + cJSON *reporting_level_local_JSON = OpenAPI_reporting_level_convertToJSON(charging_data->reporting_level); + if (reporting_level_local_JSON == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [reporting_level]"); + goto end; + } + cJSON_AddItemToObject(item, "reportingLevel", reporting_level_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [reporting_level]"); + goto end; + } + } + + if (charging_data->service_id) { + if (cJSON_AddNumberToObject(item, "serviceId", charging_data->service_id) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [service_id]"); + goto end; + } + } + + if (charging_data->sponsor_id) { + if (cJSON_AddStringToObject(item, "sponsorId", charging_data->sponsor_id) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [sponsor_id]"); + goto end; + } + } + + if (charging_data->app_svc_prov_id) { + if (cJSON_AddStringToObject(item, "appSvcProvId", charging_data->app_svc_prov_id) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [app_svc_prov_id]"); + goto end; + } + } + + if (charging_data->af_charging_identifier) { + if (cJSON_AddNumberToObject(item, "afChargingIdentifier", charging_data->af_charging_identifier) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [af_charging_identifier]"); + goto end; + } + } + + if (charging_data->af_charg_id) { + if (cJSON_AddStringToObject(item, "afChargId", charging_data->af_charg_id) == NULL) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed [af_charg_id]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dataJSON) +{ + OpenAPI_charging_data_t *charging_data_local_var = NULL; + cJSON *chg_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "chgId"); + if (!chg_id) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [chg_id]"); + goto end; + } + + + if (!cJSON_IsString(chg_id)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [chg_id]"); + goto end; + } + + cJSON *metering_method = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "meteringMethod"); + + OpenAPI_metering_method_t *metering_method_local_nonprim = NULL; + if (metering_method) { + metering_method_local_nonprim = OpenAPI_metering_method_parseFromJSON(metering_method); + } + + cJSON *offline = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "offline"); + + if (offline) { + if (!cJSON_IsBool(offline)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [offline]"); + goto end; + } + } + + cJSON *online = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "online"); + + if (online) { + if (!cJSON_IsBool(online)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [online]"); + goto end; + } + } + + cJSON *sdf_handl = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "sdfHandl"); + + if (sdf_handl) { + if (!cJSON_IsBool(sdf_handl)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [sdf_handl]"); + goto end; + } + } + + cJSON *rating_group = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "ratingGroup"); + + if (rating_group) { + if (!cJSON_IsNumber(rating_group)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [rating_group]"); + goto end; + } + } + + cJSON *reporting_level = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "reportingLevel"); + + OpenAPI_reporting_level_t *reporting_level_local_nonprim = NULL; + if (reporting_level) { + reporting_level_local_nonprim = OpenAPI_reporting_level_parseFromJSON(reporting_level); + } + + cJSON *service_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "serviceId"); + + if (service_id) { + if (!cJSON_IsNumber(service_id)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [service_id]"); + goto end; + } + } + + cJSON *sponsor_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "sponsorId"); + + if (sponsor_id) { + if (!cJSON_IsString(sponsor_id)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [sponsor_id]"); + goto end; + } + } + + cJSON *app_svc_prov_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "appSvcProvId"); + + if (app_svc_prov_id) { + if (!cJSON_IsString(app_svc_prov_id)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [app_svc_prov_id]"); + goto end; + } + } + + cJSON *af_charging_identifier = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "afChargingIdentifier"); + + if (af_charging_identifier) { + if (!cJSON_IsNumber(af_charging_identifier)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [af_charging_identifier]"); + goto end; + } + } + + cJSON *af_charg_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "afChargId"); + + if (af_charg_id) { + if (!cJSON_IsString(af_charg_id)) { + ogs_error("OpenAPI_charging_data_parseFromJSON() failed [af_charg_id]"); + goto end; + } + } + + charging_data_local_var = OpenAPI_charging_data_create ( + ogs_strdup(chg_id->valuestring), + metering_method ? metering_method_local_nonprim : NULL, + offline ? offline->valueint : 0, + online ? online->valueint : 0, + sdf_handl ? sdf_handl->valueint : 0, + rating_group ? rating_group->valuedouble : 0, + reporting_level ? reporting_level_local_nonprim : NULL, + service_id ? service_id->valuedouble : 0, + sponsor_id ? ogs_strdup(sponsor_id->valuestring) : NULL, + app_svc_prov_id ? ogs_strdup(app_svc_prov_id->valuestring) : NULL, + af_charging_identifier ? af_charging_identifier->valuedouble : 0, + af_charg_id ? ogs_strdup(af_charg_id->valuestring) : NULL + ); + + return charging_data_local_var; +end: + return NULL; +} + +OpenAPI_charging_data_t *OpenAPI_charging_data_copy(OpenAPI_charging_data_t *dst, OpenAPI_charging_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_charging_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_charging_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_charging_data_free(dst); + dst = OpenAPI_charging_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/charging_data.h b/lib/sbi/openapi/model/charging_data.h new file mode 100644 index 000000000..c1c315462 --- /dev/null +++ b/lib/sbi/openapi/model/charging_data.h @@ -0,0 +1,62 @@ +/* + * charging_data.h + * + * + */ + +#ifndef _OpenAPI_charging_data_H_ +#define _OpenAPI_charging_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "metering_method.h" +#include "reporting_level.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_charging_data_s OpenAPI_charging_data_t; +typedef struct OpenAPI_charging_data_s { + char *chg_id; + struct OpenAPI_metering_method_s *metering_method; + int offline; + int online; + int sdf_handl; + int rating_group; + struct OpenAPI_reporting_level_s *reporting_level; + int service_id; + char *sponsor_id; + char *app_svc_prov_id; + int af_charging_identifier; + char *af_charg_id; +} OpenAPI_charging_data_t; + +OpenAPI_charging_data_t *OpenAPI_charging_data_create( + char *chg_id, + OpenAPI_metering_method_t *metering_method, + int offline, + int online, + int sdf_handl, + int rating_group, + OpenAPI_reporting_level_t *reporting_level, + int service_id, + char *sponsor_id, + char *app_svc_prov_id, + int af_charging_identifier, + char *af_charg_id + ); +void OpenAPI_charging_data_free(OpenAPI_charging_data_t *charging_data); +OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dataJSON); +cJSON *OpenAPI_charging_data_convertToJSON(OpenAPI_charging_data_t *charging_data); +OpenAPI_charging_data_t *OpenAPI_charging_data_copy(OpenAPI_charging_data_t *dst, OpenAPI_charging_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_charging_data_H_ */ + diff --git a/lib/sbi/openapi/model/cn_assisted_ran_para.c b/lib/sbi/openapi/model/cn_assisted_ran_para.c index a4e15bfe3..9da31438c 100644 --- a/lib/sbi/openapi/model/cn_assisted_ran_para.c +++ b/lib/sbi/openapi/model/cn_assisted_ran_para.c @@ -5,12 +5,12 @@ #include "cn_assisted_ran_para.h" OpenAPI_cn_assisted_ran_para_t *OpenAPI_cn_assisted_ran_para_create( - OpenAPI_stationary_indication_t *stationary_indication, + OpenAPI_stationary_indication_e stationary_indication, int communication_duration_time, int periodic_time, OpenAPI_scheduled_communication_time_t *scheduled_communication_time, - OpenAPI_scheduled_communication_type_t *scheduled_communication_type, - OpenAPI_traffic_profile_t *traffic_profile, + OpenAPI_scheduled_communication_type_e scheduled_communication_type, + OpenAPI_traffic_profile_e traffic_profile, OpenAPI_battery_indication_t *battery_indication ) { @@ -35,10 +35,7 @@ void OpenAPI_cn_assisted_ran_para_free(OpenAPI_cn_assisted_ran_para_t *cn_assist return; } OpenAPI_lnode_t *node; - OpenAPI_stationary_indication_free(cn_assisted_ran_para->stationary_indication); OpenAPI_scheduled_communication_time_free(cn_assisted_ran_para->scheduled_communication_time); - OpenAPI_scheduled_communication_type_free(cn_assisted_ran_para->scheduled_communication_type); - OpenAPI_traffic_profile_free(cn_assisted_ran_para->traffic_profile); OpenAPI_battery_indication_free(cn_assisted_ran_para->battery_indication); ogs_free(cn_assisted_ran_para); } @@ -54,13 +51,7 @@ cJSON *OpenAPI_cn_assisted_ran_para_convertToJSON(OpenAPI_cn_assisted_ran_para_t item = cJSON_CreateObject(); if (cn_assisted_ran_para->stationary_indication) { - cJSON *stationary_indication_local_JSON = OpenAPI_stationary_indication_convertToJSON(cn_assisted_ran_para->stationary_indication); - if (stationary_indication_local_JSON == NULL) { - ogs_error("OpenAPI_cn_assisted_ran_para_convertToJSON() failed [stationary_indication]"); - goto end; - } - cJSON_AddItemToObject(item, "stationaryIndication", stationary_indication_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "stationaryIndication", OpenAPI_stationary_indication_ToString(cn_assisted_ran_para->stationary_indication)) == NULL) { ogs_error("OpenAPI_cn_assisted_ran_para_convertToJSON() failed [stationary_indication]"); goto end; } @@ -94,26 +85,14 @@ cJSON *OpenAPI_cn_assisted_ran_para_convertToJSON(OpenAPI_cn_assisted_ran_para_t } if (cn_assisted_ran_para->scheduled_communication_type) { - cJSON *scheduled_communication_type_local_JSON = OpenAPI_scheduled_communication_type_convertToJSON(cn_assisted_ran_para->scheduled_communication_type); - if (scheduled_communication_type_local_JSON == NULL) { - ogs_error("OpenAPI_cn_assisted_ran_para_convertToJSON() failed [scheduled_communication_type]"); - goto end; - } - cJSON_AddItemToObject(item, "scheduledCommunicationType", scheduled_communication_type_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "scheduledCommunicationType", OpenAPI_scheduled_communication_type_ToString(cn_assisted_ran_para->scheduled_communication_type)) == NULL) { ogs_error("OpenAPI_cn_assisted_ran_para_convertToJSON() failed [scheduled_communication_type]"); goto end; } } if (cn_assisted_ran_para->traffic_profile) { - cJSON *traffic_profile_local_JSON = OpenAPI_traffic_profile_convertToJSON(cn_assisted_ran_para->traffic_profile); - if (traffic_profile_local_JSON == NULL) { - ogs_error("OpenAPI_cn_assisted_ran_para_convertToJSON() failed [traffic_profile]"); - goto end; - } - cJSON_AddItemToObject(item, "trafficProfile", traffic_profile_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "trafficProfile", OpenAPI_traffic_profile_ToString(cn_assisted_ran_para->traffic_profile)) == NULL) { ogs_error("OpenAPI_cn_assisted_ran_para_convertToJSON() failed [traffic_profile]"); goto end; } @@ -141,9 +120,13 @@ OpenAPI_cn_assisted_ran_para_t *OpenAPI_cn_assisted_ran_para_parseFromJSON(cJSON OpenAPI_cn_assisted_ran_para_t *cn_assisted_ran_para_local_var = NULL; cJSON *stationary_indication = cJSON_GetObjectItemCaseSensitive(cn_assisted_ran_paraJSON, "stationaryIndication"); - OpenAPI_stationary_indication_t *stationary_indication_local_nonprim = NULL; + OpenAPI_stationary_indication_e stationary_indicationVariable; if (stationary_indication) { - stationary_indication_local_nonprim = OpenAPI_stationary_indication_parseFromJSON(stationary_indication); + if (!cJSON_IsString(stationary_indication)) { + ogs_error("OpenAPI_cn_assisted_ran_para_parseFromJSON() failed [stationary_indication]"); + goto end; + } + stationary_indicationVariable = OpenAPI_stationary_indication_FromString(stationary_indication->valuestring); } cJSON *communication_duration_time = cJSON_GetObjectItemCaseSensitive(cn_assisted_ran_paraJSON, "communicationDurationTime"); @@ -173,16 +156,24 @@ OpenAPI_cn_assisted_ran_para_t *OpenAPI_cn_assisted_ran_para_parseFromJSON(cJSON cJSON *scheduled_communication_type = cJSON_GetObjectItemCaseSensitive(cn_assisted_ran_paraJSON, "scheduledCommunicationType"); - OpenAPI_scheduled_communication_type_t *scheduled_communication_type_local_nonprim = NULL; + OpenAPI_scheduled_communication_type_e scheduled_communication_typeVariable; if (scheduled_communication_type) { - scheduled_communication_type_local_nonprim = OpenAPI_scheduled_communication_type_parseFromJSON(scheduled_communication_type); + if (!cJSON_IsString(scheduled_communication_type)) { + ogs_error("OpenAPI_cn_assisted_ran_para_parseFromJSON() failed [scheduled_communication_type]"); + goto end; + } + scheduled_communication_typeVariable = OpenAPI_scheduled_communication_type_FromString(scheduled_communication_type->valuestring); } cJSON *traffic_profile = cJSON_GetObjectItemCaseSensitive(cn_assisted_ran_paraJSON, "trafficProfile"); - OpenAPI_traffic_profile_t *traffic_profile_local_nonprim = NULL; + OpenAPI_traffic_profile_e traffic_profileVariable; if (traffic_profile) { - traffic_profile_local_nonprim = OpenAPI_traffic_profile_parseFromJSON(traffic_profile); + if (!cJSON_IsString(traffic_profile)) { + ogs_error("OpenAPI_cn_assisted_ran_para_parseFromJSON() failed [traffic_profile]"); + goto end; + } + traffic_profileVariable = OpenAPI_traffic_profile_FromString(traffic_profile->valuestring); } cJSON *battery_indication = cJSON_GetObjectItemCaseSensitive(cn_assisted_ran_paraJSON, "batteryIndication"); @@ -193,12 +184,12 @@ OpenAPI_cn_assisted_ran_para_t *OpenAPI_cn_assisted_ran_para_parseFromJSON(cJSON } cn_assisted_ran_para_local_var = OpenAPI_cn_assisted_ran_para_create ( - stationary_indication ? stationary_indication_local_nonprim : NULL, + stationary_indication ? stationary_indicationVariable : 0, communication_duration_time ? communication_duration_time->valuedouble : 0, periodic_time ? periodic_time->valuedouble : 0, scheduled_communication_time ? scheduled_communication_time_local_nonprim : NULL, - scheduled_communication_type ? scheduled_communication_type_local_nonprim : NULL, - traffic_profile ? traffic_profile_local_nonprim : NULL, + scheduled_communication_type ? scheduled_communication_typeVariable : 0, + traffic_profile ? traffic_profileVariable : 0, battery_indication ? battery_indication_local_nonprim : NULL ); diff --git a/lib/sbi/openapi/model/cn_assisted_ran_para.h b/lib/sbi/openapi/model/cn_assisted_ran_para.h index 670eed104..c316f62a3 100644 --- a/lib/sbi/openapi/model/cn_assisted_ran_para.h +++ b/lib/sbi/openapi/model/cn_assisted_ran_para.h @@ -24,22 +24,22 @@ extern "C" { typedef struct OpenAPI_cn_assisted_ran_para_s OpenAPI_cn_assisted_ran_para_t; typedef struct OpenAPI_cn_assisted_ran_para_s { - struct OpenAPI_stationary_indication_s *stationary_indication; + OpenAPI_stationary_indication_e stationary_indication; int communication_duration_time; int periodic_time; struct OpenAPI_scheduled_communication_time_s *scheduled_communication_time; - struct OpenAPI_scheduled_communication_type_s *scheduled_communication_type; - struct OpenAPI_traffic_profile_s *traffic_profile; + OpenAPI_scheduled_communication_type_e scheduled_communication_type; + OpenAPI_traffic_profile_e traffic_profile; struct OpenAPI_battery_indication_s *battery_indication; } OpenAPI_cn_assisted_ran_para_t; OpenAPI_cn_assisted_ran_para_t *OpenAPI_cn_assisted_ran_para_create( - OpenAPI_stationary_indication_t *stationary_indication, + OpenAPI_stationary_indication_e stationary_indication, int communication_duration_time, int periodic_time, OpenAPI_scheduled_communication_time_t *scheduled_communication_time, - OpenAPI_scheduled_communication_type_t *scheduled_communication_type, - OpenAPI_traffic_profile_t *traffic_profile, + OpenAPI_scheduled_communication_type_e scheduled_communication_type, + OpenAPI_traffic_profile_e traffic_profile, OpenAPI_battery_indication_t *battery_indication ); void OpenAPI_cn_assisted_ran_para_free(OpenAPI_cn_assisted_ran_para_t *cn_assisted_ran_para); diff --git a/lib/sbi/openapi/model/condition_data.c b/lib/sbi/openapi/model/condition_data.c new file mode 100644 index 000000000..1afbeae1b --- /dev/null +++ b/lib/sbi/openapi/model/condition_data.c @@ -0,0 +1,192 @@ + +#include +#include +#include +#include "condition_data.h" + +OpenAPI_condition_data_t *OpenAPI_condition_data_create( + char *cond_id, + char *activation_time, + char *deactivation_time, + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type + ) +{ + OpenAPI_condition_data_t *condition_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_condition_data_t)); + if (!condition_data_local_var) { + return NULL; + } + condition_data_local_var->cond_id = cond_id; + condition_data_local_var->activation_time = activation_time; + condition_data_local_var->deactivation_time = deactivation_time; + condition_data_local_var->access_type = access_type; + condition_data_local_var->rat_type = rat_type; + + return condition_data_local_var; +} + +void OpenAPI_condition_data_free(OpenAPI_condition_data_t *condition_data) +{ + if (NULL == condition_data) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(condition_data->cond_id); + ogs_free(condition_data->activation_time); + ogs_free(condition_data->deactivation_time); + ogs_free(condition_data); +} + +cJSON *OpenAPI_condition_data_convertToJSON(OpenAPI_condition_data_t *condition_data) +{ + cJSON *item = NULL; + + if (condition_data == NULL) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed [ConditionData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!condition_data->cond_id) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed [cond_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "condId", condition_data->cond_id) == NULL) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed [cond_id]"); + goto end; + } + + if (condition_data->activation_time) { + if (cJSON_AddStringToObject(item, "activationTime", condition_data->activation_time) == NULL) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed [activation_time]"); + goto end; + } + } + + if (condition_data->deactivation_time) { + if (cJSON_AddStringToObject(item, "deactivationTime", condition_data->deactivation_time) == NULL) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed [deactivation_time]"); + goto end; + } + } + + if (condition_data->access_type) { + if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(condition_data->access_type)) == NULL) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed [access_type]"); + goto end; + } + } + + if (condition_data->rat_type) { + if (cJSON_AddStringToObject(item, "ratType", OpenAPI_rat_type_ToString(condition_data->rat_type)) == NULL) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed [rat_type]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_condition_data_t *OpenAPI_condition_data_parseFromJSON(cJSON *condition_dataJSON) +{ + OpenAPI_condition_data_t *condition_data_local_var = NULL; + cJSON *cond_id = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "condId"); + if (!cond_id) { + ogs_error("OpenAPI_condition_data_parseFromJSON() failed [cond_id]"); + goto end; + } + + + if (!cJSON_IsString(cond_id)) { + ogs_error("OpenAPI_condition_data_parseFromJSON() failed [cond_id]"); + goto end; + } + + cJSON *activation_time = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "activationTime"); + + if (activation_time) { + if (!cJSON_IsString(activation_time)) { + ogs_error("OpenAPI_condition_data_parseFromJSON() failed [activation_time]"); + goto end; + } + } + + cJSON *deactivation_time = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "deactivationTime"); + + if (deactivation_time) { + if (!cJSON_IsString(deactivation_time)) { + ogs_error("OpenAPI_condition_data_parseFromJSON() failed [deactivation_time]"); + goto end; + } + } + + cJSON *access_type = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "accessType"); + + OpenAPI_access_type_e access_typeVariable; + if (access_type) { + if (!cJSON_IsString(access_type)) { + ogs_error("OpenAPI_condition_data_parseFromJSON() failed [access_type]"); + goto end; + } + access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring); + } + + cJSON *rat_type = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "ratType"); + + OpenAPI_rat_type_e rat_typeVariable; + if (rat_type) { + if (!cJSON_IsString(rat_type)) { + ogs_error("OpenAPI_condition_data_parseFromJSON() failed [rat_type]"); + goto end; + } + rat_typeVariable = OpenAPI_rat_type_FromString(rat_type->valuestring); + } + + condition_data_local_var = OpenAPI_condition_data_create ( + ogs_strdup(cond_id->valuestring), + activation_time ? ogs_strdup(activation_time->valuestring) : NULL, + deactivation_time ? ogs_strdup(deactivation_time->valuestring) : NULL, + access_type ? access_typeVariable : 0, + rat_type ? rat_typeVariable : 0 + ); + + return condition_data_local_var; +end: + return NULL; +} + +OpenAPI_condition_data_t *OpenAPI_condition_data_copy(OpenAPI_condition_data_t *dst, OpenAPI_condition_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_condition_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_condition_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_condition_data_free(dst); + dst = OpenAPI_condition_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/condition_data.h b/lib/sbi/openapi/model/condition_data.h new file mode 100644 index 000000000..3bd81d05b --- /dev/null +++ b/lib/sbi/openapi/model/condition_data.h @@ -0,0 +1,48 @@ +/* + * condition_data.h + * + * + */ + +#ifndef _OpenAPI_condition_data_H_ +#define _OpenAPI_condition_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "access_type.h" +#include "rat_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_condition_data_s OpenAPI_condition_data_t; +typedef struct OpenAPI_condition_data_s { + char *cond_id; + char *activation_time; + char *deactivation_time; + OpenAPI_access_type_e access_type; + OpenAPI_rat_type_e rat_type; +} OpenAPI_condition_data_t; + +OpenAPI_condition_data_t *OpenAPI_condition_data_create( + char *cond_id, + char *activation_time, + char *deactivation_time, + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type + ); +void OpenAPI_condition_data_free(OpenAPI_condition_data_t *condition_data); +OpenAPI_condition_data_t *OpenAPI_condition_data_parseFromJSON(cJSON *condition_dataJSON); +cJSON *OpenAPI_condition_data_convertToJSON(OpenAPI_condition_data_t *condition_data); +OpenAPI_condition_data_t *OpenAPI_condition_data_copy(OpenAPI_condition_data_t *dst, OpenAPI_condition_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_condition_data_H_ */ + diff --git a/lib/sbi/openapi/model/core_network_type.c b/lib/sbi/openapi/model/core_network_type.c index 9c6a64dd5..b1ea85ca4 100644 --- a/lib/sbi/openapi/model/core_network_type.c +++ b/lib/sbi/openapi/model/core_network_type.c @@ -4,82 +4,27 @@ #include #include "core_network_type.h" -OpenAPI_core_network_type_t *OpenAPI_core_network_type_create( - ) +char* OpenAPI_core_network_type_ToString(OpenAPI_core_network_type_e core_network_type) { - OpenAPI_core_network_type_t *core_network_type_local_var = OpenAPI_malloc(sizeof(OpenAPI_core_network_type_t)); - if (!core_network_type_local_var) { - return NULL; - } - - return core_network_type_local_var; + const char *core_network_typeArray[] = { "NULL", "_5GC", "EPC" }; + size_t sizeofArray = sizeof(core_network_typeArray) / sizeof(core_network_typeArray[0]); + if (core_network_type < sizeofArray) + return (char *)core_network_typeArray[core_network_type]; + else + return (char *)"Unknown"; } -void OpenAPI_core_network_type_free(OpenAPI_core_network_type_t *core_network_type) +OpenAPI_core_network_type_e OpenAPI_core_network_type_FromString(char* core_network_type) { - if (NULL == core_network_type) { - return; + int stringToReturn = 0; + const char *core_network_typeArray[] = { "NULL", "_5GC", "EPC" }; + size_t sizeofArray = sizeof(core_network_typeArray) / sizeof(core_network_typeArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(core_network_type, core_network_typeArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; } - OpenAPI_lnode_t *node; - ogs_free(core_network_type); -} - -cJSON *OpenAPI_core_network_type_convertToJSON(OpenAPI_core_network_type_t *core_network_type) -{ - cJSON *item = NULL; - - if (core_network_type == NULL) { - ogs_error("OpenAPI_core_network_type_convertToJSON() failed [CoreNetworkType]"); - return NULL; - } - - item = cJSON_CreateObject(); -end: - return item; -} - -OpenAPI_core_network_type_t *OpenAPI_core_network_type_parseFromJSON(cJSON *core_network_typeJSON) -{ - OpenAPI_core_network_type_t *core_network_type_local_var = NULL; - core_network_type_local_var = OpenAPI_core_network_type_create ( - ); - - return core_network_type_local_var; -end: - return NULL; -} - -OpenAPI_core_network_type_t *OpenAPI_core_network_type_copy(OpenAPI_core_network_type_t *dst, OpenAPI_core_network_type_t *src) -{ - cJSON *item = NULL; - char *content = NULL; - - ogs_assert(src); - item = OpenAPI_core_network_type_convertToJSON(src); - if (!item) { - ogs_error("OpenAPI_core_network_type_convertToJSON() failed"); - return NULL; - } - - content = cJSON_Print(item); - cJSON_Delete(item); - - if (!content) { - ogs_error("cJSON_Print() failed"); - return NULL; - } - - item = cJSON_Parse(content); - ogs_free(content); - if (!item) { - ogs_error("cJSON_Parse() failed"); - return NULL; - } - - OpenAPI_core_network_type_free(dst); - dst = OpenAPI_core_network_type_parseFromJSON(item); - cJSON_Delete(item); - - return dst; + return 0; } diff --git a/lib/sbi/openapi/model/core_network_type.h b/lib/sbi/openapi/model/core_network_type.h index 5c5f2275a..b1329894e 100644 --- a/lib/sbi/openapi/model/core_network_type.h +++ b/lib/sbi/openapi/model/core_network_type.h @@ -17,16 +17,11 @@ extern "C" { #endif -typedef struct OpenAPI_core_network_type_s OpenAPI_core_network_type_t; -typedef struct OpenAPI_core_network_type_s { -} OpenAPI_core_network_type_t; +typedef enum { OpenAPI_core_network_type_NULL = 0, OpenAPI_core_network_type__5GC, OpenAPI_core_network_type_EPC } OpenAPI_core_network_type_e; -OpenAPI_core_network_type_t *OpenAPI_core_network_type_create( - ); -void OpenAPI_core_network_type_free(OpenAPI_core_network_type_t *core_network_type); -OpenAPI_core_network_type_t *OpenAPI_core_network_type_parseFromJSON(cJSON *core_network_typeJSON); -cJSON *OpenAPI_core_network_type_convertToJSON(OpenAPI_core_network_type_t *core_network_type); -OpenAPI_core_network_type_t *OpenAPI_core_network_type_copy(OpenAPI_core_network_type_t *dst, OpenAPI_core_network_type_t *src); +char* OpenAPI_core_network_type_ToString(OpenAPI_core_network_type_e core_network_type); + +OpenAPI_core_network_type_e OpenAPI_core_network_type_FromString(char* core_network_type); #ifdef __cplusplus } diff --git a/lib/sbi/openapi/model/credit_management_status.c b/lib/sbi/openapi/model/credit_management_status.c new file mode 100644 index 000000000..a3680ba8b --- /dev/null +++ b/lib/sbi/openapi/model/credit_management_status.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "credit_management_status.h" + +OpenAPI_credit_management_status_t *OpenAPI_credit_management_status_create( + ) +{ + OpenAPI_credit_management_status_t *credit_management_status_local_var = OpenAPI_malloc(sizeof(OpenAPI_credit_management_status_t)); + if (!credit_management_status_local_var) { + return NULL; + } + + return credit_management_status_local_var; +} + +void OpenAPI_credit_management_status_free(OpenAPI_credit_management_status_t *credit_management_status) +{ + if (NULL == credit_management_status) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(credit_management_status); +} + +cJSON *OpenAPI_credit_management_status_convertToJSON(OpenAPI_credit_management_status_t *credit_management_status) +{ + cJSON *item = NULL; + + if (credit_management_status == NULL) { + ogs_error("OpenAPI_credit_management_status_convertToJSON() failed [CreditManagementStatus]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_credit_management_status_t *OpenAPI_credit_management_status_parseFromJSON(cJSON *credit_management_statusJSON) +{ + OpenAPI_credit_management_status_t *credit_management_status_local_var = NULL; + credit_management_status_local_var = OpenAPI_credit_management_status_create ( + ); + + return credit_management_status_local_var; +end: + return NULL; +} + +OpenAPI_credit_management_status_t *OpenAPI_credit_management_status_copy(OpenAPI_credit_management_status_t *dst, OpenAPI_credit_management_status_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_credit_management_status_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_credit_management_status_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_credit_management_status_free(dst); + dst = OpenAPI_credit_management_status_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/credit_management_status.h b/lib/sbi/openapi/model/credit_management_status.h new file mode 100644 index 000000000..bdddb0a51 --- /dev/null +++ b/lib/sbi/openapi/model/credit_management_status.h @@ -0,0 +1,36 @@ +/* + * credit_management_status.h + * + * + */ + +#ifndef _OpenAPI_credit_management_status_H_ +#define _OpenAPI_credit_management_status_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_credit_management_status_s OpenAPI_credit_management_status_t; +typedef struct OpenAPI_credit_management_status_s { +} OpenAPI_credit_management_status_t; + +OpenAPI_credit_management_status_t *OpenAPI_credit_management_status_create( + ); +void OpenAPI_credit_management_status_free(OpenAPI_credit_management_status_t *credit_management_status); +OpenAPI_credit_management_status_t *OpenAPI_credit_management_status_parseFromJSON(cJSON *credit_management_statusJSON); +cJSON *OpenAPI_credit_management_status_convertToJSON(OpenAPI_credit_management_status_t *credit_management_status); +OpenAPI_credit_management_status_t *OpenAPI_credit_management_status_copy(OpenAPI_credit_management_status_t *dst, OpenAPI_credit_management_status_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_credit_management_status_H_ */ + diff --git a/lib/sbi/openapi/model/error_report.c b/lib/sbi/openapi/model/error_report.c new file mode 100644 index 000000000..161895a1c --- /dev/null +++ b/lib/sbi/openapi/model/error_report.c @@ -0,0 +1,209 @@ + +#include +#include +#include +#include "error_report.h" + +OpenAPI_error_report_t *OpenAPI_error_report_create( + OpenAPI_problem_details_t *error, + OpenAPI_list_t *rule_reports, + OpenAPI_list_t *sess_rule_reports + ) +{ + OpenAPI_error_report_t *error_report_local_var = OpenAPI_malloc(sizeof(OpenAPI_error_report_t)); + if (!error_report_local_var) { + return NULL; + } + error_report_local_var->error = error; + error_report_local_var->rule_reports = rule_reports; + error_report_local_var->sess_rule_reports = sess_rule_reports; + + return error_report_local_var; +} + +void OpenAPI_error_report_free(OpenAPI_error_report_t *error_report) +{ + if (NULL == error_report) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_problem_details_free(error_report->error); + OpenAPI_list_for_each(error_report->rule_reports, node) { + OpenAPI_rule_report_free(node->data); + } + OpenAPI_list_free(error_report->rule_reports); + OpenAPI_list_for_each(error_report->sess_rule_reports, node) { + OpenAPI_session_rule_report_free(node->data); + } + OpenAPI_list_free(error_report->sess_rule_reports); + ogs_free(error_report); +} + +cJSON *OpenAPI_error_report_convertToJSON(OpenAPI_error_report_t *error_report) +{ + cJSON *item = NULL; + + if (error_report == NULL) { + ogs_error("OpenAPI_error_report_convertToJSON() failed [ErrorReport]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (error_report->error) { + cJSON *error_local_JSON = OpenAPI_problem_details_convertToJSON(error_report->error); + if (error_local_JSON == NULL) { + ogs_error("OpenAPI_error_report_convertToJSON() failed [error]"); + goto end; + } + cJSON_AddItemToObject(item, "error", error_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_error_report_convertToJSON() failed [error]"); + goto end; + } + } + + if (error_report->rule_reports) { + cJSON *rule_reportsList = cJSON_AddArrayToObject(item, "ruleReports"); + if (rule_reportsList == NULL) { + ogs_error("OpenAPI_error_report_convertToJSON() failed [rule_reports]"); + goto end; + } + + OpenAPI_lnode_t *rule_reports_node; + if (error_report->rule_reports) { + OpenAPI_list_for_each(error_report->rule_reports, rule_reports_node) { + cJSON *itemLocal = OpenAPI_rule_report_convertToJSON(rule_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_error_report_convertToJSON() failed [rule_reports]"); + goto end; + } + cJSON_AddItemToArray(rule_reportsList, itemLocal); + } + } + } + + if (error_report->sess_rule_reports) { + cJSON *sess_rule_reportsList = cJSON_AddArrayToObject(item, "sessRuleReports"); + if (sess_rule_reportsList == NULL) { + ogs_error("OpenAPI_error_report_convertToJSON() failed [sess_rule_reports]"); + goto end; + } + + OpenAPI_lnode_t *sess_rule_reports_node; + if (error_report->sess_rule_reports) { + OpenAPI_list_for_each(error_report->sess_rule_reports, sess_rule_reports_node) { + cJSON *itemLocal = OpenAPI_session_rule_report_convertToJSON(sess_rule_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_error_report_convertToJSON() failed [sess_rule_reports]"); + goto end; + } + cJSON_AddItemToArray(sess_rule_reportsList, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_error_report_t *OpenAPI_error_report_parseFromJSON(cJSON *error_reportJSON) +{ + OpenAPI_error_report_t *error_report_local_var = NULL; + cJSON *error = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "error"); + + OpenAPI_problem_details_t *error_local_nonprim = NULL; + if (error) { + error_local_nonprim = OpenAPI_problem_details_parseFromJSON(error); + } + + cJSON *rule_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "ruleReports"); + + OpenAPI_list_t *rule_reportsList; + if (rule_reports) { + cJSON *rule_reports_local_nonprimitive; + if (!cJSON_IsArray(rule_reports)) { + ogs_error("OpenAPI_error_report_parseFromJSON() failed [rule_reports]"); + goto end; + } + + rule_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rule_reports_local_nonprimitive, rule_reports ) { + if (!cJSON_IsObject(rule_reports_local_nonprimitive)) { + ogs_error("OpenAPI_error_report_parseFromJSON() failed [rule_reports]"); + goto end; + } + OpenAPI_rule_report_t *rule_reportsItem = OpenAPI_rule_report_parseFromJSON(rule_reports_local_nonprimitive); + + OpenAPI_list_add(rule_reportsList, rule_reportsItem); + } + } + + cJSON *sess_rule_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "sessRuleReports"); + + OpenAPI_list_t *sess_rule_reportsList; + if (sess_rule_reports) { + cJSON *sess_rule_reports_local_nonprimitive; + if (!cJSON_IsArray(sess_rule_reports)) { + ogs_error("OpenAPI_error_report_parseFromJSON() failed [sess_rule_reports]"); + goto end; + } + + sess_rule_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(sess_rule_reports_local_nonprimitive, sess_rule_reports ) { + if (!cJSON_IsObject(sess_rule_reports_local_nonprimitive)) { + ogs_error("OpenAPI_error_report_parseFromJSON() failed [sess_rule_reports]"); + goto end; + } + OpenAPI_session_rule_report_t *sess_rule_reportsItem = OpenAPI_session_rule_report_parseFromJSON(sess_rule_reports_local_nonprimitive); + + OpenAPI_list_add(sess_rule_reportsList, sess_rule_reportsItem); + } + } + + error_report_local_var = OpenAPI_error_report_create ( + error ? error_local_nonprim : NULL, + rule_reports ? rule_reportsList : NULL, + sess_rule_reports ? sess_rule_reportsList : NULL + ); + + return error_report_local_var; +end: + return NULL; +} + +OpenAPI_error_report_t *OpenAPI_error_report_copy(OpenAPI_error_report_t *dst, OpenAPI_error_report_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_error_report_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_error_report_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_error_report_free(dst); + dst = OpenAPI_error_report_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/error_report.h b/lib/sbi/openapi/model/error_report.h new file mode 100644 index 000000000..0fd986fb0 --- /dev/null +++ b/lib/sbi/openapi/model/error_report.h @@ -0,0 +1,45 @@ +/* + * error_report.h + * + * + */ + +#ifndef _OpenAPI_error_report_H_ +#define _OpenAPI_error_report_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "problem_details.h" +#include "rule_report.h" +#include "session_rule_report.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_error_report_s OpenAPI_error_report_t; +typedef struct OpenAPI_error_report_s { + struct OpenAPI_problem_details_s *error; + OpenAPI_list_t *rule_reports; + OpenAPI_list_t *sess_rule_reports; +} OpenAPI_error_report_t; + +OpenAPI_error_report_t *OpenAPI_error_report_create( + OpenAPI_problem_details_t *error, + OpenAPI_list_t *rule_reports, + OpenAPI_list_t *sess_rule_reports + ); +void OpenAPI_error_report_free(OpenAPI_error_report_t *error_report); +OpenAPI_error_report_t *OpenAPI_error_report_parseFromJSON(cJSON *error_reportJSON); +cJSON *OpenAPI_error_report_convertToJSON(OpenAPI_error_report_t *error_report); +OpenAPI_error_report_t *OpenAPI_error_report_copy(OpenAPI_error_report_t *dst, OpenAPI_error_report_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_error_report_H_ */ + diff --git a/lib/sbi/openapi/model/expected_ue_behaviour_data.c b/lib/sbi/openapi/model/expected_ue_behaviour_data.c index 25295c053..677418b4c 100644 --- a/lib/sbi/openapi/model/expected_ue_behaviour_data.c +++ b/lib/sbi/openapi/model/expected_ue_behaviour_data.c @@ -5,13 +5,13 @@ #include "expected_ue_behaviour_data.h" OpenAPI_expected_ue_behaviour_data_t *OpenAPI_expected_ue_behaviour_data_create( - OpenAPI_stationary_indication_t *stationary_indication, + OpenAPI_stationary_indication_e stationary_indication, int communication_duration_time, int periodic_time, OpenAPI_scheduled_communication_time_t *scheduled_communication_time, - OpenAPI_scheduled_communication_type_t *scheduled_communication_type, + OpenAPI_scheduled_communication_type_e scheduled_communication_type, OpenAPI_list_t *expected_umts, - OpenAPI_traffic_profile_t *traffic_profile, + OpenAPI_traffic_profile_e traffic_profile, OpenAPI_battery_indication_t *battery_indication, char *validity_time ) @@ -39,14 +39,11 @@ void OpenAPI_expected_ue_behaviour_data_free(OpenAPI_expected_ue_behaviour_data_ return; } OpenAPI_lnode_t *node; - OpenAPI_stationary_indication_free(expected_ue_behaviour_data->stationary_indication); OpenAPI_scheduled_communication_time_free(expected_ue_behaviour_data->scheduled_communication_time); - OpenAPI_scheduled_communication_type_free(expected_ue_behaviour_data->scheduled_communication_type); OpenAPI_list_for_each(expected_ue_behaviour_data->expected_umts, node) { OpenAPI_location_area_free(node->data); } OpenAPI_list_free(expected_ue_behaviour_data->expected_umts); - OpenAPI_traffic_profile_free(expected_ue_behaviour_data->traffic_profile); OpenAPI_battery_indication_free(expected_ue_behaviour_data->battery_indication); ogs_free(expected_ue_behaviour_data->validity_time); ogs_free(expected_ue_behaviour_data); @@ -63,13 +60,7 @@ cJSON *OpenAPI_expected_ue_behaviour_data_convertToJSON(OpenAPI_expected_ue_beha item = cJSON_CreateObject(); if (expected_ue_behaviour_data->stationary_indication) { - cJSON *stationary_indication_local_JSON = OpenAPI_stationary_indication_convertToJSON(expected_ue_behaviour_data->stationary_indication); - if (stationary_indication_local_JSON == NULL) { - ogs_error("OpenAPI_expected_ue_behaviour_data_convertToJSON() failed [stationary_indication]"); - goto end; - } - cJSON_AddItemToObject(item, "stationaryIndication", stationary_indication_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "stationaryIndication", OpenAPI_stationary_indication_ToString(expected_ue_behaviour_data->stationary_indication)) == NULL) { ogs_error("OpenAPI_expected_ue_behaviour_data_convertToJSON() failed [stationary_indication]"); goto end; } @@ -103,13 +94,7 @@ cJSON *OpenAPI_expected_ue_behaviour_data_convertToJSON(OpenAPI_expected_ue_beha } if (expected_ue_behaviour_data->scheduled_communication_type) { - cJSON *scheduled_communication_type_local_JSON = OpenAPI_scheduled_communication_type_convertToJSON(expected_ue_behaviour_data->scheduled_communication_type); - if (scheduled_communication_type_local_JSON == NULL) { - ogs_error("OpenAPI_expected_ue_behaviour_data_convertToJSON() failed [scheduled_communication_type]"); - goto end; - } - cJSON_AddItemToObject(item, "scheduledCommunicationType", scheduled_communication_type_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "scheduledCommunicationType", OpenAPI_scheduled_communication_type_ToString(expected_ue_behaviour_data->scheduled_communication_type)) == NULL) { ogs_error("OpenAPI_expected_ue_behaviour_data_convertToJSON() failed [scheduled_communication_type]"); goto end; } @@ -136,13 +121,7 @@ cJSON *OpenAPI_expected_ue_behaviour_data_convertToJSON(OpenAPI_expected_ue_beha } if (expected_ue_behaviour_data->traffic_profile) { - cJSON *traffic_profile_local_JSON = OpenAPI_traffic_profile_convertToJSON(expected_ue_behaviour_data->traffic_profile); - if (traffic_profile_local_JSON == NULL) { - ogs_error("OpenAPI_expected_ue_behaviour_data_convertToJSON() failed [traffic_profile]"); - goto end; - } - cJSON_AddItemToObject(item, "trafficProfile", traffic_profile_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "trafficProfile", OpenAPI_traffic_profile_ToString(expected_ue_behaviour_data->traffic_profile)) == NULL) { ogs_error("OpenAPI_expected_ue_behaviour_data_convertToJSON() failed [traffic_profile]"); goto end; } @@ -177,9 +156,13 @@ OpenAPI_expected_ue_behaviour_data_t *OpenAPI_expected_ue_behaviour_data_parseFr OpenAPI_expected_ue_behaviour_data_t *expected_ue_behaviour_data_local_var = NULL; cJSON *stationary_indication = cJSON_GetObjectItemCaseSensitive(expected_ue_behaviour_dataJSON, "stationaryIndication"); - OpenAPI_stationary_indication_t *stationary_indication_local_nonprim = NULL; + OpenAPI_stationary_indication_e stationary_indicationVariable; if (stationary_indication) { - stationary_indication_local_nonprim = OpenAPI_stationary_indication_parseFromJSON(stationary_indication); + if (!cJSON_IsString(stationary_indication)) { + ogs_error("OpenAPI_expected_ue_behaviour_data_parseFromJSON() failed [stationary_indication]"); + goto end; + } + stationary_indicationVariable = OpenAPI_stationary_indication_FromString(stationary_indication->valuestring); } cJSON *communication_duration_time = cJSON_GetObjectItemCaseSensitive(expected_ue_behaviour_dataJSON, "communicationDurationTime"); @@ -209,9 +192,13 @@ OpenAPI_expected_ue_behaviour_data_t *OpenAPI_expected_ue_behaviour_data_parseFr cJSON *scheduled_communication_type = cJSON_GetObjectItemCaseSensitive(expected_ue_behaviour_dataJSON, "scheduledCommunicationType"); - OpenAPI_scheduled_communication_type_t *scheduled_communication_type_local_nonprim = NULL; + OpenAPI_scheduled_communication_type_e scheduled_communication_typeVariable; if (scheduled_communication_type) { - scheduled_communication_type_local_nonprim = OpenAPI_scheduled_communication_type_parseFromJSON(scheduled_communication_type); + if (!cJSON_IsString(scheduled_communication_type)) { + ogs_error("OpenAPI_expected_ue_behaviour_data_parseFromJSON() failed [scheduled_communication_type]"); + goto end; + } + scheduled_communication_typeVariable = OpenAPI_scheduled_communication_type_FromString(scheduled_communication_type->valuestring); } cJSON *expected_umts = cJSON_GetObjectItemCaseSensitive(expected_ue_behaviour_dataJSON, "expectedUmts"); @@ -239,9 +226,13 @@ OpenAPI_expected_ue_behaviour_data_t *OpenAPI_expected_ue_behaviour_data_parseFr cJSON *traffic_profile = cJSON_GetObjectItemCaseSensitive(expected_ue_behaviour_dataJSON, "trafficProfile"); - OpenAPI_traffic_profile_t *traffic_profile_local_nonprim = NULL; + OpenAPI_traffic_profile_e traffic_profileVariable; if (traffic_profile) { - traffic_profile_local_nonprim = OpenAPI_traffic_profile_parseFromJSON(traffic_profile); + if (!cJSON_IsString(traffic_profile)) { + ogs_error("OpenAPI_expected_ue_behaviour_data_parseFromJSON() failed [traffic_profile]"); + goto end; + } + traffic_profileVariable = OpenAPI_traffic_profile_FromString(traffic_profile->valuestring); } cJSON *battery_indication = cJSON_GetObjectItemCaseSensitive(expected_ue_behaviour_dataJSON, "batteryIndication"); @@ -261,13 +252,13 @@ OpenAPI_expected_ue_behaviour_data_t *OpenAPI_expected_ue_behaviour_data_parseFr } expected_ue_behaviour_data_local_var = OpenAPI_expected_ue_behaviour_data_create ( - stationary_indication ? stationary_indication_local_nonprim : NULL, + stationary_indication ? stationary_indicationVariable : 0, communication_duration_time ? communication_duration_time->valuedouble : 0, periodic_time ? periodic_time->valuedouble : 0, scheduled_communication_time ? scheduled_communication_time_local_nonprim : NULL, - scheduled_communication_type ? scheduled_communication_type_local_nonprim : NULL, + scheduled_communication_type ? scheduled_communication_typeVariable : 0, expected_umts ? expected_umtsList : NULL, - traffic_profile ? traffic_profile_local_nonprim : NULL, + traffic_profile ? traffic_profileVariable : 0, battery_indication ? battery_indication_local_nonprim : NULL, validity_time ? ogs_strdup(validity_time->valuestring) : NULL ); diff --git a/lib/sbi/openapi/model/expected_ue_behaviour_data.h b/lib/sbi/openapi/model/expected_ue_behaviour_data.h index 13f113241..e7d804699 100644 --- a/lib/sbi/openapi/model/expected_ue_behaviour_data.h +++ b/lib/sbi/openapi/model/expected_ue_behaviour_data.h @@ -25,25 +25,25 @@ extern "C" { typedef struct OpenAPI_expected_ue_behaviour_data_s OpenAPI_expected_ue_behaviour_data_t; typedef struct OpenAPI_expected_ue_behaviour_data_s { - struct OpenAPI_stationary_indication_s *stationary_indication; + OpenAPI_stationary_indication_e stationary_indication; int communication_duration_time; int periodic_time; struct OpenAPI_scheduled_communication_time_s *scheduled_communication_time; - struct OpenAPI_scheduled_communication_type_s *scheduled_communication_type; + OpenAPI_scheduled_communication_type_e scheduled_communication_type; OpenAPI_list_t *expected_umts; - struct OpenAPI_traffic_profile_s *traffic_profile; + OpenAPI_traffic_profile_e traffic_profile; struct OpenAPI_battery_indication_s *battery_indication; char *validity_time; } OpenAPI_expected_ue_behaviour_data_t; OpenAPI_expected_ue_behaviour_data_t *OpenAPI_expected_ue_behaviour_data_create( - OpenAPI_stationary_indication_t *stationary_indication, + OpenAPI_stationary_indication_e stationary_indication, int communication_duration_time, int periodic_time, OpenAPI_scheduled_communication_time_t *scheduled_communication_time, - OpenAPI_scheduled_communication_type_t *scheduled_communication_type, + OpenAPI_scheduled_communication_type_e scheduled_communication_type, OpenAPI_list_t *expected_umts, - OpenAPI_traffic_profile_t *traffic_profile, + OpenAPI_traffic_profile_e traffic_profile, OpenAPI_battery_indication_t *battery_indication, char *validity_time ); diff --git a/lib/sbi/openapi/model/failure_cause.c b/lib/sbi/openapi/model/failure_cause.c new file mode 100644 index 000000000..ab0642242 --- /dev/null +++ b/lib/sbi/openapi/model/failure_cause.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "failure_cause.h" + +OpenAPI_failure_cause_t *OpenAPI_failure_cause_create( + ) +{ + OpenAPI_failure_cause_t *failure_cause_local_var = OpenAPI_malloc(sizeof(OpenAPI_failure_cause_t)); + if (!failure_cause_local_var) { + return NULL; + } + + return failure_cause_local_var; +} + +void OpenAPI_failure_cause_free(OpenAPI_failure_cause_t *failure_cause) +{ + if (NULL == failure_cause) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(failure_cause); +} + +cJSON *OpenAPI_failure_cause_convertToJSON(OpenAPI_failure_cause_t *failure_cause) +{ + cJSON *item = NULL; + + if (failure_cause == NULL) { + ogs_error("OpenAPI_failure_cause_convertToJSON() failed [FailureCause]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_failure_cause_t *OpenAPI_failure_cause_parseFromJSON(cJSON *failure_causeJSON) +{ + OpenAPI_failure_cause_t *failure_cause_local_var = NULL; + failure_cause_local_var = OpenAPI_failure_cause_create ( + ); + + return failure_cause_local_var; +end: + return NULL; +} + +OpenAPI_failure_cause_t *OpenAPI_failure_cause_copy(OpenAPI_failure_cause_t *dst, OpenAPI_failure_cause_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_failure_cause_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_failure_cause_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_failure_cause_free(dst); + dst = OpenAPI_failure_cause_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/failure_cause.h b/lib/sbi/openapi/model/failure_cause.h new file mode 100644 index 000000000..22a3a9aae --- /dev/null +++ b/lib/sbi/openapi/model/failure_cause.h @@ -0,0 +1,36 @@ +/* + * failure_cause.h + * + * + */ + +#ifndef _OpenAPI_failure_cause_H_ +#define _OpenAPI_failure_cause_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_failure_cause_s OpenAPI_failure_cause_t; +typedef struct OpenAPI_failure_cause_s { +} OpenAPI_failure_cause_t; + +OpenAPI_failure_cause_t *OpenAPI_failure_cause_create( + ); +void OpenAPI_failure_cause_free(OpenAPI_failure_cause_t *failure_cause); +OpenAPI_failure_cause_t *OpenAPI_failure_cause_parseFromJSON(cJSON *failure_causeJSON); +cJSON *OpenAPI_failure_cause_convertToJSON(OpenAPI_failure_cause_t *failure_cause); +OpenAPI_failure_cause_t *OpenAPI_failure_cause_copy(OpenAPI_failure_cause_t *dst, OpenAPI_failure_cause_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_failure_cause_H_ */ + diff --git a/lib/sbi/openapi/model/failure_code.c b/lib/sbi/openapi/model/failure_code.c new file mode 100644 index 000000000..10e5d77d9 --- /dev/null +++ b/lib/sbi/openapi/model/failure_code.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "failure_code.h" + +OpenAPI_failure_code_t *OpenAPI_failure_code_create( + ) +{ + OpenAPI_failure_code_t *failure_code_local_var = OpenAPI_malloc(sizeof(OpenAPI_failure_code_t)); + if (!failure_code_local_var) { + return NULL; + } + + return failure_code_local_var; +} + +void OpenAPI_failure_code_free(OpenAPI_failure_code_t *failure_code) +{ + if (NULL == failure_code) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(failure_code); +} + +cJSON *OpenAPI_failure_code_convertToJSON(OpenAPI_failure_code_t *failure_code) +{ + cJSON *item = NULL; + + if (failure_code == NULL) { + ogs_error("OpenAPI_failure_code_convertToJSON() failed [FailureCode]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_failure_code_t *OpenAPI_failure_code_parseFromJSON(cJSON *failure_codeJSON) +{ + OpenAPI_failure_code_t *failure_code_local_var = NULL; + failure_code_local_var = OpenAPI_failure_code_create ( + ); + + return failure_code_local_var; +end: + return NULL; +} + +OpenAPI_failure_code_t *OpenAPI_failure_code_copy(OpenAPI_failure_code_t *dst, OpenAPI_failure_code_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_failure_code_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_failure_code_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_failure_code_free(dst); + dst = OpenAPI_failure_code_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/failure_code.h b/lib/sbi/openapi/model/failure_code.h new file mode 100644 index 000000000..51f847ad0 --- /dev/null +++ b/lib/sbi/openapi/model/failure_code.h @@ -0,0 +1,36 @@ +/* + * failure_code.h + * + * Possible values are - UNK_RULE_ID: Indicates that the pre-provisioned PCC rule could not be successfully activated because the PCC rule identifier is unknown to the SMF. - RA_GR_ERR: Indicate that the PCC rule could not be successfully installed or enforced because the Rating Group specified within the Charging Data policy decision which the PCC rule refers to is unknown or, invalid. - SER_ID_ERR: Indicate that the PCC rule could not be successfully installed or enforced because the Service Identifier specified within the Charging Data policy decision which the PCC rule refers to is invalid, unknown, or not applicable to the service being charged. - NF_MAL: Indicate that the PCC rule could not be successfully installed (for those provisioned from the PCF) or activated (for those pre-defined in SMF) or enforced (for those already successfully installed) due to SMF/UPF malfunction. - RES_LIM: Indicate that the PCC rule could not be successfully installed (for those provisioned from PCF) or activated (for those pre-defined in SMF) or enforced (for those already successfully installed) due to a limitation of resources at the SMF/UPF. - MAX_NR_QoS_FLOW: Indicate that the PCC rule could not be successfully installed (for those provisioned from PCF) or activated (for those pre-defined in SMF) or enforced (for those already successfully installed) due to the fact that the maximum number of QoS flows has been reached for the PDU session. - MISS_FLOW_INFO: Indicate that the PCC rule could not be successfully installed or enforced because neither the \"flowInfos\" attribute nor the \"appId\" attribute is specified within the PccRule data structure by the PCF during the first install request of the PCC rule. - RES_ALLO_FAIL: Indicate that the PCC rule could not be successfully installed or maintained since the QoS flow establishment/modification failed, or the QoS flow was released. - UNSUCC_QOS_VAL: indicate that the QoS validation has failed or when Guaranteed Bandwidth > Max-Requested-Bandwidth. - INCOR_FLOW_INFO: Indicate that the PCC rule could not be successfully installed or modified at the SMF because the provided flow information is not supported by the network (e.g. the provided IP address(es) or Ipv6 prefix(es) do not correspond to an IP version applicable for the PDU session). - PS_TO_CS_HAN: Indicate that the PCC rule could not be maintained because of PS to CS handover. - APP_ID_ERR: Indicate that the rule could not be successfully installed or enforced because the Application Identifier is invalid, unknown, or not applicable to the application required for detection. - NO_QOS_FLOW_BOUND: Indicate that there is no QoS flow which the SMF can bind the PCC rule(s) to. - FILTER_RES: Indicate that the Flow Information within the \"flowInfos\" attribute cannot be handled by the SMF because any of the restrictions defined in subclause 5.4.2 of 3GPP TS 29.212 was not met. - MISS_REDI_SER_ADDR: Indicate that the PCC rule could not be successfully installed or enforced at the SMF because there is no valid Redirect Server Address within the Traffic Control Data policy decision which the PCC rule refers to provided by the PCF and no preconfigured redirection address for this PCC rule at the SMF. - CM_END_USER_SER_DENIED: Indicate that the charging system denied the service request due to service restrictions (e.g. terminate rating group) or limitations related to the end-user, for example the end-user's account could not cover the requested service. - CM_CREDIT_CON_NOT_APP: Indicate that the charging system determined that the service can be granted to the end user but no further credit control is needed for the service (e.g. service is free of charge or is treated for offline charging). - CM_AUTH_REJ: Indicate that the charging system denied the service request in order to terminate the service for which credit is requested. - CM_USER_UNK: Indicate that the specified end user could not be found in the charging system. - CM_RAT_FAILED: Indicate that the charging system cannot rate the service request due to insufficient rating input, incorrect AVP combination or due to an attribute or an attribute value that is not recognized or supported in the rating. - UE_STA_SUSP: Indicates that the UE is in suspend state. + */ + +#ifndef _OpenAPI_failure_code_H_ +#define _OpenAPI_failure_code_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_failure_code_s OpenAPI_failure_code_t; +typedef struct OpenAPI_failure_code_s { +} OpenAPI_failure_code_t; + +OpenAPI_failure_code_t *OpenAPI_failure_code_create( + ); +void OpenAPI_failure_code_free(OpenAPI_failure_code_t *failure_code); +OpenAPI_failure_code_t *OpenAPI_failure_code_parseFromJSON(cJSON *failure_codeJSON); +cJSON *OpenAPI_failure_code_convertToJSON(OpenAPI_failure_code_t *failure_code); +OpenAPI_failure_code_t *OpenAPI_failure_code_copy(OpenAPI_failure_code_t *dst, OpenAPI_failure_code_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_failure_code_H_ */ + diff --git a/lib/sbi/openapi/model/final_unit_action.c b/lib/sbi/openapi/model/final_unit_action.c new file mode 100644 index 000000000..030269000 --- /dev/null +++ b/lib/sbi/openapi/model/final_unit_action.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "final_unit_action.h" + +OpenAPI_final_unit_action_t *OpenAPI_final_unit_action_create( + ) +{ + OpenAPI_final_unit_action_t *final_unit_action_local_var = OpenAPI_malloc(sizeof(OpenAPI_final_unit_action_t)); + if (!final_unit_action_local_var) { + return NULL; + } + + return final_unit_action_local_var; +} + +void OpenAPI_final_unit_action_free(OpenAPI_final_unit_action_t *final_unit_action) +{ + if (NULL == final_unit_action) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(final_unit_action); +} + +cJSON *OpenAPI_final_unit_action_convertToJSON(OpenAPI_final_unit_action_t *final_unit_action) +{ + cJSON *item = NULL; + + if (final_unit_action == NULL) { + ogs_error("OpenAPI_final_unit_action_convertToJSON() failed [FinalUnitAction]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_final_unit_action_t *OpenAPI_final_unit_action_parseFromJSON(cJSON *final_unit_actionJSON) +{ + OpenAPI_final_unit_action_t *final_unit_action_local_var = NULL; + final_unit_action_local_var = OpenAPI_final_unit_action_create ( + ); + + return final_unit_action_local_var; +end: + return NULL; +} + +OpenAPI_final_unit_action_t *OpenAPI_final_unit_action_copy(OpenAPI_final_unit_action_t *dst, OpenAPI_final_unit_action_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_final_unit_action_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_final_unit_action_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_final_unit_action_free(dst); + dst = OpenAPI_final_unit_action_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/final_unit_action.h b/lib/sbi/openapi/model/final_unit_action.h new file mode 100644 index 000000000..33439c922 --- /dev/null +++ b/lib/sbi/openapi/model/final_unit_action.h @@ -0,0 +1,36 @@ +/* + * final_unit_action.h + * + * + */ + +#ifndef _OpenAPI_final_unit_action_H_ +#define _OpenAPI_final_unit_action_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_final_unit_action_s OpenAPI_final_unit_action_t; +typedef struct OpenAPI_final_unit_action_s { +} OpenAPI_final_unit_action_t; + +OpenAPI_final_unit_action_t *OpenAPI_final_unit_action_create( + ); +void OpenAPI_final_unit_action_free(OpenAPI_final_unit_action_t *final_unit_action); +OpenAPI_final_unit_action_t *OpenAPI_final_unit_action_parseFromJSON(cJSON *final_unit_actionJSON); +cJSON *OpenAPI_final_unit_action_convertToJSON(OpenAPI_final_unit_action_t *final_unit_action); +OpenAPI_final_unit_action_t *OpenAPI_final_unit_action_copy(OpenAPI_final_unit_action_t *dst, OpenAPI_final_unit_action_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_final_unit_action_H_ */ + diff --git a/lib/sbi/openapi/model/flow_direction_rm.c b/lib/sbi/openapi/model/flow_direction_rm.c new file mode 100644 index 000000000..82a931baa --- /dev/null +++ b/lib/sbi/openapi/model/flow_direction_rm.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "flow_direction_rm.h" + +OpenAPI_flow_direction_rm_t *OpenAPI_flow_direction_rm_create( + ) +{ + OpenAPI_flow_direction_rm_t *flow_direction_rm_local_var = OpenAPI_malloc(sizeof(OpenAPI_flow_direction_rm_t)); + if (!flow_direction_rm_local_var) { + return NULL; + } + + return flow_direction_rm_local_var; +} + +void OpenAPI_flow_direction_rm_free(OpenAPI_flow_direction_rm_t *flow_direction_rm) +{ + if (NULL == flow_direction_rm) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(flow_direction_rm); +} + +cJSON *OpenAPI_flow_direction_rm_convertToJSON(OpenAPI_flow_direction_rm_t *flow_direction_rm) +{ + cJSON *item = NULL; + + if (flow_direction_rm == NULL) { + ogs_error("OpenAPI_flow_direction_rm_convertToJSON() failed [FlowDirectionRm]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_flow_direction_rm_t *OpenAPI_flow_direction_rm_parseFromJSON(cJSON *flow_direction_rmJSON) +{ + OpenAPI_flow_direction_rm_t *flow_direction_rm_local_var = NULL; + flow_direction_rm_local_var = OpenAPI_flow_direction_rm_create ( + ); + + return flow_direction_rm_local_var; +end: + return NULL; +} + +OpenAPI_flow_direction_rm_t *OpenAPI_flow_direction_rm_copy(OpenAPI_flow_direction_rm_t *dst, OpenAPI_flow_direction_rm_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_flow_direction_rm_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_flow_direction_rm_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_flow_direction_rm_free(dst); + dst = OpenAPI_flow_direction_rm_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/flow_direction_rm.h b/lib/sbi/openapi/model/flow_direction_rm.h new file mode 100644 index 000000000..7dcc933bd --- /dev/null +++ b/lib/sbi/openapi/model/flow_direction_rm.h @@ -0,0 +1,38 @@ +/* + * flow_direction_rm.h + * + * + */ + +#ifndef _OpenAPI_flow_direction_rm_H_ +#define _OpenAPI_flow_direction_rm_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "flow_direction.h" +#include "null_value.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_flow_direction_rm_s OpenAPI_flow_direction_rm_t; +typedef struct OpenAPI_flow_direction_rm_s { +} OpenAPI_flow_direction_rm_t; + +OpenAPI_flow_direction_rm_t *OpenAPI_flow_direction_rm_create( + ); +void OpenAPI_flow_direction_rm_free(OpenAPI_flow_direction_rm_t *flow_direction_rm); +OpenAPI_flow_direction_rm_t *OpenAPI_flow_direction_rm_parseFromJSON(cJSON *flow_direction_rmJSON); +cJSON *OpenAPI_flow_direction_rm_convertToJSON(OpenAPI_flow_direction_rm_t *flow_direction_rm); +OpenAPI_flow_direction_rm_t *OpenAPI_flow_direction_rm_copy(OpenAPI_flow_direction_rm_t *dst, OpenAPI_flow_direction_rm_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_flow_direction_rm_H_ */ + diff --git a/lib/sbi/openapi/model/flow_information.c b/lib/sbi/openapi/model/flow_information.c new file mode 100644 index 000000000..2342e4ca3 --- /dev/null +++ b/lib/sbi/openapi/model/flow_information.c @@ -0,0 +1,252 @@ + +#include +#include +#include +#include "flow_information.h" + +OpenAPI_flow_information_t *OpenAPI_flow_information_create( + char *flow_description, + OpenAPI_eth_flow_description_t *eth_flow_description, + char *pack_filt_id, + int packet_filter_usage, + char *tos_traffic_class, + char *spi, + char *flow_label, + OpenAPI_flow_direction_rm_t *flow_direction + ) +{ + OpenAPI_flow_information_t *flow_information_local_var = OpenAPI_malloc(sizeof(OpenAPI_flow_information_t)); + if (!flow_information_local_var) { + return NULL; + } + flow_information_local_var->flow_description = flow_description; + flow_information_local_var->eth_flow_description = eth_flow_description; + flow_information_local_var->pack_filt_id = pack_filt_id; + flow_information_local_var->packet_filter_usage = packet_filter_usage; + flow_information_local_var->tos_traffic_class = tos_traffic_class; + flow_information_local_var->spi = spi; + flow_information_local_var->flow_label = flow_label; + flow_information_local_var->flow_direction = flow_direction; + + return flow_information_local_var; +} + +void OpenAPI_flow_information_free(OpenAPI_flow_information_t *flow_information) +{ + if (NULL == flow_information) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(flow_information->flow_description); + OpenAPI_eth_flow_description_free(flow_information->eth_flow_description); + ogs_free(flow_information->pack_filt_id); + ogs_free(flow_information->tos_traffic_class); + ogs_free(flow_information->spi); + ogs_free(flow_information->flow_label); + OpenAPI_flow_direction_rm_free(flow_information->flow_direction); + ogs_free(flow_information); +} + +cJSON *OpenAPI_flow_information_convertToJSON(OpenAPI_flow_information_t *flow_information) +{ + cJSON *item = NULL; + + if (flow_information == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [FlowInformation]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (flow_information->flow_description) { + if (cJSON_AddStringToObject(item, "flowDescription", flow_information->flow_description) == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [flow_description]"); + goto end; + } + } + + if (flow_information->eth_flow_description) { + cJSON *eth_flow_description_local_JSON = OpenAPI_eth_flow_description_convertToJSON(flow_information->eth_flow_description); + if (eth_flow_description_local_JSON == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [eth_flow_description]"); + goto end; + } + cJSON_AddItemToObject(item, "ethFlowDescription", eth_flow_description_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [eth_flow_description]"); + goto end; + } + } + + if (flow_information->pack_filt_id) { + if (cJSON_AddStringToObject(item, "packFiltId", flow_information->pack_filt_id) == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [pack_filt_id]"); + goto end; + } + } + + if (flow_information->packet_filter_usage) { + if (cJSON_AddBoolToObject(item, "packetFilterUsage", flow_information->packet_filter_usage) == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [packet_filter_usage]"); + goto end; + } + } + + if (flow_information->tos_traffic_class) { + if (cJSON_AddStringToObject(item, "tosTrafficClass", flow_information->tos_traffic_class) == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [tos_traffic_class]"); + goto end; + } + } + + if (flow_information->spi) { + if (cJSON_AddStringToObject(item, "spi", flow_information->spi) == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [spi]"); + goto end; + } + } + + if (flow_information->flow_label) { + if (cJSON_AddStringToObject(item, "flowLabel", flow_information->flow_label) == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [flow_label]"); + goto end; + } + } + + if (flow_information->flow_direction) { + cJSON *flow_direction_local_JSON = OpenAPI_flow_direction_rm_convertToJSON(flow_information->flow_direction); + if (flow_direction_local_JSON == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [flow_direction]"); + goto end; + } + cJSON_AddItemToObject(item, "flowDirection", flow_direction_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed [flow_direction]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_flow_information_t *OpenAPI_flow_information_parseFromJSON(cJSON *flow_informationJSON) +{ + OpenAPI_flow_information_t *flow_information_local_var = NULL; + cJSON *flow_description = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "flowDescription"); + + if (flow_description) { + if (!cJSON_IsString(flow_description)) { + ogs_error("OpenAPI_flow_information_parseFromJSON() failed [flow_description]"); + goto end; + } + } + + cJSON *eth_flow_description = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "ethFlowDescription"); + + OpenAPI_eth_flow_description_t *eth_flow_description_local_nonprim = NULL; + if (eth_flow_description) { + eth_flow_description_local_nonprim = OpenAPI_eth_flow_description_parseFromJSON(eth_flow_description); + } + + cJSON *pack_filt_id = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "packFiltId"); + + if (pack_filt_id) { + if (!cJSON_IsString(pack_filt_id)) { + ogs_error("OpenAPI_flow_information_parseFromJSON() failed [pack_filt_id]"); + goto end; + } + } + + cJSON *packet_filter_usage = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "packetFilterUsage"); + + if (packet_filter_usage) { + if (!cJSON_IsBool(packet_filter_usage)) { + ogs_error("OpenAPI_flow_information_parseFromJSON() failed [packet_filter_usage]"); + goto end; + } + } + + cJSON *tos_traffic_class = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "tosTrafficClass"); + + if (tos_traffic_class) { + if (!cJSON_IsString(tos_traffic_class)) { + ogs_error("OpenAPI_flow_information_parseFromJSON() failed [tos_traffic_class]"); + goto end; + } + } + + cJSON *spi = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "spi"); + + if (spi) { + if (!cJSON_IsString(spi)) { + ogs_error("OpenAPI_flow_information_parseFromJSON() failed [spi]"); + goto end; + } + } + + cJSON *flow_label = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "flowLabel"); + + if (flow_label) { + if (!cJSON_IsString(flow_label)) { + ogs_error("OpenAPI_flow_information_parseFromJSON() failed [flow_label]"); + goto end; + } + } + + cJSON *flow_direction = cJSON_GetObjectItemCaseSensitive(flow_informationJSON, "flowDirection"); + + OpenAPI_flow_direction_rm_t *flow_direction_local_nonprim = NULL; + if (flow_direction) { + flow_direction_local_nonprim = OpenAPI_flow_direction_rm_parseFromJSON(flow_direction); + } + + flow_information_local_var = OpenAPI_flow_information_create ( + flow_description ? ogs_strdup(flow_description->valuestring) : NULL, + eth_flow_description ? eth_flow_description_local_nonprim : NULL, + pack_filt_id ? ogs_strdup(pack_filt_id->valuestring) : NULL, + packet_filter_usage ? packet_filter_usage->valueint : 0, + tos_traffic_class ? ogs_strdup(tos_traffic_class->valuestring) : NULL, + spi ? ogs_strdup(spi->valuestring) : NULL, + flow_label ? ogs_strdup(flow_label->valuestring) : NULL, + flow_direction ? flow_direction_local_nonprim : NULL + ); + + return flow_information_local_var; +end: + return NULL; +} + +OpenAPI_flow_information_t *OpenAPI_flow_information_copy(OpenAPI_flow_information_t *dst, OpenAPI_flow_information_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_flow_information_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_flow_information_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_flow_information_free(dst); + dst = OpenAPI_flow_information_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/flow_information.h b/lib/sbi/openapi/model/flow_information.h new file mode 100644 index 000000000..003217517 --- /dev/null +++ b/lib/sbi/openapi/model/flow_information.h @@ -0,0 +1,54 @@ +/* + * flow_information.h + * + * + */ + +#ifndef _OpenAPI_flow_information_H_ +#define _OpenAPI_flow_information_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "eth_flow_description.h" +#include "flow_direction_rm.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_flow_information_s OpenAPI_flow_information_t; +typedef struct OpenAPI_flow_information_s { + char *flow_description; + struct OpenAPI_eth_flow_description_s *eth_flow_description; + char *pack_filt_id; + int packet_filter_usage; + char *tos_traffic_class; + char *spi; + char *flow_label; + struct OpenAPI_flow_direction_rm_s *flow_direction; +} OpenAPI_flow_information_t; + +OpenAPI_flow_information_t *OpenAPI_flow_information_create( + char *flow_description, + OpenAPI_eth_flow_description_t *eth_flow_description, + char *pack_filt_id, + int packet_filter_usage, + char *tos_traffic_class, + char *spi, + char *flow_label, + OpenAPI_flow_direction_rm_t *flow_direction + ); +void OpenAPI_flow_information_free(OpenAPI_flow_information_t *flow_information); +OpenAPI_flow_information_t *OpenAPI_flow_information_parseFromJSON(cJSON *flow_informationJSON); +cJSON *OpenAPI_flow_information_convertToJSON(OpenAPI_flow_information_t *flow_information); +OpenAPI_flow_information_t *OpenAPI_flow_information_copy(OpenAPI_flow_information_t *dst, OpenAPI_flow_information_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_flow_information_H_ */ + diff --git a/lib/sbi/openapi/model/flow_status.c b/lib/sbi/openapi/model/flow_status.c new file mode 100644 index 000000000..600253596 --- /dev/null +++ b/lib/sbi/openapi/model/flow_status.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "flow_status.h" + +OpenAPI_flow_status_t *OpenAPI_flow_status_create( + ) +{ + OpenAPI_flow_status_t *flow_status_local_var = OpenAPI_malloc(sizeof(OpenAPI_flow_status_t)); + if (!flow_status_local_var) { + return NULL; + } + + return flow_status_local_var; +} + +void OpenAPI_flow_status_free(OpenAPI_flow_status_t *flow_status) +{ + if (NULL == flow_status) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(flow_status); +} + +cJSON *OpenAPI_flow_status_convertToJSON(OpenAPI_flow_status_t *flow_status) +{ + cJSON *item = NULL; + + if (flow_status == NULL) { + ogs_error("OpenAPI_flow_status_convertToJSON() failed [FlowStatus]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_flow_status_t *OpenAPI_flow_status_parseFromJSON(cJSON *flow_statusJSON) +{ + OpenAPI_flow_status_t *flow_status_local_var = NULL; + flow_status_local_var = OpenAPI_flow_status_create ( + ); + + return flow_status_local_var; +end: + return NULL; +} + +OpenAPI_flow_status_t *OpenAPI_flow_status_copy(OpenAPI_flow_status_t *dst, OpenAPI_flow_status_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_flow_status_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_flow_status_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_flow_status_free(dst); + dst = OpenAPI_flow_status_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/flow_status.h b/lib/sbi/openapi/model/flow_status.h new file mode 100644 index 000000000..3a6ea6a5d --- /dev/null +++ b/lib/sbi/openapi/model/flow_status.h @@ -0,0 +1,36 @@ +/* + * flow_status.h + * + * + */ + +#ifndef _OpenAPI_flow_status_H_ +#define _OpenAPI_flow_status_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_flow_status_s OpenAPI_flow_status_t; +typedef struct OpenAPI_flow_status_s { +} OpenAPI_flow_status_t; + +OpenAPI_flow_status_t *OpenAPI_flow_status_create( + ); +void OpenAPI_flow_status_free(OpenAPI_flow_status_t *flow_status); +OpenAPI_flow_status_t *OpenAPI_flow_status_parseFromJSON(cJSON *flow_statusJSON); +cJSON *OpenAPI_flow_status_convertToJSON(OpenAPI_flow_status_t *flow_status); +OpenAPI_flow_status_t *OpenAPI_flow_status_copy(OpenAPI_flow_status_t *dst, OpenAPI_flow_status_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_flow_status_H_ */ + diff --git a/lib/sbi/openapi/model/hsmf_update_data.c b/lib/sbi/openapi/model/hsmf_update_data.c index 4c59cef1c..e3bc8c421 100644 --- a/lib/sbi/openapi/model/hsmf_update_data.c +++ b/lib/sbi/openapi/model/hsmf_update_data.c @@ -44,7 +44,7 @@ OpenAPI_hsmf_update_data_t *OpenAPI_hsmf_update_data_create( OpenAPI_n4_information_t *n4_info, OpenAPI_n4_information_t *n4_info_ext1, OpenAPI_n4_information_t *n4_info_ext2, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, char *vsmf_pdu_session_uri, char *vsmf_id, char *v_smf_service_instance_id, @@ -174,7 +174,6 @@ void OpenAPI_hsmf_update_data_free(OpenAPI_hsmf_update_data_t *hsmf_update_data) OpenAPI_n4_information_free(hsmf_update_data->n4_info); OpenAPI_n4_information_free(hsmf_update_data->n4_info_ext1); OpenAPI_n4_information_free(hsmf_update_data->n4_info_ext2); - OpenAPI_presence_state_free(hsmf_update_data->presence_in_ladn); ogs_free(hsmf_update_data->vsmf_pdu_session_uri); ogs_free(hsmf_update_data->vsmf_id); ogs_free(hsmf_update_data->v_smf_service_instance_id); @@ -653,13 +652,7 @@ cJSON *OpenAPI_hsmf_update_data_convertToJSON(OpenAPI_hsmf_update_data_t *hsmf_u } if (hsmf_update_data->presence_in_ladn) { - cJSON *presence_in_ladn_local_JSON = OpenAPI_presence_state_convertToJSON(hsmf_update_data->presence_in_ladn); - if (presence_in_ladn_local_JSON == NULL) { - ogs_error("OpenAPI_hsmf_update_data_convertToJSON() failed [presence_in_ladn]"); - goto end; - } - cJSON_AddItemToObject(item, "presenceInLadn", presence_in_ladn_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "presenceInLadn", OpenAPI_presence_state_ToString(hsmf_update_data->presence_in_ladn)) == NULL) { ogs_error("OpenAPI_hsmf_update_data_convertToJSON() failed [presence_in_ladn]"); goto end; } @@ -1248,9 +1241,13 @@ OpenAPI_hsmf_update_data_t *OpenAPI_hsmf_update_data_parseFromJSON(cJSON *hsmf_u cJSON *presence_in_ladn = cJSON_GetObjectItemCaseSensitive(hsmf_update_dataJSON, "presenceInLadn"); - OpenAPI_presence_state_t *presence_in_ladn_local_nonprim = NULL; + OpenAPI_presence_state_e presence_in_ladnVariable; if (presence_in_ladn) { - presence_in_ladn_local_nonprim = OpenAPI_presence_state_parseFromJSON(presence_in_ladn); + if (!cJSON_IsString(presence_in_ladn)) { + ogs_error("OpenAPI_hsmf_update_data_parseFromJSON() failed [presence_in_ladn]"); + goto end; + } + presence_in_ladnVariable = OpenAPI_presence_state_FromString(presence_in_ladn->valuestring); } cJSON *vsmf_pdu_session_uri = cJSON_GetObjectItemCaseSensitive(hsmf_update_dataJSON, "vsmfPduSessionUri"); @@ -1413,7 +1410,7 @@ OpenAPI_hsmf_update_data_t *OpenAPI_hsmf_update_data_parseFromJSON(cJSON *hsmf_u n4_info ? n4_info_local_nonprim : NULL, n4_info_ext1 ? n4_info_ext1_local_nonprim : NULL, n4_info_ext2 ? n4_info_ext2_local_nonprim : NULL, - presence_in_ladn ? presence_in_ladn_local_nonprim : NULL, + presence_in_ladn ? presence_in_ladnVariable : 0, vsmf_pdu_session_uri ? ogs_strdup(vsmf_pdu_session_uri->valuestring) : NULL, vsmf_id ? ogs_strdup(vsmf_id->valuestring) : NULL, v_smf_service_instance_id ? ogs_strdup(v_smf_service_instance_id->valuestring) : NULL, diff --git a/lib/sbi/openapi/model/hsmf_update_data.h b/lib/sbi/openapi/model/hsmf_update_data.h index 3adcef66c..7feaf2da8 100644 --- a/lib/sbi/openapi/model/hsmf_update_data.h +++ b/lib/sbi/openapi/model/hsmf_update_data.h @@ -83,7 +83,7 @@ typedef struct OpenAPI_hsmf_update_data_s { struct OpenAPI_n4_information_s *n4_info; struct OpenAPI_n4_information_s *n4_info_ext1; struct OpenAPI_n4_information_s *n4_info_ext2; - struct OpenAPI_presence_state_s *presence_in_ladn; + OpenAPI_presence_state_e presence_in_ladn; char *vsmf_pdu_session_uri; char *vsmf_id; char *v_smf_service_instance_id; @@ -139,7 +139,7 @@ OpenAPI_hsmf_update_data_t *OpenAPI_hsmf_update_data_create( OpenAPI_n4_information_t *n4_info, OpenAPI_n4_information_t *n4_info_ext1, OpenAPI_n4_information_t *n4_info_ext2, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, char *vsmf_pdu_session_uri, char *vsmf_id, char *v_smf_service_instance_id, diff --git a/lib/sbi/openapi/model/ip_multicast_address_info.c b/lib/sbi/openapi/model/ip_multicast_address_info.c new file mode 100644 index 000000000..a8581886d --- /dev/null +++ b/lib/sbi/openapi/model/ip_multicast_address_info.c @@ -0,0 +1,165 @@ + +#include +#include +#include +#include "ip_multicast_address_info.h" + +OpenAPI_ip_multicast_address_info_t *OpenAPI_ip_multicast_address_info_create( + char *src_ipv4_addr, + char *ipv4_mul_addr, + char *src_ipv6_addr, + char *ipv6_mul_addr + ) +{ + OpenAPI_ip_multicast_address_info_t *ip_multicast_address_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_ip_multicast_address_info_t)); + if (!ip_multicast_address_info_local_var) { + return NULL; + } + ip_multicast_address_info_local_var->src_ipv4_addr = src_ipv4_addr; + ip_multicast_address_info_local_var->ipv4_mul_addr = ipv4_mul_addr; + ip_multicast_address_info_local_var->src_ipv6_addr = src_ipv6_addr; + ip_multicast_address_info_local_var->ipv6_mul_addr = ipv6_mul_addr; + + return ip_multicast_address_info_local_var; +} + +void OpenAPI_ip_multicast_address_info_free(OpenAPI_ip_multicast_address_info_t *ip_multicast_address_info) +{ + if (NULL == ip_multicast_address_info) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(ip_multicast_address_info->src_ipv4_addr); + ogs_free(ip_multicast_address_info->ipv4_mul_addr); + ogs_free(ip_multicast_address_info->src_ipv6_addr); + ogs_free(ip_multicast_address_info->ipv6_mul_addr); + ogs_free(ip_multicast_address_info); +} + +cJSON *OpenAPI_ip_multicast_address_info_convertToJSON(OpenAPI_ip_multicast_address_info_t *ip_multicast_address_info) +{ + cJSON *item = NULL; + + if (ip_multicast_address_info == NULL) { + ogs_error("OpenAPI_ip_multicast_address_info_convertToJSON() failed [IpMulticastAddressInfo]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (ip_multicast_address_info->src_ipv4_addr) { + if (cJSON_AddStringToObject(item, "srcIpv4Addr", ip_multicast_address_info->src_ipv4_addr) == NULL) { + ogs_error("OpenAPI_ip_multicast_address_info_convertToJSON() failed [src_ipv4_addr]"); + goto end; + } + } + + if (ip_multicast_address_info->ipv4_mul_addr) { + if (cJSON_AddStringToObject(item, "ipv4MulAddr", ip_multicast_address_info->ipv4_mul_addr) == NULL) { + ogs_error("OpenAPI_ip_multicast_address_info_convertToJSON() failed [ipv4_mul_addr]"); + goto end; + } + } + + if (ip_multicast_address_info->src_ipv6_addr) { + if (cJSON_AddStringToObject(item, "srcIpv6Addr", ip_multicast_address_info->src_ipv6_addr) == NULL) { + ogs_error("OpenAPI_ip_multicast_address_info_convertToJSON() failed [src_ipv6_addr]"); + goto end; + } + } + + if (ip_multicast_address_info->ipv6_mul_addr) { + if (cJSON_AddStringToObject(item, "ipv6MulAddr", ip_multicast_address_info->ipv6_mul_addr) == NULL) { + ogs_error("OpenAPI_ip_multicast_address_info_convertToJSON() failed [ipv6_mul_addr]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_ip_multicast_address_info_t *OpenAPI_ip_multicast_address_info_parseFromJSON(cJSON *ip_multicast_address_infoJSON) +{ + OpenAPI_ip_multicast_address_info_t *ip_multicast_address_info_local_var = NULL; + cJSON *src_ipv4_addr = cJSON_GetObjectItemCaseSensitive(ip_multicast_address_infoJSON, "srcIpv4Addr"); + + if (src_ipv4_addr) { + if (!cJSON_IsString(src_ipv4_addr)) { + ogs_error("OpenAPI_ip_multicast_address_info_parseFromJSON() failed [src_ipv4_addr]"); + goto end; + } + } + + cJSON *ipv4_mul_addr = cJSON_GetObjectItemCaseSensitive(ip_multicast_address_infoJSON, "ipv4MulAddr"); + + if (ipv4_mul_addr) { + if (!cJSON_IsString(ipv4_mul_addr)) { + ogs_error("OpenAPI_ip_multicast_address_info_parseFromJSON() failed [ipv4_mul_addr]"); + goto end; + } + } + + cJSON *src_ipv6_addr = cJSON_GetObjectItemCaseSensitive(ip_multicast_address_infoJSON, "srcIpv6Addr"); + + if (src_ipv6_addr) { + if (!cJSON_IsString(src_ipv6_addr)) { + ogs_error("OpenAPI_ip_multicast_address_info_parseFromJSON() failed [src_ipv6_addr]"); + goto end; + } + } + + cJSON *ipv6_mul_addr = cJSON_GetObjectItemCaseSensitive(ip_multicast_address_infoJSON, "ipv6MulAddr"); + + if (ipv6_mul_addr) { + if (!cJSON_IsString(ipv6_mul_addr)) { + ogs_error("OpenAPI_ip_multicast_address_info_parseFromJSON() failed [ipv6_mul_addr]"); + goto end; + } + } + + ip_multicast_address_info_local_var = OpenAPI_ip_multicast_address_info_create ( + src_ipv4_addr ? ogs_strdup(src_ipv4_addr->valuestring) : NULL, + ipv4_mul_addr ? ogs_strdup(ipv4_mul_addr->valuestring) : NULL, + src_ipv6_addr ? ogs_strdup(src_ipv6_addr->valuestring) : NULL, + ipv6_mul_addr ? ogs_strdup(ipv6_mul_addr->valuestring) : NULL + ); + + return ip_multicast_address_info_local_var; +end: + return NULL; +} + +OpenAPI_ip_multicast_address_info_t *OpenAPI_ip_multicast_address_info_copy(OpenAPI_ip_multicast_address_info_t *dst, OpenAPI_ip_multicast_address_info_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_ip_multicast_address_info_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_ip_multicast_address_info_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_ip_multicast_address_info_free(dst); + dst = OpenAPI_ip_multicast_address_info_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/ip_multicast_address_info.h b/lib/sbi/openapi/model/ip_multicast_address_info.h new file mode 100644 index 000000000..e1a48a084 --- /dev/null +++ b/lib/sbi/openapi/model/ip_multicast_address_info.h @@ -0,0 +1,44 @@ +/* + * ip_multicast_address_info.h + * + * + */ + +#ifndef _OpenAPI_ip_multicast_address_info_H_ +#define _OpenAPI_ip_multicast_address_info_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_ip_multicast_address_info_s OpenAPI_ip_multicast_address_info_t; +typedef struct OpenAPI_ip_multicast_address_info_s { + char *src_ipv4_addr; + char *ipv4_mul_addr; + char *src_ipv6_addr; + char *ipv6_mul_addr; +} OpenAPI_ip_multicast_address_info_t; + +OpenAPI_ip_multicast_address_info_t *OpenAPI_ip_multicast_address_info_create( + char *src_ipv4_addr, + char *ipv4_mul_addr, + char *src_ipv6_addr, + char *ipv6_mul_addr + ); +void OpenAPI_ip_multicast_address_info_free(OpenAPI_ip_multicast_address_info_t *ip_multicast_address_info); +OpenAPI_ip_multicast_address_info_t *OpenAPI_ip_multicast_address_info_parseFromJSON(cJSON *ip_multicast_address_infoJSON); +cJSON *OpenAPI_ip_multicast_address_info_convertToJSON(OpenAPI_ip_multicast_address_info_t *ip_multicast_address_info); +OpenAPI_ip_multicast_address_info_t *OpenAPI_ip_multicast_address_info_copy(OpenAPI_ip_multicast_address_info_t *dst, OpenAPI_ip_multicast_address_info_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_ip_multicast_address_info_H_ */ + diff --git a/lib/sbi/openapi/model/ladn_info.c b/lib/sbi/openapi/model/ladn_info.c index 5587aa91c..8f5afc2c3 100644 --- a/lib/sbi/openapi/model/ladn_info.c +++ b/lib/sbi/openapi/model/ladn_info.c @@ -6,7 +6,7 @@ OpenAPI_ladn_info_t *OpenAPI_ladn_info_create( char *ladn, - OpenAPI_presence_state_t *presence + OpenAPI_presence_state_e presence ) { OpenAPI_ladn_info_t *ladn_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_ladn_info_t)); @@ -26,7 +26,6 @@ void OpenAPI_ladn_info_free(OpenAPI_ladn_info_t *ladn_info) } OpenAPI_lnode_t *node; ogs_free(ladn_info->ladn); - OpenAPI_presence_state_free(ladn_info->presence); ogs_free(ladn_info); } @@ -50,13 +49,7 @@ cJSON *OpenAPI_ladn_info_convertToJSON(OpenAPI_ladn_info_t *ladn_info) } if (ladn_info->presence) { - cJSON *presence_local_JSON = OpenAPI_presence_state_convertToJSON(ladn_info->presence); - if (presence_local_JSON == NULL) { - ogs_error("OpenAPI_ladn_info_convertToJSON() failed [presence]"); - goto end; - } - cJSON_AddItemToObject(item, "presence", presence_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "presence", OpenAPI_presence_state_ToString(ladn_info->presence)) == NULL) { ogs_error("OpenAPI_ladn_info_convertToJSON() failed [presence]"); goto end; } @@ -83,14 +76,18 @@ OpenAPI_ladn_info_t *OpenAPI_ladn_info_parseFromJSON(cJSON *ladn_infoJSON) cJSON *presence = cJSON_GetObjectItemCaseSensitive(ladn_infoJSON, "presence"); - OpenAPI_presence_state_t *presence_local_nonprim = NULL; + OpenAPI_presence_state_e presenceVariable; if (presence) { - presence_local_nonprim = OpenAPI_presence_state_parseFromJSON(presence); + if (!cJSON_IsString(presence)) { + ogs_error("OpenAPI_ladn_info_parseFromJSON() failed [presence]"); + goto end; + } + presenceVariable = OpenAPI_presence_state_FromString(presence->valuestring); } ladn_info_local_var = OpenAPI_ladn_info_create ( ogs_strdup(ladn->valuestring), - presence ? presence_local_nonprim : NULL + presence ? presenceVariable : 0 ); return ladn_info_local_var; diff --git a/lib/sbi/openapi/model/ladn_info.h b/lib/sbi/openapi/model/ladn_info.h index 3bfd44929..8be7c4b10 100644 --- a/lib/sbi/openapi/model/ladn_info.h +++ b/lib/sbi/openapi/model/ladn_info.h @@ -21,12 +21,12 @@ extern "C" { typedef struct OpenAPI_ladn_info_s OpenAPI_ladn_info_t; typedef struct OpenAPI_ladn_info_s { char *ladn; - struct OpenAPI_presence_state_s *presence; + OpenAPI_presence_state_e presence; } OpenAPI_ladn_info_t; OpenAPI_ladn_info_t *OpenAPI_ladn_info_create( char *ladn, - OpenAPI_presence_state_t *presence + OpenAPI_presence_state_e presence ); void OpenAPI_ladn_info_free(OpenAPI_ladn_info_t *ladn_info); OpenAPI_ladn_info_t *OpenAPI_ladn_info_parseFromJSON(cJSON *ladn_infoJSON); diff --git a/lib/sbi/openapi/model/ma_pdu_indication.c b/lib/sbi/openapi/model/ma_pdu_indication.c new file mode 100644 index 000000000..6bb8f8afc --- /dev/null +++ b/lib/sbi/openapi/model/ma_pdu_indication.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "ma_pdu_indication.h" + +OpenAPI_ma_pdu_indication_t *OpenAPI_ma_pdu_indication_create( + ) +{ + OpenAPI_ma_pdu_indication_t *ma_pdu_indication_local_var = OpenAPI_malloc(sizeof(OpenAPI_ma_pdu_indication_t)); + if (!ma_pdu_indication_local_var) { + return NULL; + } + + return ma_pdu_indication_local_var; +} + +void OpenAPI_ma_pdu_indication_free(OpenAPI_ma_pdu_indication_t *ma_pdu_indication) +{ + if (NULL == ma_pdu_indication) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(ma_pdu_indication); +} + +cJSON *OpenAPI_ma_pdu_indication_convertToJSON(OpenAPI_ma_pdu_indication_t *ma_pdu_indication) +{ + cJSON *item = NULL; + + if (ma_pdu_indication == NULL) { + ogs_error("OpenAPI_ma_pdu_indication_convertToJSON() failed [MaPduIndication]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_ma_pdu_indication_t *OpenAPI_ma_pdu_indication_parseFromJSON(cJSON *ma_pdu_indicationJSON) +{ + OpenAPI_ma_pdu_indication_t *ma_pdu_indication_local_var = NULL; + ma_pdu_indication_local_var = OpenAPI_ma_pdu_indication_create ( + ); + + return ma_pdu_indication_local_var; +end: + return NULL; +} + +OpenAPI_ma_pdu_indication_t *OpenAPI_ma_pdu_indication_copy(OpenAPI_ma_pdu_indication_t *dst, OpenAPI_ma_pdu_indication_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_ma_pdu_indication_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_ma_pdu_indication_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_ma_pdu_indication_free(dst); + dst = OpenAPI_ma_pdu_indication_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/ma_pdu_indication.h b/lib/sbi/openapi/model/ma_pdu_indication.h new file mode 100644 index 000000000..69fe1ac27 --- /dev/null +++ b/lib/sbi/openapi/model/ma_pdu_indication.h @@ -0,0 +1,36 @@ +/* + * ma_pdu_indication.h + * + * + */ + +#ifndef _OpenAPI_ma_pdu_indication_H_ +#define _OpenAPI_ma_pdu_indication_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_ma_pdu_indication_s OpenAPI_ma_pdu_indication_t; +typedef struct OpenAPI_ma_pdu_indication_s { +} OpenAPI_ma_pdu_indication_t; + +OpenAPI_ma_pdu_indication_t *OpenAPI_ma_pdu_indication_create( + ); +void OpenAPI_ma_pdu_indication_free(OpenAPI_ma_pdu_indication_t *ma_pdu_indication); +OpenAPI_ma_pdu_indication_t *OpenAPI_ma_pdu_indication_parseFromJSON(cJSON *ma_pdu_indicationJSON); +cJSON *OpenAPI_ma_pdu_indication_convertToJSON(OpenAPI_ma_pdu_indication_t *ma_pdu_indication); +OpenAPI_ma_pdu_indication_t *OpenAPI_ma_pdu_indication_copy(OpenAPI_ma_pdu_indication_t *dst, OpenAPI_ma_pdu_indication_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_ma_pdu_indication_H_ */ + diff --git a/lib/sbi/openapi/model/mapping_of_snssai.c b/lib/sbi/openapi/model/mapping_of_snssai.c new file mode 100644 index 000000000..8d37aca6a --- /dev/null +++ b/lib/sbi/openapi/model/mapping_of_snssai.c @@ -0,0 +1,143 @@ + +#include +#include +#include +#include "mapping_of_snssai.h" + +OpenAPI_mapping_of_snssai_t *OpenAPI_mapping_of_snssai_create( + OpenAPI_snssai_t *serving_snssai, + OpenAPI_snssai_t *home_snssai + ) +{ + OpenAPI_mapping_of_snssai_t *mapping_of_snssai_local_var = OpenAPI_malloc(sizeof(OpenAPI_mapping_of_snssai_t)); + if (!mapping_of_snssai_local_var) { + return NULL; + } + mapping_of_snssai_local_var->serving_snssai = serving_snssai; + mapping_of_snssai_local_var->home_snssai = home_snssai; + + return mapping_of_snssai_local_var; +} + +void OpenAPI_mapping_of_snssai_free(OpenAPI_mapping_of_snssai_t *mapping_of_snssai) +{ + if (NULL == mapping_of_snssai) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_snssai_free(mapping_of_snssai->serving_snssai); + OpenAPI_snssai_free(mapping_of_snssai->home_snssai); + ogs_free(mapping_of_snssai); +} + +cJSON *OpenAPI_mapping_of_snssai_convertToJSON(OpenAPI_mapping_of_snssai_t *mapping_of_snssai) +{ + cJSON *item = NULL; + + if (mapping_of_snssai == NULL) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed [MappingOfSnssai]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!mapping_of_snssai->serving_snssai) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed [serving_snssai]"); + goto end; + } + cJSON *serving_snssai_local_JSON = OpenAPI_snssai_convertToJSON(mapping_of_snssai->serving_snssai); + if (serving_snssai_local_JSON == NULL) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed [serving_snssai]"); + goto end; + } + cJSON_AddItemToObject(item, "servingSnssai", serving_snssai_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed [serving_snssai]"); + goto end; + } + + if (!mapping_of_snssai->home_snssai) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed [home_snssai]"); + goto end; + } + cJSON *home_snssai_local_JSON = OpenAPI_snssai_convertToJSON(mapping_of_snssai->home_snssai); + if (home_snssai_local_JSON == NULL) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed [home_snssai]"); + goto end; + } + cJSON_AddItemToObject(item, "homeSnssai", home_snssai_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed [home_snssai]"); + goto end; + } + +end: + return item; +} + +OpenAPI_mapping_of_snssai_t *OpenAPI_mapping_of_snssai_parseFromJSON(cJSON *mapping_of_snssaiJSON) +{ + OpenAPI_mapping_of_snssai_t *mapping_of_snssai_local_var = NULL; + cJSON *serving_snssai = cJSON_GetObjectItemCaseSensitive(mapping_of_snssaiJSON, "servingSnssai"); + if (!serving_snssai) { + ogs_error("OpenAPI_mapping_of_snssai_parseFromJSON() failed [serving_snssai]"); + goto end; + } + + OpenAPI_snssai_t *serving_snssai_local_nonprim = NULL; + + serving_snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(serving_snssai); + + cJSON *home_snssai = cJSON_GetObjectItemCaseSensitive(mapping_of_snssaiJSON, "homeSnssai"); + if (!home_snssai) { + ogs_error("OpenAPI_mapping_of_snssai_parseFromJSON() failed [home_snssai]"); + goto end; + } + + OpenAPI_snssai_t *home_snssai_local_nonprim = NULL; + + home_snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(home_snssai); + + mapping_of_snssai_local_var = OpenAPI_mapping_of_snssai_create ( + serving_snssai_local_nonprim, + home_snssai_local_nonprim + ); + + return mapping_of_snssai_local_var; +end: + return NULL; +} + +OpenAPI_mapping_of_snssai_t *OpenAPI_mapping_of_snssai_copy(OpenAPI_mapping_of_snssai_t *dst, OpenAPI_mapping_of_snssai_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_mapping_of_snssai_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_mapping_of_snssai_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_mapping_of_snssai_free(dst); + dst = OpenAPI_mapping_of_snssai_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/mapping_of_snssai.h b/lib/sbi/openapi/model/mapping_of_snssai.h new file mode 100644 index 000000000..9f7464a69 --- /dev/null +++ b/lib/sbi/openapi/model/mapping_of_snssai.h @@ -0,0 +1,41 @@ +/* + * mapping_of_snssai.h + * + * + */ + +#ifndef _OpenAPI_mapping_of_snssai_H_ +#define _OpenAPI_mapping_of_snssai_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "snssai.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_mapping_of_snssai_s OpenAPI_mapping_of_snssai_t; +typedef struct OpenAPI_mapping_of_snssai_s { + struct OpenAPI_snssai_s *serving_snssai; + struct OpenAPI_snssai_s *home_snssai; +} OpenAPI_mapping_of_snssai_t; + +OpenAPI_mapping_of_snssai_t *OpenAPI_mapping_of_snssai_create( + OpenAPI_snssai_t *serving_snssai, + OpenAPI_snssai_t *home_snssai + ); +void OpenAPI_mapping_of_snssai_free(OpenAPI_mapping_of_snssai_t *mapping_of_snssai); +OpenAPI_mapping_of_snssai_t *OpenAPI_mapping_of_snssai_parseFromJSON(cJSON *mapping_of_snssaiJSON); +cJSON *OpenAPI_mapping_of_snssai_convertToJSON(OpenAPI_mapping_of_snssai_t *mapping_of_snssai); +OpenAPI_mapping_of_snssai_t *OpenAPI_mapping_of_snssai_copy(OpenAPI_mapping_of_snssai_t *dst, OpenAPI_mapping_of_snssai_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_mapping_of_snssai_H_ */ + diff --git a/lib/sbi/openapi/model/metering_method.c b/lib/sbi/openapi/model/metering_method.c new file mode 100644 index 000000000..ed7272ebf --- /dev/null +++ b/lib/sbi/openapi/model/metering_method.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "metering_method.h" + +OpenAPI_metering_method_t *OpenAPI_metering_method_create( + ) +{ + OpenAPI_metering_method_t *metering_method_local_var = OpenAPI_malloc(sizeof(OpenAPI_metering_method_t)); + if (!metering_method_local_var) { + return NULL; + } + + return metering_method_local_var; +} + +void OpenAPI_metering_method_free(OpenAPI_metering_method_t *metering_method) +{ + if (NULL == metering_method) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(metering_method); +} + +cJSON *OpenAPI_metering_method_convertToJSON(OpenAPI_metering_method_t *metering_method) +{ + cJSON *item = NULL; + + if (metering_method == NULL) { + ogs_error("OpenAPI_metering_method_convertToJSON() failed [MeteringMethod]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_metering_method_t *OpenAPI_metering_method_parseFromJSON(cJSON *metering_methodJSON) +{ + OpenAPI_metering_method_t *metering_method_local_var = NULL; + metering_method_local_var = OpenAPI_metering_method_create ( + ); + + return metering_method_local_var; +end: + return NULL; +} + +OpenAPI_metering_method_t *OpenAPI_metering_method_copy(OpenAPI_metering_method_t *dst, OpenAPI_metering_method_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_metering_method_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_metering_method_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_metering_method_free(dst); + dst = OpenAPI_metering_method_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/metering_method.h b/lib/sbi/openapi/model/metering_method.h new file mode 100644 index 000000000..3d0451b9c --- /dev/null +++ b/lib/sbi/openapi/model/metering_method.h @@ -0,0 +1,37 @@ +/* + * metering_method.h + * + * Possible values are - DURATION: Indicates that the duration of the service data flow traffic shall be metered. - VOLUME: Indicates that volume of the service data flow traffic shall be metered. - DURATION_VOLUME: Indicates that the duration and the volume of the service data flow traffic shall be metered. - EVENT: Indicates that events of the service data flow traffic shall be metered. + */ + +#ifndef _OpenAPI_metering_method_H_ +#define _OpenAPI_metering_method_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "null_value.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_metering_method_s OpenAPI_metering_method_t; +typedef struct OpenAPI_metering_method_s { +} OpenAPI_metering_method_t; + +OpenAPI_metering_method_t *OpenAPI_metering_method_create( + ); +void OpenAPI_metering_method_free(OpenAPI_metering_method_t *metering_method); +OpenAPI_metering_method_t *OpenAPI_metering_method_parseFromJSON(cJSON *metering_methodJSON); +cJSON *OpenAPI_metering_method_convertToJSON(OpenAPI_metering_method_t *metering_method); +OpenAPI_metering_method_t *OpenAPI_metering_method_copy(OpenAPI_metering_method_t *dst, OpenAPI_metering_method_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_metering_method_H_ */ + diff --git a/lib/sbi/openapi/model/packet_filter_info.c b/lib/sbi/openapi/model/packet_filter_info.c new file mode 100644 index 000000000..165b57768 --- /dev/null +++ b/lib/sbi/openapi/model/packet_filter_info.c @@ -0,0 +1,209 @@ + +#include +#include +#include +#include "packet_filter_info.h" + +OpenAPI_packet_filter_info_t *OpenAPI_packet_filter_info_create( + char *pack_filt_id, + char *pack_filt_cont, + char *tos_traffic_class, + char *spi, + char *flow_label, + OpenAPI_flow_direction_t *flow_direction + ) +{ + OpenAPI_packet_filter_info_t *packet_filter_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_packet_filter_info_t)); + if (!packet_filter_info_local_var) { + return NULL; + } + packet_filter_info_local_var->pack_filt_id = pack_filt_id; + packet_filter_info_local_var->pack_filt_cont = pack_filt_cont; + packet_filter_info_local_var->tos_traffic_class = tos_traffic_class; + packet_filter_info_local_var->spi = spi; + packet_filter_info_local_var->flow_label = flow_label; + packet_filter_info_local_var->flow_direction = flow_direction; + + return packet_filter_info_local_var; +} + +void OpenAPI_packet_filter_info_free(OpenAPI_packet_filter_info_t *packet_filter_info) +{ + if (NULL == packet_filter_info) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(packet_filter_info->pack_filt_id); + ogs_free(packet_filter_info->pack_filt_cont); + ogs_free(packet_filter_info->tos_traffic_class); + ogs_free(packet_filter_info->spi); + ogs_free(packet_filter_info->flow_label); + OpenAPI_flow_direction_free(packet_filter_info->flow_direction); + ogs_free(packet_filter_info); +} + +cJSON *OpenAPI_packet_filter_info_convertToJSON(OpenAPI_packet_filter_info_t *packet_filter_info) +{ + cJSON *item = NULL; + + if (packet_filter_info == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [PacketFilterInfo]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (packet_filter_info->pack_filt_id) { + if (cJSON_AddStringToObject(item, "packFiltId", packet_filter_info->pack_filt_id) == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [pack_filt_id]"); + goto end; + } + } + + if (packet_filter_info->pack_filt_cont) { + if (cJSON_AddStringToObject(item, "packFiltCont", packet_filter_info->pack_filt_cont) == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [pack_filt_cont]"); + goto end; + } + } + + if (packet_filter_info->tos_traffic_class) { + if (cJSON_AddStringToObject(item, "tosTrafficClass", packet_filter_info->tos_traffic_class) == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [tos_traffic_class]"); + goto end; + } + } + + if (packet_filter_info->spi) { + if (cJSON_AddStringToObject(item, "spi", packet_filter_info->spi) == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [spi]"); + goto end; + } + } + + if (packet_filter_info->flow_label) { + if (cJSON_AddStringToObject(item, "flowLabel", packet_filter_info->flow_label) == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [flow_label]"); + goto end; + } + } + + if (packet_filter_info->flow_direction) { + cJSON *flow_direction_local_JSON = OpenAPI_flow_direction_convertToJSON(packet_filter_info->flow_direction); + if (flow_direction_local_JSON == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [flow_direction]"); + goto end; + } + cJSON_AddItemToObject(item, "flowDirection", flow_direction_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed [flow_direction]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_packet_filter_info_t *OpenAPI_packet_filter_info_parseFromJSON(cJSON *packet_filter_infoJSON) +{ + OpenAPI_packet_filter_info_t *packet_filter_info_local_var = NULL; + cJSON *pack_filt_id = cJSON_GetObjectItemCaseSensitive(packet_filter_infoJSON, "packFiltId"); + + if (pack_filt_id) { + if (!cJSON_IsString(pack_filt_id)) { + ogs_error("OpenAPI_packet_filter_info_parseFromJSON() failed [pack_filt_id]"); + goto end; + } + } + + cJSON *pack_filt_cont = cJSON_GetObjectItemCaseSensitive(packet_filter_infoJSON, "packFiltCont"); + + if (pack_filt_cont) { + if (!cJSON_IsString(pack_filt_cont)) { + ogs_error("OpenAPI_packet_filter_info_parseFromJSON() failed [pack_filt_cont]"); + goto end; + } + } + + cJSON *tos_traffic_class = cJSON_GetObjectItemCaseSensitive(packet_filter_infoJSON, "tosTrafficClass"); + + if (tos_traffic_class) { + if (!cJSON_IsString(tos_traffic_class)) { + ogs_error("OpenAPI_packet_filter_info_parseFromJSON() failed [tos_traffic_class]"); + goto end; + } + } + + cJSON *spi = cJSON_GetObjectItemCaseSensitive(packet_filter_infoJSON, "spi"); + + if (spi) { + if (!cJSON_IsString(spi)) { + ogs_error("OpenAPI_packet_filter_info_parseFromJSON() failed [spi]"); + goto end; + } + } + + cJSON *flow_label = cJSON_GetObjectItemCaseSensitive(packet_filter_infoJSON, "flowLabel"); + + if (flow_label) { + if (!cJSON_IsString(flow_label)) { + ogs_error("OpenAPI_packet_filter_info_parseFromJSON() failed [flow_label]"); + goto end; + } + } + + cJSON *flow_direction = cJSON_GetObjectItemCaseSensitive(packet_filter_infoJSON, "flowDirection"); + + OpenAPI_flow_direction_t *flow_direction_local_nonprim = NULL; + if (flow_direction) { + flow_direction_local_nonprim = OpenAPI_flow_direction_parseFromJSON(flow_direction); + } + + packet_filter_info_local_var = OpenAPI_packet_filter_info_create ( + pack_filt_id ? ogs_strdup(pack_filt_id->valuestring) : NULL, + pack_filt_cont ? ogs_strdup(pack_filt_cont->valuestring) : NULL, + tos_traffic_class ? ogs_strdup(tos_traffic_class->valuestring) : NULL, + spi ? ogs_strdup(spi->valuestring) : NULL, + flow_label ? ogs_strdup(flow_label->valuestring) : NULL, + flow_direction ? flow_direction_local_nonprim : NULL + ); + + return packet_filter_info_local_var; +end: + return NULL; +} + +OpenAPI_packet_filter_info_t *OpenAPI_packet_filter_info_copy(OpenAPI_packet_filter_info_t *dst, OpenAPI_packet_filter_info_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_packet_filter_info_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_packet_filter_info_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_packet_filter_info_free(dst); + dst = OpenAPI_packet_filter_info_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/packet_filter_info.h b/lib/sbi/openapi/model/packet_filter_info.h new file mode 100644 index 000000000..6cb76c865 --- /dev/null +++ b/lib/sbi/openapi/model/packet_filter_info.h @@ -0,0 +1,49 @@ +/* + * packet_filter_info.h + * + * + */ + +#ifndef _OpenAPI_packet_filter_info_H_ +#define _OpenAPI_packet_filter_info_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "flow_direction.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_packet_filter_info_s OpenAPI_packet_filter_info_t; +typedef struct OpenAPI_packet_filter_info_s { + char *pack_filt_id; + char *pack_filt_cont; + char *tos_traffic_class; + char *spi; + char *flow_label; + struct OpenAPI_flow_direction_s *flow_direction; +} OpenAPI_packet_filter_info_t; + +OpenAPI_packet_filter_info_t *OpenAPI_packet_filter_info_create( + char *pack_filt_id, + char *pack_filt_cont, + char *tos_traffic_class, + char *spi, + char *flow_label, + OpenAPI_flow_direction_t *flow_direction + ); +void OpenAPI_packet_filter_info_free(OpenAPI_packet_filter_info_t *packet_filter_info); +OpenAPI_packet_filter_info_t *OpenAPI_packet_filter_info_parseFromJSON(cJSON *packet_filter_infoJSON); +cJSON *OpenAPI_packet_filter_info_convertToJSON(OpenAPI_packet_filter_info_t *packet_filter_info); +OpenAPI_packet_filter_info_t *OpenAPI_packet_filter_info_copy(OpenAPI_packet_filter_info_t *dst, OpenAPI_packet_filter_info_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_packet_filter_info_H_ */ + diff --git a/lib/sbi/openapi/model/partial_success_report.c b/lib/sbi/openapi/model/partial_success_report.c new file mode 100644 index 000000000..b520e4e60 --- /dev/null +++ b/lib/sbi/openapi/model/partial_success_report.c @@ -0,0 +1,238 @@ + +#include +#include +#include +#include "partial_success_report.h" + +OpenAPI_partial_success_report_t *OpenAPI_partial_success_report_create( + OpenAPI_failure_cause_t *failure_cause, + OpenAPI_list_t *rule_reports, + OpenAPI_list_t *sess_rule_reports, + OpenAPI_ue_camping_rep_t *ue_camping_rep + ) +{ + OpenAPI_partial_success_report_t *partial_success_report_local_var = OpenAPI_malloc(sizeof(OpenAPI_partial_success_report_t)); + if (!partial_success_report_local_var) { + return NULL; + } + partial_success_report_local_var->failure_cause = failure_cause; + partial_success_report_local_var->rule_reports = rule_reports; + partial_success_report_local_var->sess_rule_reports = sess_rule_reports; + partial_success_report_local_var->ue_camping_rep = ue_camping_rep; + + return partial_success_report_local_var; +} + +void OpenAPI_partial_success_report_free(OpenAPI_partial_success_report_t *partial_success_report) +{ + if (NULL == partial_success_report) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_failure_cause_free(partial_success_report->failure_cause); + OpenAPI_list_for_each(partial_success_report->rule_reports, node) { + OpenAPI_rule_report_free(node->data); + } + OpenAPI_list_free(partial_success_report->rule_reports); + OpenAPI_list_for_each(partial_success_report->sess_rule_reports, node) { + OpenAPI_session_rule_report_free(node->data); + } + OpenAPI_list_free(partial_success_report->sess_rule_reports); + OpenAPI_ue_camping_rep_free(partial_success_report->ue_camping_rep); + ogs_free(partial_success_report); +} + +cJSON *OpenAPI_partial_success_report_convertToJSON(OpenAPI_partial_success_report_t *partial_success_report) +{ + cJSON *item = NULL; + + if (partial_success_report == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [PartialSuccessReport]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!partial_success_report->failure_cause) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [failure_cause]"); + goto end; + } + cJSON *failure_cause_local_JSON = OpenAPI_failure_cause_convertToJSON(partial_success_report->failure_cause); + if (failure_cause_local_JSON == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [failure_cause]"); + goto end; + } + cJSON_AddItemToObject(item, "failureCause", failure_cause_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [failure_cause]"); + goto end; + } + + if (partial_success_report->rule_reports) { + cJSON *rule_reportsList = cJSON_AddArrayToObject(item, "ruleReports"); + if (rule_reportsList == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [rule_reports]"); + goto end; + } + + OpenAPI_lnode_t *rule_reports_node; + if (partial_success_report->rule_reports) { + OpenAPI_list_for_each(partial_success_report->rule_reports, rule_reports_node) { + cJSON *itemLocal = OpenAPI_rule_report_convertToJSON(rule_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [rule_reports]"); + goto end; + } + cJSON_AddItemToArray(rule_reportsList, itemLocal); + } + } + } + + if (partial_success_report->sess_rule_reports) { + cJSON *sess_rule_reportsList = cJSON_AddArrayToObject(item, "sessRuleReports"); + if (sess_rule_reportsList == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [sess_rule_reports]"); + goto end; + } + + OpenAPI_lnode_t *sess_rule_reports_node; + if (partial_success_report->sess_rule_reports) { + OpenAPI_list_for_each(partial_success_report->sess_rule_reports, sess_rule_reports_node) { + cJSON *itemLocal = OpenAPI_session_rule_report_convertToJSON(sess_rule_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [sess_rule_reports]"); + goto end; + } + cJSON_AddItemToArray(sess_rule_reportsList, itemLocal); + } + } + } + + if (partial_success_report->ue_camping_rep) { + cJSON *ue_camping_rep_local_JSON = OpenAPI_ue_camping_rep_convertToJSON(partial_success_report->ue_camping_rep); + if (ue_camping_rep_local_JSON == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [ue_camping_rep]"); + goto end; + } + cJSON_AddItemToObject(item, "ueCampingRep", ue_camping_rep_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed [ue_camping_rep]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_partial_success_report_t *OpenAPI_partial_success_report_parseFromJSON(cJSON *partial_success_reportJSON) +{ + OpenAPI_partial_success_report_t *partial_success_report_local_var = NULL; + cJSON *failure_cause = cJSON_GetObjectItemCaseSensitive(partial_success_reportJSON, "failureCause"); + if (!failure_cause) { + ogs_error("OpenAPI_partial_success_report_parseFromJSON() failed [failure_cause]"); + goto end; + } + + OpenAPI_failure_cause_t *failure_cause_local_nonprim = NULL; + + failure_cause_local_nonprim = OpenAPI_failure_cause_parseFromJSON(failure_cause); + + cJSON *rule_reports = cJSON_GetObjectItemCaseSensitive(partial_success_reportJSON, "ruleReports"); + + OpenAPI_list_t *rule_reportsList; + if (rule_reports) { + cJSON *rule_reports_local_nonprimitive; + if (!cJSON_IsArray(rule_reports)) { + ogs_error("OpenAPI_partial_success_report_parseFromJSON() failed [rule_reports]"); + goto end; + } + + rule_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rule_reports_local_nonprimitive, rule_reports ) { + if (!cJSON_IsObject(rule_reports_local_nonprimitive)) { + ogs_error("OpenAPI_partial_success_report_parseFromJSON() failed [rule_reports]"); + goto end; + } + OpenAPI_rule_report_t *rule_reportsItem = OpenAPI_rule_report_parseFromJSON(rule_reports_local_nonprimitive); + + OpenAPI_list_add(rule_reportsList, rule_reportsItem); + } + } + + cJSON *sess_rule_reports = cJSON_GetObjectItemCaseSensitive(partial_success_reportJSON, "sessRuleReports"); + + OpenAPI_list_t *sess_rule_reportsList; + if (sess_rule_reports) { + cJSON *sess_rule_reports_local_nonprimitive; + if (!cJSON_IsArray(sess_rule_reports)) { + ogs_error("OpenAPI_partial_success_report_parseFromJSON() failed [sess_rule_reports]"); + goto end; + } + + sess_rule_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(sess_rule_reports_local_nonprimitive, sess_rule_reports ) { + if (!cJSON_IsObject(sess_rule_reports_local_nonprimitive)) { + ogs_error("OpenAPI_partial_success_report_parseFromJSON() failed [sess_rule_reports]"); + goto end; + } + OpenAPI_session_rule_report_t *sess_rule_reportsItem = OpenAPI_session_rule_report_parseFromJSON(sess_rule_reports_local_nonprimitive); + + OpenAPI_list_add(sess_rule_reportsList, sess_rule_reportsItem); + } + } + + cJSON *ue_camping_rep = cJSON_GetObjectItemCaseSensitive(partial_success_reportJSON, "ueCampingRep"); + + OpenAPI_ue_camping_rep_t *ue_camping_rep_local_nonprim = NULL; + if (ue_camping_rep) { + ue_camping_rep_local_nonprim = OpenAPI_ue_camping_rep_parseFromJSON(ue_camping_rep); + } + + partial_success_report_local_var = OpenAPI_partial_success_report_create ( + failure_cause_local_nonprim, + rule_reports ? rule_reportsList : NULL, + sess_rule_reports ? sess_rule_reportsList : NULL, + ue_camping_rep ? ue_camping_rep_local_nonprim : NULL + ); + + return partial_success_report_local_var; +end: + return NULL; +} + +OpenAPI_partial_success_report_t *OpenAPI_partial_success_report_copy(OpenAPI_partial_success_report_t *dst, OpenAPI_partial_success_report_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_partial_success_report_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_partial_success_report_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_partial_success_report_free(dst); + dst = OpenAPI_partial_success_report_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/partial_success_report.h b/lib/sbi/openapi/model/partial_success_report.h new file mode 100644 index 000000000..bcb2c92f8 --- /dev/null +++ b/lib/sbi/openapi/model/partial_success_report.h @@ -0,0 +1,48 @@ +/* + * partial_success_report.h + * + * + */ + +#ifndef _OpenAPI_partial_success_report_H_ +#define _OpenAPI_partial_success_report_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "failure_cause.h" +#include "rule_report.h" +#include "session_rule_report.h" +#include "ue_camping_rep.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_partial_success_report_s OpenAPI_partial_success_report_t; +typedef struct OpenAPI_partial_success_report_s { + struct OpenAPI_failure_cause_s *failure_cause; + OpenAPI_list_t *rule_reports; + OpenAPI_list_t *sess_rule_reports; + struct OpenAPI_ue_camping_rep_s *ue_camping_rep; +} OpenAPI_partial_success_report_t; + +OpenAPI_partial_success_report_t *OpenAPI_partial_success_report_create( + OpenAPI_failure_cause_t *failure_cause, + OpenAPI_list_t *rule_reports, + OpenAPI_list_t *sess_rule_reports, + OpenAPI_ue_camping_rep_t *ue_camping_rep + ); +void OpenAPI_partial_success_report_free(OpenAPI_partial_success_report_t *partial_success_report); +OpenAPI_partial_success_report_t *OpenAPI_partial_success_report_parseFromJSON(cJSON *partial_success_reportJSON); +cJSON *OpenAPI_partial_success_report_convertToJSON(OpenAPI_partial_success_report_t *partial_success_report); +OpenAPI_partial_success_report_t *OpenAPI_partial_success_report_copy(OpenAPI_partial_success_report_t *dst, OpenAPI_partial_success_report_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_partial_success_report_H_ */ + diff --git a/lib/sbi/openapi/model/pcc_rule.c b/lib/sbi/openapi/model/pcc_rule.c new file mode 100644 index 000000000..d6934eb74 --- /dev/null +++ b/lib/sbi/openapi/model/pcc_rule.c @@ -0,0 +1,692 @@ + +#include +#include +#include +#include "pcc_rule.h" + +OpenAPI_pcc_rule_t *OpenAPI_pcc_rule_create( + OpenAPI_list_t *flow_infos, + char *app_id, + int cont_ver, + char *pcc_rule_id, + int precedence, + OpenAPI_af_sig_protocol_t *af_sig_protocol, + int app_reloc, + OpenAPI_list_t *ref_qos_data, + OpenAPI_list_t *ref_alt_qos_params, + OpenAPI_list_t *ref_tc_data, + OpenAPI_list_t *ref_chg_data, + OpenAPI_list_t *ref_chg_n3g_data, + OpenAPI_list_t *ref_um_data, + OpenAPI_list_t *ref_um_n3g_data, + char *ref_cond_data, + OpenAPI_list_t *ref_qos_mon, + int addr_preser_ind, + OpenAPI_tscai_input_container_t *tscai_input_dl, + OpenAPI_tscai_input_container_t *tscai_input_ul + ) +{ + OpenAPI_pcc_rule_t *pcc_rule_local_var = OpenAPI_malloc(sizeof(OpenAPI_pcc_rule_t)); + if (!pcc_rule_local_var) { + return NULL; + } + pcc_rule_local_var->flow_infos = flow_infos; + pcc_rule_local_var->app_id = app_id; + pcc_rule_local_var->cont_ver = cont_ver; + pcc_rule_local_var->pcc_rule_id = pcc_rule_id; + pcc_rule_local_var->precedence = precedence; + pcc_rule_local_var->af_sig_protocol = af_sig_protocol; + pcc_rule_local_var->app_reloc = app_reloc; + pcc_rule_local_var->ref_qos_data = ref_qos_data; + pcc_rule_local_var->ref_alt_qos_params = ref_alt_qos_params; + pcc_rule_local_var->ref_tc_data = ref_tc_data; + pcc_rule_local_var->ref_chg_data = ref_chg_data; + pcc_rule_local_var->ref_chg_n3g_data = ref_chg_n3g_data; + pcc_rule_local_var->ref_um_data = ref_um_data; + pcc_rule_local_var->ref_um_n3g_data = ref_um_n3g_data; + pcc_rule_local_var->ref_cond_data = ref_cond_data; + pcc_rule_local_var->ref_qos_mon = ref_qos_mon; + pcc_rule_local_var->addr_preser_ind = addr_preser_ind; + pcc_rule_local_var->tscai_input_dl = tscai_input_dl; + pcc_rule_local_var->tscai_input_ul = tscai_input_ul; + + return pcc_rule_local_var; +} + +void OpenAPI_pcc_rule_free(OpenAPI_pcc_rule_t *pcc_rule) +{ + if (NULL == pcc_rule) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(pcc_rule->flow_infos, node) { + OpenAPI_flow_information_free(node->data); + } + OpenAPI_list_free(pcc_rule->flow_infos); + ogs_free(pcc_rule->app_id); + ogs_free(pcc_rule->pcc_rule_id); + OpenAPI_af_sig_protocol_free(pcc_rule->af_sig_protocol); + OpenAPI_list_for_each(pcc_rule->ref_qos_data, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_qos_data); + OpenAPI_list_for_each(pcc_rule->ref_alt_qos_params, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_alt_qos_params); + OpenAPI_list_for_each(pcc_rule->ref_tc_data, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_tc_data); + OpenAPI_list_for_each(pcc_rule->ref_chg_data, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_chg_data); + OpenAPI_list_for_each(pcc_rule->ref_chg_n3g_data, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_chg_n3g_data); + OpenAPI_list_for_each(pcc_rule->ref_um_data, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_um_data); + OpenAPI_list_for_each(pcc_rule->ref_um_n3g_data, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_um_n3g_data); + ogs_free(pcc_rule->ref_cond_data); + OpenAPI_list_for_each(pcc_rule->ref_qos_mon, node) { + ogs_free(node->data); + } + OpenAPI_list_free(pcc_rule->ref_qos_mon); + OpenAPI_tscai_input_container_free(pcc_rule->tscai_input_dl); + OpenAPI_tscai_input_container_free(pcc_rule->tscai_input_ul); + ogs_free(pcc_rule); +} + +cJSON *OpenAPI_pcc_rule_convertToJSON(OpenAPI_pcc_rule_t *pcc_rule) +{ + cJSON *item = NULL; + + if (pcc_rule == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [PccRule]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (pcc_rule->flow_infos) { + cJSON *flow_infosList = cJSON_AddArrayToObject(item, "flowInfos"); + if (flow_infosList == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [flow_infos]"); + goto end; + } + + OpenAPI_lnode_t *flow_infos_node; + if (pcc_rule->flow_infos) { + OpenAPI_list_for_each(pcc_rule->flow_infos, flow_infos_node) { + cJSON *itemLocal = OpenAPI_flow_information_convertToJSON(flow_infos_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [flow_infos]"); + goto end; + } + cJSON_AddItemToArray(flow_infosList, itemLocal); + } + } + } + + if (pcc_rule->app_id) { + if (cJSON_AddStringToObject(item, "appId", pcc_rule->app_id) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [app_id]"); + goto end; + } + } + + if (pcc_rule->cont_ver) { + if (cJSON_AddNumberToObject(item, "contVer", pcc_rule->cont_ver) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [cont_ver]"); + goto end; + } + } + + if (!pcc_rule->pcc_rule_id) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [pcc_rule_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "pccRuleId", pcc_rule->pcc_rule_id) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [pcc_rule_id]"); + goto end; + } + + if (pcc_rule->precedence) { + if (cJSON_AddNumberToObject(item, "precedence", pcc_rule->precedence) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [precedence]"); + goto end; + } + } + + if (pcc_rule->af_sig_protocol) { + cJSON *af_sig_protocol_local_JSON = OpenAPI_af_sig_protocol_convertToJSON(pcc_rule->af_sig_protocol); + if (af_sig_protocol_local_JSON == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [af_sig_protocol]"); + goto end; + } + cJSON_AddItemToObject(item, "afSigProtocol", af_sig_protocol_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [af_sig_protocol]"); + goto end; + } + } + + if (pcc_rule->app_reloc) { + if (cJSON_AddBoolToObject(item, "appReloc", pcc_rule->app_reloc) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [app_reloc]"); + goto end; + } + } + + if (pcc_rule->ref_qos_data) { + cJSON *ref_qos_data = cJSON_AddArrayToObject(item, "refQosData"); + if (ref_qos_data == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_qos_data]"); + goto end; + } + + OpenAPI_lnode_t *ref_qos_data_node; + OpenAPI_list_for_each(pcc_rule->ref_qos_data, ref_qos_data_node) { + if (cJSON_AddStringToObject(ref_qos_data, "", (char*)ref_qos_data_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_qos_data]"); + goto end; + } + } + } + + if (pcc_rule->ref_alt_qos_params) { + cJSON *ref_alt_qos_params = cJSON_AddArrayToObject(item, "refAltQosParams"); + if (ref_alt_qos_params == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_alt_qos_params]"); + goto end; + } + + OpenAPI_lnode_t *ref_alt_qos_params_node; + OpenAPI_list_for_each(pcc_rule->ref_alt_qos_params, ref_alt_qos_params_node) { + if (cJSON_AddStringToObject(ref_alt_qos_params, "", (char*)ref_alt_qos_params_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_alt_qos_params]"); + goto end; + } + } + } + + if (pcc_rule->ref_tc_data) { + cJSON *ref_tc_data = cJSON_AddArrayToObject(item, "refTcData"); + if (ref_tc_data == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_tc_data]"); + goto end; + } + + OpenAPI_lnode_t *ref_tc_data_node; + OpenAPI_list_for_each(pcc_rule->ref_tc_data, ref_tc_data_node) { + if (cJSON_AddStringToObject(ref_tc_data, "", (char*)ref_tc_data_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_tc_data]"); + goto end; + } + } + } + + if (pcc_rule->ref_chg_data) { + cJSON *ref_chg_data = cJSON_AddArrayToObject(item, "refChgData"); + if (ref_chg_data == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_chg_data]"); + goto end; + } + + OpenAPI_lnode_t *ref_chg_data_node; + OpenAPI_list_for_each(pcc_rule->ref_chg_data, ref_chg_data_node) { + if (cJSON_AddStringToObject(ref_chg_data, "", (char*)ref_chg_data_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_chg_data]"); + goto end; + } + } + } + + if (pcc_rule->ref_chg_n3g_data) { + cJSON *ref_chg_n3g_data = cJSON_AddArrayToObject(item, "refChgN3gData"); + if (ref_chg_n3g_data == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_chg_n3g_data]"); + goto end; + } + + OpenAPI_lnode_t *ref_chg_n3g_data_node; + OpenAPI_list_for_each(pcc_rule->ref_chg_n3g_data, ref_chg_n3g_data_node) { + if (cJSON_AddStringToObject(ref_chg_n3g_data, "", (char*)ref_chg_n3g_data_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_chg_n3g_data]"); + goto end; + } + } + } + + if (pcc_rule->ref_um_data) { + cJSON *ref_um_data = cJSON_AddArrayToObject(item, "refUmData"); + if (ref_um_data == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_um_data]"); + goto end; + } + + OpenAPI_lnode_t *ref_um_data_node; + OpenAPI_list_for_each(pcc_rule->ref_um_data, ref_um_data_node) { + if (cJSON_AddStringToObject(ref_um_data, "", (char*)ref_um_data_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_um_data]"); + goto end; + } + } + } + + if (pcc_rule->ref_um_n3g_data) { + cJSON *ref_um_n3g_data = cJSON_AddArrayToObject(item, "refUmN3gData"); + if (ref_um_n3g_data == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_um_n3g_data]"); + goto end; + } + + OpenAPI_lnode_t *ref_um_n3g_data_node; + OpenAPI_list_for_each(pcc_rule->ref_um_n3g_data, ref_um_n3g_data_node) { + if (cJSON_AddStringToObject(ref_um_n3g_data, "", (char*)ref_um_n3g_data_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_um_n3g_data]"); + goto end; + } + } + } + + if (pcc_rule->ref_cond_data) { + if (cJSON_AddStringToObject(item, "refCondData", pcc_rule->ref_cond_data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_cond_data]"); + goto end; + } + } + + if (pcc_rule->ref_qos_mon) { + cJSON *ref_qos_mon = cJSON_AddArrayToObject(item, "refQosMon"); + if (ref_qos_mon == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_qos_mon]"); + goto end; + } + + OpenAPI_lnode_t *ref_qos_mon_node; + OpenAPI_list_for_each(pcc_rule->ref_qos_mon, ref_qos_mon_node) { + if (cJSON_AddStringToObject(ref_qos_mon, "", (char*)ref_qos_mon_node->data) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [ref_qos_mon]"); + goto end; + } + } + } + + if (pcc_rule->addr_preser_ind) { + if (cJSON_AddBoolToObject(item, "addrPreserInd", pcc_rule->addr_preser_ind) == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [addr_preser_ind]"); + goto end; + } + } + + if (pcc_rule->tscai_input_dl) { + cJSON *tscai_input_dl_local_JSON = OpenAPI_tscai_input_container_convertToJSON(pcc_rule->tscai_input_dl); + if (tscai_input_dl_local_JSON == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [tscai_input_dl]"); + goto end; + } + cJSON_AddItemToObject(item, "tscaiInputDl", tscai_input_dl_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [tscai_input_dl]"); + goto end; + } + } + + if (pcc_rule->tscai_input_ul) { + cJSON *tscai_input_ul_local_JSON = OpenAPI_tscai_input_container_convertToJSON(pcc_rule->tscai_input_ul); + if (tscai_input_ul_local_JSON == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [tscai_input_ul]"); + goto end; + } + cJSON_AddItemToObject(item, "tscaiInputUl", tscai_input_ul_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed [tscai_input_ul]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_pcc_rule_t *OpenAPI_pcc_rule_parseFromJSON(cJSON *pcc_ruleJSON) +{ + OpenAPI_pcc_rule_t *pcc_rule_local_var = NULL; + cJSON *flow_infos = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "flowInfos"); + + OpenAPI_list_t *flow_infosList; + if (flow_infos) { + cJSON *flow_infos_local_nonprimitive; + if (!cJSON_IsArray(flow_infos)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [flow_infos]"); + goto end; + } + + flow_infosList = OpenAPI_list_create(); + + cJSON_ArrayForEach(flow_infos_local_nonprimitive, flow_infos ) { + if (!cJSON_IsObject(flow_infos_local_nonprimitive)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [flow_infos]"); + goto end; + } + OpenAPI_flow_information_t *flow_infosItem = OpenAPI_flow_information_parseFromJSON(flow_infos_local_nonprimitive); + + OpenAPI_list_add(flow_infosList, flow_infosItem); + } + } + + cJSON *app_id = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "appId"); + + if (app_id) { + if (!cJSON_IsString(app_id)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [app_id]"); + goto end; + } + } + + cJSON *cont_ver = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "contVer"); + + if (cont_ver) { + if (!cJSON_IsNumber(cont_ver)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [cont_ver]"); + goto end; + } + } + + cJSON *pcc_rule_id = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "pccRuleId"); + if (!pcc_rule_id) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [pcc_rule_id]"); + goto end; + } + + + if (!cJSON_IsString(pcc_rule_id)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [pcc_rule_id]"); + goto end; + } + + cJSON *precedence = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "precedence"); + + if (precedence) { + if (!cJSON_IsNumber(precedence)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [precedence]"); + goto end; + } + } + + cJSON *af_sig_protocol = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "afSigProtocol"); + + OpenAPI_af_sig_protocol_t *af_sig_protocol_local_nonprim = NULL; + if (af_sig_protocol) { + af_sig_protocol_local_nonprim = OpenAPI_af_sig_protocol_parseFromJSON(af_sig_protocol); + } + + cJSON *app_reloc = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "appReloc"); + + if (app_reloc) { + if (!cJSON_IsBool(app_reloc)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [app_reloc]"); + goto end; + } + } + + cJSON *ref_qos_data = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refQosData"); + + OpenAPI_list_t *ref_qos_dataList; + if (ref_qos_data) { + cJSON *ref_qos_data_local; + if (!cJSON_IsArray(ref_qos_data)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_qos_data]"); + goto end; + } + ref_qos_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_qos_data_local, ref_qos_data) { + if (!cJSON_IsString(ref_qos_data_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_qos_data]"); + goto end; + } + OpenAPI_list_add(ref_qos_dataList, ogs_strdup(ref_qos_data_local->valuestring)); + } + } + + cJSON *ref_alt_qos_params = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refAltQosParams"); + + OpenAPI_list_t *ref_alt_qos_paramsList; + if (ref_alt_qos_params) { + cJSON *ref_alt_qos_params_local; + if (!cJSON_IsArray(ref_alt_qos_params)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_alt_qos_params]"); + goto end; + } + ref_alt_qos_paramsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_alt_qos_params_local, ref_alt_qos_params) { + if (!cJSON_IsString(ref_alt_qos_params_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_alt_qos_params]"); + goto end; + } + OpenAPI_list_add(ref_alt_qos_paramsList, ogs_strdup(ref_alt_qos_params_local->valuestring)); + } + } + + cJSON *ref_tc_data = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refTcData"); + + OpenAPI_list_t *ref_tc_dataList; + if (ref_tc_data) { + cJSON *ref_tc_data_local; + if (!cJSON_IsArray(ref_tc_data)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_tc_data]"); + goto end; + } + ref_tc_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_tc_data_local, ref_tc_data) { + if (!cJSON_IsString(ref_tc_data_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_tc_data]"); + goto end; + } + OpenAPI_list_add(ref_tc_dataList, ogs_strdup(ref_tc_data_local->valuestring)); + } + } + + cJSON *ref_chg_data = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refChgData"); + + OpenAPI_list_t *ref_chg_dataList; + if (ref_chg_data) { + cJSON *ref_chg_data_local; + if (!cJSON_IsArray(ref_chg_data)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_chg_data]"); + goto end; + } + ref_chg_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_chg_data_local, ref_chg_data) { + if (!cJSON_IsString(ref_chg_data_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_chg_data]"); + goto end; + } + OpenAPI_list_add(ref_chg_dataList, ogs_strdup(ref_chg_data_local->valuestring)); + } + } + + cJSON *ref_chg_n3g_data = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refChgN3gData"); + + OpenAPI_list_t *ref_chg_n3g_dataList; + if (ref_chg_n3g_data) { + cJSON *ref_chg_n3g_data_local; + if (!cJSON_IsArray(ref_chg_n3g_data)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_chg_n3g_data]"); + goto end; + } + ref_chg_n3g_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_chg_n3g_data_local, ref_chg_n3g_data) { + if (!cJSON_IsString(ref_chg_n3g_data_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_chg_n3g_data]"); + goto end; + } + OpenAPI_list_add(ref_chg_n3g_dataList, ogs_strdup(ref_chg_n3g_data_local->valuestring)); + } + } + + cJSON *ref_um_data = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refUmData"); + + OpenAPI_list_t *ref_um_dataList; + if (ref_um_data) { + cJSON *ref_um_data_local; + if (!cJSON_IsArray(ref_um_data)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_um_data]"); + goto end; + } + ref_um_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_um_data_local, ref_um_data) { + if (!cJSON_IsString(ref_um_data_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_um_data]"); + goto end; + } + OpenAPI_list_add(ref_um_dataList, ogs_strdup(ref_um_data_local->valuestring)); + } + } + + cJSON *ref_um_n3g_data = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refUmN3gData"); + + OpenAPI_list_t *ref_um_n3g_dataList; + if (ref_um_n3g_data) { + cJSON *ref_um_n3g_data_local; + if (!cJSON_IsArray(ref_um_n3g_data)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_um_n3g_data]"); + goto end; + } + ref_um_n3g_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_um_n3g_data_local, ref_um_n3g_data) { + if (!cJSON_IsString(ref_um_n3g_data_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_um_n3g_data]"); + goto end; + } + OpenAPI_list_add(ref_um_n3g_dataList, ogs_strdup(ref_um_n3g_data_local->valuestring)); + } + } + + cJSON *ref_cond_data = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refCondData"); + + if (ref_cond_data) { + if (!cJSON_IsString(ref_cond_data)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_cond_data]"); + goto end; + } + } + + cJSON *ref_qos_mon = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "refQosMon"); + + OpenAPI_list_t *ref_qos_monList; + if (ref_qos_mon) { + cJSON *ref_qos_mon_local; + if (!cJSON_IsArray(ref_qos_mon)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_qos_mon]"); + goto end; + } + ref_qos_monList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_qos_mon_local, ref_qos_mon) { + if (!cJSON_IsString(ref_qos_mon_local)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [ref_qos_mon]"); + goto end; + } + OpenAPI_list_add(ref_qos_monList, ogs_strdup(ref_qos_mon_local->valuestring)); + } + } + + cJSON *addr_preser_ind = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "addrPreserInd"); + + if (addr_preser_ind) { + if (!cJSON_IsBool(addr_preser_ind)) { + ogs_error("OpenAPI_pcc_rule_parseFromJSON() failed [addr_preser_ind]"); + goto end; + } + } + + cJSON *tscai_input_dl = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "tscaiInputDl"); + + OpenAPI_tscai_input_container_t *tscai_input_dl_local_nonprim = NULL; + if (tscai_input_dl) { + tscai_input_dl_local_nonprim = OpenAPI_tscai_input_container_parseFromJSON(tscai_input_dl); + } + + cJSON *tscai_input_ul = cJSON_GetObjectItemCaseSensitive(pcc_ruleJSON, "tscaiInputUl"); + + OpenAPI_tscai_input_container_t *tscai_input_ul_local_nonprim = NULL; + if (tscai_input_ul) { + tscai_input_ul_local_nonprim = OpenAPI_tscai_input_container_parseFromJSON(tscai_input_ul); + } + + pcc_rule_local_var = OpenAPI_pcc_rule_create ( + flow_infos ? flow_infosList : NULL, + app_id ? ogs_strdup(app_id->valuestring) : NULL, + cont_ver ? cont_ver->valuedouble : 0, + ogs_strdup(pcc_rule_id->valuestring), + precedence ? precedence->valuedouble : 0, + af_sig_protocol ? af_sig_protocol_local_nonprim : NULL, + app_reloc ? app_reloc->valueint : 0, + ref_qos_data ? ref_qos_dataList : NULL, + ref_alt_qos_params ? ref_alt_qos_paramsList : NULL, + ref_tc_data ? ref_tc_dataList : NULL, + ref_chg_data ? ref_chg_dataList : NULL, + ref_chg_n3g_data ? ref_chg_n3g_dataList : NULL, + ref_um_data ? ref_um_dataList : NULL, + ref_um_n3g_data ? ref_um_n3g_dataList : NULL, + ref_cond_data ? ogs_strdup(ref_cond_data->valuestring) : NULL, + ref_qos_mon ? ref_qos_monList : NULL, + addr_preser_ind ? addr_preser_ind->valueint : 0, + tscai_input_dl ? tscai_input_dl_local_nonprim : NULL, + tscai_input_ul ? tscai_input_ul_local_nonprim : NULL + ); + + return pcc_rule_local_var; +end: + return NULL; +} + +OpenAPI_pcc_rule_t *OpenAPI_pcc_rule_copy(OpenAPI_pcc_rule_t *dst, OpenAPI_pcc_rule_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_pcc_rule_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_pcc_rule_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_pcc_rule_free(dst); + dst = OpenAPI_pcc_rule_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/pcc_rule.h b/lib/sbi/openapi/model/pcc_rule.h new file mode 100644 index 000000000..f201a7515 --- /dev/null +++ b/lib/sbi/openapi/model/pcc_rule.h @@ -0,0 +1,77 @@ +/* + * pcc_rule.h + * + * + */ + +#ifndef _OpenAPI_pcc_rule_H_ +#define _OpenAPI_pcc_rule_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "af_sig_protocol.h" +#include "flow_information.h" +#include "tscai_input_container.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_pcc_rule_s OpenAPI_pcc_rule_t; +typedef struct OpenAPI_pcc_rule_s { + OpenAPI_list_t *flow_infos; + char *app_id; + int cont_ver; + char *pcc_rule_id; + int precedence; + struct OpenAPI_af_sig_protocol_s *af_sig_protocol; + int app_reloc; + OpenAPI_list_t *ref_qos_data; + OpenAPI_list_t *ref_alt_qos_params; + OpenAPI_list_t *ref_tc_data; + OpenAPI_list_t *ref_chg_data; + OpenAPI_list_t *ref_chg_n3g_data; + OpenAPI_list_t *ref_um_data; + OpenAPI_list_t *ref_um_n3g_data; + char *ref_cond_data; + OpenAPI_list_t *ref_qos_mon; + int addr_preser_ind; + struct OpenAPI_tscai_input_container_s *tscai_input_dl; + struct OpenAPI_tscai_input_container_s *tscai_input_ul; +} OpenAPI_pcc_rule_t; + +OpenAPI_pcc_rule_t *OpenAPI_pcc_rule_create( + OpenAPI_list_t *flow_infos, + char *app_id, + int cont_ver, + char *pcc_rule_id, + int precedence, + OpenAPI_af_sig_protocol_t *af_sig_protocol, + int app_reloc, + OpenAPI_list_t *ref_qos_data, + OpenAPI_list_t *ref_alt_qos_params, + OpenAPI_list_t *ref_tc_data, + OpenAPI_list_t *ref_chg_data, + OpenAPI_list_t *ref_chg_n3g_data, + OpenAPI_list_t *ref_um_data, + OpenAPI_list_t *ref_um_n3g_data, + char *ref_cond_data, + OpenAPI_list_t *ref_qos_mon, + int addr_preser_ind, + OpenAPI_tscai_input_container_t *tscai_input_dl, + OpenAPI_tscai_input_container_t *tscai_input_ul + ); +void OpenAPI_pcc_rule_free(OpenAPI_pcc_rule_t *pcc_rule); +OpenAPI_pcc_rule_t *OpenAPI_pcc_rule_parseFromJSON(cJSON *pcc_ruleJSON); +cJSON *OpenAPI_pcc_rule_convertToJSON(OpenAPI_pcc_rule_t *pcc_rule); +OpenAPI_pcc_rule_t *OpenAPI_pcc_rule_copy(OpenAPI_pcc_rule_t *dst, OpenAPI_pcc_rule_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_pcc_rule_H_ */ + diff --git a/lib/sbi/openapi/model/pdu_session_create_data.c b/lib/sbi/openapi/model/pdu_session_create_data.c index 08768f9af..17bc96a60 100644 --- a/lib/sbi/openapi/model/pdu_session_create_data.c +++ b/lib/sbi/openapi/model/pdu_session_create_data.c @@ -58,7 +58,7 @@ OpenAPI_pdu_session_create_data_t *OpenAPI_pdu_session_create_data_create( int ma_request_ind, int ma_nw_upgrade_ind, OpenAPI_list_t *dnai_list, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, OpenAPI_list_t *secondary_rat_usage_info, OpenAPI_small_data_rate_status_t *small_data_rate_status, OpenAPI_apn_rate_status_t *apn_rate_status, @@ -179,7 +179,6 @@ void OpenAPI_pdu_session_create_data_free(OpenAPI_pdu_session_create_data_t *pdu ogs_free(node->data); } OpenAPI_list_free(pdu_session_create_data->dnai_list); - OpenAPI_presence_state_free(pdu_session_create_data->presence_in_ladn); OpenAPI_list_for_each(pdu_session_create_data->secondary_rat_usage_info, node) { OpenAPI_secondary_rat_usage_info_free(node->data); } @@ -667,13 +666,7 @@ cJSON *OpenAPI_pdu_session_create_data_convertToJSON(OpenAPI_pdu_session_create_ } if (pdu_session_create_data->presence_in_ladn) { - cJSON *presence_in_ladn_local_JSON = OpenAPI_presence_state_convertToJSON(pdu_session_create_data->presence_in_ladn); - if (presence_in_ladn_local_JSON == NULL) { - ogs_error("OpenAPI_pdu_session_create_data_convertToJSON() failed [presence_in_ladn]"); - goto end; - } - cJSON_AddItemToObject(item, "presenceInLadn", presence_in_ladn_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "presenceInLadn", OpenAPI_presence_state_ToString(pdu_session_create_data->presence_in_ladn)) == NULL) { ogs_error("OpenAPI_pdu_session_create_data_convertToJSON() failed [presence_in_ladn]"); goto end; } @@ -1237,9 +1230,13 @@ OpenAPI_pdu_session_create_data_t *OpenAPI_pdu_session_create_data_parseFromJSON cJSON *presence_in_ladn = cJSON_GetObjectItemCaseSensitive(pdu_session_create_dataJSON, "presenceInLadn"); - OpenAPI_presence_state_t *presence_in_ladn_local_nonprim = NULL; + OpenAPI_presence_state_e presence_in_ladnVariable; if (presence_in_ladn) { - presence_in_ladn_local_nonprim = OpenAPI_presence_state_parseFromJSON(presence_in_ladn); + if (!cJSON_IsString(presence_in_ladn)) { + ogs_error("OpenAPI_pdu_session_create_data_parseFromJSON() failed [presence_in_ladn]"); + goto end; + } + presence_in_ladnVariable = OpenAPI_presence_state_FromString(presence_in_ladn->valuestring); } cJSON *secondary_rat_usage_info = cJSON_GetObjectItemCaseSensitive(pdu_session_create_dataJSON, "secondaryRatUsageInfo"); @@ -1342,7 +1339,7 @@ OpenAPI_pdu_session_create_data_t *OpenAPI_pdu_session_create_data_parseFromJSON ma_request_ind ? ma_request_ind->valueint : 0, ma_nw_upgrade_ind ? ma_nw_upgrade_ind->valueint : 0, dnai_list ? dnai_listList : NULL, - presence_in_ladn ? presence_in_ladn_local_nonprim : NULL, + presence_in_ladn ? presence_in_ladnVariable : 0, secondary_rat_usage_info ? secondary_rat_usage_infoList : NULL, small_data_rate_status ? small_data_rate_status_local_nonprim : NULL, apn_rate_status ? apn_rate_status_local_nonprim : NULL, diff --git a/lib/sbi/openapi/model/pdu_session_create_data.h b/lib/sbi/openapi/model/pdu_session_create_data.h index e64baa708..0130a2f6e 100644 --- a/lib/sbi/openapi/model/pdu_session_create_data.h +++ b/lib/sbi/openapi/model/pdu_session_create_data.h @@ -88,7 +88,7 @@ typedef struct OpenAPI_pdu_session_create_data_s { int ma_request_ind; int ma_nw_upgrade_ind; OpenAPI_list_t *dnai_list; - struct OpenAPI_presence_state_s *presence_in_ladn; + OpenAPI_presence_state_e presence_in_ladn; OpenAPI_list_t *secondary_rat_usage_info; struct OpenAPI_small_data_rate_status_s *small_data_rate_status; struct OpenAPI_apn_rate_status_s *apn_rate_status; @@ -149,7 +149,7 @@ OpenAPI_pdu_session_create_data_t *OpenAPI_pdu_session_create_data_create( int ma_request_ind, int ma_nw_upgrade_ind, OpenAPI_list_t *dnai_list, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, OpenAPI_list_t *secondary_rat_usage_info, OpenAPI_small_data_rate_status_t *small_data_rate_status, OpenAPI_apn_rate_status_t *apn_rate_status, diff --git a/lib/sbi/openapi/model/pdu_session_rel_cause.c b/lib/sbi/openapi/model/pdu_session_rel_cause.c new file mode 100644 index 000000000..c666eb233 --- /dev/null +++ b/lib/sbi/openapi/model/pdu_session_rel_cause.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "pdu_session_rel_cause.h" + +OpenAPI_pdu_session_rel_cause_t *OpenAPI_pdu_session_rel_cause_create( + ) +{ + OpenAPI_pdu_session_rel_cause_t *pdu_session_rel_cause_local_var = OpenAPI_malloc(sizeof(OpenAPI_pdu_session_rel_cause_t)); + if (!pdu_session_rel_cause_local_var) { + return NULL; + } + + return pdu_session_rel_cause_local_var; +} + +void OpenAPI_pdu_session_rel_cause_free(OpenAPI_pdu_session_rel_cause_t *pdu_session_rel_cause) +{ + if (NULL == pdu_session_rel_cause) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(pdu_session_rel_cause); +} + +cJSON *OpenAPI_pdu_session_rel_cause_convertToJSON(OpenAPI_pdu_session_rel_cause_t *pdu_session_rel_cause) +{ + cJSON *item = NULL; + + if (pdu_session_rel_cause == NULL) { + ogs_error("OpenAPI_pdu_session_rel_cause_convertToJSON() failed [PduSessionRelCause]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_pdu_session_rel_cause_t *OpenAPI_pdu_session_rel_cause_parseFromJSON(cJSON *pdu_session_rel_causeJSON) +{ + OpenAPI_pdu_session_rel_cause_t *pdu_session_rel_cause_local_var = NULL; + pdu_session_rel_cause_local_var = OpenAPI_pdu_session_rel_cause_create ( + ); + + return pdu_session_rel_cause_local_var; +end: + return NULL; +} + +OpenAPI_pdu_session_rel_cause_t *OpenAPI_pdu_session_rel_cause_copy(OpenAPI_pdu_session_rel_cause_t *dst, OpenAPI_pdu_session_rel_cause_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_pdu_session_rel_cause_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_pdu_session_rel_cause_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_pdu_session_rel_cause_free(dst); + dst = OpenAPI_pdu_session_rel_cause_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/pdu_session_rel_cause.h b/lib/sbi/openapi/model/pdu_session_rel_cause.h new file mode 100644 index 000000000..45cdcb0fc --- /dev/null +++ b/lib/sbi/openapi/model/pdu_session_rel_cause.h @@ -0,0 +1,36 @@ +/* + * pdu_session_rel_cause.h + * + * + */ + +#ifndef _OpenAPI_pdu_session_rel_cause_H_ +#define _OpenAPI_pdu_session_rel_cause_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_pdu_session_rel_cause_s OpenAPI_pdu_session_rel_cause_t; +typedef struct OpenAPI_pdu_session_rel_cause_s { +} OpenAPI_pdu_session_rel_cause_t; + +OpenAPI_pdu_session_rel_cause_t *OpenAPI_pdu_session_rel_cause_create( + ); +void OpenAPI_pdu_session_rel_cause_free(OpenAPI_pdu_session_rel_cause_t *pdu_session_rel_cause); +OpenAPI_pdu_session_rel_cause_t *OpenAPI_pdu_session_rel_cause_parseFromJSON(cJSON *pdu_session_rel_causeJSON); +cJSON *OpenAPI_pdu_session_rel_cause_convertToJSON(OpenAPI_pdu_session_rel_cause_t *pdu_session_rel_cause); +OpenAPI_pdu_session_rel_cause_t *OpenAPI_pdu_session_rel_cause_copy(OpenAPI_pdu_session_rel_cause_t *dst, OpenAPI_pdu_session_rel_cause_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_pdu_session_rel_cause_H_ */ + diff --git a/lib/sbi/openapi/model/policy_association.c b/lib/sbi/openapi/model/policy_association.c new file mode 100644 index 000000000..34588a359 --- /dev/null +++ b/lib/sbi/openapi/model/policy_association.c @@ -0,0 +1,367 @@ + +#include +#include +#include +#include "policy_association.h" + +OpenAPI_policy_association_t *OpenAPI_policy_association_create( + OpenAPI_policy_association_request_t *request, + OpenAPI_list_t *triggers, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_smf_selection_data_t *smf_sel_info, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t* pras, + char *supp_feat + ) +{ + OpenAPI_policy_association_t *policy_association_local_var = OpenAPI_malloc(sizeof(OpenAPI_policy_association_t)); + if (!policy_association_local_var) { + return NULL; + } + policy_association_local_var->request = request; + policy_association_local_var->triggers = triggers; + policy_association_local_var->serv_area_res = serv_area_res; + policy_association_local_var->wl_serv_area_res = wl_serv_area_res; + policy_association_local_var->rfsp = rfsp; + policy_association_local_var->smf_sel_info = smf_sel_info; + policy_association_local_var->ue_ambr = ue_ambr; + policy_association_local_var->rg_tmbr = rg_tmbr; + policy_association_local_var->pras = pras; + policy_association_local_var->supp_feat = supp_feat; + + return policy_association_local_var; +} + +void OpenAPI_policy_association_free(OpenAPI_policy_association_t *policy_association) +{ + if (NULL == policy_association) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_policy_association_request_free(policy_association->request); + OpenAPI_list_free(policy_association->triggers); + OpenAPI_service_area_restriction_free(policy_association->serv_area_res); + OpenAPI_wireline_service_area_restriction_free(policy_association->wl_serv_area_res); + OpenAPI_smf_selection_data_free(policy_association->smf_sel_info); + OpenAPI_ambr_free(policy_association->ue_ambr); + OpenAPI_ambr_free(policy_association->rg_tmbr); + OpenAPI_list_for_each(policy_association->pras, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_presence_info_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(policy_association->pras); + ogs_free(policy_association->supp_feat); + ogs_free(policy_association); +} + +cJSON *OpenAPI_policy_association_convertToJSON(OpenAPI_policy_association_t *policy_association) +{ + cJSON *item = NULL; + + if (policy_association == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [PolicyAssociation]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (policy_association->request) { + cJSON *request_local_JSON = OpenAPI_policy_association_request_convertToJSON(policy_association->request); + if (request_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [request]"); + goto end; + } + cJSON_AddItemToObject(item, "request", request_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [request]"); + goto end; + } + } + + if (policy_association->triggers) { + cJSON *triggers = cJSON_AddArrayToObject(item, "triggers"); + if (triggers == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [triggers]"); + goto end; + } + OpenAPI_lnode_t *triggers_node; + OpenAPI_list_for_each(policy_association->triggers, triggers_node) { + if (cJSON_AddStringToObject(triggers, "", OpenAPI_request_trigger_ToString((OpenAPI_request_trigger_e)triggers_node->data)) == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [triggers]"); + goto end; + } + } + } + + if (policy_association->serv_area_res) { + cJSON *serv_area_res_local_JSON = OpenAPI_service_area_restriction_convertToJSON(policy_association->serv_area_res); + if (serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "servAreaRes", serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [serv_area_res]"); + goto end; + } + } + + if (policy_association->wl_serv_area_res) { + cJSON *wl_serv_area_res_local_JSON = OpenAPI_wireline_service_area_restriction_convertToJSON(policy_association->wl_serv_area_res); + if (wl_serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "wlServAreaRes", wl_serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + } + + if (policy_association->rfsp) { + if (cJSON_AddNumberToObject(item, "rfsp", policy_association->rfsp) == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [rfsp]"); + goto end; + } + } + + if (policy_association->smf_sel_info) { + cJSON *smf_sel_info_local_JSON = OpenAPI_smf_selection_data_convertToJSON(policy_association->smf_sel_info); + if (smf_sel_info_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [smf_sel_info]"); + goto end; + } + cJSON_AddItemToObject(item, "smfSelInfo", smf_sel_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [smf_sel_info]"); + goto end; + } + } + + if (policy_association->ue_ambr) { + cJSON *ue_ambr_local_JSON = OpenAPI_ambr_convertToJSON(policy_association->ue_ambr); + if (ue_ambr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [ue_ambr]"); + goto end; + } + cJSON_AddItemToObject(item, "ueAmbr", ue_ambr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [ue_ambr]"); + goto end; + } + } + + if (policy_association->rg_tmbr) { + cJSON *rg_tmbr_local_JSON = OpenAPI_ambr_convertToJSON(policy_association->rg_tmbr); + if (rg_tmbr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [rg_tmbr]"); + goto end; + } + cJSON_AddItemToObject(item, "rgTmbr", rg_tmbr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [rg_tmbr]"); + goto end; + } + } + + if (policy_association->pras) { + cJSON *pras = cJSON_AddObjectToObject(item, "pras"); + if (pras == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [pras]"); + goto end; + } + cJSON *localMapObject = pras; + OpenAPI_lnode_t *pras_node; + if (policy_association->pras) { + OpenAPI_list_for_each(policy_association->pras, pras_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)pras_node->data; + cJSON *itemLocal = OpenAPI_presence_info_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [pras]"); + goto end; + } + cJSON_AddItemToObject(pras, localKeyValue->key, itemLocal); + } + } + } + + if (!policy_association->supp_feat) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [supp_feat]"); + goto end; + } + if (cJSON_AddStringToObject(item, "suppFeat", policy_association->supp_feat) == NULL) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed [supp_feat]"); + goto end; + } + +end: + return item; +} + +OpenAPI_policy_association_t *OpenAPI_policy_association_parseFromJSON(cJSON *policy_associationJSON) +{ + OpenAPI_policy_association_t *policy_association_local_var = NULL; + cJSON *request = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "request"); + + OpenAPI_policy_association_request_t *request_local_nonprim = NULL; + if (request) { + request_local_nonprim = OpenAPI_policy_association_request_parseFromJSON(request); + } + + cJSON *triggers = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "triggers"); + + OpenAPI_list_t *triggersList; + if (triggers) { + cJSON *triggers_local_nonprimitive; + if (!cJSON_IsArray(triggers)) { + ogs_error("OpenAPI_policy_association_parseFromJSON() failed [triggers]"); + goto end; + } + + triggersList = OpenAPI_list_create(); + + cJSON_ArrayForEach(triggers_local_nonprimitive, triggers ) { + if (!cJSON_IsString(triggers_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_parseFromJSON() failed [triggers]"); + goto end; + } + + OpenAPI_list_add(triggersList, (void *)OpenAPI_request_trigger_FromString(triggers_local_nonprimitive->valuestring)); + } + } + + cJSON *serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "servAreaRes"); + + OpenAPI_service_area_restriction_t *serv_area_res_local_nonprim = NULL; + if (serv_area_res) { + serv_area_res_local_nonprim = OpenAPI_service_area_restriction_parseFromJSON(serv_area_res); + } + + cJSON *wl_serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "wlServAreaRes"); + + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res_local_nonprim = NULL; + if (wl_serv_area_res) { + wl_serv_area_res_local_nonprim = OpenAPI_wireline_service_area_restriction_parseFromJSON(wl_serv_area_res); + } + + cJSON *rfsp = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "rfsp"); + + if (rfsp) { + if (!cJSON_IsNumber(rfsp)) { + ogs_error("OpenAPI_policy_association_parseFromJSON() failed [rfsp]"); + goto end; + } + } + + cJSON *smf_sel_info = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "smfSelInfo"); + + OpenAPI_smf_selection_data_t *smf_sel_info_local_nonprim = NULL; + if (smf_sel_info) { + smf_sel_info_local_nonprim = OpenAPI_smf_selection_data_parseFromJSON(smf_sel_info); + } + + cJSON *ue_ambr = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "ueAmbr"); + + OpenAPI_ambr_t *ue_ambr_local_nonprim = NULL; + if (ue_ambr) { + ue_ambr_local_nonprim = OpenAPI_ambr_parseFromJSON(ue_ambr); + } + + cJSON *rg_tmbr = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "rgTmbr"); + + OpenAPI_ambr_t *rg_tmbr_local_nonprim = NULL; + if (rg_tmbr) { + rg_tmbr_local_nonprim = OpenAPI_ambr_parseFromJSON(rg_tmbr); + } + + cJSON *pras = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "pras"); + + OpenAPI_list_t *prasList; + if (pras) { + cJSON *pras_local_map; + if (!cJSON_IsObject(pras)) { + ogs_error("OpenAPI_policy_association_parseFromJSON() failed [pras]"); + goto end; + } + prasList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(pras_local_map, pras) { + cJSON *localMapObject = pras_local_map; + if (!cJSON_IsObject(pras_local_map)) { + ogs_error("OpenAPI_policy_association_parseFromJSON() failed [pras]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_presence_info_parseFromJSON(localMapObject)); + OpenAPI_list_add(prasList, localMapKeyPair); + } + } + + cJSON *supp_feat = cJSON_GetObjectItemCaseSensitive(policy_associationJSON, "suppFeat"); + if (!supp_feat) { + ogs_error("OpenAPI_policy_association_parseFromJSON() failed [supp_feat]"); + goto end; + } + + + if (!cJSON_IsString(supp_feat)) { + ogs_error("OpenAPI_policy_association_parseFromJSON() failed [supp_feat]"); + goto end; + } + + policy_association_local_var = OpenAPI_policy_association_create ( + request ? request_local_nonprim : NULL, + triggers ? triggersList : NULL, + serv_area_res ? serv_area_res_local_nonprim : NULL, + wl_serv_area_res ? wl_serv_area_res_local_nonprim : NULL, + rfsp ? rfsp->valuedouble : 0, + smf_sel_info ? smf_sel_info_local_nonprim : NULL, + ue_ambr ? ue_ambr_local_nonprim : NULL, + rg_tmbr ? rg_tmbr_local_nonprim : NULL, + pras ? prasList : NULL, + ogs_strdup(supp_feat->valuestring) + ); + + return policy_association_local_var; +end: + return NULL; +} + +OpenAPI_policy_association_t *OpenAPI_policy_association_copy(OpenAPI_policy_association_t *dst, OpenAPI_policy_association_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_policy_association_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_policy_association_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_policy_association_free(dst); + dst = OpenAPI_policy_association_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/policy_association.h b/lib/sbi/openapi/model/policy_association.h new file mode 100644 index 000000000..979da2d0f --- /dev/null +++ b/lib/sbi/openapi/model/policy_association.h @@ -0,0 +1,63 @@ +/* + * policy_association.h + * + * + */ + +#ifndef _OpenAPI_policy_association_H_ +#define _OpenAPI_policy_association_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "ambr.h" +#include "policy_association_request.h" +#include "presence_info.h" +#include "request_trigger.h" +#include "service_area_restriction.h" +#include "smf_selection_data.h" +#include "wireline_service_area_restriction.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_policy_association_s OpenAPI_policy_association_t; +typedef struct OpenAPI_policy_association_s { + struct OpenAPI_policy_association_request_s *request; + OpenAPI_list_t *triggers; + struct OpenAPI_service_area_restriction_s *serv_area_res; + struct OpenAPI_wireline_service_area_restriction_s *wl_serv_area_res; + int rfsp; + struct OpenAPI_smf_selection_data_s *smf_sel_info; + struct OpenAPI_ambr_s *ue_ambr; + struct OpenAPI_ambr_s *rg_tmbr; + OpenAPI_list_t* pras; + char *supp_feat; +} OpenAPI_policy_association_t; + +OpenAPI_policy_association_t *OpenAPI_policy_association_create( + OpenAPI_policy_association_request_t *request, + OpenAPI_list_t *triggers, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_smf_selection_data_t *smf_sel_info, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t* pras, + char *supp_feat + ); +void OpenAPI_policy_association_free(OpenAPI_policy_association_t *policy_association); +OpenAPI_policy_association_t *OpenAPI_policy_association_parseFromJSON(cJSON *policy_associationJSON); +cJSON *OpenAPI_policy_association_convertToJSON(OpenAPI_policy_association_t *policy_association); +OpenAPI_policy_association_t *OpenAPI_policy_association_copy(OpenAPI_policy_association_t *dst, OpenAPI_policy_association_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_policy_association_H_ */ + diff --git a/lib/sbi/openapi/model/policy_association_release_cause.c b/lib/sbi/openapi/model/policy_association_release_cause.c new file mode 100644 index 000000000..4e930d38e --- /dev/null +++ b/lib/sbi/openapi/model/policy_association_release_cause.c @@ -0,0 +1,30 @@ + +#include +#include +#include +#include "policy_association_release_cause.h" + +char* OpenAPI_policy_association_release_cause_ToString(OpenAPI_policy_association_release_cause_e policy_association_release_cause) +{ + const char *policy_association_release_causeArray[] = { "NULL", "UNSPECIFIED", "UE_SUBSCRIPTION", "INSUFFICIENT_RES" }; + size_t sizeofArray = sizeof(policy_association_release_causeArray) / sizeof(policy_association_release_causeArray[0]); + if (policy_association_release_cause < sizeofArray) + return (char *)policy_association_release_causeArray[policy_association_release_cause]; + else + return (char *)"Unknown"; +} + +OpenAPI_policy_association_release_cause_e OpenAPI_policy_association_release_cause_FromString(char* policy_association_release_cause) +{ + int stringToReturn = 0; + const char *policy_association_release_causeArray[] = { "NULL", "UNSPECIFIED", "UE_SUBSCRIPTION", "INSUFFICIENT_RES" }; + size_t sizeofArray = sizeof(policy_association_release_causeArray) / sizeof(policy_association_release_causeArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(policy_association_release_cause, policy_association_release_causeArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; + } + return 0; +} + diff --git a/lib/sbi/openapi/model/policy_association_release_cause.h b/lib/sbi/openapi/model/policy_association_release_cause.h new file mode 100644 index 000000000..3cc96ada9 --- /dev/null +++ b/lib/sbi/openapi/model/policy_association_release_cause.h @@ -0,0 +1,31 @@ +/* + * policy_association_release_cause.h + * + * + */ + +#ifndef _OpenAPI_policy_association_release_cause_H_ +#define _OpenAPI_policy_association_release_cause_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { OpenAPI_policy_association_release_cause_NULL = 0, OpenAPI_policy_association_release_cause_UNSPECIFIED, OpenAPI_policy_association_release_cause_UE_SUBSCRIPTION, OpenAPI_policy_association_release_cause_INSUFFICIENT_RES } OpenAPI_policy_association_release_cause_e; + +char* OpenAPI_policy_association_release_cause_ToString(OpenAPI_policy_association_release_cause_e policy_association_release_cause); + +OpenAPI_policy_association_release_cause_e OpenAPI_policy_association_release_cause_FromString(char* policy_association_release_cause); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_policy_association_release_cause_H_ */ + diff --git a/lib/sbi/openapi/model/policy_association_request.c b/lib/sbi/openapi/model/policy_association_request.c new file mode 100644 index 000000000..8982fd14f --- /dev/null +++ b/lib/sbi/openapi/model/policy_association_request.c @@ -0,0 +1,854 @@ + +#include +#include +#include +#include "policy_association_request.h" + +OpenAPI_policy_association_request_t *OpenAPI_policy_association_request_create( + char *notification_uri, + OpenAPI_list_t *alt_notif_ipv4_addrs, + OpenAPI_list_t *alt_notif_ipv6_addrs, + char *supi, + char *gpsi, + OpenAPI_access_type_e access_type, + OpenAPI_list_t *access_types, + char *pei, + OpenAPI_user_location_t *user_loc, + char *time_zone, + OpenAPI_plmn_id_nid_t *serving_plmn, + OpenAPI_rat_type_e rat_type, + OpenAPI_list_t *rat_types, + OpenAPI_list_t *group_ids, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t *allowed_snssais, + OpenAPI_list_t *mapping_snssais, + OpenAPI_list_t *n3g_allowed_snssais, + OpenAPI_guami_t *guami, + char *servive_name, + OpenAPI_trace_data_t *trace_req, + char *supp_feat + ) +{ + OpenAPI_policy_association_request_t *policy_association_request_local_var = OpenAPI_malloc(sizeof(OpenAPI_policy_association_request_t)); + if (!policy_association_request_local_var) { + return NULL; + } + policy_association_request_local_var->notification_uri = notification_uri; + policy_association_request_local_var->alt_notif_ipv4_addrs = alt_notif_ipv4_addrs; + policy_association_request_local_var->alt_notif_ipv6_addrs = alt_notif_ipv6_addrs; + policy_association_request_local_var->supi = supi; + policy_association_request_local_var->gpsi = gpsi; + policy_association_request_local_var->access_type = access_type; + policy_association_request_local_var->access_types = access_types; + policy_association_request_local_var->pei = pei; + policy_association_request_local_var->user_loc = user_loc; + policy_association_request_local_var->time_zone = time_zone; + policy_association_request_local_var->serving_plmn = serving_plmn; + policy_association_request_local_var->rat_type = rat_type; + policy_association_request_local_var->rat_types = rat_types; + policy_association_request_local_var->group_ids = group_ids; + policy_association_request_local_var->serv_area_res = serv_area_res; + policy_association_request_local_var->wl_serv_area_res = wl_serv_area_res; + policy_association_request_local_var->rfsp = rfsp; + policy_association_request_local_var->ue_ambr = ue_ambr; + policy_association_request_local_var->rg_tmbr = rg_tmbr; + policy_association_request_local_var->allowed_snssais = allowed_snssais; + policy_association_request_local_var->mapping_snssais = mapping_snssais; + policy_association_request_local_var->n3g_allowed_snssais = n3g_allowed_snssais; + policy_association_request_local_var->guami = guami; + policy_association_request_local_var->servive_name = servive_name; + policy_association_request_local_var->trace_req = trace_req; + policy_association_request_local_var->supp_feat = supp_feat; + + return policy_association_request_local_var; +} + +void OpenAPI_policy_association_request_free(OpenAPI_policy_association_request_t *policy_association_request) +{ + if (NULL == policy_association_request) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(policy_association_request->notification_uri); + OpenAPI_list_for_each(policy_association_request->alt_notif_ipv4_addrs, node) { + ogs_free(node->data); + } + OpenAPI_list_free(policy_association_request->alt_notif_ipv4_addrs); + OpenAPI_list_for_each(policy_association_request->alt_notif_ipv6_addrs, node) { + ogs_free(node->data); + } + OpenAPI_list_free(policy_association_request->alt_notif_ipv6_addrs); + ogs_free(policy_association_request->supi); + ogs_free(policy_association_request->gpsi); + OpenAPI_list_free(policy_association_request->access_types); + ogs_free(policy_association_request->pei); + OpenAPI_user_location_free(policy_association_request->user_loc); + ogs_free(policy_association_request->time_zone); + OpenAPI_plmn_id_nid_free(policy_association_request->serving_plmn); + OpenAPI_list_free(policy_association_request->rat_types); + OpenAPI_list_for_each(policy_association_request->group_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(policy_association_request->group_ids); + OpenAPI_service_area_restriction_free(policy_association_request->serv_area_res); + OpenAPI_wireline_service_area_restriction_free(policy_association_request->wl_serv_area_res); + OpenAPI_ambr_free(policy_association_request->ue_ambr); + OpenAPI_ambr_free(policy_association_request->rg_tmbr); + OpenAPI_list_for_each(policy_association_request->allowed_snssais, node) { + OpenAPI_snssai_free(node->data); + } + OpenAPI_list_free(policy_association_request->allowed_snssais); + OpenAPI_list_for_each(policy_association_request->mapping_snssais, node) { + OpenAPI_mapping_of_snssai_free(node->data); + } + OpenAPI_list_free(policy_association_request->mapping_snssais); + OpenAPI_list_for_each(policy_association_request->n3g_allowed_snssais, node) { + OpenAPI_snssai_free(node->data); + } + OpenAPI_list_free(policy_association_request->n3g_allowed_snssais); + OpenAPI_guami_free(policy_association_request->guami); + ogs_free(policy_association_request->servive_name); + OpenAPI_trace_data_free(policy_association_request->trace_req); + ogs_free(policy_association_request->supp_feat); + ogs_free(policy_association_request); +} + +cJSON *OpenAPI_policy_association_request_convertToJSON(OpenAPI_policy_association_request_t *policy_association_request) +{ + cJSON *item = NULL; + + if (policy_association_request == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [PolicyAssociationRequest]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!policy_association_request->notification_uri) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [notification_uri]"); + goto end; + } + if (cJSON_AddStringToObject(item, "notificationUri", policy_association_request->notification_uri) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [notification_uri]"); + goto end; + } + + if (policy_association_request->alt_notif_ipv4_addrs) { + cJSON *alt_notif_ipv4_addrs = cJSON_AddArrayToObject(item, "altNotifIpv4Addrs"); + if (alt_notif_ipv4_addrs == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + + OpenAPI_lnode_t *alt_notif_ipv4_addrs_node; + OpenAPI_list_for_each(policy_association_request->alt_notif_ipv4_addrs, alt_notif_ipv4_addrs_node) { + if (cJSON_AddStringToObject(alt_notif_ipv4_addrs, "", (char*)alt_notif_ipv4_addrs_node->data) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + } + } + + if (policy_association_request->alt_notif_ipv6_addrs) { + cJSON *alt_notif_ipv6_addrs = cJSON_AddArrayToObject(item, "altNotifIpv6Addrs"); + if (alt_notif_ipv6_addrs == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + + OpenAPI_lnode_t *alt_notif_ipv6_addrs_node; + OpenAPI_list_for_each(policy_association_request->alt_notif_ipv6_addrs, alt_notif_ipv6_addrs_node) { + if (cJSON_AddStringToObject(alt_notif_ipv6_addrs, "", (char*)alt_notif_ipv6_addrs_node->data) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + } + } + + if (!policy_association_request->supi) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [supi]"); + goto end; + } + if (cJSON_AddStringToObject(item, "supi", policy_association_request->supi) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [supi]"); + goto end; + } + + if (policy_association_request->gpsi) { + if (cJSON_AddStringToObject(item, "gpsi", policy_association_request->gpsi) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [gpsi]"); + goto end; + } + } + + if (policy_association_request->access_type) { + if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(policy_association_request->access_type)) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [access_type]"); + goto end; + } + } + + if (policy_association_request->access_types) { + cJSON *access_types = cJSON_AddArrayToObject(item, "accessTypes"); + if (access_types == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [access_types]"); + goto end; + } + OpenAPI_lnode_t *access_types_node; + OpenAPI_list_for_each(policy_association_request->access_types, access_types_node) { + if (cJSON_AddStringToObject(access_types, "", OpenAPI_access_type_ToString((OpenAPI_access_type_e)access_types_node->data)) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [access_types]"); + goto end; + } + } + } + + if (policy_association_request->pei) { + if (cJSON_AddStringToObject(item, "pei", policy_association_request->pei) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [pei]"); + goto end; + } + } + + if (policy_association_request->user_loc) { + cJSON *user_loc_local_JSON = OpenAPI_user_location_convertToJSON(policy_association_request->user_loc); + if (user_loc_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [user_loc]"); + goto end; + } + cJSON_AddItemToObject(item, "userLoc", user_loc_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [user_loc]"); + goto end; + } + } + + if (policy_association_request->time_zone) { + if (cJSON_AddStringToObject(item, "timeZone", policy_association_request->time_zone) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [time_zone]"); + goto end; + } + } + + if (policy_association_request->serving_plmn) { + cJSON *serving_plmn_local_JSON = OpenAPI_plmn_id_nid_convertToJSON(policy_association_request->serving_plmn); + if (serving_plmn_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [serving_plmn]"); + goto end; + } + cJSON_AddItemToObject(item, "servingPlmn", serving_plmn_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [serving_plmn]"); + goto end; + } + } + + if (policy_association_request->rat_type) { + if (cJSON_AddStringToObject(item, "ratType", OpenAPI_rat_type_ToString(policy_association_request->rat_type)) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [rat_type]"); + goto end; + } + } + + if (policy_association_request->rat_types) { + cJSON *rat_types = cJSON_AddArrayToObject(item, "ratTypes"); + if (rat_types == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [rat_types]"); + goto end; + } + OpenAPI_lnode_t *rat_types_node; + OpenAPI_list_for_each(policy_association_request->rat_types, rat_types_node) { + if (cJSON_AddStringToObject(rat_types, "", OpenAPI_rat_type_ToString((OpenAPI_rat_type_e)rat_types_node->data)) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [rat_types]"); + goto end; + } + } + } + + if (policy_association_request->group_ids) { + cJSON *group_ids = cJSON_AddArrayToObject(item, "groupIds"); + if (group_ids == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [group_ids]"); + goto end; + } + + OpenAPI_lnode_t *group_ids_node; + OpenAPI_list_for_each(policy_association_request->group_ids, group_ids_node) { + if (cJSON_AddStringToObject(group_ids, "", (char*)group_ids_node->data) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [group_ids]"); + goto end; + } + } + } + + if (policy_association_request->serv_area_res) { + cJSON *serv_area_res_local_JSON = OpenAPI_service_area_restriction_convertToJSON(policy_association_request->serv_area_res); + if (serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "servAreaRes", serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [serv_area_res]"); + goto end; + } + } + + if (policy_association_request->wl_serv_area_res) { + cJSON *wl_serv_area_res_local_JSON = OpenAPI_wireline_service_area_restriction_convertToJSON(policy_association_request->wl_serv_area_res); + if (wl_serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "wlServAreaRes", wl_serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + } + + if (policy_association_request->rfsp) { + if (cJSON_AddNumberToObject(item, "rfsp", policy_association_request->rfsp) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [rfsp]"); + goto end; + } + } + + if (policy_association_request->ue_ambr) { + cJSON *ue_ambr_local_JSON = OpenAPI_ambr_convertToJSON(policy_association_request->ue_ambr); + if (ue_ambr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [ue_ambr]"); + goto end; + } + cJSON_AddItemToObject(item, "ueAmbr", ue_ambr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [ue_ambr]"); + goto end; + } + } + + if (policy_association_request->rg_tmbr) { + cJSON *rg_tmbr_local_JSON = OpenAPI_ambr_convertToJSON(policy_association_request->rg_tmbr); + if (rg_tmbr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [rg_tmbr]"); + goto end; + } + cJSON_AddItemToObject(item, "rgTmbr", rg_tmbr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [rg_tmbr]"); + goto end; + } + } + + if (policy_association_request->allowed_snssais) { + cJSON *allowed_snssaisList = cJSON_AddArrayToObject(item, "allowedSnssais"); + if (allowed_snssaisList == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [allowed_snssais]"); + goto end; + } + + OpenAPI_lnode_t *allowed_snssais_node; + if (policy_association_request->allowed_snssais) { + OpenAPI_list_for_each(policy_association_request->allowed_snssais, allowed_snssais_node) { + cJSON *itemLocal = OpenAPI_snssai_convertToJSON(allowed_snssais_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [allowed_snssais]"); + goto end; + } + cJSON_AddItemToArray(allowed_snssaisList, itemLocal); + } + } + } + + if (policy_association_request->mapping_snssais) { + cJSON *mapping_snssaisList = cJSON_AddArrayToObject(item, "mappingSnssais"); + if (mapping_snssaisList == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [mapping_snssais]"); + goto end; + } + + OpenAPI_lnode_t *mapping_snssais_node; + if (policy_association_request->mapping_snssais) { + OpenAPI_list_for_each(policy_association_request->mapping_snssais, mapping_snssais_node) { + cJSON *itemLocal = OpenAPI_mapping_of_snssai_convertToJSON(mapping_snssais_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [mapping_snssais]"); + goto end; + } + cJSON_AddItemToArray(mapping_snssaisList, itemLocal); + } + } + } + + if (policy_association_request->n3g_allowed_snssais) { + cJSON *n3g_allowed_snssaisList = cJSON_AddArrayToObject(item, "n3gAllowedSnssais"); + if (n3g_allowed_snssaisList == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [n3g_allowed_snssais]"); + goto end; + } + + OpenAPI_lnode_t *n3g_allowed_snssais_node; + if (policy_association_request->n3g_allowed_snssais) { + OpenAPI_list_for_each(policy_association_request->n3g_allowed_snssais, n3g_allowed_snssais_node) { + cJSON *itemLocal = OpenAPI_snssai_convertToJSON(n3g_allowed_snssais_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [n3g_allowed_snssais]"); + goto end; + } + cJSON_AddItemToArray(n3g_allowed_snssaisList, itemLocal); + } + } + } + + if (policy_association_request->guami) { + cJSON *guami_local_JSON = OpenAPI_guami_convertToJSON(policy_association_request->guami); + if (guami_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [guami]"); + goto end; + } + cJSON_AddItemToObject(item, "guami", guami_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [guami]"); + goto end; + } + } + + if (policy_association_request->servive_name) { + if (cJSON_AddStringToObject(item, "serviveName", policy_association_request->servive_name) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [servive_name]"); + goto end; + } + } + + if (policy_association_request->trace_req) { + cJSON *trace_req_local_JSON = OpenAPI_trace_data_convertToJSON(policy_association_request->trace_req); + if (trace_req_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [trace_req]"); + goto end; + } + cJSON_AddItemToObject(item, "traceReq", trace_req_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [trace_req]"); + goto end; + } + } + + if (!policy_association_request->supp_feat) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [supp_feat]"); + goto end; + } + if (cJSON_AddStringToObject(item, "suppFeat", policy_association_request->supp_feat) == NULL) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed [supp_feat]"); + goto end; + } + +end: + return item; +} + +OpenAPI_policy_association_request_t *OpenAPI_policy_association_request_parseFromJSON(cJSON *policy_association_requestJSON) +{ + OpenAPI_policy_association_request_t *policy_association_request_local_var = NULL; + cJSON *notification_uri = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "notificationUri"); + if (!notification_uri) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [notification_uri]"); + goto end; + } + + + if (!cJSON_IsString(notification_uri)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [notification_uri]"); + goto end; + } + + cJSON *alt_notif_ipv4_addrs = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "altNotifIpv4Addrs"); + + OpenAPI_list_t *alt_notif_ipv4_addrsList; + if (alt_notif_ipv4_addrs) { + cJSON *alt_notif_ipv4_addrs_local; + if (!cJSON_IsArray(alt_notif_ipv4_addrs)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + alt_notif_ipv4_addrsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(alt_notif_ipv4_addrs_local, alt_notif_ipv4_addrs) { + if (!cJSON_IsString(alt_notif_ipv4_addrs_local)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + OpenAPI_list_add(alt_notif_ipv4_addrsList, ogs_strdup(alt_notif_ipv4_addrs_local->valuestring)); + } + } + + cJSON *alt_notif_ipv6_addrs = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "altNotifIpv6Addrs"); + + OpenAPI_list_t *alt_notif_ipv6_addrsList; + if (alt_notif_ipv6_addrs) { + cJSON *alt_notif_ipv6_addrs_local; + if (!cJSON_IsArray(alt_notif_ipv6_addrs)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + alt_notif_ipv6_addrsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(alt_notif_ipv6_addrs_local, alt_notif_ipv6_addrs) { + if (!cJSON_IsString(alt_notif_ipv6_addrs_local)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + OpenAPI_list_add(alt_notif_ipv6_addrsList, ogs_strdup(alt_notif_ipv6_addrs_local->valuestring)); + } + } + + cJSON *supi = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "supi"); + if (!supi) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [supi]"); + goto end; + } + + + if (!cJSON_IsString(supi)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [supi]"); + goto end; + } + + cJSON *gpsi = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "gpsi"); + + if (gpsi) { + if (!cJSON_IsString(gpsi)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [gpsi]"); + goto end; + } + } + + cJSON *access_type = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "accessType"); + + OpenAPI_access_type_e access_typeVariable; + if (access_type) { + if (!cJSON_IsString(access_type)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [access_type]"); + goto end; + } + access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring); + } + + cJSON *access_types = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "accessTypes"); + + OpenAPI_list_t *access_typesList; + if (access_types) { + cJSON *access_types_local_nonprimitive; + if (!cJSON_IsArray(access_types)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [access_types]"); + goto end; + } + + access_typesList = OpenAPI_list_create(); + + cJSON_ArrayForEach(access_types_local_nonprimitive, access_types ) { + if (!cJSON_IsString(access_types_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [access_types]"); + goto end; + } + + OpenAPI_list_add(access_typesList, (void *)OpenAPI_access_type_FromString(access_types_local_nonprimitive->valuestring)); + } + } + + cJSON *pei = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "pei"); + + if (pei) { + if (!cJSON_IsString(pei)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [pei]"); + goto end; + } + } + + cJSON *user_loc = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "userLoc"); + + OpenAPI_user_location_t *user_loc_local_nonprim = NULL; + if (user_loc) { + user_loc_local_nonprim = OpenAPI_user_location_parseFromJSON(user_loc); + } + + cJSON *time_zone = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "timeZone"); + + if (time_zone) { + if (!cJSON_IsString(time_zone)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [time_zone]"); + goto end; + } + } + + cJSON *serving_plmn = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "servingPlmn"); + + OpenAPI_plmn_id_nid_t *serving_plmn_local_nonprim = NULL; + if (serving_plmn) { + serving_plmn_local_nonprim = OpenAPI_plmn_id_nid_parseFromJSON(serving_plmn); + } + + cJSON *rat_type = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "ratType"); + + OpenAPI_rat_type_e rat_typeVariable; + if (rat_type) { + if (!cJSON_IsString(rat_type)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [rat_type]"); + goto end; + } + rat_typeVariable = OpenAPI_rat_type_FromString(rat_type->valuestring); + } + + cJSON *rat_types = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "ratTypes"); + + OpenAPI_list_t *rat_typesList; + if (rat_types) { + cJSON *rat_types_local_nonprimitive; + if (!cJSON_IsArray(rat_types)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [rat_types]"); + goto end; + } + + rat_typesList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rat_types_local_nonprimitive, rat_types ) { + if (!cJSON_IsString(rat_types_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [rat_types]"); + goto end; + } + + OpenAPI_list_add(rat_typesList, (void *)OpenAPI_rat_type_FromString(rat_types_local_nonprimitive->valuestring)); + } + } + + cJSON *group_ids = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "groupIds"); + + OpenAPI_list_t *group_idsList; + if (group_ids) { + cJSON *group_ids_local; + if (!cJSON_IsArray(group_ids)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [group_ids]"); + goto end; + } + group_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(group_ids_local, group_ids) { + if (!cJSON_IsString(group_ids_local)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [group_ids]"); + goto end; + } + OpenAPI_list_add(group_idsList, ogs_strdup(group_ids_local->valuestring)); + } + } + + cJSON *serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "servAreaRes"); + + OpenAPI_service_area_restriction_t *serv_area_res_local_nonprim = NULL; + if (serv_area_res) { + serv_area_res_local_nonprim = OpenAPI_service_area_restriction_parseFromJSON(serv_area_res); + } + + cJSON *wl_serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "wlServAreaRes"); + + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res_local_nonprim = NULL; + if (wl_serv_area_res) { + wl_serv_area_res_local_nonprim = OpenAPI_wireline_service_area_restriction_parseFromJSON(wl_serv_area_res); + } + + cJSON *rfsp = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "rfsp"); + + if (rfsp) { + if (!cJSON_IsNumber(rfsp)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [rfsp]"); + goto end; + } + } + + cJSON *ue_ambr = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "ueAmbr"); + + OpenAPI_ambr_t *ue_ambr_local_nonprim = NULL; + if (ue_ambr) { + ue_ambr_local_nonprim = OpenAPI_ambr_parseFromJSON(ue_ambr); + } + + cJSON *rg_tmbr = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "rgTmbr"); + + OpenAPI_ambr_t *rg_tmbr_local_nonprim = NULL; + if (rg_tmbr) { + rg_tmbr_local_nonprim = OpenAPI_ambr_parseFromJSON(rg_tmbr); + } + + cJSON *allowed_snssais = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "allowedSnssais"); + + OpenAPI_list_t *allowed_snssaisList; + if (allowed_snssais) { + cJSON *allowed_snssais_local_nonprimitive; + if (!cJSON_IsArray(allowed_snssais)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [allowed_snssais]"); + goto end; + } + + allowed_snssaisList = OpenAPI_list_create(); + + cJSON_ArrayForEach(allowed_snssais_local_nonprimitive, allowed_snssais ) { + if (!cJSON_IsObject(allowed_snssais_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [allowed_snssais]"); + goto end; + } + OpenAPI_snssai_t *allowed_snssaisItem = OpenAPI_snssai_parseFromJSON(allowed_snssais_local_nonprimitive); + + OpenAPI_list_add(allowed_snssaisList, allowed_snssaisItem); + } + } + + cJSON *mapping_snssais = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "mappingSnssais"); + + OpenAPI_list_t *mapping_snssaisList; + if (mapping_snssais) { + cJSON *mapping_snssais_local_nonprimitive; + if (!cJSON_IsArray(mapping_snssais)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [mapping_snssais]"); + goto end; + } + + mapping_snssaisList = OpenAPI_list_create(); + + cJSON_ArrayForEach(mapping_snssais_local_nonprimitive, mapping_snssais ) { + if (!cJSON_IsObject(mapping_snssais_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [mapping_snssais]"); + goto end; + } + OpenAPI_mapping_of_snssai_t *mapping_snssaisItem = OpenAPI_mapping_of_snssai_parseFromJSON(mapping_snssais_local_nonprimitive); + + OpenAPI_list_add(mapping_snssaisList, mapping_snssaisItem); + } + } + + cJSON *n3g_allowed_snssais = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "n3gAllowedSnssais"); + + OpenAPI_list_t *n3g_allowed_snssaisList; + if (n3g_allowed_snssais) { + cJSON *n3g_allowed_snssais_local_nonprimitive; + if (!cJSON_IsArray(n3g_allowed_snssais)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [n3g_allowed_snssais]"); + goto end; + } + + n3g_allowed_snssaisList = OpenAPI_list_create(); + + cJSON_ArrayForEach(n3g_allowed_snssais_local_nonprimitive, n3g_allowed_snssais ) { + if (!cJSON_IsObject(n3g_allowed_snssais_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [n3g_allowed_snssais]"); + goto end; + } + OpenAPI_snssai_t *n3g_allowed_snssaisItem = OpenAPI_snssai_parseFromJSON(n3g_allowed_snssais_local_nonprimitive); + + OpenAPI_list_add(n3g_allowed_snssaisList, n3g_allowed_snssaisItem); + } + } + + cJSON *guami = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "guami"); + + OpenAPI_guami_t *guami_local_nonprim = NULL; + if (guami) { + guami_local_nonprim = OpenAPI_guami_parseFromJSON(guami); + } + + cJSON *servive_name = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "serviveName"); + + if (servive_name) { + if (!cJSON_IsString(servive_name)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [servive_name]"); + goto end; + } + } + + cJSON *trace_req = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "traceReq"); + + OpenAPI_trace_data_t *trace_req_local_nonprim = NULL; + if (trace_req) { + trace_req_local_nonprim = OpenAPI_trace_data_parseFromJSON(trace_req); + } + + cJSON *supp_feat = cJSON_GetObjectItemCaseSensitive(policy_association_requestJSON, "suppFeat"); + if (!supp_feat) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [supp_feat]"); + goto end; + } + + + if (!cJSON_IsString(supp_feat)) { + ogs_error("OpenAPI_policy_association_request_parseFromJSON() failed [supp_feat]"); + goto end; + } + + policy_association_request_local_var = OpenAPI_policy_association_request_create ( + ogs_strdup(notification_uri->valuestring), + alt_notif_ipv4_addrs ? alt_notif_ipv4_addrsList : NULL, + alt_notif_ipv6_addrs ? alt_notif_ipv6_addrsList : NULL, + ogs_strdup(supi->valuestring), + gpsi ? ogs_strdup(gpsi->valuestring) : NULL, + access_type ? access_typeVariable : 0, + access_types ? access_typesList : NULL, + pei ? ogs_strdup(pei->valuestring) : NULL, + user_loc ? user_loc_local_nonprim : NULL, + time_zone ? ogs_strdup(time_zone->valuestring) : NULL, + serving_plmn ? serving_plmn_local_nonprim : NULL, + rat_type ? rat_typeVariable : 0, + rat_types ? rat_typesList : NULL, + group_ids ? group_idsList : NULL, + serv_area_res ? serv_area_res_local_nonprim : NULL, + wl_serv_area_res ? wl_serv_area_res_local_nonprim : NULL, + rfsp ? rfsp->valuedouble : 0, + ue_ambr ? ue_ambr_local_nonprim : NULL, + rg_tmbr ? rg_tmbr_local_nonprim : NULL, + allowed_snssais ? allowed_snssaisList : NULL, + mapping_snssais ? mapping_snssaisList : NULL, + n3g_allowed_snssais ? n3g_allowed_snssaisList : NULL, + guami ? guami_local_nonprim : NULL, + servive_name ? ogs_strdup(servive_name->valuestring) : NULL, + trace_req ? trace_req_local_nonprim : NULL, + ogs_strdup(supp_feat->valuestring) + ); + + return policy_association_request_local_var; +end: + return NULL; +} + +OpenAPI_policy_association_request_t *OpenAPI_policy_association_request_copy(OpenAPI_policy_association_request_t *dst, OpenAPI_policy_association_request_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_policy_association_request_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_policy_association_request_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_policy_association_request_free(dst); + dst = OpenAPI_policy_association_request_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/policy_association_request.h b/lib/sbi/openapi/model/policy_association_request.h new file mode 100644 index 000000000..69f0eafcb --- /dev/null +++ b/lib/sbi/openapi/model/policy_association_request.h @@ -0,0 +1,99 @@ +/* + * policy_association_request.h + * + * Information which the NF service consumer provides when requesting the creation of a policy association. The serviveName property corresponds to the serviceName in the main body of the specification. + */ + +#ifndef _OpenAPI_policy_association_request_H_ +#define _OpenAPI_policy_association_request_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "access_type.h" +#include "ambr.h" +#include "guami.h" +#include "mapping_of_snssai.h" +#include "plmn_id_nid.h" +#include "rat_type.h" +#include "service_area_restriction.h" +#include "snssai.h" +#include "trace_data.h" +#include "user_location.h" +#include "wireline_service_area_restriction.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_policy_association_request_s OpenAPI_policy_association_request_t; +typedef struct OpenAPI_policy_association_request_s { + char *notification_uri; + OpenAPI_list_t *alt_notif_ipv4_addrs; + OpenAPI_list_t *alt_notif_ipv6_addrs; + char *supi; + char *gpsi; + OpenAPI_access_type_e access_type; + OpenAPI_list_t *access_types; + char *pei; + struct OpenAPI_user_location_s *user_loc; + char *time_zone; + struct OpenAPI_plmn_id_nid_s *serving_plmn; + OpenAPI_rat_type_e rat_type; + OpenAPI_list_t *rat_types; + OpenAPI_list_t *group_ids; + struct OpenAPI_service_area_restriction_s *serv_area_res; + struct OpenAPI_wireline_service_area_restriction_s *wl_serv_area_res; + int rfsp; + struct OpenAPI_ambr_s *ue_ambr; + struct OpenAPI_ambr_s *rg_tmbr; + OpenAPI_list_t *allowed_snssais; + OpenAPI_list_t *mapping_snssais; + OpenAPI_list_t *n3g_allowed_snssais; + struct OpenAPI_guami_s *guami; + char *servive_name; + struct OpenAPI_trace_data_s *trace_req; + char *supp_feat; +} OpenAPI_policy_association_request_t; + +OpenAPI_policy_association_request_t *OpenAPI_policy_association_request_create( + char *notification_uri, + OpenAPI_list_t *alt_notif_ipv4_addrs, + OpenAPI_list_t *alt_notif_ipv6_addrs, + char *supi, + char *gpsi, + OpenAPI_access_type_e access_type, + OpenAPI_list_t *access_types, + char *pei, + OpenAPI_user_location_t *user_loc, + char *time_zone, + OpenAPI_plmn_id_nid_t *serving_plmn, + OpenAPI_rat_type_e rat_type, + OpenAPI_list_t *rat_types, + OpenAPI_list_t *group_ids, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t *allowed_snssais, + OpenAPI_list_t *mapping_snssais, + OpenAPI_list_t *n3g_allowed_snssais, + OpenAPI_guami_t *guami, + char *servive_name, + OpenAPI_trace_data_t *trace_req, + char *supp_feat + ); +void OpenAPI_policy_association_request_free(OpenAPI_policy_association_request_t *policy_association_request); +OpenAPI_policy_association_request_t *OpenAPI_policy_association_request_parseFromJSON(cJSON *policy_association_requestJSON); +cJSON *OpenAPI_policy_association_request_convertToJSON(OpenAPI_policy_association_request_t *policy_association_request); +OpenAPI_policy_association_request_t *OpenAPI_policy_association_request_copy(OpenAPI_policy_association_request_t *dst, OpenAPI_policy_association_request_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_policy_association_request_H_ */ + diff --git a/lib/sbi/openapi/model/policy_association_update_request.c b/lib/sbi/openapi/model/policy_association_update_request.c new file mode 100644 index 000000000..8ff4900c8 --- /dev/null +++ b/lib/sbi/openapi/model/policy_association_update_request.c @@ -0,0 +1,728 @@ + +#include +#include +#include +#include "policy_association_update_request.h" + +OpenAPI_policy_association_update_request_t *OpenAPI_policy_association_update_request_create( + char *notification_uri, + OpenAPI_list_t *alt_notif_ipv4_addrs, + OpenAPI_list_t *alt_notif_ipv6_addrs, + OpenAPI_list_t *triggers, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_smf_selection_data_t *smf_sel_info, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t* pra_statuses, + OpenAPI_user_location_t *user_loc, + OpenAPI_list_t *allowed_snssais, + OpenAPI_list_t *mapping_snssais, + OpenAPI_list_t *access_types, + OpenAPI_list_t *rat_types, + OpenAPI_list_t *n3g_allowed_snssais, + OpenAPI_trace_data_t *trace_req, + OpenAPI_guami_t *guami + ) +{ + OpenAPI_policy_association_update_request_t *policy_association_update_request_local_var = OpenAPI_malloc(sizeof(OpenAPI_policy_association_update_request_t)); + if (!policy_association_update_request_local_var) { + return NULL; + } + policy_association_update_request_local_var->notification_uri = notification_uri; + policy_association_update_request_local_var->alt_notif_ipv4_addrs = alt_notif_ipv4_addrs; + policy_association_update_request_local_var->alt_notif_ipv6_addrs = alt_notif_ipv6_addrs; + policy_association_update_request_local_var->triggers = triggers; + policy_association_update_request_local_var->serv_area_res = serv_area_res; + policy_association_update_request_local_var->wl_serv_area_res = wl_serv_area_res; + policy_association_update_request_local_var->rfsp = rfsp; + policy_association_update_request_local_var->smf_sel_info = smf_sel_info; + policy_association_update_request_local_var->ue_ambr = ue_ambr; + policy_association_update_request_local_var->rg_tmbr = rg_tmbr; + policy_association_update_request_local_var->pra_statuses = pra_statuses; + policy_association_update_request_local_var->user_loc = user_loc; + policy_association_update_request_local_var->allowed_snssais = allowed_snssais; + policy_association_update_request_local_var->mapping_snssais = mapping_snssais; + policy_association_update_request_local_var->access_types = access_types; + policy_association_update_request_local_var->rat_types = rat_types; + policy_association_update_request_local_var->n3g_allowed_snssais = n3g_allowed_snssais; + policy_association_update_request_local_var->trace_req = trace_req; + policy_association_update_request_local_var->guami = guami; + + return policy_association_update_request_local_var; +} + +void OpenAPI_policy_association_update_request_free(OpenAPI_policy_association_update_request_t *policy_association_update_request) +{ + if (NULL == policy_association_update_request) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(policy_association_update_request->notification_uri); + OpenAPI_list_for_each(policy_association_update_request->alt_notif_ipv4_addrs, node) { + ogs_free(node->data); + } + OpenAPI_list_free(policy_association_update_request->alt_notif_ipv4_addrs); + OpenAPI_list_for_each(policy_association_update_request->alt_notif_ipv6_addrs, node) { + ogs_free(node->data); + } + OpenAPI_list_free(policy_association_update_request->alt_notif_ipv6_addrs); + OpenAPI_list_free(policy_association_update_request->triggers); + OpenAPI_service_area_restriction_free(policy_association_update_request->serv_area_res); + OpenAPI_wireline_service_area_restriction_free(policy_association_update_request->wl_serv_area_res); + OpenAPI_smf_selection_data_free(policy_association_update_request->smf_sel_info); + OpenAPI_ambr_free(policy_association_update_request->ue_ambr); + OpenAPI_ambr_free(policy_association_update_request->rg_tmbr); + OpenAPI_list_for_each(policy_association_update_request->pra_statuses, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_presence_info_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(policy_association_update_request->pra_statuses); + OpenAPI_user_location_free(policy_association_update_request->user_loc); + OpenAPI_list_for_each(policy_association_update_request->allowed_snssais, node) { + OpenAPI_snssai_free(node->data); + } + OpenAPI_list_free(policy_association_update_request->allowed_snssais); + OpenAPI_list_for_each(policy_association_update_request->mapping_snssais, node) { + OpenAPI_mapping_of_snssai_free(node->data); + } + OpenAPI_list_free(policy_association_update_request->mapping_snssais); + OpenAPI_list_free(policy_association_update_request->access_types); + OpenAPI_list_free(policy_association_update_request->rat_types); + OpenAPI_list_for_each(policy_association_update_request->n3g_allowed_snssais, node) { + OpenAPI_snssai_free(node->data); + } + OpenAPI_list_free(policy_association_update_request->n3g_allowed_snssais); + OpenAPI_trace_data_free(policy_association_update_request->trace_req); + OpenAPI_guami_free(policy_association_update_request->guami); + ogs_free(policy_association_update_request); +} + +cJSON *OpenAPI_policy_association_update_request_convertToJSON(OpenAPI_policy_association_update_request_t *policy_association_update_request) +{ + cJSON *item = NULL; + + if (policy_association_update_request == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [PolicyAssociationUpdateRequest]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (policy_association_update_request->notification_uri) { + if (cJSON_AddStringToObject(item, "notificationUri", policy_association_update_request->notification_uri) == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [notification_uri]"); + goto end; + } + } + + if (policy_association_update_request->alt_notif_ipv4_addrs) { + cJSON *alt_notif_ipv4_addrs = cJSON_AddArrayToObject(item, "altNotifIpv4Addrs"); + if (alt_notif_ipv4_addrs == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + + OpenAPI_lnode_t *alt_notif_ipv4_addrs_node; + OpenAPI_list_for_each(policy_association_update_request->alt_notif_ipv4_addrs, alt_notif_ipv4_addrs_node) { + if (cJSON_AddStringToObject(alt_notif_ipv4_addrs, "", (char*)alt_notif_ipv4_addrs_node->data) == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + } + } + + if (policy_association_update_request->alt_notif_ipv6_addrs) { + cJSON *alt_notif_ipv6_addrs = cJSON_AddArrayToObject(item, "altNotifIpv6Addrs"); + if (alt_notif_ipv6_addrs == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + + OpenAPI_lnode_t *alt_notif_ipv6_addrs_node; + OpenAPI_list_for_each(policy_association_update_request->alt_notif_ipv6_addrs, alt_notif_ipv6_addrs_node) { + if (cJSON_AddStringToObject(alt_notif_ipv6_addrs, "", (char*)alt_notif_ipv6_addrs_node->data) == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + } + } + + if (policy_association_update_request->triggers) { + cJSON *triggers = cJSON_AddArrayToObject(item, "triggers"); + if (triggers == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [triggers]"); + goto end; + } + OpenAPI_lnode_t *triggers_node; + OpenAPI_list_for_each(policy_association_update_request->triggers, triggers_node) { + if (cJSON_AddStringToObject(triggers, "", OpenAPI_request_trigger_ToString((OpenAPI_request_trigger_e)triggers_node->data)) == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [triggers]"); + goto end; + } + } + } + + if (policy_association_update_request->serv_area_res) { + cJSON *serv_area_res_local_JSON = OpenAPI_service_area_restriction_convertToJSON(policy_association_update_request->serv_area_res); + if (serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "servAreaRes", serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [serv_area_res]"); + goto end; + } + } + + if (policy_association_update_request->wl_serv_area_res) { + cJSON *wl_serv_area_res_local_JSON = OpenAPI_wireline_service_area_restriction_convertToJSON(policy_association_update_request->wl_serv_area_res); + if (wl_serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "wlServAreaRes", wl_serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + } + + if (policy_association_update_request->rfsp) { + if (cJSON_AddNumberToObject(item, "rfsp", policy_association_update_request->rfsp) == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [rfsp]"); + goto end; + } + } + + if (policy_association_update_request->smf_sel_info) { + cJSON *smf_sel_info_local_JSON = OpenAPI_smf_selection_data_convertToJSON(policy_association_update_request->smf_sel_info); + if (smf_sel_info_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [smf_sel_info]"); + goto end; + } + cJSON_AddItemToObject(item, "smfSelInfo", smf_sel_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [smf_sel_info]"); + goto end; + } + } + + if (policy_association_update_request->ue_ambr) { + cJSON *ue_ambr_local_JSON = OpenAPI_ambr_convertToJSON(policy_association_update_request->ue_ambr); + if (ue_ambr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [ue_ambr]"); + goto end; + } + cJSON_AddItemToObject(item, "ueAmbr", ue_ambr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [ue_ambr]"); + goto end; + } + } + + if (policy_association_update_request->rg_tmbr) { + cJSON *rg_tmbr_local_JSON = OpenAPI_ambr_convertToJSON(policy_association_update_request->rg_tmbr); + if (rg_tmbr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [rg_tmbr]"); + goto end; + } + cJSON_AddItemToObject(item, "rgTmbr", rg_tmbr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [rg_tmbr]"); + goto end; + } + } + + if (policy_association_update_request->pra_statuses) { + cJSON *pra_statuses = cJSON_AddObjectToObject(item, "praStatuses"); + if (pra_statuses == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [pra_statuses]"); + goto end; + } + cJSON *localMapObject = pra_statuses; + OpenAPI_lnode_t *pra_statuses_node; + if (policy_association_update_request->pra_statuses) { + OpenAPI_list_for_each(policy_association_update_request->pra_statuses, pra_statuses_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)pra_statuses_node->data; + cJSON *itemLocal = OpenAPI_presence_info_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [pra_statuses]"); + goto end; + } + cJSON_AddItemToObject(pra_statuses, localKeyValue->key, itemLocal); + } + } + } + + if (policy_association_update_request->user_loc) { + cJSON *user_loc_local_JSON = OpenAPI_user_location_convertToJSON(policy_association_update_request->user_loc); + if (user_loc_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [user_loc]"); + goto end; + } + cJSON_AddItemToObject(item, "userLoc", user_loc_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [user_loc]"); + goto end; + } + } + + if (policy_association_update_request->allowed_snssais) { + cJSON *allowed_snssaisList = cJSON_AddArrayToObject(item, "allowedSnssais"); + if (allowed_snssaisList == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [allowed_snssais]"); + goto end; + } + + OpenAPI_lnode_t *allowed_snssais_node; + if (policy_association_update_request->allowed_snssais) { + OpenAPI_list_for_each(policy_association_update_request->allowed_snssais, allowed_snssais_node) { + cJSON *itemLocal = OpenAPI_snssai_convertToJSON(allowed_snssais_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [allowed_snssais]"); + goto end; + } + cJSON_AddItemToArray(allowed_snssaisList, itemLocal); + } + } + } + + if (policy_association_update_request->mapping_snssais) { + cJSON *mapping_snssaisList = cJSON_AddArrayToObject(item, "mappingSnssais"); + if (mapping_snssaisList == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [mapping_snssais]"); + goto end; + } + + OpenAPI_lnode_t *mapping_snssais_node; + if (policy_association_update_request->mapping_snssais) { + OpenAPI_list_for_each(policy_association_update_request->mapping_snssais, mapping_snssais_node) { + cJSON *itemLocal = OpenAPI_mapping_of_snssai_convertToJSON(mapping_snssais_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [mapping_snssais]"); + goto end; + } + cJSON_AddItemToArray(mapping_snssaisList, itemLocal); + } + } + } + + if (policy_association_update_request->access_types) { + cJSON *access_types = cJSON_AddArrayToObject(item, "accessTypes"); + if (access_types == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [access_types]"); + goto end; + } + OpenAPI_lnode_t *access_types_node; + OpenAPI_list_for_each(policy_association_update_request->access_types, access_types_node) { + if (cJSON_AddStringToObject(access_types, "", OpenAPI_access_type_ToString((OpenAPI_access_type_e)access_types_node->data)) == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [access_types]"); + goto end; + } + } + } + + if (policy_association_update_request->rat_types) { + cJSON *rat_types = cJSON_AddArrayToObject(item, "ratTypes"); + if (rat_types == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [rat_types]"); + goto end; + } + OpenAPI_lnode_t *rat_types_node; + OpenAPI_list_for_each(policy_association_update_request->rat_types, rat_types_node) { + if (cJSON_AddStringToObject(rat_types, "", OpenAPI_rat_type_ToString((OpenAPI_rat_type_e)rat_types_node->data)) == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [rat_types]"); + goto end; + } + } + } + + if (policy_association_update_request->n3g_allowed_snssais) { + cJSON *n3g_allowed_snssaisList = cJSON_AddArrayToObject(item, "n3gAllowedSnssais"); + if (n3g_allowed_snssaisList == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [n3g_allowed_snssais]"); + goto end; + } + + OpenAPI_lnode_t *n3g_allowed_snssais_node; + if (policy_association_update_request->n3g_allowed_snssais) { + OpenAPI_list_for_each(policy_association_update_request->n3g_allowed_snssais, n3g_allowed_snssais_node) { + cJSON *itemLocal = OpenAPI_snssai_convertToJSON(n3g_allowed_snssais_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [n3g_allowed_snssais]"); + goto end; + } + cJSON_AddItemToArray(n3g_allowed_snssaisList, itemLocal); + } + } + } + + if (policy_association_update_request->trace_req) { + cJSON *trace_req_local_JSON = OpenAPI_trace_data_convertToJSON(policy_association_update_request->trace_req); + if (trace_req_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [trace_req]"); + goto end; + } + cJSON_AddItemToObject(item, "traceReq", trace_req_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [trace_req]"); + goto end; + } + } + + if (policy_association_update_request->guami) { + cJSON *guami_local_JSON = OpenAPI_guami_convertToJSON(policy_association_update_request->guami); + if (guami_local_JSON == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [guami]"); + goto end; + } + cJSON_AddItemToObject(item, "guami", guami_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed [guami]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_policy_association_update_request_t *OpenAPI_policy_association_update_request_parseFromJSON(cJSON *policy_association_update_requestJSON) +{ + OpenAPI_policy_association_update_request_t *policy_association_update_request_local_var = NULL; + cJSON *notification_uri = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "notificationUri"); + + if (notification_uri) { + if (!cJSON_IsString(notification_uri)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [notification_uri]"); + goto end; + } + } + + cJSON *alt_notif_ipv4_addrs = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "altNotifIpv4Addrs"); + + OpenAPI_list_t *alt_notif_ipv4_addrsList; + if (alt_notif_ipv4_addrs) { + cJSON *alt_notif_ipv4_addrs_local; + if (!cJSON_IsArray(alt_notif_ipv4_addrs)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + alt_notif_ipv4_addrsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(alt_notif_ipv4_addrs_local, alt_notif_ipv4_addrs) { + if (!cJSON_IsString(alt_notif_ipv4_addrs_local)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [alt_notif_ipv4_addrs]"); + goto end; + } + OpenAPI_list_add(alt_notif_ipv4_addrsList, ogs_strdup(alt_notif_ipv4_addrs_local->valuestring)); + } + } + + cJSON *alt_notif_ipv6_addrs = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "altNotifIpv6Addrs"); + + OpenAPI_list_t *alt_notif_ipv6_addrsList; + if (alt_notif_ipv6_addrs) { + cJSON *alt_notif_ipv6_addrs_local; + if (!cJSON_IsArray(alt_notif_ipv6_addrs)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + alt_notif_ipv6_addrsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(alt_notif_ipv6_addrs_local, alt_notif_ipv6_addrs) { + if (!cJSON_IsString(alt_notif_ipv6_addrs_local)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [alt_notif_ipv6_addrs]"); + goto end; + } + OpenAPI_list_add(alt_notif_ipv6_addrsList, ogs_strdup(alt_notif_ipv6_addrs_local->valuestring)); + } + } + + cJSON *triggers = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "triggers"); + + OpenAPI_list_t *triggersList; + if (triggers) { + cJSON *triggers_local_nonprimitive; + if (!cJSON_IsArray(triggers)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [triggers]"); + goto end; + } + + triggersList = OpenAPI_list_create(); + + cJSON_ArrayForEach(triggers_local_nonprimitive, triggers ) { + if (!cJSON_IsString(triggers_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [triggers]"); + goto end; + } + + OpenAPI_list_add(triggersList, (void *)OpenAPI_request_trigger_FromString(triggers_local_nonprimitive->valuestring)); + } + } + + cJSON *serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "servAreaRes"); + + OpenAPI_service_area_restriction_t *serv_area_res_local_nonprim = NULL; + if (serv_area_res) { + serv_area_res_local_nonprim = OpenAPI_service_area_restriction_parseFromJSON(serv_area_res); + } + + cJSON *wl_serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "wlServAreaRes"); + + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res_local_nonprim = NULL; + if (wl_serv_area_res) { + wl_serv_area_res_local_nonprim = OpenAPI_wireline_service_area_restriction_parseFromJSON(wl_serv_area_res); + } + + cJSON *rfsp = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "rfsp"); + + if (rfsp) { + if (!cJSON_IsNumber(rfsp)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [rfsp]"); + goto end; + } + } + + cJSON *smf_sel_info = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "smfSelInfo"); + + OpenAPI_smf_selection_data_t *smf_sel_info_local_nonprim = NULL; + if (smf_sel_info) { + smf_sel_info_local_nonprim = OpenAPI_smf_selection_data_parseFromJSON(smf_sel_info); + } + + cJSON *ue_ambr = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "ueAmbr"); + + OpenAPI_ambr_t *ue_ambr_local_nonprim = NULL; + if (ue_ambr) { + ue_ambr_local_nonprim = OpenAPI_ambr_parseFromJSON(ue_ambr); + } + + cJSON *rg_tmbr = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "rgTmbr"); + + OpenAPI_ambr_t *rg_tmbr_local_nonprim = NULL; + if (rg_tmbr) { + rg_tmbr_local_nonprim = OpenAPI_ambr_parseFromJSON(rg_tmbr); + } + + cJSON *pra_statuses = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "praStatuses"); + + OpenAPI_list_t *pra_statusesList; + if (pra_statuses) { + cJSON *pra_statuses_local_map; + if (!cJSON_IsObject(pra_statuses)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [pra_statuses]"); + goto end; + } + pra_statusesList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(pra_statuses_local_map, pra_statuses) { + cJSON *localMapObject = pra_statuses_local_map; + if (!cJSON_IsObject(pra_statuses_local_map)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [pra_statuses]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_presence_info_parseFromJSON(localMapObject)); + OpenAPI_list_add(pra_statusesList, localMapKeyPair); + } + } + + cJSON *user_loc = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "userLoc"); + + OpenAPI_user_location_t *user_loc_local_nonprim = NULL; + if (user_loc) { + user_loc_local_nonprim = OpenAPI_user_location_parseFromJSON(user_loc); + } + + cJSON *allowed_snssais = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "allowedSnssais"); + + OpenAPI_list_t *allowed_snssaisList; + if (allowed_snssais) { + cJSON *allowed_snssais_local_nonprimitive; + if (!cJSON_IsArray(allowed_snssais)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [allowed_snssais]"); + goto end; + } + + allowed_snssaisList = OpenAPI_list_create(); + + cJSON_ArrayForEach(allowed_snssais_local_nonprimitive, allowed_snssais ) { + if (!cJSON_IsObject(allowed_snssais_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [allowed_snssais]"); + goto end; + } + OpenAPI_snssai_t *allowed_snssaisItem = OpenAPI_snssai_parseFromJSON(allowed_snssais_local_nonprimitive); + + OpenAPI_list_add(allowed_snssaisList, allowed_snssaisItem); + } + } + + cJSON *mapping_snssais = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "mappingSnssais"); + + OpenAPI_list_t *mapping_snssaisList; + if (mapping_snssais) { + cJSON *mapping_snssais_local_nonprimitive; + if (!cJSON_IsArray(mapping_snssais)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [mapping_snssais]"); + goto end; + } + + mapping_snssaisList = OpenAPI_list_create(); + + cJSON_ArrayForEach(mapping_snssais_local_nonprimitive, mapping_snssais ) { + if (!cJSON_IsObject(mapping_snssais_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [mapping_snssais]"); + goto end; + } + OpenAPI_mapping_of_snssai_t *mapping_snssaisItem = OpenAPI_mapping_of_snssai_parseFromJSON(mapping_snssais_local_nonprimitive); + + OpenAPI_list_add(mapping_snssaisList, mapping_snssaisItem); + } + } + + cJSON *access_types = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "accessTypes"); + + OpenAPI_list_t *access_typesList; + if (access_types) { + cJSON *access_types_local_nonprimitive; + if (!cJSON_IsArray(access_types)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [access_types]"); + goto end; + } + + access_typesList = OpenAPI_list_create(); + + cJSON_ArrayForEach(access_types_local_nonprimitive, access_types ) { + if (!cJSON_IsString(access_types_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [access_types]"); + goto end; + } + + OpenAPI_list_add(access_typesList, (void *)OpenAPI_access_type_FromString(access_types_local_nonprimitive->valuestring)); + } + } + + cJSON *rat_types = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "ratTypes"); + + OpenAPI_list_t *rat_typesList; + if (rat_types) { + cJSON *rat_types_local_nonprimitive; + if (!cJSON_IsArray(rat_types)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [rat_types]"); + goto end; + } + + rat_typesList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rat_types_local_nonprimitive, rat_types ) { + if (!cJSON_IsString(rat_types_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [rat_types]"); + goto end; + } + + OpenAPI_list_add(rat_typesList, (void *)OpenAPI_rat_type_FromString(rat_types_local_nonprimitive->valuestring)); + } + } + + cJSON *n3g_allowed_snssais = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "n3gAllowedSnssais"); + + OpenAPI_list_t *n3g_allowed_snssaisList; + if (n3g_allowed_snssais) { + cJSON *n3g_allowed_snssais_local_nonprimitive; + if (!cJSON_IsArray(n3g_allowed_snssais)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [n3g_allowed_snssais]"); + goto end; + } + + n3g_allowed_snssaisList = OpenAPI_list_create(); + + cJSON_ArrayForEach(n3g_allowed_snssais_local_nonprimitive, n3g_allowed_snssais ) { + if (!cJSON_IsObject(n3g_allowed_snssais_local_nonprimitive)) { + ogs_error("OpenAPI_policy_association_update_request_parseFromJSON() failed [n3g_allowed_snssais]"); + goto end; + } + OpenAPI_snssai_t *n3g_allowed_snssaisItem = OpenAPI_snssai_parseFromJSON(n3g_allowed_snssais_local_nonprimitive); + + OpenAPI_list_add(n3g_allowed_snssaisList, n3g_allowed_snssaisItem); + } + } + + cJSON *trace_req = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "traceReq"); + + OpenAPI_trace_data_t *trace_req_local_nonprim = NULL; + if (trace_req) { + trace_req_local_nonprim = OpenAPI_trace_data_parseFromJSON(trace_req); + } + + cJSON *guami = cJSON_GetObjectItemCaseSensitive(policy_association_update_requestJSON, "guami"); + + OpenAPI_guami_t *guami_local_nonprim = NULL; + if (guami) { + guami_local_nonprim = OpenAPI_guami_parseFromJSON(guami); + } + + policy_association_update_request_local_var = OpenAPI_policy_association_update_request_create ( + notification_uri ? ogs_strdup(notification_uri->valuestring) : NULL, + alt_notif_ipv4_addrs ? alt_notif_ipv4_addrsList : NULL, + alt_notif_ipv6_addrs ? alt_notif_ipv6_addrsList : NULL, + triggers ? triggersList : NULL, + serv_area_res ? serv_area_res_local_nonprim : NULL, + wl_serv_area_res ? wl_serv_area_res_local_nonprim : NULL, + rfsp ? rfsp->valuedouble : 0, + smf_sel_info ? smf_sel_info_local_nonprim : NULL, + ue_ambr ? ue_ambr_local_nonprim : NULL, + rg_tmbr ? rg_tmbr_local_nonprim : NULL, + pra_statuses ? pra_statusesList : NULL, + user_loc ? user_loc_local_nonprim : NULL, + allowed_snssais ? allowed_snssaisList : NULL, + mapping_snssais ? mapping_snssaisList : NULL, + access_types ? access_typesList : NULL, + rat_types ? rat_typesList : NULL, + n3g_allowed_snssais ? n3g_allowed_snssaisList : NULL, + trace_req ? trace_req_local_nonprim : NULL, + guami ? guami_local_nonprim : NULL + ); + + return policy_association_update_request_local_var; +end: + return NULL; +} + +OpenAPI_policy_association_update_request_t *OpenAPI_policy_association_update_request_copy(OpenAPI_policy_association_update_request_t *dst, OpenAPI_policy_association_update_request_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_policy_association_update_request_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_policy_association_update_request_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_policy_association_update_request_free(dst); + dst = OpenAPI_policy_association_update_request_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/policy_association_update_request.h b/lib/sbi/openapi/model/policy_association_update_request.h new file mode 100644 index 000000000..814cdd4eb --- /dev/null +++ b/lib/sbi/openapi/model/policy_association_update_request.h @@ -0,0 +1,87 @@ +/* + * policy_association_update_request.h + * + * + */ + +#ifndef _OpenAPI_policy_association_update_request_H_ +#define _OpenAPI_policy_association_update_request_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "access_type.h" +#include "ambr.h" +#include "guami.h" +#include "mapping_of_snssai.h" +#include "presence_info.h" +#include "rat_type.h" +#include "request_trigger.h" +#include "service_area_restriction.h" +#include "smf_selection_data.h" +#include "snssai.h" +#include "trace_data.h" +#include "user_location.h" +#include "wireline_service_area_restriction.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_policy_association_update_request_s OpenAPI_policy_association_update_request_t; +typedef struct OpenAPI_policy_association_update_request_s { + char *notification_uri; + OpenAPI_list_t *alt_notif_ipv4_addrs; + OpenAPI_list_t *alt_notif_ipv6_addrs; + OpenAPI_list_t *triggers; + struct OpenAPI_service_area_restriction_s *serv_area_res; + struct OpenAPI_wireline_service_area_restriction_s *wl_serv_area_res; + int rfsp; + struct OpenAPI_smf_selection_data_s *smf_sel_info; + struct OpenAPI_ambr_s *ue_ambr; + struct OpenAPI_ambr_s *rg_tmbr; + OpenAPI_list_t* pra_statuses; + struct OpenAPI_user_location_s *user_loc; + OpenAPI_list_t *allowed_snssais; + OpenAPI_list_t *mapping_snssais; + OpenAPI_list_t *access_types; + OpenAPI_list_t *rat_types; + OpenAPI_list_t *n3g_allowed_snssais; + struct OpenAPI_trace_data_s *trace_req; + struct OpenAPI_guami_s *guami; +} OpenAPI_policy_association_update_request_t; + +OpenAPI_policy_association_update_request_t *OpenAPI_policy_association_update_request_create( + char *notification_uri, + OpenAPI_list_t *alt_notif_ipv4_addrs, + OpenAPI_list_t *alt_notif_ipv6_addrs, + OpenAPI_list_t *triggers, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_smf_selection_data_t *smf_sel_info, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t* pra_statuses, + OpenAPI_user_location_t *user_loc, + OpenAPI_list_t *allowed_snssais, + OpenAPI_list_t *mapping_snssais, + OpenAPI_list_t *access_types, + OpenAPI_list_t *rat_types, + OpenAPI_list_t *n3g_allowed_snssais, + OpenAPI_trace_data_t *trace_req, + OpenAPI_guami_t *guami + ); +void OpenAPI_policy_association_update_request_free(OpenAPI_policy_association_update_request_t *policy_association_update_request); +OpenAPI_policy_association_update_request_t *OpenAPI_policy_association_update_request_parseFromJSON(cJSON *policy_association_update_requestJSON); +cJSON *OpenAPI_policy_association_update_request_convertToJSON(OpenAPI_policy_association_update_request_t *policy_association_update_request); +OpenAPI_policy_association_update_request_t *OpenAPI_policy_association_update_request_copy(OpenAPI_policy_association_update_request_t *dst, OpenAPI_policy_association_update_request_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_policy_association_update_request_H_ */ + diff --git a/lib/sbi/openapi/model/policy_control_request_trigger.c b/lib/sbi/openapi/model/policy_control_request_trigger.c new file mode 100644 index 000000000..3fa244568 --- /dev/null +++ b/lib/sbi/openapi/model/policy_control_request_trigger.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "policy_control_request_trigger.h" + +OpenAPI_policy_control_request_trigger_t *OpenAPI_policy_control_request_trigger_create( + ) +{ + OpenAPI_policy_control_request_trigger_t *policy_control_request_trigger_local_var = OpenAPI_malloc(sizeof(OpenAPI_policy_control_request_trigger_t)); + if (!policy_control_request_trigger_local_var) { + return NULL; + } + + return policy_control_request_trigger_local_var; +} + +void OpenAPI_policy_control_request_trigger_free(OpenAPI_policy_control_request_trigger_t *policy_control_request_trigger) +{ + if (NULL == policy_control_request_trigger) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(policy_control_request_trigger); +} + +cJSON *OpenAPI_policy_control_request_trigger_convertToJSON(OpenAPI_policy_control_request_trigger_t *policy_control_request_trigger) +{ + cJSON *item = NULL; + + if (policy_control_request_trigger == NULL) { + ogs_error("OpenAPI_policy_control_request_trigger_convertToJSON() failed [PolicyControlRequestTrigger]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_policy_control_request_trigger_t *OpenAPI_policy_control_request_trigger_parseFromJSON(cJSON *policy_control_request_triggerJSON) +{ + OpenAPI_policy_control_request_trigger_t *policy_control_request_trigger_local_var = NULL; + policy_control_request_trigger_local_var = OpenAPI_policy_control_request_trigger_create ( + ); + + return policy_control_request_trigger_local_var; +end: + return NULL; +} + +OpenAPI_policy_control_request_trigger_t *OpenAPI_policy_control_request_trigger_copy(OpenAPI_policy_control_request_trigger_t *dst, OpenAPI_policy_control_request_trigger_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_policy_control_request_trigger_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_policy_control_request_trigger_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_policy_control_request_trigger_free(dst); + dst = OpenAPI_policy_control_request_trigger_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/policy_control_request_trigger.h b/lib/sbi/openapi/model/policy_control_request_trigger.h new file mode 100644 index 000000000..4ac39e3cc --- /dev/null +++ b/lib/sbi/openapi/model/policy_control_request_trigger.h @@ -0,0 +1,36 @@ +/* + * policy_control_request_trigger.h + * + * Possible values are - PLMN_CH: PLMN Change - RES_MO_RE: A request for resource modification has been received by the SMF. The SMF always reports to the PCF. - AC_TY_CH: Access Type Change - UE_IP_CH: UE IP address change. The SMF always reports to the PCF. - UE_MAC_CH: A new UE MAC address is detected or a used UE MAC address is inactive for a specific period - AN_CH_COR: Access Network Charging Correlation Information - US_RE: The PDU Session or the Monitoring key specific resources consumed by a UE either reached the threshold or needs to be reported for other reasons. - APP_STA: The start of application traffic has been detected. - APP_STO: The stop of application traffic has been detected. - AN_INFO: Access Network Information report - CM_SES_FAIL: Credit management session failure - PS_DA_OFF: The SMF reports when the 3GPP PS Data Off status changes. The SMF always reports to the PCF. - DEF_QOS_CH: Default QoS Change. The SMF always reports to the PCF. - SE_AMBR_CH: Session AMBR Change. The SMF always reports to the PCF. - QOS_NOTIF: The SMF notify the PCF when receiving notification from RAN that QoS targets of the QoS Flow cannot be guranteed or gurateed again. - NO_CREDIT: Out of credit - REALLO_OF_CREDIT: Reallocation of credit - PRA_CH: Change of UE presence in Presence Reporting Area - SAREA_CH: Location Change with respect to the Serving Area - SCNN_CH: Location Change with respect to the Serving CN node - RE_TIMEOUT: Indicates the SMF generated the request because there has been a PCC revalidation timeout - RES_RELEASE: Indicate that the SMF can inform the PCF of the outcome of the release of resources for those rules that require so. - SUCC_RES_ALLO: Indicates that the requested rule data is the successful resource allocation. - RAT_TY_CH: RAT Type Change. - REF_QOS_IND_CH: Reflective QoS indication Change - NUM_OF_PACKET_FILTER: Indicates that the SMF shall report the number of supported packet filter for signalled QoS rules - UE_STATUS_RESUME: Indicates that the UE’s status is resumed. - UE_TZ_CH: UE Time Zone Change - AUTH_PROF_CH: The DN-AAA authorization profile index has changed - QOS_MONITORING: Indicate that the SMF notifies the PCF of the QoS Monitoring information. - SCELL_CH: Location Change with respect to the Serving Cell. Only applicable to the interworking scenario as defined in Annex B. - EPS_FALLBACK: EPS Fallback report is enabled in the SMF. - MA_PDU: UE Indicates that the SMF notifies the PCF of the MA PDU session request - TSN_ETHER_PORT: Manageable Ethernet port detected - TSN_CONTAINER: Port management container detected. - 5G_RG_JOIN: The 5G-RG has joined to an IP Multicast Group. - 5G_RG_LEAVE: The 5G-RG has left an IP Multicast Group. + */ + +#ifndef _OpenAPI_policy_control_request_trigger_H_ +#define _OpenAPI_policy_control_request_trigger_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_policy_control_request_trigger_s OpenAPI_policy_control_request_trigger_t; +typedef struct OpenAPI_policy_control_request_trigger_s { +} OpenAPI_policy_control_request_trigger_t; + +OpenAPI_policy_control_request_trigger_t *OpenAPI_policy_control_request_trigger_create( + ); +void OpenAPI_policy_control_request_trigger_free(OpenAPI_policy_control_request_trigger_t *policy_control_request_trigger); +OpenAPI_policy_control_request_trigger_t *OpenAPI_policy_control_request_trigger_parseFromJSON(cJSON *policy_control_request_triggerJSON); +cJSON *OpenAPI_policy_control_request_trigger_convertToJSON(OpenAPI_policy_control_request_trigger_t *policy_control_request_trigger); +OpenAPI_policy_control_request_trigger_t *OpenAPI_policy_control_request_trigger_copy(OpenAPI_policy_control_request_trigger_t *dst, OpenAPI_policy_control_request_trigger_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_policy_control_request_trigger_H_ */ + diff --git a/lib/sbi/openapi/model/policy_update.c b/lib/sbi/openapi/model/policy_update.c new file mode 100644 index 000000000..c40ebcced --- /dev/null +++ b/lib/sbi/openapi/model/policy_update.c @@ -0,0 +1,343 @@ + +#include +#include +#include +#include "policy_update.h" + +OpenAPI_policy_update_t *OpenAPI_policy_update_create( + char *resource_uri, + OpenAPI_list_t *triggers, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_smf_selection_data_t *smf_sel_info, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t* pras + ) +{ + OpenAPI_policy_update_t *policy_update_local_var = OpenAPI_malloc(sizeof(OpenAPI_policy_update_t)); + if (!policy_update_local_var) { + return NULL; + } + policy_update_local_var->resource_uri = resource_uri; + policy_update_local_var->triggers = triggers; + policy_update_local_var->serv_area_res = serv_area_res; + policy_update_local_var->wl_serv_area_res = wl_serv_area_res; + policy_update_local_var->rfsp = rfsp; + policy_update_local_var->smf_sel_info = smf_sel_info; + policy_update_local_var->ue_ambr = ue_ambr; + policy_update_local_var->rg_tmbr = rg_tmbr; + policy_update_local_var->pras = pras; + + return policy_update_local_var; +} + +void OpenAPI_policy_update_free(OpenAPI_policy_update_t *policy_update) +{ + if (NULL == policy_update) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(policy_update->resource_uri); + OpenAPI_list_free(policy_update->triggers); + OpenAPI_service_area_restriction_free(policy_update->serv_area_res); + OpenAPI_wireline_service_area_restriction_free(policy_update->wl_serv_area_res); + OpenAPI_smf_selection_data_free(policy_update->smf_sel_info); + OpenAPI_ambr_free(policy_update->ue_ambr); + OpenAPI_ambr_free(policy_update->rg_tmbr); + OpenAPI_list_for_each(policy_update->pras, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_presence_info_rm_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(policy_update->pras); + ogs_free(policy_update); +} + +cJSON *OpenAPI_policy_update_convertToJSON(OpenAPI_policy_update_t *policy_update) +{ + cJSON *item = NULL; + + if (policy_update == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [PolicyUpdate]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!policy_update->resource_uri) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [resource_uri]"); + goto end; + } + if (cJSON_AddStringToObject(item, "resourceUri", policy_update->resource_uri) == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [resource_uri]"); + goto end; + } + + if (policy_update->triggers) { + cJSON *triggers = cJSON_AddArrayToObject(item, "triggers"); + if (triggers == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [triggers]"); + goto end; + } + OpenAPI_lnode_t *triggers_node; + OpenAPI_list_for_each(policy_update->triggers, triggers_node) { + if (cJSON_AddStringToObject(triggers, "", OpenAPI_request_trigger_ToString((OpenAPI_request_trigger_e)triggers_node->data)) == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [triggers]"); + goto end; + } + } + } + + if (policy_update->serv_area_res) { + cJSON *serv_area_res_local_JSON = OpenAPI_service_area_restriction_convertToJSON(policy_update->serv_area_res); + if (serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "servAreaRes", serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [serv_area_res]"); + goto end; + } + } + + if (policy_update->wl_serv_area_res) { + cJSON *wl_serv_area_res_local_JSON = OpenAPI_wireline_service_area_restriction_convertToJSON(policy_update->wl_serv_area_res); + if (wl_serv_area_res_local_JSON == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + cJSON_AddItemToObject(item, "wlServAreaRes", wl_serv_area_res_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [wl_serv_area_res]"); + goto end; + } + } + + if (policy_update->rfsp) { + if (cJSON_AddNumberToObject(item, "rfsp", policy_update->rfsp) == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [rfsp]"); + goto end; + } + } + + if (policy_update->smf_sel_info) { + cJSON *smf_sel_info_local_JSON = OpenAPI_smf_selection_data_convertToJSON(policy_update->smf_sel_info); + if (smf_sel_info_local_JSON == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [smf_sel_info]"); + goto end; + } + cJSON_AddItemToObject(item, "smfSelInfo", smf_sel_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [smf_sel_info]"); + goto end; + } + } + + if (policy_update->ue_ambr) { + cJSON *ue_ambr_local_JSON = OpenAPI_ambr_convertToJSON(policy_update->ue_ambr); + if (ue_ambr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [ue_ambr]"); + goto end; + } + cJSON_AddItemToObject(item, "ueAmbr", ue_ambr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [ue_ambr]"); + goto end; + } + } + + if (policy_update->rg_tmbr) { + cJSON *rg_tmbr_local_JSON = OpenAPI_ambr_convertToJSON(policy_update->rg_tmbr); + if (rg_tmbr_local_JSON == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [rg_tmbr]"); + goto end; + } + cJSON_AddItemToObject(item, "rgTmbr", rg_tmbr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [rg_tmbr]"); + goto end; + } + } + + if (policy_update->pras) { + cJSON *pras = cJSON_AddObjectToObject(item, "pras"); + if (pras == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [pras]"); + goto end; + } + cJSON *localMapObject = pras; + OpenAPI_lnode_t *pras_node; + if (policy_update->pras) { + OpenAPI_list_for_each(policy_update->pras, pras_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)pras_node->data; + cJSON *itemLocal = OpenAPI_presence_info_rm_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed [pras]"); + goto end; + } + cJSON_AddItemToObject(pras, localKeyValue->key, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_policy_update_t *OpenAPI_policy_update_parseFromJSON(cJSON *policy_updateJSON) +{ + OpenAPI_policy_update_t *policy_update_local_var = NULL; + cJSON *resource_uri = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "resourceUri"); + if (!resource_uri) { + ogs_error("OpenAPI_policy_update_parseFromJSON() failed [resource_uri]"); + goto end; + } + + + if (!cJSON_IsString(resource_uri)) { + ogs_error("OpenAPI_policy_update_parseFromJSON() failed [resource_uri]"); + goto end; + } + + cJSON *triggers = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "triggers"); + + OpenAPI_list_t *triggersList; + if (triggers) { + cJSON *triggers_local_nonprimitive; + if (!cJSON_IsArray(triggers)) { + ogs_error("OpenAPI_policy_update_parseFromJSON() failed [triggers]"); + goto end; + } + + triggersList = OpenAPI_list_create(); + + cJSON_ArrayForEach(triggers_local_nonprimitive, triggers ) { + if (!cJSON_IsString(triggers_local_nonprimitive)) { + ogs_error("OpenAPI_policy_update_parseFromJSON() failed [triggers]"); + goto end; + } + + OpenAPI_list_add(triggersList, (void *)OpenAPI_request_trigger_FromString(triggers_local_nonprimitive->valuestring)); + } + } + + cJSON *serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "servAreaRes"); + + OpenAPI_service_area_restriction_t *serv_area_res_local_nonprim = NULL; + if (serv_area_res) { + serv_area_res_local_nonprim = OpenAPI_service_area_restriction_parseFromJSON(serv_area_res); + } + + cJSON *wl_serv_area_res = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "wlServAreaRes"); + + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res_local_nonprim = NULL; + if (wl_serv_area_res) { + wl_serv_area_res_local_nonprim = OpenAPI_wireline_service_area_restriction_parseFromJSON(wl_serv_area_res); + } + + cJSON *rfsp = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "rfsp"); + + if (rfsp) { + if (!cJSON_IsNumber(rfsp)) { + ogs_error("OpenAPI_policy_update_parseFromJSON() failed [rfsp]"); + goto end; + } + } + + cJSON *smf_sel_info = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "smfSelInfo"); + + OpenAPI_smf_selection_data_t *smf_sel_info_local_nonprim = NULL; + if (smf_sel_info) { + smf_sel_info_local_nonprim = OpenAPI_smf_selection_data_parseFromJSON(smf_sel_info); + } + + cJSON *ue_ambr = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "ueAmbr"); + + OpenAPI_ambr_t *ue_ambr_local_nonprim = NULL; + if (ue_ambr) { + ue_ambr_local_nonprim = OpenAPI_ambr_parseFromJSON(ue_ambr); + } + + cJSON *rg_tmbr = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "rgTmbr"); + + OpenAPI_ambr_t *rg_tmbr_local_nonprim = NULL; + if (rg_tmbr) { + rg_tmbr_local_nonprim = OpenAPI_ambr_parseFromJSON(rg_tmbr); + } + + cJSON *pras = cJSON_GetObjectItemCaseSensitive(policy_updateJSON, "pras"); + + OpenAPI_list_t *prasList; + if (pras) { + cJSON *pras_local_map; + if (!cJSON_IsObject(pras)) { + ogs_error("OpenAPI_policy_update_parseFromJSON() failed [pras]"); + goto end; + } + prasList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(pras_local_map, pras) { + cJSON *localMapObject = pras_local_map; + if (!cJSON_IsObject(pras_local_map)) { + ogs_error("OpenAPI_policy_update_parseFromJSON() failed [pras]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_presence_info_rm_parseFromJSON(localMapObject)); + OpenAPI_list_add(prasList, localMapKeyPair); + } + } + + policy_update_local_var = OpenAPI_policy_update_create ( + ogs_strdup(resource_uri->valuestring), + triggers ? triggersList : NULL, + serv_area_res ? serv_area_res_local_nonprim : NULL, + wl_serv_area_res ? wl_serv_area_res_local_nonprim : NULL, + rfsp ? rfsp->valuedouble : 0, + smf_sel_info ? smf_sel_info_local_nonprim : NULL, + ue_ambr ? ue_ambr_local_nonprim : NULL, + rg_tmbr ? rg_tmbr_local_nonprim : NULL, + pras ? prasList : NULL + ); + + return policy_update_local_var; +end: + return NULL; +} + +OpenAPI_policy_update_t *OpenAPI_policy_update_copy(OpenAPI_policy_update_t *dst, OpenAPI_policy_update_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_policy_update_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_policy_update_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_policy_update_free(dst); + dst = OpenAPI_policy_update_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/policy_update.h b/lib/sbi/openapi/model/policy_update.h new file mode 100644 index 000000000..3bd87f370 --- /dev/null +++ b/lib/sbi/openapi/model/policy_update.h @@ -0,0 +1,60 @@ +/* + * policy_update.h + * + * + */ + +#ifndef _OpenAPI_policy_update_H_ +#define _OpenAPI_policy_update_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "ambr.h" +#include "presence_info_rm.h" +#include "request_trigger.h" +#include "service_area_restriction.h" +#include "smf_selection_data.h" +#include "wireline_service_area_restriction.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_policy_update_s OpenAPI_policy_update_t; +typedef struct OpenAPI_policy_update_s { + char *resource_uri; + OpenAPI_list_t *triggers; + struct OpenAPI_service_area_restriction_s *serv_area_res; + struct OpenAPI_wireline_service_area_restriction_s *wl_serv_area_res; + int rfsp; + struct OpenAPI_smf_selection_data_s *smf_sel_info; + struct OpenAPI_ambr_s *ue_ambr; + struct OpenAPI_ambr_s *rg_tmbr; + OpenAPI_list_t* pras; +} OpenAPI_policy_update_t; + +OpenAPI_policy_update_t *OpenAPI_policy_update_create( + char *resource_uri, + OpenAPI_list_t *triggers, + OpenAPI_service_area_restriction_t *serv_area_res, + OpenAPI_wireline_service_area_restriction_t *wl_serv_area_res, + int rfsp, + OpenAPI_smf_selection_data_t *smf_sel_info, + OpenAPI_ambr_t *ue_ambr, + OpenAPI_ambr_t *rg_tmbr, + OpenAPI_list_t* pras + ); +void OpenAPI_policy_update_free(OpenAPI_policy_update_t *policy_update); +OpenAPI_policy_update_t *OpenAPI_policy_update_parseFromJSON(cJSON *policy_updateJSON); +cJSON *OpenAPI_policy_update_convertToJSON(OpenAPI_policy_update_t *policy_update); +OpenAPI_policy_update_t *OpenAPI_policy_update_copy(OpenAPI_policy_update_t *dst, OpenAPI_policy_update_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_policy_update_H_ */ + diff --git a/lib/sbi/openapi/model/port_management_container.c b/lib/sbi/openapi/model/port_management_container.c new file mode 100644 index 000000000..7a31c93fc --- /dev/null +++ b/lib/sbi/openapi/model/port_management_container.c @@ -0,0 +1,138 @@ + +#include +#include +#include +#include "port_management_container.h" + +OpenAPI_port_management_container_t *OpenAPI_port_management_container_create( + char port_man_cont, + OpenAPI_tsn_port_identifier_t *port_identifier + ) +{ + OpenAPI_port_management_container_t *port_management_container_local_var = OpenAPI_malloc(sizeof(OpenAPI_port_management_container_t)); + if (!port_management_container_local_var) { + return NULL; + } + port_management_container_local_var->port_man_cont = port_man_cont; + port_management_container_local_var->port_identifier = port_identifier; + + return port_management_container_local_var; +} + +void OpenAPI_port_management_container_free(OpenAPI_port_management_container_t *port_management_container) +{ + if (NULL == port_management_container) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_tsn_port_identifier_free(port_management_container->port_identifier); + ogs_free(port_management_container); +} + +cJSON *OpenAPI_port_management_container_convertToJSON(OpenAPI_port_management_container_t *port_management_container) +{ + cJSON *item = NULL; + + if (port_management_container == NULL) { + ogs_error("OpenAPI_port_management_container_convertToJSON() failed [PortManagementContainer]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!port_management_container->port_man_cont) { + ogs_error("OpenAPI_port_management_container_convertToJSON() failed [port_man_cont]"); + goto end; + } + if (cJSON_AddNumberToObject(item, "portManCont", port_management_container->port_man_cont) == NULL) { + ogs_error("OpenAPI_port_management_container_convertToJSON() failed [port_man_cont]"); + goto end; + } + + if (!port_management_container->port_identifier) { + ogs_error("OpenAPI_port_management_container_convertToJSON() failed [port_identifier]"); + goto end; + } + cJSON *port_identifier_local_JSON = OpenAPI_tsn_port_identifier_convertToJSON(port_management_container->port_identifier); + if (port_identifier_local_JSON == NULL) { + ogs_error("OpenAPI_port_management_container_convertToJSON() failed [port_identifier]"); + goto end; + } + cJSON_AddItemToObject(item, "portIdentifier", port_identifier_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_port_management_container_convertToJSON() failed [port_identifier]"); + goto end; + } + +end: + return item; +} + +OpenAPI_port_management_container_t *OpenAPI_port_management_container_parseFromJSON(cJSON *port_management_containerJSON) +{ + OpenAPI_port_management_container_t *port_management_container_local_var = NULL; + cJSON *port_man_cont = cJSON_GetObjectItemCaseSensitive(port_management_containerJSON, "portManCont"); + if (!port_man_cont) { + ogs_error("OpenAPI_port_management_container_parseFromJSON() failed [port_man_cont]"); + goto end; + } + + + if (!cJSON_IsNumber(port_man_cont)) { + ogs_error("OpenAPI_port_management_container_parseFromJSON() failed [port_man_cont]"); + goto end; + } + + cJSON *port_identifier = cJSON_GetObjectItemCaseSensitive(port_management_containerJSON, "portIdentifier"); + if (!port_identifier) { + ogs_error("OpenAPI_port_management_container_parseFromJSON() failed [port_identifier]"); + goto end; + } + + OpenAPI_tsn_port_identifier_t *port_identifier_local_nonprim = NULL; + + port_identifier_local_nonprim = OpenAPI_tsn_port_identifier_parseFromJSON(port_identifier); + + port_management_container_local_var = OpenAPI_port_management_container_create ( + port_man_cont->valueint, + port_identifier_local_nonprim + ); + + return port_management_container_local_var; +end: + return NULL; +} + +OpenAPI_port_management_container_t *OpenAPI_port_management_container_copy(OpenAPI_port_management_container_t *dst, OpenAPI_port_management_container_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_port_management_container_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_port_management_container_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_port_management_container_free(dst); + dst = OpenAPI_port_management_container_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/port_management_container.h b/lib/sbi/openapi/model/port_management_container.h new file mode 100644 index 000000000..38b8701ad --- /dev/null +++ b/lib/sbi/openapi/model/port_management_container.h @@ -0,0 +1,41 @@ +/* + * port_management_container.h + * + * + */ + +#ifndef _OpenAPI_port_management_container_H_ +#define _OpenAPI_port_management_container_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "tsn_port_identifier.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_port_management_container_s OpenAPI_port_management_container_t; +typedef struct OpenAPI_port_management_container_s { + char port_man_cont; + struct OpenAPI_tsn_port_identifier_s *port_identifier; +} OpenAPI_port_management_container_t; + +OpenAPI_port_management_container_t *OpenAPI_port_management_container_create( + char port_man_cont, + OpenAPI_tsn_port_identifier_t *port_identifier + ); +void OpenAPI_port_management_container_free(OpenAPI_port_management_container_t *port_management_container); +OpenAPI_port_management_container_t *OpenAPI_port_management_container_parseFromJSON(cJSON *port_management_containerJSON); +cJSON *OpenAPI_port_management_container_convertToJSON(OpenAPI_port_management_container_t *port_management_container); +OpenAPI_port_management_container_t *OpenAPI_port_management_container_copy(OpenAPI_port_management_container_t *dst, OpenAPI_port_management_container_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_port_management_container_H_ */ + diff --git a/lib/sbi/openapi/model/presence_info.c b/lib/sbi/openapi/model/presence_info.c index 874521ba3..af22c17b9 100644 --- a/lib/sbi/openapi/model/presence_info.c +++ b/lib/sbi/openapi/model/presence_info.c @@ -6,7 +6,7 @@ OpenAPI_presence_info_t *OpenAPI_presence_info_create( char *pra_id, - OpenAPI_presence_state_t *presence_state, + OpenAPI_presence_state_e presence_state, OpenAPI_list_t *tracking_area_list, OpenAPI_list_t *ecgi_list, OpenAPI_list_t *ncgi_list, @@ -36,7 +36,6 @@ void OpenAPI_presence_info_free(OpenAPI_presence_info_t *presence_info) } OpenAPI_lnode_t *node; ogs_free(presence_info->pra_id); - OpenAPI_presence_state_free(presence_info->presence_state); OpenAPI_list_for_each(presence_info->tracking_area_list, node) { OpenAPI_tai_free(node->data); } @@ -78,13 +77,7 @@ cJSON *OpenAPI_presence_info_convertToJSON(OpenAPI_presence_info_t *presence_inf } if (presence_info->presence_state) { - cJSON *presence_state_local_JSON = OpenAPI_presence_state_convertToJSON(presence_info->presence_state); - if (presence_state_local_JSON == NULL) { - ogs_error("OpenAPI_presence_info_convertToJSON() failed [presence_state]"); - goto end; - } - cJSON_AddItemToObject(item, "presenceState", presence_state_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "presenceState", OpenAPI_presence_state_ToString(presence_info->presence_state)) == NULL) { ogs_error("OpenAPI_presence_info_convertToJSON() failed [presence_state]"); goto end; } @@ -208,9 +201,13 @@ OpenAPI_presence_info_t *OpenAPI_presence_info_parseFromJSON(cJSON *presence_inf cJSON *presence_state = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "presenceState"); - OpenAPI_presence_state_t *presence_state_local_nonprim = NULL; + OpenAPI_presence_state_e presence_stateVariable; if (presence_state) { - presence_state_local_nonprim = OpenAPI_presence_state_parseFromJSON(presence_state); + if (!cJSON_IsString(presence_state)) { + ogs_error("OpenAPI_presence_info_parseFromJSON() failed [presence_state]"); + goto end; + } + presence_stateVariable = OpenAPI_presence_state_FromString(presence_state->valuestring); } cJSON *tracking_area_list = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "trackingAreaList"); @@ -330,7 +327,7 @@ OpenAPI_presence_info_t *OpenAPI_presence_info_parseFromJSON(cJSON *presence_inf presence_info_local_var = OpenAPI_presence_info_create ( pra_id ? ogs_strdup(pra_id->valuestring) : NULL, - presence_state ? presence_state_local_nonprim : NULL, + presence_state ? presence_stateVariable : 0, tracking_area_list ? tracking_area_listList : NULL, ecgi_list ? ecgi_listList : NULL, ncgi_list ? ncgi_listList : NULL, diff --git a/lib/sbi/openapi/model/presence_info.h b/lib/sbi/openapi/model/presence_info.h index b96920e02..f820e86b9 100644 --- a/lib/sbi/openapi/model/presence_info.h +++ b/lib/sbi/openapi/model/presence_info.h @@ -25,7 +25,7 @@ extern "C" { typedef struct OpenAPI_presence_info_s OpenAPI_presence_info_t; typedef struct OpenAPI_presence_info_s { char *pra_id; - struct OpenAPI_presence_state_s *presence_state; + OpenAPI_presence_state_e presence_state; OpenAPI_list_t *tracking_area_list; OpenAPI_list_t *ecgi_list; OpenAPI_list_t *ncgi_list; @@ -35,7 +35,7 @@ typedef struct OpenAPI_presence_info_s { OpenAPI_presence_info_t *OpenAPI_presence_info_create( char *pra_id, - OpenAPI_presence_state_t *presence_state, + OpenAPI_presence_state_e presence_state, OpenAPI_list_t *tracking_area_list, OpenAPI_list_t *ecgi_list, OpenAPI_list_t *ncgi_list, diff --git a/lib/sbi/openapi/model/presence_info_rm.c b/lib/sbi/openapi/model/presence_info_rm.c new file mode 100644 index 000000000..76808e541 --- /dev/null +++ b/lib/sbi/openapi/model/presence_info_rm.c @@ -0,0 +1,376 @@ + +#include +#include +#include +#include "presence_info_rm.h" + +OpenAPI_presence_info_rm_t *OpenAPI_presence_info_rm_create( + char *pra_id, + OpenAPI_presence_state_e presence_state, + OpenAPI_list_t *tracking_area_list, + OpenAPI_list_t *ecgi_list, + OpenAPI_list_t *ncgi_list, + OpenAPI_list_t *global_ran_node_id_list, + OpenAPI_list_t *globale_nb_id_list + ) +{ + OpenAPI_presence_info_rm_t *presence_info_rm_local_var = OpenAPI_malloc(sizeof(OpenAPI_presence_info_rm_t)); + if (!presence_info_rm_local_var) { + return NULL; + } + presence_info_rm_local_var->pra_id = pra_id; + presence_info_rm_local_var->presence_state = presence_state; + presence_info_rm_local_var->tracking_area_list = tracking_area_list; + presence_info_rm_local_var->ecgi_list = ecgi_list; + presence_info_rm_local_var->ncgi_list = ncgi_list; + presence_info_rm_local_var->global_ran_node_id_list = global_ran_node_id_list; + presence_info_rm_local_var->globale_nb_id_list = globale_nb_id_list; + + return presence_info_rm_local_var; +} + +void OpenAPI_presence_info_rm_free(OpenAPI_presence_info_rm_t *presence_info_rm) +{ + if (NULL == presence_info_rm) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(presence_info_rm->pra_id); + OpenAPI_list_for_each(presence_info_rm->tracking_area_list, node) { + OpenAPI_tai_free(node->data); + } + OpenAPI_list_free(presence_info_rm->tracking_area_list); + OpenAPI_list_for_each(presence_info_rm->ecgi_list, node) { + OpenAPI_ecgi_free(node->data); + } + OpenAPI_list_free(presence_info_rm->ecgi_list); + OpenAPI_list_for_each(presence_info_rm->ncgi_list, node) { + OpenAPI_ncgi_free(node->data); + } + OpenAPI_list_free(presence_info_rm->ncgi_list); + OpenAPI_list_for_each(presence_info_rm->global_ran_node_id_list, node) { + OpenAPI_global_ran_node_id_free(node->data); + } + OpenAPI_list_free(presence_info_rm->global_ran_node_id_list); + OpenAPI_list_for_each(presence_info_rm->globale_nb_id_list, node) { + OpenAPI_global_ran_node_id_free(node->data); + } + OpenAPI_list_free(presence_info_rm->globale_nb_id_list); + ogs_free(presence_info_rm); +} + +cJSON *OpenAPI_presence_info_rm_convertToJSON(OpenAPI_presence_info_rm_t *presence_info_rm) +{ + cJSON *item = NULL; + + if (presence_info_rm == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [PresenceInfoRm]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (presence_info_rm->pra_id) { + if (cJSON_AddStringToObject(item, "praId", presence_info_rm->pra_id) == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [pra_id]"); + goto end; + } + } + + if (presence_info_rm->presence_state) { + if (cJSON_AddStringToObject(item, "presenceState", OpenAPI_presence_state_ToString(presence_info_rm->presence_state)) == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [presence_state]"); + goto end; + } + } + + if (presence_info_rm->tracking_area_list) { + cJSON *tracking_area_listList = cJSON_AddArrayToObject(item, "trackingAreaList"); + if (tracking_area_listList == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [tracking_area_list]"); + goto end; + } + + OpenAPI_lnode_t *tracking_area_list_node; + if (presence_info_rm->tracking_area_list) { + OpenAPI_list_for_each(presence_info_rm->tracking_area_list, tracking_area_list_node) { + cJSON *itemLocal = OpenAPI_tai_convertToJSON(tracking_area_list_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [tracking_area_list]"); + goto end; + } + cJSON_AddItemToArray(tracking_area_listList, itemLocal); + } + } + } + + if (presence_info_rm->ecgi_list) { + cJSON *ecgi_listList = cJSON_AddArrayToObject(item, "ecgiList"); + if (ecgi_listList == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [ecgi_list]"); + goto end; + } + + OpenAPI_lnode_t *ecgi_list_node; + if (presence_info_rm->ecgi_list) { + OpenAPI_list_for_each(presence_info_rm->ecgi_list, ecgi_list_node) { + cJSON *itemLocal = OpenAPI_ecgi_convertToJSON(ecgi_list_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [ecgi_list]"); + goto end; + } + cJSON_AddItemToArray(ecgi_listList, itemLocal); + } + } + } + + if (presence_info_rm->ncgi_list) { + cJSON *ncgi_listList = cJSON_AddArrayToObject(item, "ncgiList"); + if (ncgi_listList == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [ncgi_list]"); + goto end; + } + + OpenAPI_lnode_t *ncgi_list_node; + if (presence_info_rm->ncgi_list) { + OpenAPI_list_for_each(presence_info_rm->ncgi_list, ncgi_list_node) { + cJSON *itemLocal = OpenAPI_ncgi_convertToJSON(ncgi_list_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [ncgi_list]"); + goto end; + } + cJSON_AddItemToArray(ncgi_listList, itemLocal); + } + } + } + + if (presence_info_rm->global_ran_node_id_list) { + cJSON *global_ran_node_id_listList = cJSON_AddArrayToObject(item, "globalRanNodeIdList"); + if (global_ran_node_id_listList == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [global_ran_node_id_list]"); + goto end; + } + + OpenAPI_lnode_t *global_ran_node_id_list_node; + if (presence_info_rm->global_ran_node_id_list) { + OpenAPI_list_for_each(presence_info_rm->global_ran_node_id_list, global_ran_node_id_list_node) { + cJSON *itemLocal = OpenAPI_global_ran_node_id_convertToJSON(global_ran_node_id_list_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [global_ran_node_id_list]"); + goto end; + } + cJSON_AddItemToArray(global_ran_node_id_listList, itemLocal); + } + } + } + + if (presence_info_rm->globale_nb_id_list) { + cJSON *globale_nb_id_listList = cJSON_AddArrayToObject(item, "globaleNbIdList"); + if (globale_nb_id_listList == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [globale_nb_id_list]"); + goto end; + } + + OpenAPI_lnode_t *globale_nb_id_list_node; + if (presence_info_rm->globale_nb_id_list) { + OpenAPI_list_for_each(presence_info_rm->globale_nb_id_list, globale_nb_id_list_node) { + cJSON *itemLocal = OpenAPI_global_ran_node_id_convertToJSON(globale_nb_id_list_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed [globale_nb_id_list]"); + goto end; + } + cJSON_AddItemToArray(globale_nb_id_listList, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_presence_info_rm_t *OpenAPI_presence_info_rm_parseFromJSON(cJSON *presence_info_rmJSON) +{ + OpenAPI_presence_info_rm_t *presence_info_rm_local_var = NULL; + cJSON *pra_id = cJSON_GetObjectItemCaseSensitive(presence_info_rmJSON, "praId"); + + if (pra_id) { + if (!cJSON_IsString(pra_id)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [pra_id]"); + goto end; + } + } + + cJSON *presence_state = cJSON_GetObjectItemCaseSensitive(presence_info_rmJSON, "presenceState"); + + OpenAPI_presence_state_e presence_stateVariable; + if (presence_state) { + if (!cJSON_IsString(presence_state)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [presence_state]"); + goto end; + } + presence_stateVariable = OpenAPI_presence_state_FromString(presence_state->valuestring); + } + + cJSON *tracking_area_list = cJSON_GetObjectItemCaseSensitive(presence_info_rmJSON, "trackingAreaList"); + + OpenAPI_list_t *tracking_area_listList; + if (tracking_area_list) { + cJSON *tracking_area_list_local_nonprimitive; + if (!cJSON_IsArray(tracking_area_list)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [tracking_area_list]"); + goto end; + } + + tracking_area_listList = OpenAPI_list_create(); + + cJSON_ArrayForEach(tracking_area_list_local_nonprimitive, tracking_area_list ) { + if (!cJSON_IsObject(tracking_area_list_local_nonprimitive)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [tracking_area_list]"); + goto end; + } + OpenAPI_tai_t *tracking_area_listItem = OpenAPI_tai_parseFromJSON(tracking_area_list_local_nonprimitive); + + OpenAPI_list_add(tracking_area_listList, tracking_area_listItem); + } + } + + cJSON *ecgi_list = cJSON_GetObjectItemCaseSensitive(presence_info_rmJSON, "ecgiList"); + + OpenAPI_list_t *ecgi_listList; + if (ecgi_list) { + cJSON *ecgi_list_local_nonprimitive; + if (!cJSON_IsArray(ecgi_list)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [ecgi_list]"); + goto end; + } + + ecgi_listList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ecgi_list_local_nonprimitive, ecgi_list ) { + if (!cJSON_IsObject(ecgi_list_local_nonprimitive)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [ecgi_list]"); + goto end; + } + OpenAPI_ecgi_t *ecgi_listItem = OpenAPI_ecgi_parseFromJSON(ecgi_list_local_nonprimitive); + + OpenAPI_list_add(ecgi_listList, ecgi_listItem); + } + } + + cJSON *ncgi_list = cJSON_GetObjectItemCaseSensitive(presence_info_rmJSON, "ncgiList"); + + OpenAPI_list_t *ncgi_listList; + if (ncgi_list) { + cJSON *ncgi_list_local_nonprimitive; + if (!cJSON_IsArray(ncgi_list)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [ncgi_list]"); + goto end; + } + + ncgi_listList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ncgi_list_local_nonprimitive, ncgi_list ) { + if (!cJSON_IsObject(ncgi_list_local_nonprimitive)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [ncgi_list]"); + goto end; + } + OpenAPI_ncgi_t *ncgi_listItem = OpenAPI_ncgi_parseFromJSON(ncgi_list_local_nonprimitive); + + OpenAPI_list_add(ncgi_listList, ncgi_listItem); + } + } + + cJSON *global_ran_node_id_list = cJSON_GetObjectItemCaseSensitive(presence_info_rmJSON, "globalRanNodeIdList"); + + OpenAPI_list_t *global_ran_node_id_listList; + if (global_ran_node_id_list) { + cJSON *global_ran_node_id_list_local_nonprimitive; + if (!cJSON_IsArray(global_ran_node_id_list)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [global_ran_node_id_list]"); + goto end; + } + + global_ran_node_id_listList = OpenAPI_list_create(); + + cJSON_ArrayForEach(global_ran_node_id_list_local_nonprimitive, global_ran_node_id_list ) { + if (!cJSON_IsObject(global_ran_node_id_list_local_nonprimitive)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [global_ran_node_id_list]"); + goto end; + } + OpenAPI_global_ran_node_id_t *global_ran_node_id_listItem = OpenAPI_global_ran_node_id_parseFromJSON(global_ran_node_id_list_local_nonprimitive); + + OpenAPI_list_add(global_ran_node_id_listList, global_ran_node_id_listItem); + } + } + + cJSON *globale_nb_id_list = cJSON_GetObjectItemCaseSensitive(presence_info_rmJSON, "globaleNbIdList"); + + OpenAPI_list_t *globale_nb_id_listList; + if (globale_nb_id_list) { + cJSON *globale_nb_id_list_local_nonprimitive; + if (!cJSON_IsArray(globale_nb_id_list)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [globale_nb_id_list]"); + goto end; + } + + globale_nb_id_listList = OpenAPI_list_create(); + + cJSON_ArrayForEach(globale_nb_id_list_local_nonprimitive, globale_nb_id_list ) { + if (!cJSON_IsObject(globale_nb_id_list_local_nonprimitive)) { + ogs_error("OpenAPI_presence_info_rm_parseFromJSON() failed [globale_nb_id_list]"); + goto end; + } + OpenAPI_global_ran_node_id_t *globale_nb_id_listItem = OpenAPI_global_ran_node_id_parseFromJSON(globale_nb_id_list_local_nonprimitive); + + OpenAPI_list_add(globale_nb_id_listList, globale_nb_id_listItem); + } + } + + presence_info_rm_local_var = OpenAPI_presence_info_rm_create ( + pra_id ? ogs_strdup(pra_id->valuestring) : NULL, + presence_state ? presence_stateVariable : 0, + tracking_area_list ? tracking_area_listList : NULL, + ecgi_list ? ecgi_listList : NULL, + ncgi_list ? ncgi_listList : NULL, + global_ran_node_id_list ? global_ran_node_id_listList : NULL, + globale_nb_id_list ? globale_nb_id_listList : NULL + ); + + return presence_info_rm_local_var; +end: + return NULL; +} + +OpenAPI_presence_info_rm_t *OpenAPI_presence_info_rm_copy(OpenAPI_presence_info_rm_t *dst, OpenAPI_presence_info_rm_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_presence_info_rm_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_presence_info_rm_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_presence_info_rm_free(dst); + dst = OpenAPI_presence_info_rm_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/presence_info_rm.h b/lib/sbi/openapi/model/presence_info_rm.h new file mode 100644 index 000000000..4ec124413 --- /dev/null +++ b/lib/sbi/openapi/model/presence_info_rm.h @@ -0,0 +1,55 @@ +/* + * presence_info_rm.h + * + * + */ + +#ifndef _OpenAPI_presence_info_rm_H_ +#define _OpenAPI_presence_info_rm_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "ecgi.h" +#include "global_ran_node_id.h" +#include "ncgi.h" +#include "presence_state.h" +#include "tai.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_presence_info_rm_s OpenAPI_presence_info_rm_t; +typedef struct OpenAPI_presence_info_rm_s { + char *pra_id; + OpenAPI_presence_state_e presence_state; + OpenAPI_list_t *tracking_area_list; + OpenAPI_list_t *ecgi_list; + OpenAPI_list_t *ncgi_list; + OpenAPI_list_t *global_ran_node_id_list; + OpenAPI_list_t *globale_nb_id_list; +} OpenAPI_presence_info_rm_t; + +OpenAPI_presence_info_rm_t *OpenAPI_presence_info_rm_create( + char *pra_id, + OpenAPI_presence_state_e presence_state, + OpenAPI_list_t *tracking_area_list, + OpenAPI_list_t *ecgi_list, + OpenAPI_list_t *ncgi_list, + OpenAPI_list_t *global_ran_node_id_list, + OpenAPI_list_t *globale_nb_id_list + ); +void OpenAPI_presence_info_rm_free(OpenAPI_presence_info_rm_t *presence_info_rm); +OpenAPI_presence_info_rm_t *OpenAPI_presence_info_rm_parseFromJSON(cJSON *presence_info_rmJSON); +cJSON *OpenAPI_presence_info_rm_convertToJSON(OpenAPI_presence_info_rm_t *presence_info_rm); +OpenAPI_presence_info_rm_t *OpenAPI_presence_info_rm_copy(OpenAPI_presence_info_rm_t *dst, OpenAPI_presence_info_rm_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_presence_info_rm_H_ */ + diff --git a/lib/sbi/openapi/model/presence_state.c b/lib/sbi/openapi/model/presence_state.c index a26ec6115..2dca87a05 100644 --- a/lib/sbi/openapi/model/presence_state.c +++ b/lib/sbi/openapi/model/presence_state.c @@ -4,82 +4,27 @@ #include #include "presence_state.h" -OpenAPI_presence_state_t *OpenAPI_presence_state_create( - ) +char* OpenAPI_presence_state_ToString(OpenAPI_presence_state_e presence_state) { - OpenAPI_presence_state_t *presence_state_local_var = OpenAPI_malloc(sizeof(OpenAPI_presence_state_t)); - if (!presence_state_local_var) { - return NULL; - } - - return presence_state_local_var; + const char *presence_stateArray[] = { "NULL", "IN_AREA", "OUT_OF_AREA", "UNKNOWN", "INACTIVE" }; + size_t sizeofArray = sizeof(presence_stateArray) / sizeof(presence_stateArray[0]); + if (presence_state < sizeofArray) + return (char *)presence_stateArray[presence_state]; + else + return (char *)"Unknown"; } -void OpenAPI_presence_state_free(OpenAPI_presence_state_t *presence_state) +OpenAPI_presence_state_e OpenAPI_presence_state_FromString(char* presence_state) { - if (NULL == presence_state) { - return; + int stringToReturn = 0; + const char *presence_stateArray[] = { "NULL", "IN_AREA", "OUT_OF_AREA", "UNKNOWN", "INACTIVE" }; + size_t sizeofArray = sizeof(presence_stateArray) / sizeof(presence_stateArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(presence_state, presence_stateArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; } - OpenAPI_lnode_t *node; - ogs_free(presence_state); -} - -cJSON *OpenAPI_presence_state_convertToJSON(OpenAPI_presence_state_t *presence_state) -{ - cJSON *item = NULL; - - if (presence_state == NULL) { - ogs_error("OpenAPI_presence_state_convertToJSON() failed [PresenceState]"); - return NULL; - } - - item = cJSON_CreateObject(); -end: - return item; -} - -OpenAPI_presence_state_t *OpenAPI_presence_state_parseFromJSON(cJSON *presence_stateJSON) -{ - OpenAPI_presence_state_t *presence_state_local_var = NULL; - presence_state_local_var = OpenAPI_presence_state_create ( - ); - - return presence_state_local_var; -end: - return NULL; -} - -OpenAPI_presence_state_t *OpenAPI_presence_state_copy(OpenAPI_presence_state_t *dst, OpenAPI_presence_state_t *src) -{ - cJSON *item = NULL; - char *content = NULL; - - ogs_assert(src); - item = OpenAPI_presence_state_convertToJSON(src); - if (!item) { - ogs_error("OpenAPI_presence_state_convertToJSON() failed"); - return NULL; - } - - content = cJSON_Print(item); - cJSON_Delete(item); - - if (!content) { - ogs_error("cJSON_Print() failed"); - return NULL; - } - - item = cJSON_Parse(content); - ogs_free(content); - if (!item) { - ogs_error("cJSON_Parse() failed"); - return NULL; - } - - OpenAPI_presence_state_free(dst); - dst = OpenAPI_presence_state_parseFromJSON(item); - cJSON_Delete(item); - - return dst; + return 0; } diff --git a/lib/sbi/openapi/model/presence_state.h b/lib/sbi/openapi/model/presence_state.h index b7cda4566..e0e4d9d8e 100644 --- a/lib/sbi/openapi/model/presence_state.h +++ b/lib/sbi/openapi/model/presence_state.h @@ -17,16 +17,11 @@ extern "C" { #endif -typedef struct OpenAPI_presence_state_s OpenAPI_presence_state_t; -typedef struct OpenAPI_presence_state_s { -} OpenAPI_presence_state_t; +typedef enum { OpenAPI_presence_state_NULL = 0, OpenAPI_presence_state_IN_AREA, OpenAPI_presence_state_OUT_OF_AREA, OpenAPI_presence_state_UNKNOWN, OpenAPI_presence_state_INACTIVE } OpenAPI_presence_state_e; -OpenAPI_presence_state_t *OpenAPI_presence_state_create( - ); -void OpenAPI_presence_state_free(OpenAPI_presence_state_t *presence_state); -OpenAPI_presence_state_t *OpenAPI_presence_state_parseFromJSON(cJSON *presence_stateJSON); -cJSON *OpenAPI_presence_state_convertToJSON(OpenAPI_presence_state_t *presence_state); -OpenAPI_presence_state_t *OpenAPI_presence_state_copy(OpenAPI_presence_state_t *dst, OpenAPI_presence_state_t *src); +char* OpenAPI_presence_state_ToString(OpenAPI_presence_state_e presence_state); + +OpenAPI_presence_state_e OpenAPI_presence_state_FromString(char* presence_state); #ifdef __cplusplus } diff --git a/lib/sbi/openapi/model/qos_characteristics.c b/lib/sbi/openapi/model/qos_characteristics.c new file mode 100644 index 000000000..0b496b948 --- /dev/null +++ b/lib/sbi/openapi/model/qos_characteristics.c @@ -0,0 +1,268 @@ + +#include +#include +#include +#include "qos_characteristics.h" + +OpenAPI_qos_characteristics_t *OpenAPI_qos_characteristics_create( + int _5qi, + OpenAPI_qos_resource_type_t *resource_type, + int priority_level, + int packet_delay_budget, + char *packet_error_rate, + int averaging_window, + int max_data_burst_vol, + int ext_max_data_burst_vol + ) +{ + OpenAPI_qos_characteristics_t *qos_characteristics_local_var = OpenAPI_malloc(sizeof(OpenAPI_qos_characteristics_t)); + if (!qos_characteristics_local_var) { + return NULL; + } + qos_characteristics_local_var->_5qi = _5qi; + qos_characteristics_local_var->resource_type = resource_type; + qos_characteristics_local_var->priority_level = priority_level; + qos_characteristics_local_var->packet_delay_budget = packet_delay_budget; + qos_characteristics_local_var->packet_error_rate = packet_error_rate; + qos_characteristics_local_var->averaging_window = averaging_window; + qos_characteristics_local_var->max_data_burst_vol = max_data_burst_vol; + qos_characteristics_local_var->ext_max_data_burst_vol = ext_max_data_burst_vol; + + return qos_characteristics_local_var; +} + +void OpenAPI_qos_characteristics_free(OpenAPI_qos_characteristics_t *qos_characteristics) +{ + if (NULL == qos_characteristics) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_qos_resource_type_free(qos_characteristics->resource_type); + ogs_free(qos_characteristics->packet_error_rate); + ogs_free(qos_characteristics); +} + +cJSON *OpenAPI_qos_characteristics_convertToJSON(OpenAPI_qos_characteristics_t *qos_characteristics) +{ + cJSON *item = NULL; + + if (qos_characteristics == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [QosCharacteristics]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!qos_characteristics->_5qi) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [_5qi]"); + goto end; + } + if (cJSON_AddNumberToObject(item, "5qi", qos_characteristics->_5qi) == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [_5qi]"); + goto end; + } + + if (!qos_characteristics->resource_type) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [resource_type]"); + goto end; + } + cJSON *resource_type_local_JSON = OpenAPI_qos_resource_type_convertToJSON(qos_characteristics->resource_type); + if (resource_type_local_JSON == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [resource_type]"); + goto end; + } + cJSON_AddItemToObject(item, "resourceType", resource_type_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [resource_type]"); + goto end; + } + + if (!qos_characteristics->priority_level) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [priority_level]"); + goto end; + } + if (cJSON_AddNumberToObject(item, "priorityLevel", qos_characteristics->priority_level) == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [priority_level]"); + goto end; + } + + if (!qos_characteristics->packet_delay_budget) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [packet_delay_budget]"); + goto end; + } + if (cJSON_AddNumberToObject(item, "packetDelayBudget", qos_characteristics->packet_delay_budget) == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [packet_delay_budget]"); + goto end; + } + + if (!qos_characteristics->packet_error_rate) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [packet_error_rate]"); + goto end; + } + if (cJSON_AddStringToObject(item, "packetErrorRate", qos_characteristics->packet_error_rate) == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [packet_error_rate]"); + goto end; + } + + if (qos_characteristics->averaging_window) { + if (cJSON_AddNumberToObject(item, "averagingWindow", qos_characteristics->averaging_window) == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [averaging_window]"); + goto end; + } + } + + if (qos_characteristics->max_data_burst_vol) { + if (cJSON_AddNumberToObject(item, "maxDataBurstVol", qos_characteristics->max_data_burst_vol) == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [max_data_burst_vol]"); + goto end; + } + } + + if (qos_characteristics->ext_max_data_burst_vol) { + if (cJSON_AddNumberToObject(item, "extMaxDataBurstVol", qos_characteristics->ext_max_data_burst_vol) == NULL) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed [ext_max_data_burst_vol]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_qos_characteristics_t *OpenAPI_qos_characteristics_parseFromJSON(cJSON *qos_characteristicsJSON) +{ + OpenAPI_qos_characteristics_t *qos_characteristics_local_var = NULL; + cJSON *_5qi = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "5qi"); + if (!_5qi) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [_5qi]"); + goto end; + } + + + if (!cJSON_IsNumber(_5qi)) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [_5qi]"); + goto end; + } + + cJSON *resource_type = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "resourceType"); + if (!resource_type) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [resource_type]"); + goto end; + } + + OpenAPI_qos_resource_type_t *resource_type_local_nonprim = NULL; + + resource_type_local_nonprim = OpenAPI_qos_resource_type_parseFromJSON(resource_type); + + cJSON *priority_level = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "priorityLevel"); + if (!priority_level) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [priority_level]"); + goto end; + } + + + if (!cJSON_IsNumber(priority_level)) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [priority_level]"); + goto end; + } + + cJSON *packet_delay_budget = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "packetDelayBudget"); + if (!packet_delay_budget) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [packet_delay_budget]"); + goto end; + } + + + if (!cJSON_IsNumber(packet_delay_budget)) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [packet_delay_budget]"); + goto end; + } + + cJSON *packet_error_rate = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "packetErrorRate"); + if (!packet_error_rate) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [packet_error_rate]"); + goto end; + } + + + if (!cJSON_IsString(packet_error_rate)) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [packet_error_rate]"); + goto end; + } + + cJSON *averaging_window = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "averagingWindow"); + + if (averaging_window) { + if (!cJSON_IsNumber(averaging_window)) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [averaging_window]"); + goto end; + } + } + + cJSON *max_data_burst_vol = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "maxDataBurstVol"); + + if (max_data_burst_vol) { + if (!cJSON_IsNumber(max_data_burst_vol)) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [max_data_burst_vol]"); + goto end; + } + } + + cJSON *ext_max_data_burst_vol = cJSON_GetObjectItemCaseSensitive(qos_characteristicsJSON, "extMaxDataBurstVol"); + + if (ext_max_data_burst_vol) { + if (!cJSON_IsNumber(ext_max_data_burst_vol)) { + ogs_error("OpenAPI_qos_characteristics_parseFromJSON() failed [ext_max_data_burst_vol]"); + goto end; + } + } + + qos_characteristics_local_var = OpenAPI_qos_characteristics_create ( + _5qi->valuedouble, + resource_type_local_nonprim, + priority_level->valuedouble, + packet_delay_budget->valuedouble, + ogs_strdup(packet_error_rate->valuestring), + averaging_window ? averaging_window->valuedouble : 0, + max_data_burst_vol ? max_data_burst_vol->valuedouble : 0, + ext_max_data_burst_vol ? ext_max_data_burst_vol->valuedouble : 0 + ); + + return qos_characteristics_local_var; +end: + return NULL; +} + +OpenAPI_qos_characteristics_t *OpenAPI_qos_characteristics_copy(OpenAPI_qos_characteristics_t *dst, OpenAPI_qos_characteristics_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_qos_characteristics_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_qos_characteristics_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_qos_characteristics_free(dst); + dst = OpenAPI_qos_characteristics_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/qos_characteristics.h b/lib/sbi/openapi/model/qos_characteristics.h new file mode 100644 index 000000000..37d89de8d --- /dev/null +++ b/lib/sbi/openapi/model/qos_characteristics.h @@ -0,0 +1,53 @@ +/* + * qos_characteristics.h + * + * + */ + +#ifndef _OpenAPI_qos_characteristics_H_ +#define _OpenAPI_qos_characteristics_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "qos_resource_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_qos_characteristics_s OpenAPI_qos_characteristics_t; +typedef struct OpenAPI_qos_characteristics_s { + int _5qi; + struct OpenAPI_qos_resource_type_s *resource_type; + int priority_level; + int packet_delay_budget; + char *packet_error_rate; + int averaging_window; + int max_data_burst_vol; + int ext_max_data_burst_vol; +} OpenAPI_qos_characteristics_t; + +OpenAPI_qos_characteristics_t *OpenAPI_qos_characteristics_create( + int _5qi, + OpenAPI_qos_resource_type_t *resource_type, + int priority_level, + int packet_delay_budget, + char *packet_error_rate, + int averaging_window, + int max_data_burst_vol, + int ext_max_data_burst_vol + ); +void OpenAPI_qos_characteristics_free(OpenAPI_qos_characteristics_t *qos_characteristics); +OpenAPI_qos_characteristics_t *OpenAPI_qos_characteristics_parseFromJSON(cJSON *qos_characteristicsJSON); +cJSON *OpenAPI_qos_characteristics_convertToJSON(OpenAPI_qos_characteristics_t *qos_characteristics); +OpenAPI_qos_characteristics_t *OpenAPI_qos_characteristics_copy(OpenAPI_qos_characteristics_t *dst, OpenAPI_qos_characteristics_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_qos_characteristics_H_ */ + diff --git a/lib/sbi/openapi/model/qos_data.c b/lib/sbi/openapi/model/qos_data.c new file mode 100644 index 000000000..da037a1de --- /dev/null +++ b/lib/sbi/openapi/model/qos_data.c @@ -0,0 +1,444 @@ + +#include +#include +#include +#include "qos_data.h" + +OpenAPI_qos_data_t *OpenAPI_qos_data_create( + char *qos_id, + int _5qi, + char *maxbr_ul, + char *maxbr_dl, + char *gbr_ul, + char *gbr_dl, + OpenAPI_arp_t *arp, + int qnc, + int priority_level, + int aver_window, + int max_data_burst_vol, + int reflective_qos, + char *sharing_key_dl, + char *sharing_key_ul, + int max_packet_loss_rate_dl, + int max_packet_loss_rate_ul, + int def_qos_flow_indication, + int ext_max_data_burst_vol + ) +{ + OpenAPI_qos_data_t *qos_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_qos_data_t)); + if (!qos_data_local_var) { + return NULL; + } + qos_data_local_var->qos_id = qos_id; + qos_data_local_var->_5qi = _5qi; + qos_data_local_var->maxbr_ul = maxbr_ul; + qos_data_local_var->maxbr_dl = maxbr_dl; + qos_data_local_var->gbr_ul = gbr_ul; + qos_data_local_var->gbr_dl = gbr_dl; + qos_data_local_var->arp = arp; + qos_data_local_var->qnc = qnc; + qos_data_local_var->priority_level = priority_level; + qos_data_local_var->aver_window = aver_window; + qos_data_local_var->max_data_burst_vol = max_data_burst_vol; + qos_data_local_var->reflective_qos = reflective_qos; + qos_data_local_var->sharing_key_dl = sharing_key_dl; + qos_data_local_var->sharing_key_ul = sharing_key_ul; + qos_data_local_var->max_packet_loss_rate_dl = max_packet_loss_rate_dl; + qos_data_local_var->max_packet_loss_rate_ul = max_packet_loss_rate_ul; + qos_data_local_var->def_qos_flow_indication = def_qos_flow_indication; + qos_data_local_var->ext_max_data_burst_vol = ext_max_data_burst_vol; + + return qos_data_local_var; +} + +void OpenAPI_qos_data_free(OpenAPI_qos_data_t *qos_data) +{ + if (NULL == qos_data) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(qos_data->qos_id); + ogs_free(qos_data->maxbr_ul); + ogs_free(qos_data->maxbr_dl); + ogs_free(qos_data->gbr_ul); + ogs_free(qos_data->gbr_dl); + OpenAPI_arp_free(qos_data->arp); + ogs_free(qos_data->sharing_key_dl); + ogs_free(qos_data->sharing_key_ul); + ogs_free(qos_data); +} + +cJSON *OpenAPI_qos_data_convertToJSON(OpenAPI_qos_data_t *qos_data) +{ + cJSON *item = NULL; + + if (qos_data == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [QosData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!qos_data->qos_id) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [qos_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "qosId", qos_data->qos_id) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [qos_id]"); + goto end; + } + + if (qos_data->_5qi) { + if (cJSON_AddNumberToObject(item, "5qi", qos_data->_5qi) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [_5qi]"); + goto end; + } + } + + if (qos_data->maxbr_ul) { + if (cJSON_AddStringToObject(item, "maxbrUl", qos_data->maxbr_ul) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [maxbr_ul]"); + goto end; + } + } + + if (qos_data->maxbr_dl) { + if (cJSON_AddStringToObject(item, "maxbrDl", qos_data->maxbr_dl) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [maxbr_dl]"); + goto end; + } + } + + if (qos_data->gbr_ul) { + if (cJSON_AddStringToObject(item, "gbrUl", qos_data->gbr_ul) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [gbr_ul]"); + goto end; + } + } + + if (qos_data->gbr_dl) { + if (cJSON_AddStringToObject(item, "gbrDl", qos_data->gbr_dl) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [gbr_dl]"); + goto end; + } + } + + if (qos_data->arp) { + cJSON *arp_local_JSON = OpenAPI_arp_convertToJSON(qos_data->arp); + if (arp_local_JSON == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [arp]"); + goto end; + } + cJSON_AddItemToObject(item, "arp", arp_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [arp]"); + goto end; + } + } + + if (qos_data->qnc) { + if (cJSON_AddBoolToObject(item, "qnc", qos_data->qnc) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [qnc]"); + goto end; + } + } + + if (qos_data->priority_level) { + if (cJSON_AddNumberToObject(item, "priorityLevel", qos_data->priority_level) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [priority_level]"); + goto end; + } + } + + if (qos_data->aver_window) { + if (cJSON_AddNumberToObject(item, "averWindow", qos_data->aver_window) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [aver_window]"); + goto end; + } + } + + if (qos_data->max_data_burst_vol) { + if (cJSON_AddNumberToObject(item, "maxDataBurstVol", qos_data->max_data_burst_vol) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [max_data_burst_vol]"); + goto end; + } + } + + if (qos_data->reflective_qos) { + if (cJSON_AddBoolToObject(item, "reflectiveQos", qos_data->reflective_qos) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [reflective_qos]"); + goto end; + } + } + + if (qos_data->sharing_key_dl) { + if (cJSON_AddStringToObject(item, "sharingKeyDl", qos_data->sharing_key_dl) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [sharing_key_dl]"); + goto end; + } + } + + if (qos_data->sharing_key_ul) { + if (cJSON_AddStringToObject(item, "sharingKeyUl", qos_data->sharing_key_ul) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [sharing_key_ul]"); + goto end; + } + } + + if (qos_data->max_packet_loss_rate_dl) { + if (cJSON_AddNumberToObject(item, "maxPacketLossRateDl", qos_data->max_packet_loss_rate_dl) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [max_packet_loss_rate_dl]"); + goto end; + } + } + + if (qos_data->max_packet_loss_rate_ul) { + if (cJSON_AddNumberToObject(item, "maxPacketLossRateUl", qos_data->max_packet_loss_rate_ul) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [max_packet_loss_rate_ul]"); + goto end; + } + } + + if (qos_data->def_qos_flow_indication) { + if (cJSON_AddBoolToObject(item, "defQosFlowIndication", qos_data->def_qos_flow_indication) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [def_qos_flow_indication]"); + goto end; + } + } + + if (qos_data->ext_max_data_burst_vol) { + if (cJSON_AddNumberToObject(item, "extMaxDataBurstVol", qos_data->ext_max_data_burst_vol) == NULL) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed [ext_max_data_burst_vol]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_qos_data_t *OpenAPI_qos_data_parseFromJSON(cJSON *qos_dataJSON) +{ + OpenAPI_qos_data_t *qos_data_local_var = NULL; + cJSON *qos_id = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "qosId"); + if (!qos_id) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [qos_id]"); + goto end; + } + + + if (!cJSON_IsString(qos_id)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [qos_id]"); + goto end; + } + + cJSON *_5qi = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "5qi"); + + if (_5qi) { + if (!cJSON_IsNumber(_5qi)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [_5qi]"); + goto end; + } + } + + cJSON *maxbr_ul = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "maxbrUl"); + + if (maxbr_ul) { + if (!cJSON_IsString(maxbr_ul)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [maxbr_ul]"); + goto end; + } + } + + cJSON *maxbr_dl = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "maxbrDl"); + + if (maxbr_dl) { + if (!cJSON_IsString(maxbr_dl)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [maxbr_dl]"); + goto end; + } + } + + cJSON *gbr_ul = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "gbrUl"); + + if (gbr_ul) { + if (!cJSON_IsString(gbr_ul)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [gbr_ul]"); + goto end; + } + } + + cJSON *gbr_dl = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "gbrDl"); + + if (gbr_dl) { + if (!cJSON_IsString(gbr_dl)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [gbr_dl]"); + goto end; + } + } + + cJSON *arp = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "arp"); + + OpenAPI_arp_t *arp_local_nonprim = NULL; + if (arp) { + arp_local_nonprim = OpenAPI_arp_parseFromJSON(arp); + } + + cJSON *qnc = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "qnc"); + + if (qnc) { + if (!cJSON_IsBool(qnc)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [qnc]"); + goto end; + } + } + + cJSON *priority_level = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "priorityLevel"); + + if (priority_level) { + if (!cJSON_IsNumber(priority_level)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [priority_level]"); + goto end; + } + } + + cJSON *aver_window = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "averWindow"); + + if (aver_window) { + if (!cJSON_IsNumber(aver_window)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [aver_window]"); + goto end; + } + } + + cJSON *max_data_burst_vol = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "maxDataBurstVol"); + + if (max_data_burst_vol) { + if (!cJSON_IsNumber(max_data_burst_vol)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [max_data_burst_vol]"); + goto end; + } + } + + cJSON *reflective_qos = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "reflectiveQos"); + + if (reflective_qos) { + if (!cJSON_IsBool(reflective_qos)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [reflective_qos]"); + goto end; + } + } + + cJSON *sharing_key_dl = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "sharingKeyDl"); + + if (sharing_key_dl) { + if (!cJSON_IsString(sharing_key_dl)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [sharing_key_dl]"); + goto end; + } + } + + cJSON *sharing_key_ul = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "sharingKeyUl"); + + if (sharing_key_ul) { + if (!cJSON_IsString(sharing_key_ul)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [sharing_key_ul]"); + goto end; + } + } + + cJSON *max_packet_loss_rate_dl = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "maxPacketLossRateDl"); + + if (max_packet_loss_rate_dl) { + if (!cJSON_IsNumber(max_packet_loss_rate_dl)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [max_packet_loss_rate_dl]"); + goto end; + } + } + + cJSON *max_packet_loss_rate_ul = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "maxPacketLossRateUl"); + + if (max_packet_loss_rate_ul) { + if (!cJSON_IsNumber(max_packet_loss_rate_ul)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [max_packet_loss_rate_ul]"); + goto end; + } + } + + cJSON *def_qos_flow_indication = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "defQosFlowIndication"); + + if (def_qos_flow_indication) { + if (!cJSON_IsBool(def_qos_flow_indication)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [def_qos_flow_indication]"); + goto end; + } + } + + cJSON *ext_max_data_burst_vol = cJSON_GetObjectItemCaseSensitive(qos_dataJSON, "extMaxDataBurstVol"); + + if (ext_max_data_burst_vol) { + if (!cJSON_IsNumber(ext_max_data_burst_vol)) { + ogs_error("OpenAPI_qos_data_parseFromJSON() failed [ext_max_data_burst_vol]"); + goto end; + } + } + + qos_data_local_var = OpenAPI_qos_data_create ( + ogs_strdup(qos_id->valuestring), + _5qi ? _5qi->valuedouble : 0, + maxbr_ul ? ogs_strdup(maxbr_ul->valuestring) : NULL, + maxbr_dl ? ogs_strdup(maxbr_dl->valuestring) : NULL, + gbr_ul ? ogs_strdup(gbr_ul->valuestring) : NULL, + gbr_dl ? ogs_strdup(gbr_dl->valuestring) : NULL, + arp ? arp_local_nonprim : NULL, + qnc ? qnc->valueint : 0, + priority_level ? priority_level->valuedouble : 0, + aver_window ? aver_window->valuedouble : 0, + max_data_burst_vol ? max_data_burst_vol->valuedouble : 0, + reflective_qos ? reflective_qos->valueint : 0, + sharing_key_dl ? ogs_strdup(sharing_key_dl->valuestring) : NULL, + sharing_key_ul ? ogs_strdup(sharing_key_ul->valuestring) : NULL, + max_packet_loss_rate_dl ? max_packet_loss_rate_dl->valuedouble : 0, + max_packet_loss_rate_ul ? max_packet_loss_rate_ul->valuedouble : 0, + def_qos_flow_indication ? def_qos_flow_indication->valueint : 0, + ext_max_data_burst_vol ? ext_max_data_burst_vol->valuedouble : 0 + ); + + return qos_data_local_var; +end: + return NULL; +} + +OpenAPI_qos_data_t *OpenAPI_qos_data_copy(OpenAPI_qos_data_t *dst, OpenAPI_qos_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_qos_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_qos_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_qos_data_free(dst); + dst = OpenAPI_qos_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/qos_data.h b/lib/sbi/openapi/model/qos_data.h new file mode 100644 index 000000000..ade6efde5 --- /dev/null +++ b/lib/sbi/openapi/model/qos_data.h @@ -0,0 +1,73 @@ +/* + * qos_data.h + * + * + */ + +#ifndef _OpenAPI_qos_data_H_ +#define _OpenAPI_qos_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "arp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_qos_data_s OpenAPI_qos_data_t; +typedef struct OpenAPI_qos_data_s { + char *qos_id; + int _5qi; + char *maxbr_ul; + char *maxbr_dl; + char *gbr_ul; + char *gbr_dl; + struct OpenAPI_arp_s *arp; + int qnc; + int priority_level; + int aver_window; + int max_data_burst_vol; + int reflective_qos; + char *sharing_key_dl; + char *sharing_key_ul; + int max_packet_loss_rate_dl; + int max_packet_loss_rate_ul; + int def_qos_flow_indication; + int ext_max_data_burst_vol; +} OpenAPI_qos_data_t; + +OpenAPI_qos_data_t *OpenAPI_qos_data_create( + char *qos_id, + int _5qi, + char *maxbr_ul, + char *maxbr_dl, + char *gbr_ul, + char *gbr_dl, + OpenAPI_arp_t *arp, + int qnc, + int priority_level, + int aver_window, + int max_data_burst_vol, + int reflective_qos, + char *sharing_key_dl, + char *sharing_key_ul, + int max_packet_loss_rate_dl, + int max_packet_loss_rate_ul, + int def_qos_flow_indication, + int ext_max_data_burst_vol + ); +void OpenAPI_qos_data_free(OpenAPI_qos_data_t *qos_data); +OpenAPI_qos_data_t *OpenAPI_qos_data_parseFromJSON(cJSON *qos_dataJSON); +cJSON *OpenAPI_qos_data_convertToJSON(OpenAPI_qos_data_t *qos_data); +OpenAPI_qos_data_t *OpenAPI_qos_data_copy(OpenAPI_qos_data_t *dst, OpenAPI_qos_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_qos_data_H_ */ + diff --git a/lib/sbi/openapi/model/qos_flow_usage.c b/lib/sbi/openapi/model/qos_flow_usage.c new file mode 100644 index 000000000..cace47632 --- /dev/null +++ b/lib/sbi/openapi/model/qos_flow_usage.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "qos_flow_usage.h" + +OpenAPI_qos_flow_usage_t *OpenAPI_qos_flow_usage_create( + ) +{ + OpenAPI_qos_flow_usage_t *qos_flow_usage_local_var = OpenAPI_malloc(sizeof(OpenAPI_qos_flow_usage_t)); + if (!qos_flow_usage_local_var) { + return NULL; + } + + return qos_flow_usage_local_var; +} + +void OpenAPI_qos_flow_usage_free(OpenAPI_qos_flow_usage_t *qos_flow_usage) +{ + if (NULL == qos_flow_usage) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(qos_flow_usage); +} + +cJSON *OpenAPI_qos_flow_usage_convertToJSON(OpenAPI_qos_flow_usage_t *qos_flow_usage) +{ + cJSON *item = NULL; + + if (qos_flow_usage == NULL) { + ogs_error("OpenAPI_qos_flow_usage_convertToJSON() failed [QosFlowUsage]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_qos_flow_usage_t *OpenAPI_qos_flow_usage_parseFromJSON(cJSON *qos_flow_usageJSON) +{ + OpenAPI_qos_flow_usage_t *qos_flow_usage_local_var = NULL; + qos_flow_usage_local_var = OpenAPI_qos_flow_usage_create ( + ); + + return qos_flow_usage_local_var; +end: + return NULL; +} + +OpenAPI_qos_flow_usage_t *OpenAPI_qos_flow_usage_copy(OpenAPI_qos_flow_usage_t *dst, OpenAPI_qos_flow_usage_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_qos_flow_usage_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_qos_flow_usage_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_qos_flow_usage_free(dst); + dst = OpenAPI_qos_flow_usage_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/qos_flow_usage.h b/lib/sbi/openapi/model/qos_flow_usage.h new file mode 100644 index 000000000..1a4b2d926 --- /dev/null +++ b/lib/sbi/openapi/model/qos_flow_usage.h @@ -0,0 +1,36 @@ +/* + * qos_flow_usage.h + * + * Possible values are - GENERAL: Indicate no specific QoS flow usage information is available. - IMS_SIG: Indicate that the QoS flow is used for IMS signalling only. + */ + +#ifndef _OpenAPI_qos_flow_usage_H_ +#define _OpenAPI_qos_flow_usage_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_qos_flow_usage_s OpenAPI_qos_flow_usage_t; +typedef struct OpenAPI_qos_flow_usage_s { +} OpenAPI_qos_flow_usage_t; + +OpenAPI_qos_flow_usage_t *OpenAPI_qos_flow_usage_create( + ); +void OpenAPI_qos_flow_usage_free(OpenAPI_qos_flow_usage_t *qos_flow_usage); +OpenAPI_qos_flow_usage_t *OpenAPI_qos_flow_usage_parseFromJSON(cJSON *qos_flow_usageJSON); +cJSON *OpenAPI_qos_flow_usage_convertToJSON(OpenAPI_qos_flow_usage_t *qos_flow_usage); +OpenAPI_qos_flow_usage_t *OpenAPI_qos_flow_usage_copy(OpenAPI_qos_flow_usage_t *dst, OpenAPI_qos_flow_usage_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_qos_flow_usage_H_ */ + diff --git a/lib/sbi/openapi/model/qos_monitoring_data.c b/lib/sbi/openapi/model/qos_monitoring_data.c new file mode 100644 index 000000000..0656d0f6e --- /dev/null +++ b/lib/sbi/openapi/model/qos_monitoring_data.c @@ -0,0 +1,345 @@ + +#include +#include +#include +#include "qos_monitoring_data.h" + +OpenAPI_qos_monitoring_data_t *OpenAPI_qos_monitoring_data_create( + char *qm_id, + OpenAPI_list_t *req_qos_mon_params, + OpenAPI_list_t *rep_freqs, + int rep_thresh_dl, + int rep_thresh_ul, + int rep_thresh_rp, + int wait_time, + int rep_period, + char *notify_uri, + char *notify_corre_id + ) +{ + OpenAPI_qos_monitoring_data_t *qos_monitoring_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_qos_monitoring_data_t)); + if (!qos_monitoring_data_local_var) { + return NULL; + } + qos_monitoring_data_local_var->qm_id = qm_id; + qos_monitoring_data_local_var->req_qos_mon_params = req_qos_mon_params; + qos_monitoring_data_local_var->rep_freqs = rep_freqs; + qos_monitoring_data_local_var->rep_thresh_dl = rep_thresh_dl; + qos_monitoring_data_local_var->rep_thresh_ul = rep_thresh_ul; + qos_monitoring_data_local_var->rep_thresh_rp = rep_thresh_rp; + qos_monitoring_data_local_var->wait_time = wait_time; + qos_monitoring_data_local_var->rep_period = rep_period; + qos_monitoring_data_local_var->notify_uri = notify_uri; + qos_monitoring_data_local_var->notify_corre_id = notify_corre_id; + + return qos_monitoring_data_local_var; +} + +void OpenAPI_qos_monitoring_data_free(OpenAPI_qos_monitoring_data_t *qos_monitoring_data) +{ + if (NULL == qos_monitoring_data) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(qos_monitoring_data->qm_id); + OpenAPI_list_for_each(qos_monitoring_data->req_qos_mon_params, node) { + OpenAPI_requested_qos_monitoring_parameter_free(node->data); + } + OpenAPI_list_free(qos_monitoring_data->req_qos_mon_params); + OpenAPI_list_for_each(qos_monitoring_data->rep_freqs, node) { + OpenAPI_reporting_frequency_free(node->data); + } + OpenAPI_list_free(qos_monitoring_data->rep_freqs); + ogs_free(qos_monitoring_data->notify_uri); + ogs_free(qos_monitoring_data->notify_corre_id); + ogs_free(qos_monitoring_data); +} + +cJSON *OpenAPI_qos_monitoring_data_convertToJSON(OpenAPI_qos_monitoring_data_t *qos_monitoring_data) +{ + cJSON *item = NULL; + + if (qos_monitoring_data == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [QosMonitoringData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!qos_monitoring_data->qm_id) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [qm_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "qmId", qos_monitoring_data->qm_id) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [qm_id]"); + goto end; + } + + if (qos_monitoring_data->req_qos_mon_params) { + cJSON *req_qos_mon_paramsList = cJSON_AddArrayToObject(item, "reqQosMonParams"); + if (req_qos_mon_paramsList == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [req_qos_mon_params]"); + goto end; + } + + OpenAPI_lnode_t *req_qos_mon_params_node; + if (qos_monitoring_data->req_qos_mon_params) { + OpenAPI_list_for_each(qos_monitoring_data->req_qos_mon_params, req_qos_mon_params_node) { + cJSON *itemLocal = OpenAPI_requested_qos_monitoring_parameter_convertToJSON(req_qos_mon_params_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [req_qos_mon_params]"); + goto end; + } + cJSON_AddItemToArray(req_qos_mon_paramsList, itemLocal); + } + } + } + + if (qos_monitoring_data->rep_freqs) { + cJSON *rep_freqsList = cJSON_AddArrayToObject(item, "repFreqs"); + if (rep_freqsList == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [rep_freqs]"); + goto end; + } + + OpenAPI_lnode_t *rep_freqs_node; + if (qos_monitoring_data->rep_freqs) { + OpenAPI_list_for_each(qos_monitoring_data->rep_freqs, rep_freqs_node) { + cJSON *itemLocal = OpenAPI_reporting_frequency_convertToJSON(rep_freqs_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [rep_freqs]"); + goto end; + } + cJSON_AddItemToArray(rep_freqsList, itemLocal); + } + } + } + + if (qos_monitoring_data->rep_thresh_dl) { + if (cJSON_AddNumberToObject(item, "repThreshDl", qos_monitoring_data->rep_thresh_dl) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [rep_thresh_dl]"); + goto end; + } + } + + if (qos_monitoring_data->rep_thresh_ul) { + if (cJSON_AddNumberToObject(item, "repThreshUl", qos_monitoring_data->rep_thresh_ul) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [rep_thresh_ul]"); + goto end; + } + } + + if (qos_monitoring_data->rep_thresh_rp) { + if (cJSON_AddNumberToObject(item, "repThreshRp", qos_monitoring_data->rep_thresh_rp) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [rep_thresh_rp]"); + goto end; + } + } + + if (qos_monitoring_data->wait_time) { + if (cJSON_AddNumberToObject(item, "waitTime", qos_monitoring_data->wait_time) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [wait_time]"); + goto end; + } + } + + if (qos_monitoring_data->rep_period) { + if (cJSON_AddNumberToObject(item, "repPeriod", qos_monitoring_data->rep_period) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [rep_period]"); + goto end; + } + } + + if (qos_monitoring_data->notify_uri) { + if (cJSON_AddStringToObject(item, "notifyUri", qos_monitoring_data->notify_uri) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [notify_uri]"); + goto end; + } + } + + if (qos_monitoring_data->notify_corre_id) { + if (cJSON_AddStringToObject(item, "notifyCorreId", qos_monitoring_data->notify_corre_id) == NULL) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed [notify_corre_id]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_qos_monitoring_data_t *OpenAPI_qos_monitoring_data_parseFromJSON(cJSON *qos_monitoring_dataJSON) +{ + OpenAPI_qos_monitoring_data_t *qos_monitoring_data_local_var = NULL; + cJSON *qm_id = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "qmId"); + if (!qm_id) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [qm_id]"); + goto end; + } + + + if (!cJSON_IsString(qm_id)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [qm_id]"); + goto end; + } + + cJSON *req_qos_mon_params = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "reqQosMonParams"); + + OpenAPI_list_t *req_qos_mon_paramsList; + if (req_qos_mon_params) { + cJSON *req_qos_mon_params_local_nonprimitive; + if (!cJSON_IsArray(req_qos_mon_params)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [req_qos_mon_params]"); + goto end; + } + + req_qos_mon_paramsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(req_qos_mon_params_local_nonprimitive, req_qos_mon_params ) { + if (!cJSON_IsObject(req_qos_mon_params_local_nonprimitive)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [req_qos_mon_params]"); + goto end; + } + OpenAPI_requested_qos_monitoring_parameter_t *req_qos_mon_paramsItem = OpenAPI_requested_qos_monitoring_parameter_parseFromJSON(req_qos_mon_params_local_nonprimitive); + + OpenAPI_list_add(req_qos_mon_paramsList, req_qos_mon_paramsItem); + } + } + + cJSON *rep_freqs = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "repFreqs"); + + OpenAPI_list_t *rep_freqsList; + if (rep_freqs) { + cJSON *rep_freqs_local_nonprimitive; + if (!cJSON_IsArray(rep_freqs)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [rep_freqs]"); + goto end; + } + + rep_freqsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rep_freqs_local_nonprimitive, rep_freqs ) { + if (!cJSON_IsObject(rep_freqs_local_nonprimitive)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [rep_freqs]"); + goto end; + } + OpenAPI_reporting_frequency_t *rep_freqsItem = OpenAPI_reporting_frequency_parseFromJSON(rep_freqs_local_nonprimitive); + + OpenAPI_list_add(rep_freqsList, rep_freqsItem); + } + } + + cJSON *rep_thresh_dl = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "repThreshDl"); + + if (rep_thresh_dl) { + if (!cJSON_IsNumber(rep_thresh_dl)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [rep_thresh_dl]"); + goto end; + } + } + + cJSON *rep_thresh_ul = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "repThreshUl"); + + if (rep_thresh_ul) { + if (!cJSON_IsNumber(rep_thresh_ul)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [rep_thresh_ul]"); + goto end; + } + } + + cJSON *rep_thresh_rp = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "repThreshRp"); + + if (rep_thresh_rp) { + if (!cJSON_IsNumber(rep_thresh_rp)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [rep_thresh_rp]"); + goto end; + } + } + + cJSON *wait_time = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "waitTime"); + + if (wait_time) { + if (!cJSON_IsNumber(wait_time)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [wait_time]"); + goto end; + } + } + + cJSON *rep_period = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "repPeriod"); + + if (rep_period) { + if (!cJSON_IsNumber(rep_period)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [rep_period]"); + goto end; + } + } + + cJSON *notify_uri = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "notifyUri"); + + if (notify_uri) { + if (!cJSON_IsString(notify_uri)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [notify_uri]"); + goto end; + } + } + + cJSON *notify_corre_id = cJSON_GetObjectItemCaseSensitive(qos_monitoring_dataJSON, "notifyCorreId"); + + if (notify_corre_id) { + if (!cJSON_IsString(notify_corre_id)) { + ogs_error("OpenAPI_qos_monitoring_data_parseFromJSON() failed [notify_corre_id]"); + goto end; + } + } + + qos_monitoring_data_local_var = OpenAPI_qos_monitoring_data_create ( + ogs_strdup(qm_id->valuestring), + req_qos_mon_params ? req_qos_mon_paramsList : NULL, + rep_freqs ? rep_freqsList : NULL, + rep_thresh_dl ? rep_thresh_dl->valuedouble : 0, + rep_thresh_ul ? rep_thresh_ul->valuedouble : 0, + rep_thresh_rp ? rep_thresh_rp->valuedouble : 0, + wait_time ? wait_time->valuedouble : 0, + rep_period ? rep_period->valuedouble : 0, + notify_uri ? ogs_strdup(notify_uri->valuestring) : NULL, + notify_corre_id ? ogs_strdup(notify_corre_id->valuestring) : NULL + ); + + return qos_monitoring_data_local_var; +end: + return NULL; +} + +OpenAPI_qos_monitoring_data_t *OpenAPI_qos_monitoring_data_copy(OpenAPI_qos_monitoring_data_t *dst, OpenAPI_qos_monitoring_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_qos_monitoring_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_qos_monitoring_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_qos_monitoring_data_free(dst); + dst = OpenAPI_qos_monitoring_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/qos_monitoring_data.h b/lib/sbi/openapi/model/qos_monitoring_data.h new file mode 100644 index 000000000..50f617d6b --- /dev/null +++ b/lib/sbi/openapi/model/qos_monitoring_data.h @@ -0,0 +1,58 @@ +/* + * qos_monitoring_data.h + * + * + */ + +#ifndef _OpenAPI_qos_monitoring_data_H_ +#define _OpenAPI_qos_monitoring_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "reporting_frequency.h" +#include "requested_qos_monitoring_parameter.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_qos_monitoring_data_s OpenAPI_qos_monitoring_data_t; +typedef struct OpenAPI_qos_monitoring_data_s { + char *qm_id; + OpenAPI_list_t *req_qos_mon_params; + OpenAPI_list_t *rep_freqs; + int rep_thresh_dl; + int rep_thresh_ul; + int rep_thresh_rp; + int wait_time; + int rep_period; + char *notify_uri; + char *notify_corre_id; +} OpenAPI_qos_monitoring_data_t; + +OpenAPI_qos_monitoring_data_t *OpenAPI_qos_monitoring_data_create( + char *qm_id, + OpenAPI_list_t *req_qos_mon_params, + OpenAPI_list_t *rep_freqs, + int rep_thresh_dl, + int rep_thresh_ul, + int rep_thresh_rp, + int wait_time, + int rep_period, + char *notify_uri, + char *notify_corre_id + ); +void OpenAPI_qos_monitoring_data_free(OpenAPI_qos_monitoring_data_t *qos_monitoring_data); +OpenAPI_qos_monitoring_data_t *OpenAPI_qos_monitoring_data_parseFromJSON(cJSON *qos_monitoring_dataJSON); +cJSON *OpenAPI_qos_monitoring_data_convertToJSON(OpenAPI_qos_monitoring_data_t *qos_monitoring_data); +OpenAPI_qos_monitoring_data_t *OpenAPI_qos_monitoring_data_copy(OpenAPI_qos_monitoring_data_t *dst, OpenAPI_qos_monitoring_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_qos_monitoring_data_H_ */ + diff --git a/lib/sbi/openapi/model/qos_monitoring_report.c b/lib/sbi/openapi/model/qos_monitoring_report.c new file mode 100644 index 000000000..7f26691a6 --- /dev/null +++ b/lib/sbi/openapi/model/qos_monitoring_report.c @@ -0,0 +1,262 @@ + +#include +#include +#include +#include "qos_monitoring_report.h" + +OpenAPI_qos_monitoring_report_t *OpenAPI_qos_monitoring_report_create( + OpenAPI_list_t *ref_pcc_rule_ids, + OpenAPI_list_t *ul_delays, + OpenAPI_list_t *dl_delays, + OpenAPI_list_t *rt_delays + ) +{ + OpenAPI_qos_monitoring_report_t *qos_monitoring_report_local_var = OpenAPI_malloc(sizeof(OpenAPI_qos_monitoring_report_t)); + if (!qos_monitoring_report_local_var) { + return NULL; + } + qos_monitoring_report_local_var->ref_pcc_rule_ids = ref_pcc_rule_ids; + qos_monitoring_report_local_var->ul_delays = ul_delays; + qos_monitoring_report_local_var->dl_delays = dl_delays; + qos_monitoring_report_local_var->rt_delays = rt_delays; + + return qos_monitoring_report_local_var; +} + +void OpenAPI_qos_monitoring_report_free(OpenAPI_qos_monitoring_report_t *qos_monitoring_report) +{ + if (NULL == qos_monitoring_report) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(qos_monitoring_report->ref_pcc_rule_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(qos_monitoring_report->ref_pcc_rule_ids); + OpenAPI_list_for_each(qos_monitoring_report->ul_delays, node) { + ogs_free(node->data); + } + OpenAPI_list_free(qos_monitoring_report->ul_delays); + OpenAPI_list_for_each(qos_monitoring_report->dl_delays, node) { + ogs_free(node->data); + } + OpenAPI_list_free(qos_monitoring_report->dl_delays); + OpenAPI_list_for_each(qos_monitoring_report->rt_delays, node) { + ogs_free(node->data); + } + OpenAPI_list_free(qos_monitoring_report->rt_delays); + ogs_free(qos_monitoring_report); +} + +cJSON *OpenAPI_qos_monitoring_report_convertToJSON(OpenAPI_qos_monitoring_report_t *qos_monitoring_report) +{ + cJSON *item = NULL; + + if (qos_monitoring_report == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [QosMonitoringReport]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!qos_monitoring_report->ref_pcc_rule_ids) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + cJSON *ref_pcc_rule_ids = cJSON_AddArrayToObject(item, "refPccRuleIds"); + if (ref_pcc_rule_ids == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + + OpenAPI_lnode_t *ref_pcc_rule_ids_node; + OpenAPI_list_for_each(qos_monitoring_report->ref_pcc_rule_ids, ref_pcc_rule_ids_node) { + if (cJSON_AddStringToObject(ref_pcc_rule_ids, "", (char*)ref_pcc_rule_ids_node->data) == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + } + + if (qos_monitoring_report->ul_delays) { + cJSON *ul_delays = cJSON_AddArrayToObject(item, "ulDelays"); + if (ul_delays == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [ul_delays]"); + goto end; + } + + OpenAPI_lnode_t *ul_delays_node; + OpenAPI_list_for_each(qos_monitoring_report->ul_delays, ul_delays_node) { + if (cJSON_AddNumberToObject(ul_delays, "", *(double *)ul_delays_node->data) == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [ul_delays]"); + goto end; + } + } + } + + if (qos_monitoring_report->dl_delays) { + cJSON *dl_delays = cJSON_AddArrayToObject(item, "dlDelays"); + if (dl_delays == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [dl_delays]"); + goto end; + } + + OpenAPI_lnode_t *dl_delays_node; + OpenAPI_list_for_each(qos_monitoring_report->dl_delays, dl_delays_node) { + if (cJSON_AddNumberToObject(dl_delays, "", *(double *)dl_delays_node->data) == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [dl_delays]"); + goto end; + } + } + } + + if (qos_monitoring_report->rt_delays) { + cJSON *rt_delays = cJSON_AddArrayToObject(item, "rtDelays"); + if (rt_delays == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [rt_delays]"); + goto end; + } + + OpenAPI_lnode_t *rt_delays_node; + OpenAPI_list_for_each(qos_monitoring_report->rt_delays, rt_delays_node) { + if (cJSON_AddNumberToObject(rt_delays, "", *(double *)rt_delays_node->data) == NULL) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed [rt_delays]"); + goto end; + } + } + } + +end: + return item; +} + +OpenAPI_qos_monitoring_report_t *OpenAPI_qos_monitoring_report_parseFromJSON(cJSON *qos_monitoring_reportJSON) +{ + OpenAPI_qos_monitoring_report_t *qos_monitoring_report_local_var = NULL; + cJSON *ref_pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(qos_monitoring_reportJSON, "refPccRuleIds"); + if (!ref_pcc_rule_ids) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + + OpenAPI_list_t *ref_pcc_rule_idsList; + + cJSON *ref_pcc_rule_ids_local; + if (!cJSON_IsArray(ref_pcc_rule_ids)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + ref_pcc_rule_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_pcc_rule_ids_local, ref_pcc_rule_ids) { + if (!cJSON_IsString(ref_pcc_rule_ids_local)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup(ref_pcc_rule_ids_local->valuestring)); + } + + cJSON *ul_delays = cJSON_GetObjectItemCaseSensitive(qos_monitoring_reportJSON, "ulDelays"); + + OpenAPI_list_t *ul_delaysList; + if (ul_delays) { + cJSON *ul_delays_local; + if (!cJSON_IsArray(ul_delays)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [ul_delays]"); + goto end; + } + ul_delaysList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ul_delays_local, ul_delays) { + if (!cJSON_IsNumber(ul_delays_local)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [ul_delays]"); + goto end; + } + OpenAPI_list_add(ul_delaysList, &ul_delays_local->valuedouble); + } + } + + cJSON *dl_delays = cJSON_GetObjectItemCaseSensitive(qos_monitoring_reportJSON, "dlDelays"); + + OpenAPI_list_t *dl_delaysList; + if (dl_delays) { + cJSON *dl_delays_local; + if (!cJSON_IsArray(dl_delays)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [dl_delays]"); + goto end; + } + dl_delaysList = OpenAPI_list_create(); + + cJSON_ArrayForEach(dl_delays_local, dl_delays) { + if (!cJSON_IsNumber(dl_delays_local)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [dl_delays]"); + goto end; + } + OpenAPI_list_add(dl_delaysList, &dl_delays_local->valuedouble); + } + } + + cJSON *rt_delays = cJSON_GetObjectItemCaseSensitive(qos_monitoring_reportJSON, "rtDelays"); + + OpenAPI_list_t *rt_delaysList; + if (rt_delays) { + cJSON *rt_delays_local; + if (!cJSON_IsArray(rt_delays)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [rt_delays]"); + goto end; + } + rt_delaysList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rt_delays_local, rt_delays) { + if (!cJSON_IsNumber(rt_delays_local)) { + ogs_error("OpenAPI_qos_monitoring_report_parseFromJSON() failed [rt_delays]"); + goto end; + } + OpenAPI_list_add(rt_delaysList, &rt_delays_local->valuedouble); + } + } + + qos_monitoring_report_local_var = OpenAPI_qos_monitoring_report_create ( + ref_pcc_rule_idsList, + ul_delays ? ul_delaysList : NULL, + dl_delays ? dl_delaysList : NULL, + rt_delays ? rt_delaysList : NULL + ); + + return qos_monitoring_report_local_var; +end: + return NULL; +} + +OpenAPI_qos_monitoring_report_t *OpenAPI_qos_monitoring_report_copy(OpenAPI_qos_monitoring_report_t *dst, OpenAPI_qos_monitoring_report_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_qos_monitoring_report_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_qos_monitoring_report_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_qos_monitoring_report_free(dst); + dst = OpenAPI_qos_monitoring_report_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/qos_monitoring_report.h b/lib/sbi/openapi/model/qos_monitoring_report.h new file mode 100644 index 000000000..0285f86ad --- /dev/null +++ b/lib/sbi/openapi/model/qos_monitoring_report.h @@ -0,0 +1,44 @@ +/* + * qos_monitoring_report.h + * + * + */ + +#ifndef _OpenAPI_qos_monitoring_report_H_ +#define _OpenAPI_qos_monitoring_report_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_qos_monitoring_report_s OpenAPI_qos_monitoring_report_t; +typedef struct OpenAPI_qos_monitoring_report_s { + OpenAPI_list_t *ref_pcc_rule_ids; + OpenAPI_list_t *ul_delays; + OpenAPI_list_t *dl_delays; + OpenAPI_list_t *rt_delays; +} OpenAPI_qos_monitoring_report_t; + +OpenAPI_qos_monitoring_report_t *OpenAPI_qos_monitoring_report_create( + OpenAPI_list_t *ref_pcc_rule_ids, + OpenAPI_list_t *ul_delays, + OpenAPI_list_t *dl_delays, + OpenAPI_list_t *rt_delays + ); +void OpenAPI_qos_monitoring_report_free(OpenAPI_qos_monitoring_report_t *qos_monitoring_report); +OpenAPI_qos_monitoring_report_t *OpenAPI_qos_monitoring_report_parseFromJSON(cJSON *qos_monitoring_reportJSON); +cJSON *OpenAPI_qos_monitoring_report_convertToJSON(OpenAPI_qos_monitoring_report_t *qos_monitoring_report); +OpenAPI_qos_monitoring_report_t *OpenAPI_qos_monitoring_report_copy(OpenAPI_qos_monitoring_report_t *dst, OpenAPI_qos_monitoring_report_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_qos_monitoring_report_H_ */ + diff --git a/lib/sbi/openapi/model/qos_notif_type.c b/lib/sbi/openapi/model/qos_notif_type.c new file mode 100644 index 000000000..711dccc11 --- /dev/null +++ b/lib/sbi/openapi/model/qos_notif_type.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "qos_notif_type.h" + +OpenAPI_qos_notif_type_t *OpenAPI_qos_notif_type_create( + ) +{ + OpenAPI_qos_notif_type_t *qos_notif_type_local_var = OpenAPI_malloc(sizeof(OpenAPI_qos_notif_type_t)); + if (!qos_notif_type_local_var) { + return NULL; + } + + return qos_notif_type_local_var; +} + +void OpenAPI_qos_notif_type_free(OpenAPI_qos_notif_type_t *qos_notif_type) +{ + if (NULL == qos_notif_type) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(qos_notif_type); +} + +cJSON *OpenAPI_qos_notif_type_convertToJSON(OpenAPI_qos_notif_type_t *qos_notif_type) +{ + cJSON *item = NULL; + + if (qos_notif_type == NULL) { + ogs_error("OpenAPI_qos_notif_type_convertToJSON() failed [QosNotifType]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_qos_notif_type_t *OpenAPI_qos_notif_type_parseFromJSON(cJSON *qos_notif_typeJSON) +{ + OpenAPI_qos_notif_type_t *qos_notif_type_local_var = NULL; + qos_notif_type_local_var = OpenAPI_qos_notif_type_create ( + ); + + return qos_notif_type_local_var; +end: + return NULL; +} + +OpenAPI_qos_notif_type_t *OpenAPI_qos_notif_type_copy(OpenAPI_qos_notif_type_t *dst, OpenAPI_qos_notif_type_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_qos_notif_type_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_qos_notif_type_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_qos_notif_type_free(dst); + dst = OpenAPI_qos_notif_type_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/qos_notif_type.h b/lib/sbi/openapi/model/qos_notif_type.h new file mode 100644 index 000000000..aa0967fb0 --- /dev/null +++ b/lib/sbi/openapi/model/qos_notif_type.h @@ -0,0 +1,36 @@ +/* + * qos_notif_type.h + * + * + */ + +#ifndef _OpenAPI_qos_notif_type_H_ +#define _OpenAPI_qos_notif_type_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_qos_notif_type_s OpenAPI_qos_notif_type_t; +typedef struct OpenAPI_qos_notif_type_s { +} OpenAPI_qos_notif_type_t; + +OpenAPI_qos_notif_type_t *OpenAPI_qos_notif_type_create( + ); +void OpenAPI_qos_notif_type_free(OpenAPI_qos_notif_type_t *qos_notif_type); +OpenAPI_qos_notif_type_t *OpenAPI_qos_notif_type_parseFromJSON(cJSON *qos_notif_typeJSON); +cJSON *OpenAPI_qos_notif_type_convertToJSON(OpenAPI_qos_notif_type_t *qos_notif_type); +OpenAPI_qos_notif_type_t *OpenAPI_qos_notif_type_copy(OpenAPI_qos_notif_type_t *dst, OpenAPI_qos_notif_type_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_qos_notif_type_H_ */ + diff --git a/lib/sbi/openapi/model/qos_notification_control_info.c b/lib/sbi/openapi/model/qos_notification_control_info.c new file mode 100644 index 000000000..b1aea4d0f --- /dev/null +++ b/lib/sbi/openapi/model/qos_notification_control_info.c @@ -0,0 +1,201 @@ + +#include +#include +#include +#include "qos_notification_control_info.h" + +OpenAPI_qos_notification_control_info_t *OpenAPI_qos_notification_control_info_create( + OpenAPI_list_t *ref_pcc_rule_ids, + OpenAPI_qos_notif_type_t *notif_type, + int cont_ver, + char *alt_qos_param_id + ) +{ + OpenAPI_qos_notification_control_info_t *qos_notification_control_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_qos_notification_control_info_t)); + if (!qos_notification_control_info_local_var) { + return NULL; + } + qos_notification_control_info_local_var->ref_pcc_rule_ids = ref_pcc_rule_ids; + qos_notification_control_info_local_var->notif_type = notif_type; + qos_notification_control_info_local_var->cont_ver = cont_ver; + qos_notification_control_info_local_var->alt_qos_param_id = alt_qos_param_id; + + return qos_notification_control_info_local_var; +} + +void OpenAPI_qos_notification_control_info_free(OpenAPI_qos_notification_control_info_t *qos_notification_control_info) +{ + if (NULL == qos_notification_control_info) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(qos_notification_control_info->ref_pcc_rule_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(qos_notification_control_info->ref_pcc_rule_ids); + OpenAPI_qos_notif_type_free(qos_notification_control_info->notif_type); + ogs_free(qos_notification_control_info->alt_qos_param_id); + ogs_free(qos_notification_control_info); +} + +cJSON *OpenAPI_qos_notification_control_info_convertToJSON(OpenAPI_qos_notification_control_info_t *qos_notification_control_info) +{ + cJSON *item = NULL; + + if (qos_notification_control_info == NULL) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [QosNotificationControlInfo]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!qos_notification_control_info->ref_pcc_rule_ids) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + cJSON *ref_pcc_rule_ids = cJSON_AddArrayToObject(item, "refPccRuleIds"); + if (ref_pcc_rule_ids == NULL) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + + OpenAPI_lnode_t *ref_pcc_rule_ids_node; + OpenAPI_list_for_each(qos_notification_control_info->ref_pcc_rule_ids, ref_pcc_rule_ids_node) { + if (cJSON_AddStringToObject(ref_pcc_rule_ids, "", (char*)ref_pcc_rule_ids_node->data) == NULL) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + } + + if (!qos_notification_control_info->notif_type) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [notif_type]"); + goto end; + } + cJSON *notif_type_local_JSON = OpenAPI_qos_notif_type_convertToJSON(qos_notification_control_info->notif_type); + if (notif_type_local_JSON == NULL) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [notif_type]"); + goto end; + } + cJSON_AddItemToObject(item, "notifType", notif_type_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [notif_type]"); + goto end; + } + + if (qos_notification_control_info->cont_ver) { + if (cJSON_AddNumberToObject(item, "contVer", qos_notification_control_info->cont_ver) == NULL) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [cont_ver]"); + goto end; + } + } + + if (qos_notification_control_info->alt_qos_param_id) { + if (cJSON_AddStringToObject(item, "altQosParamId", qos_notification_control_info->alt_qos_param_id) == NULL) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed [alt_qos_param_id]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_qos_notification_control_info_t *OpenAPI_qos_notification_control_info_parseFromJSON(cJSON *qos_notification_control_infoJSON) +{ + OpenAPI_qos_notification_control_info_t *qos_notification_control_info_local_var = NULL; + cJSON *ref_pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(qos_notification_control_infoJSON, "refPccRuleIds"); + if (!ref_pcc_rule_ids) { + ogs_error("OpenAPI_qos_notification_control_info_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + + OpenAPI_list_t *ref_pcc_rule_idsList; + + cJSON *ref_pcc_rule_ids_local; + if (!cJSON_IsArray(ref_pcc_rule_ids)) { + ogs_error("OpenAPI_qos_notification_control_info_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + ref_pcc_rule_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_pcc_rule_ids_local, ref_pcc_rule_ids) { + if (!cJSON_IsString(ref_pcc_rule_ids_local)) { + ogs_error("OpenAPI_qos_notification_control_info_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup(ref_pcc_rule_ids_local->valuestring)); + } + + cJSON *notif_type = cJSON_GetObjectItemCaseSensitive(qos_notification_control_infoJSON, "notifType"); + if (!notif_type) { + ogs_error("OpenAPI_qos_notification_control_info_parseFromJSON() failed [notif_type]"); + goto end; + } + + OpenAPI_qos_notif_type_t *notif_type_local_nonprim = NULL; + + notif_type_local_nonprim = OpenAPI_qos_notif_type_parseFromJSON(notif_type); + + cJSON *cont_ver = cJSON_GetObjectItemCaseSensitive(qos_notification_control_infoJSON, "contVer"); + + if (cont_ver) { + if (!cJSON_IsNumber(cont_ver)) { + ogs_error("OpenAPI_qos_notification_control_info_parseFromJSON() failed [cont_ver]"); + goto end; + } + } + + cJSON *alt_qos_param_id = cJSON_GetObjectItemCaseSensitive(qos_notification_control_infoJSON, "altQosParamId"); + + if (alt_qos_param_id) { + if (!cJSON_IsString(alt_qos_param_id)) { + ogs_error("OpenAPI_qos_notification_control_info_parseFromJSON() failed [alt_qos_param_id]"); + goto end; + } + } + + qos_notification_control_info_local_var = OpenAPI_qos_notification_control_info_create ( + ref_pcc_rule_idsList, + notif_type_local_nonprim, + cont_ver ? cont_ver->valuedouble : 0, + alt_qos_param_id ? ogs_strdup(alt_qos_param_id->valuestring) : NULL + ); + + return qos_notification_control_info_local_var; +end: + return NULL; +} + +OpenAPI_qos_notification_control_info_t *OpenAPI_qos_notification_control_info_copy(OpenAPI_qos_notification_control_info_t *dst, OpenAPI_qos_notification_control_info_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_qos_notification_control_info_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_qos_notification_control_info_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_qos_notification_control_info_free(dst); + dst = OpenAPI_qos_notification_control_info_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/qos_notification_control_info.h b/lib/sbi/openapi/model/qos_notification_control_info.h new file mode 100644 index 000000000..2b03fd7e6 --- /dev/null +++ b/lib/sbi/openapi/model/qos_notification_control_info.h @@ -0,0 +1,45 @@ +/* + * qos_notification_control_info.h + * + * + */ + +#ifndef _OpenAPI_qos_notification_control_info_H_ +#define _OpenAPI_qos_notification_control_info_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "qos_notif_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_qos_notification_control_info_s OpenAPI_qos_notification_control_info_t; +typedef struct OpenAPI_qos_notification_control_info_s { + OpenAPI_list_t *ref_pcc_rule_ids; + struct OpenAPI_qos_notif_type_s *notif_type; + int cont_ver; + char *alt_qos_param_id; +} OpenAPI_qos_notification_control_info_t; + +OpenAPI_qos_notification_control_info_t *OpenAPI_qos_notification_control_info_create( + OpenAPI_list_t *ref_pcc_rule_ids, + OpenAPI_qos_notif_type_t *notif_type, + int cont_ver, + char *alt_qos_param_id + ); +void OpenAPI_qos_notification_control_info_free(OpenAPI_qos_notification_control_info_t *qos_notification_control_info); +OpenAPI_qos_notification_control_info_t *OpenAPI_qos_notification_control_info_parseFromJSON(cJSON *qos_notification_control_infoJSON); +cJSON *OpenAPI_qos_notification_control_info_convertToJSON(OpenAPI_qos_notification_control_info_t *qos_notification_control_info); +OpenAPI_qos_notification_control_info_t *OpenAPI_qos_notification_control_info_copy(OpenAPI_qos_notification_control_info_t *dst, OpenAPI_qos_notification_control_info_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_qos_notification_control_info_H_ */ + diff --git a/lib/sbi/openapi/model/ran_nas_rel_cause.c b/lib/sbi/openapi/model/ran_nas_rel_cause.c new file mode 100644 index 000000000..46dcbc012 --- /dev/null +++ b/lib/sbi/openapi/model/ran_nas_rel_cause.c @@ -0,0 +1,147 @@ + +#include +#include +#include +#include "ran_nas_rel_cause.h" + +OpenAPI_ran_nas_rel_cause_t *OpenAPI_ran_nas_rel_cause_create( + OpenAPI_ng_ap_cause_t *ng_ap_cause, + int _5g_mm_cause, + int _5g_sm_cause + ) +{ + OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_cause_local_var = OpenAPI_malloc(sizeof(OpenAPI_ran_nas_rel_cause_t)); + if (!ran_nas_rel_cause_local_var) { + return NULL; + } + ran_nas_rel_cause_local_var->ng_ap_cause = ng_ap_cause; + ran_nas_rel_cause_local_var->_5g_mm_cause = _5g_mm_cause; + ran_nas_rel_cause_local_var->_5g_sm_cause = _5g_sm_cause; + + return ran_nas_rel_cause_local_var; +} + +void OpenAPI_ran_nas_rel_cause_free(OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_cause) +{ + if (NULL == ran_nas_rel_cause) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_ng_ap_cause_free(ran_nas_rel_cause->ng_ap_cause); + ogs_free(ran_nas_rel_cause); +} + +cJSON *OpenAPI_ran_nas_rel_cause_convertToJSON(OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_cause) +{ + cJSON *item = NULL; + + if (ran_nas_rel_cause == NULL) { + ogs_error("OpenAPI_ran_nas_rel_cause_convertToJSON() failed [RanNasRelCause]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (ran_nas_rel_cause->ng_ap_cause) { + cJSON *ng_ap_cause_local_JSON = OpenAPI_ng_ap_cause_convertToJSON(ran_nas_rel_cause->ng_ap_cause); + if (ng_ap_cause_local_JSON == NULL) { + ogs_error("OpenAPI_ran_nas_rel_cause_convertToJSON() failed [ng_ap_cause]"); + goto end; + } + cJSON_AddItemToObject(item, "ngApCause", ng_ap_cause_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_ran_nas_rel_cause_convertToJSON() failed [ng_ap_cause]"); + goto end; + } + } + + if (ran_nas_rel_cause->_5g_mm_cause) { + if (cJSON_AddNumberToObject(item, "5gMmCause", ran_nas_rel_cause->_5g_mm_cause) == NULL) { + ogs_error("OpenAPI_ran_nas_rel_cause_convertToJSON() failed [_5g_mm_cause]"); + goto end; + } + } + + if (ran_nas_rel_cause->_5g_sm_cause) { + if (cJSON_AddNumberToObject(item, "5gSmCause", ran_nas_rel_cause->_5g_sm_cause) == NULL) { + ogs_error("OpenAPI_ran_nas_rel_cause_convertToJSON() failed [_5g_sm_cause]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_ran_nas_rel_cause_t *OpenAPI_ran_nas_rel_cause_parseFromJSON(cJSON *ran_nas_rel_causeJSON) +{ + OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_cause_local_var = NULL; + cJSON *ng_ap_cause = cJSON_GetObjectItemCaseSensitive(ran_nas_rel_causeJSON, "ngApCause"); + + OpenAPI_ng_ap_cause_t *ng_ap_cause_local_nonprim = NULL; + if (ng_ap_cause) { + ng_ap_cause_local_nonprim = OpenAPI_ng_ap_cause_parseFromJSON(ng_ap_cause); + } + + cJSON *_5g_mm_cause = cJSON_GetObjectItemCaseSensitive(ran_nas_rel_causeJSON, "5gMmCause"); + + if (_5g_mm_cause) { + if (!cJSON_IsNumber(_5g_mm_cause)) { + ogs_error("OpenAPI_ran_nas_rel_cause_parseFromJSON() failed [_5g_mm_cause]"); + goto end; + } + } + + cJSON *_5g_sm_cause = cJSON_GetObjectItemCaseSensitive(ran_nas_rel_causeJSON, "5gSmCause"); + + if (_5g_sm_cause) { + if (!cJSON_IsNumber(_5g_sm_cause)) { + ogs_error("OpenAPI_ran_nas_rel_cause_parseFromJSON() failed [_5g_sm_cause]"); + goto end; + } + } + + ran_nas_rel_cause_local_var = OpenAPI_ran_nas_rel_cause_create ( + ng_ap_cause ? ng_ap_cause_local_nonprim : NULL, + _5g_mm_cause ? _5g_mm_cause->valuedouble : 0, + _5g_sm_cause ? _5g_sm_cause->valuedouble : 0 + ); + + return ran_nas_rel_cause_local_var; +end: + return NULL; +} + +OpenAPI_ran_nas_rel_cause_t *OpenAPI_ran_nas_rel_cause_copy(OpenAPI_ran_nas_rel_cause_t *dst, OpenAPI_ran_nas_rel_cause_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_ran_nas_rel_cause_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_ran_nas_rel_cause_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_ran_nas_rel_cause_free(dst); + dst = OpenAPI_ran_nas_rel_cause_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/ran_nas_rel_cause.h b/lib/sbi/openapi/model/ran_nas_rel_cause.h new file mode 100644 index 000000000..7a6111d39 --- /dev/null +++ b/lib/sbi/openapi/model/ran_nas_rel_cause.h @@ -0,0 +1,43 @@ +/* + * ran_nas_rel_cause.h + * + * + */ + +#ifndef _OpenAPI_ran_nas_rel_cause_H_ +#define _OpenAPI_ran_nas_rel_cause_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "ng_ap_cause.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_ran_nas_rel_cause_s OpenAPI_ran_nas_rel_cause_t; +typedef struct OpenAPI_ran_nas_rel_cause_s { + struct OpenAPI_ng_ap_cause_s *ng_ap_cause; + int _5g_mm_cause; + int _5g_sm_cause; +} OpenAPI_ran_nas_rel_cause_t; + +OpenAPI_ran_nas_rel_cause_t *OpenAPI_ran_nas_rel_cause_create( + OpenAPI_ng_ap_cause_t *ng_ap_cause, + int _5g_mm_cause, + int _5g_sm_cause + ); +void OpenAPI_ran_nas_rel_cause_free(OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_cause); +OpenAPI_ran_nas_rel_cause_t *OpenAPI_ran_nas_rel_cause_parseFromJSON(cJSON *ran_nas_rel_causeJSON); +cJSON *OpenAPI_ran_nas_rel_cause_convertToJSON(OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_cause); +OpenAPI_ran_nas_rel_cause_t *OpenAPI_ran_nas_rel_cause_copy(OpenAPI_ran_nas_rel_cause_t *dst, OpenAPI_ran_nas_rel_cause_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_ran_nas_rel_cause_H_ */ + diff --git a/lib/sbi/openapi/model/redirect_address_type.c b/lib/sbi/openapi/model/redirect_address_type.c new file mode 100644 index 000000000..373fe17c0 --- /dev/null +++ b/lib/sbi/openapi/model/redirect_address_type.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "redirect_address_type.h" + +OpenAPI_redirect_address_type_t *OpenAPI_redirect_address_type_create( + ) +{ + OpenAPI_redirect_address_type_t *redirect_address_type_local_var = OpenAPI_malloc(sizeof(OpenAPI_redirect_address_type_t)); + if (!redirect_address_type_local_var) { + return NULL; + } + + return redirect_address_type_local_var; +} + +void OpenAPI_redirect_address_type_free(OpenAPI_redirect_address_type_t *redirect_address_type) +{ + if (NULL == redirect_address_type) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(redirect_address_type); +} + +cJSON *OpenAPI_redirect_address_type_convertToJSON(OpenAPI_redirect_address_type_t *redirect_address_type) +{ + cJSON *item = NULL; + + if (redirect_address_type == NULL) { + ogs_error("OpenAPI_redirect_address_type_convertToJSON() failed [RedirectAddressType]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_redirect_address_type_t *OpenAPI_redirect_address_type_parseFromJSON(cJSON *redirect_address_typeJSON) +{ + OpenAPI_redirect_address_type_t *redirect_address_type_local_var = NULL; + redirect_address_type_local_var = OpenAPI_redirect_address_type_create ( + ); + + return redirect_address_type_local_var; +end: + return NULL; +} + +OpenAPI_redirect_address_type_t *OpenAPI_redirect_address_type_copy(OpenAPI_redirect_address_type_t *dst, OpenAPI_redirect_address_type_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_redirect_address_type_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_redirect_address_type_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_redirect_address_type_free(dst); + dst = OpenAPI_redirect_address_type_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/redirect_address_type.h b/lib/sbi/openapi/model/redirect_address_type.h new file mode 100644 index 000000000..cef9c0d3f --- /dev/null +++ b/lib/sbi/openapi/model/redirect_address_type.h @@ -0,0 +1,36 @@ +/* + * redirect_address_type.h + * + * Possible values are - IPV4_ADDR: Indicates that the address type is in the form of \"dotted-decimal\" IPv4 address. - IPV6_ADDR: Indicates that the address type is in the form of IPv6 address. - URL: Indicates that the address type is in the form of Uniform Resource Locator. - SIP_URI: Indicates that the address type is in the form of SIP Uniform Resource Identifier. + */ + +#ifndef _OpenAPI_redirect_address_type_H_ +#define _OpenAPI_redirect_address_type_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_redirect_address_type_s OpenAPI_redirect_address_type_t; +typedef struct OpenAPI_redirect_address_type_s { +} OpenAPI_redirect_address_type_t; + +OpenAPI_redirect_address_type_t *OpenAPI_redirect_address_type_create( + ); +void OpenAPI_redirect_address_type_free(OpenAPI_redirect_address_type_t *redirect_address_type); +OpenAPI_redirect_address_type_t *OpenAPI_redirect_address_type_parseFromJSON(cJSON *redirect_address_typeJSON); +cJSON *OpenAPI_redirect_address_type_convertToJSON(OpenAPI_redirect_address_type_t *redirect_address_type); +OpenAPI_redirect_address_type_t *OpenAPI_redirect_address_type_copy(OpenAPI_redirect_address_type_t *dst, OpenAPI_redirect_address_type_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_redirect_address_type_H_ */ + diff --git a/lib/sbi/openapi/model/redirect_information.c b/lib/sbi/openapi/model/redirect_information.c new file mode 100644 index 000000000..6d0150ed1 --- /dev/null +++ b/lib/sbi/openapi/model/redirect_information.c @@ -0,0 +1,148 @@ + +#include +#include +#include +#include "redirect_information.h" + +OpenAPI_redirect_information_t *OpenAPI_redirect_information_create( + int redirect_enabled, + OpenAPI_redirect_address_type_t *redirect_address_type, + char *redirect_server_address + ) +{ + OpenAPI_redirect_information_t *redirect_information_local_var = OpenAPI_malloc(sizeof(OpenAPI_redirect_information_t)); + if (!redirect_information_local_var) { + return NULL; + } + redirect_information_local_var->redirect_enabled = redirect_enabled; + redirect_information_local_var->redirect_address_type = redirect_address_type; + redirect_information_local_var->redirect_server_address = redirect_server_address; + + return redirect_information_local_var; +} + +void OpenAPI_redirect_information_free(OpenAPI_redirect_information_t *redirect_information) +{ + if (NULL == redirect_information) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_redirect_address_type_free(redirect_information->redirect_address_type); + ogs_free(redirect_information->redirect_server_address); + ogs_free(redirect_information); +} + +cJSON *OpenAPI_redirect_information_convertToJSON(OpenAPI_redirect_information_t *redirect_information) +{ + cJSON *item = NULL; + + if (redirect_information == NULL) { + ogs_error("OpenAPI_redirect_information_convertToJSON() failed [RedirectInformation]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (redirect_information->redirect_enabled) { + if (cJSON_AddBoolToObject(item, "redirectEnabled", redirect_information->redirect_enabled) == NULL) { + ogs_error("OpenAPI_redirect_information_convertToJSON() failed [redirect_enabled]"); + goto end; + } + } + + if (redirect_information->redirect_address_type) { + cJSON *redirect_address_type_local_JSON = OpenAPI_redirect_address_type_convertToJSON(redirect_information->redirect_address_type); + if (redirect_address_type_local_JSON == NULL) { + ogs_error("OpenAPI_redirect_information_convertToJSON() failed [redirect_address_type]"); + goto end; + } + cJSON_AddItemToObject(item, "redirectAddressType", redirect_address_type_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_redirect_information_convertToJSON() failed [redirect_address_type]"); + goto end; + } + } + + if (redirect_information->redirect_server_address) { + if (cJSON_AddStringToObject(item, "redirectServerAddress", redirect_information->redirect_server_address) == NULL) { + ogs_error("OpenAPI_redirect_information_convertToJSON() failed [redirect_server_address]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_redirect_information_t *OpenAPI_redirect_information_parseFromJSON(cJSON *redirect_informationJSON) +{ + OpenAPI_redirect_information_t *redirect_information_local_var = NULL; + cJSON *redirect_enabled = cJSON_GetObjectItemCaseSensitive(redirect_informationJSON, "redirectEnabled"); + + if (redirect_enabled) { + if (!cJSON_IsBool(redirect_enabled)) { + ogs_error("OpenAPI_redirect_information_parseFromJSON() failed [redirect_enabled]"); + goto end; + } + } + + cJSON *redirect_address_type = cJSON_GetObjectItemCaseSensitive(redirect_informationJSON, "redirectAddressType"); + + OpenAPI_redirect_address_type_t *redirect_address_type_local_nonprim = NULL; + if (redirect_address_type) { + redirect_address_type_local_nonprim = OpenAPI_redirect_address_type_parseFromJSON(redirect_address_type); + } + + cJSON *redirect_server_address = cJSON_GetObjectItemCaseSensitive(redirect_informationJSON, "redirectServerAddress"); + + if (redirect_server_address) { + if (!cJSON_IsString(redirect_server_address)) { + ogs_error("OpenAPI_redirect_information_parseFromJSON() failed [redirect_server_address]"); + goto end; + } + } + + redirect_information_local_var = OpenAPI_redirect_information_create ( + redirect_enabled ? redirect_enabled->valueint : 0, + redirect_address_type ? redirect_address_type_local_nonprim : NULL, + redirect_server_address ? ogs_strdup(redirect_server_address->valuestring) : NULL + ); + + return redirect_information_local_var; +end: + return NULL; +} + +OpenAPI_redirect_information_t *OpenAPI_redirect_information_copy(OpenAPI_redirect_information_t *dst, OpenAPI_redirect_information_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_redirect_information_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_redirect_information_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_redirect_information_free(dst); + dst = OpenAPI_redirect_information_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/redirect_information.h b/lib/sbi/openapi/model/redirect_information.h new file mode 100644 index 000000000..14aacd06d --- /dev/null +++ b/lib/sbi/openapi/model/redirect_information.h @@ -0,0 +1,43 @@ +/* + * redirect_information.h + * + * + */ + +#ifndef _OpenAPI_redirect_information_H_ +#define _OpenAPI_redirect_information_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "redirect_address_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_redirect_information_s OpenAPI_redirect_information_t; +typedef struct OpenAPI_redirect_information_s { + int redirect_enabled; + struct OpenAPI_redirect_address_type_s *redirect_address_type; + char *redirect_server_address; +} OpenAPI_redirect_information_t; + +OpenAPI_redirect_information_t *OpenAPI_redirect_information_create( + int redirect_enabled, + OpenAPI_redirect_address_type_t *redirect_address_type, + char *redirect_server_address + ); +void OpenAPI_redirect_information_free(OpenAPI_redirect_information_t *redirect_information); +OpenAPI_redirect_information_t *OpenAPI_redirect_information_parseFromJSON(cJSON *redirect_informationJSON); +cJSON *OpenAPI_redirect_information_convertToJSON(OpenAPI_redirect_information_t *redirect_information); +OpenAPI_redirect_information_t *OpenAPI_redirect_information_copy(OpenAPI_redirect_information_t *dst, OpenAPI_redirect_information_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_redirect_information_H_ */ + diff --git a/lib/sbi/openapi/model/reporting_frequency.c b/lib/sbi/openapi/model/reporting_frequency.c new file mode 100644 index 000000000..770b5563f --- /dev/null +++ b/lib/sbi/openapi/model/reporting_frequency.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "reporting_frequency.h" + +OpenAPI_reporting_frequency_t *OpenAPI_reporting_frequency_create( + ) +{ + OpenAPI_reporting_frequency_t *reporting_frequency_local_var = OpenAPI_malloc(sizeof(OpenAPI_reporting_frequency_t)); + if (!reporting_frequency_local_var) { + return NULL; + } + + return reporting_frequency_local_var; +} + +void OpenAPI_reporting_frequency_free(OpenAPI_reporting_frequency_t *reporting_frequency) +{ + if (NULL == reporting_frequency) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(reporting_frequency); +} + +cJSON *OpenAPI_reporting_frequency_convertToJSON(OpenAPI_reporting_frequency_t *reporting_frequency) +{ + cJSON *item = NULL; + + if (reporting_frequency == NULL) { + ogs_error("OpenAPI_reporting_frequency_convertToJSON() failed [ReportingFrequency]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_reporting_frequency_t *OpenAPI_reporting_frequency_parseFromJSON(cJSON *reporting_frequencyJSON) +{ + OpenAPI_reporting_frequency_t *reporting_frequency_local_var = NULL; + reporting_frequency_local_var = OpenAPI_reporting_frequency_create ( + ); + + return reporting_frequency_local_var; +end: + return NULL; +} + +OpenAPI_reporting_frequency_t *OpenAPI_reporting_frequency_copy(OpenAPI_reporting_frequency_t *dst, OpenAPI_reporting_frequency_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_reporting_frequency_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_reporting_frequency_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_reporting_frequency_free(dst); + dst = OpenAPI_reporting_frequency_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/reporting_frequency.h b/lib/sbi/openapi/model/reporting_frequency.h new file mode 100644 index 000000000..144cf50a8 --- /dev/null +++ b/lib/sbi/openapi/model/reporting_frequency.h @@ -0,0 +1,36 @@ +/* + * reporting_frequency.h + * + * + */ + +#ifndef _OpenAPI_reporting_frequency_H_ +#define _OpenAPI_reporting_frequency_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_reporting_frequency_s OpenAPI_reporting_frequency_t; +typedef struct OpenAPI_reporting_frequency_s { +} OpenAPI_reporting_frequency_t; + +OpenAPI_reporting_frequency_t *OpenAPI_reporting_frequency_create( + ); +void OpenAPI_reporting_frequency_free(OpenAPI_reporting_frequency_t *reporting_frequency); +OpenAPI_reporting_frequency_t *OpenAPI_reporting_frequency_parseFromJSON(cJSON *reporting_frequencyJSON); +cJSON *OpenAPI_reporting_frequency_convertToJSON(OpenAPI_reporting_frequency_t *reporting_frequency); +OpenAPI_reporting_frequency_t *OpenAPI_reporting_frequency_copy(OpenAPI_reporting_frequency_t *dst, OpenAPI_reporting_frequency_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_reporting_frequency_H_ */ + diff --git a/lib/sbi/openapi/model/reporting_level.c b/lib/sbi/openapi/model/reporting_level.c new file mode 100644 index 000000000..b0b8292ef --- /dev/null +++ b/lib/sbi/openapi/model/reporting_level.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "reporting_level.h" + +OpenAPI_reporting_level_t *OpenAPI_reporting_level_create( + ) +{ + OpenAPI_reporting_level_t *reporting_level_local_var = OpenAPI_malloc(sizeof(OpenAPI_reporting_level_t)); + if (!reporting_level_local_var) { + return NULL; + } + + return reporting_level_local_var; +} + +void OpenAPI_reporting_level_free(OpenAPI_reporting_level_t *reporting_level) +{ + if (NULL == reporting_level) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(reporting_level); +} + +cJSON *OpenAPI_reporting_level_convertToJSON(OpenAPI_reporting_level_t *reporting_level) +{ + cJSON *item = NULL; + + if (reporting_level == NULL) { + ogs_error("OpenAPI_reporting_level_convertToJSON() failed [ReportingLevel]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_reporting_level_t *OpenAPI_reporting_level_parseFromJSON(cJSON *reporting_levelJSON) +{ + OpenAPI_reporting_level_t *reporting_level_local_var = NULL; + reporting_level_local_var = OpenAPI_reporting_level_create ( + ); + + return reporting_level_local_var; +end: + return NULL; +} + +OpenAPI_reporting_level_t *OpenAPI_reporting_level_copy(OpenAPI_reporting_level_t *dst, OpenAPI_reporting_level_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_reporting_level_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_reporting_level_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_reporting_level_free(dst); + dst = OpenAPI_reporting_level_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/reporting_level.h b/lib/sbi/openapi/model/reporting_level.h new file mode 100644 index 000000000..c01de44f9 --- /dev/null +++ b/lib/sbi/openapi/model/reporting_level.h @@ -0,0 +1,37 @@ +/* + * reporting_level.h + * + * Possible values are - SER_ID_LEVEL: Indicates that the usage shall be reported on service id and rating group combination level. - RAT_GR_LEVEL: Indicates that the usage shall be reported on rating group level. - SPON_CON_LEVEL: Indicates that the usage shall be reported on sponsor identity and rating group combination level. + */ + +#ifndef _OpenAPI_reporting_level_H_ +#define _OpenAPI_reporting_level_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "null_value.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_reporting_level_s OpenAPI_reporting_level_t; +typedef struct OpenAPI_reporting_level_s { +} OpenAPI_reporting_level_t; + +OpenAPI_reporting_level_t *OpenAPI_reporting_level_create( + ); +void OpenAPI_reporting_level_free(OpenAPI_reporting_level_t *reporting_level); +OpenAPI_reporting_level_t *OpenAPI_reporting_level_parseFromJSON(cJSON *reporting_levelJSON); +cJSON *OpenAPI_reporting_level_convertToJSON(OpenAPI_reporting_level_t *reporting_level); +OpenAPI_reporting_level_t *OpenAPI_reporting_level_copy(OpenAPI_reporting_level_t *dst, OpenAPI_reporting_level_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_reporting_level_H_ */ + diff --git a/lib/sbi/openapi/model/request_trigger.c b/lib/sbi/openapi/model/request_trigger.c new file mode 100644 index 000000000..614b2278c --- /dev/null +++ b/lib/sbi/openapi/model/request_trigger.c @@ -0,0 +1,30 @@ + +#include +#include +#include +#include "request_trigger.h" + +char* OpenAPI_request_trigger_ToString(OpenAPI_request_trigger_e request_trigger) +{ + const char *request_triggerArray[] = { "NULL", "LOC_CH", "PRA_CH", "SERV_AREA_CH", "RFSP_CH", "ALLOWED_NSSAI_CH", "UE_AMBR_CH", "SMF_SELECT_CH", "ACCESS_TYPE_CH", "RG_TMBR_CH" }; + size_t sizeofArray = sizeof(request_triggerArray) / sizeof(request_triggerArray[0]); + if (request_trigger < sizeofArray) + return (char *)request_triggerArray[request_trigger]; + else + return (char *)"Unknown"; +} + +OpenAPI_request_trigger_e OpenAPI_request_trigger_FromString(char* request_trigger) +{ + int stringToReturn = 0; + const char *request_triggerArray[] = { "NULL", "LOC_CH", "PRA_CH", "SERV_AREA_CH", "RFSP_CH", "ALLOWED_NSSAI_CH", "UE_AMBR_CH", "SMF_SELECT_CH", "ACCESS_TYPE_CH", "RG_TMBR_CH" }; + size_t sizeofArray = sizeof(request_triggerArray) / sizeof(request_triggerArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(request_trigger, request_triggerArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; + } + return 0; +} + diff --git a/lib/sbi/openapi/model/request_trigger.h b/lib/sbi/openapi/model/request_trigger.h new file mode 100644 index 000000000..5c95fca98 --- /dev/null +++ b/lib/sbi/openapi/model/request_trigger.h @@ -0,0 +1,31 @@ +/* + * request_trigger.h + * + * + */ + +#ifndef _OpenAPI_request_trigger_H_ +#define _OpenAPI_request_trigger_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { OpenAPI_request_trigger_NULL = 0, OpenAPI_request_trigger_LOC_CH, OpenAPI_request_trigger_PRA_CH, OpenAPI_request_trigger_SERV_AREA_CH, OpenAPI_request_trigger_RFSP_CH, OpenAPI_request_trigger_ALLOWED_NSSAI_CH, OpenAPI_request_trigger_UE_AMBR_CH, OpenAPI_request_trigger_SMF_SELECT_CH, OpenAPI_request_trigger_ACCESS_TYPE_CH, OpenAPI_request_trigger_RG_TMBR_CH } OpenAPI_request_trigger_e; + +char* OpenAPI_request_trigger_ToString(OpenAPI_request_trigger_e request_trigger); + +OpenAPI_request_trigger_e OpenAPI_request_trigger_FromString(char* request_trigger); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_request_trigger_H_ */ + diff --git a/lib/sbi/openapi/model/requested_qos.c b/lib/sbi/openapi/model/requested_qos.c new file mode 100644 index 000000000..92c27cc2b --- /dev/null +++ b/lib/sbi/openapi/model/requested_qos.c @@ -0,0 +1,149 @@ + +#include +#include +#include +#include "requested_qos.h" + +OpenAPI_requested_qos_t *OpenAPI_requested_qos_create( + int _5qi, + char *gbr_ul, + char *gbr_dl + ) +{ + OpenAPI_requested_qos_t *requested_qos_local_var = OpenAPI_malloc(sizeof(OpenAPI_requested_qos_t)); + if (!requested_qos_local_var) { + return NULL; + } + requested_qos_local_var->_5qi = _5qi; + requested_qos_local_var->gbr_ul = gbr_ul; + requested_qos_local_var->gbr_dl = gbr_dl; + + return requested_qos_local_var; +} + +void OpenAPI_requested_qos_free(OpenAPI_requested_qos_t *requested_qos) +{ + if (NULL == requested_qos) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(requested_qos->gbr_ul); + ogs_free(requested_qos->gbr_dl); + ogs_free(requested_qos); +} + +cJSON *OpenAPI_requested_qos_convertToJSON(OpenAPI_requested_qos_t *requested_qos) +{ + cJSON *item = NULL; + + if (requested_qos == NULL) { + ogs_error("OpenAPI_requested_qos_convertToJSON() failed [RequestedQos]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!requested_qos->_5qi) { + ogs_error("OpenAPI_requested_qos_convertToJSON() failed [_5qi]"); + goto end; + } + if (cJSON_AddNumberToObject(item, "5qi", requested_qos->_5qi) == NULL) { + ogs_error("OpenAPI_requested_qos_convertToJSON() failed [_5qi]"); + goto end; + } + + if (requested_qos->gbr_ul) { + if (cJSON_AddStringToObject(item, "gbrUl", requested_qos->gbr_ul) == NULL) { + ogs_error("OpenAPI_requested_qos_convertToJSON() failed [gbr_ul]"); + goto end; + } + } + + if (requested_qos->gbr_dl) { + if (cJSON_AddStringToObject(item, "gbrDl", requested_qos->gbr_dl) == NULL) { + ogs_error("OpenAPI_requested_qos_convertToJSON() failed [gbr_dl]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_requested_qos_t *OpenAPI_requested_qos_parseFromJSON(cJSON *requested_qosJSON) +{ + OpenAPI_requested_qos_t *requested_qos_local_var = NULL; + cJSON *_5qi = cJSON_GetObjectItemCaseSensitive(requested_qosJSON, "5qi"); + if (!_5qi) { + ogs_error("OpenAPI_requested_qos_parseFromJSON() failed [_5qi]"); + goto end; + } + + + if (!cJSON_IsNumber(_5qi)) { + ogs_error("OpenAPI_requested_qos_parseFromJSON() failed [_5qi]"); + goto end; + } + + cJSON *gbr_ul = cJSON_GetObjectItemCaseSensitive(requested_qosJSON, "gbrUl"); + + if (gbr_ul) { + if (!cJSON_IsString(gbr_ul)) { + ogs_error("OpenAPI_requested_qos_parseFromJSON() failed [gbr_ul]"); + goto end; + } + } + + cJSON *gbr_dl = cJSON_GetObjectItemCaseSensitive(requested_qosJSON, "gbrDl"); + + if (gbr_dl) { + if (!cJSON_IsString(gbr_dl)) { + ogs_error("OpenAPI_requested_qos_parseFromJSON() failed [gbr_dl]"); + goto end; + } + } + + requested_qos_local_var = OpenAPI_requested_qos_create ( + _5qi->valuedouble, + gbr_ul ? ogs_strdup(gbr_ul->valuestring) : NULL, + gbr_dl ? ogs_strdup(gbr_dl->valuestring) : NULL + ); + + return requested_qos_local_var; +end: + return NULL; +} + +OpenAPI_requested_qos_t *OpenAPI_requested_qos_copy(OpenAPI_requested_qos_t *dst, OpenAPI_requested_qos_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_requested_qos_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_requested_qos_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_requested_qos_free(dst); + dst = OpenAPI_requested_qos_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/requested_qos.h b/lib/sbi/openapi/model/requested_qos.h new file mode 100644 index 000000000..be41ba4f1 --- /dev/null +++ b/lib/sbi/openapi/model/requested_qos.h @@ -0,0 +1,42 @@ +/* + * requested_qos.h + * + * + */ + +#ifndef _OpenAPI_requested_qos_H_ +#define _OpenAPI_requested_qos_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_requested_qos_s OpenAPI_requested_qos_t; +typedef struct OpenAPI_requested_qos_s { + int _5qi; + char *gbr_ul; + char *gbr_dl; +} OpenAPI_requested_qos_t; + +OpenAPI_requested_qos_t *OpenAPI_requested_qos_create( + int _5qi, + char *gbr_ul, + char *gbr_dl + ); +void OpenAPI_requested_qos_free(OpenAPI_requested_qos_t *requested_qos); +OpenAPI_requested_qos_t *OpenAPI_requested_qos_parseFromJSON(cJSON *requested_qosJSON); +cJSON *OpenAPI_requested_qos_convertToJSON(OpenAPI_requested_qos_t *requested_qos); +OpenAPI_requested_qos_t *OpenAPI_requested_qos_copy(OpenAPI_requested_qos_t *dst, OpenAPI_requested_qos_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_requested_qos_H_ */ + diff --git a/lib/sbi/openapi/model/requested_qos_monitoring_parameter.c b/lib/sbi/openapi/model/requested_qos_monitoring_parameter.c new file mode 100644 index 000000000..a8e20bbf8 --- /dev/null +++ b/lib/sbi/openapi/model/requested_qos_monitoring_parameter.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "requested_qos_monitoring_parameter.h" + +OpenAPI_requested_qos_monitoring_parameter_t *OpenAPI_requested_qos_monitoring_parameter_create( + ) +{ + OpenAPI_requested_qos_monitoring_parameter_t *requested_qos_monitoring_parameter_local_var = OpenAPI_malloc(sizeof(OpenAPI_requested_qos_monitoring_parameter_t)); + if (!requested_qos_monitoring_parameter_local_var) { + return NULL; + } + + return requested_qos_monitoring_parameter_local_var; +} + +void OpenAPI_requested_qos_monitoring_parameter_free(OpenAPI_requested_qos_monitoring_parameter_t *requested_qos_monitoring_parameter) +{ + if (NULL == requested_qos_monitoring_parameter) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(requested_qos_monitoring_parameter); +} + +cJSON *OpenAPI_requested_qos_monitoring_parameter_convertToJSON(OpenAPI_requested_qos_monitoring_parameter_t *requested_qos_monitoring_parameter) +{ + cJSON *item = NULL; + + if (requested_qos_monitoring_parameter == NULL) { + ogs_error("OpenAPI_requested_qos_monitoring_parameter_convertToJSON() failed [RequestedQosMonitoringParameter]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_requested_qos_monitoring_parameter_t *OpenAPI_requested_qos_monitoring_parameter_parseFromJSON(cJSON *requested_qos_monitoring_parameterJSON) +{ + OpenAPI_requested_qos_monitoring_parameter_t *requested_qos_monitoring_parameter_local_var = NULL; + requested_qos_monitoring_parameter_local_var = OpenAPI_requested_qos_monitoring_parameter_create ( + ); + + return requested_qos_monitoring_parameter_local_var; +end: + return NULL; +} + +OpenAPI_requested_qos_monitoring_parameter_t *OpenAPI_requested_qos_monitoring_parameter_copy(OpenAPI_requested_qos_monitoring_parameter_t *dst, OpenAPI_requested_qos_monitoring_parameter_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_requested_qos_monitoring_parameter_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_requested_qos_monitoring_parameter_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_requested_qos_monitoring_parameter_free(dst); + dst = OpenAPI_requested_qos_monitoring_parameter_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/requested_qos_monitoring_parameter.h b/lib/sbi/openapi/model/requested_qos_monitoring_parameter.h new file mode 100644 index 000000000..8783b112f --- /dev/null +++ b/lib/sbi/openapi/model/requested_qos_monitoring_parameter.h @@ -0,0 +1,36 @@ +/* + * requested_qos_monitoring_parameter.h + * + * + */ + +#ifndef _OpenAPI_requested_qos_monitoring_parameter_H_ +#define _OpenAPI_requested_qos_monitoring_parameter_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_requested_qos_monitoring_parameter_s OpenAPI_requested_qos_monitoring_parameter_t; +typedef struct OpenAPI_requested_qos_monitoring_parameter_s { +} OpenAPI_requested_qos_monitoring_parameter_t; + +OpenAPI_requested_qos_monitoring_parameter_t *OpenAPI_requested_qos_monitoring_parameter_create( + ); +void OpenAPI_requested_qos_monitoring_parameter_free(OpenAPI_requested_qos_monitoring_parameter_t *requested_qos_monitoring_parameter); +OpenAPI_requested_qos_monitoring_parameter_t *OpenAPI_requested_qos_monitoring_parameter_parseFromJSON(cJSON *requested_qos_monitoring_parameterJSON); +cJSON *OpenAPI_requested_qos_monitoring_parameter_convertToJSON(OpenAPI_requested_qos_monitoring_parameter_t *requested_qos_monitoring_parameter); +OpenAPI_requested_qos_monitoring_parameter_t *OpenAPI_requested_qos_monitoring_parameter_copy(OpenAPI_requested_qos_monitoring_parameter_t *dst, OpenAPI_requested_qos_monitoring_parameter_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_requested_qos_monitoring_parameter_H_ */ + diff --git a/lib/sbi/openapi/model/requested_rule_data.c b/lib/sbi/openapi/model/requested_rule_data.c new file mode 100644 index 000000000..7588715f3 --- /dev/null +++ b/lib/sbi/openapi/model/requested_rule_data.c @@ -0,0 +1,188 @@ + +#include +#include +#include +#include "requested_rule_data.h" + +OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_create( + OpenAPI_list_t *ref_pcc_rule_ids, + OpenAPI_list_t *req_data + ) +{ + OpenAPI_requested_rule_data_t *requested_rule_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_requested_rule_data_t)); + if (!requested_rule_data_local_var) { + return NULL; + } + requested_rule_data_local_var->ref_pcc_rule_ids = ref_pcc_rule_ids; + requested_rule_data_local_var->req_data = req_data; + + return requested_rule_data_local_var; +} + +void OpenAPI_requested_rule_data_free(OpenAPI_requested_rule_data_t *requested_rule_data) +{ + if (NULL == requested_rule_data) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(requested_rule_data->ref_pcc_rule_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(requested_rule_data->ref_pcc_rule_ids); + OpenAPI_list_for_each(requested_rule_data->req_data, node) { + OpenAPI_requested_rule_data_type_free(node->data); + } + OpenAPI_list_free(requested_rule_data->req_data); + ogs_free(requested_rule_data); +} + +cJSON *OpenAPI_requested_rule_data_convertToJSON(OpenAPI_requested_rule_data_t *requested_rule_data) +{ + cJSON *item = NULL; + + if (requested_rule_data == NULL) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [RequestedRuleData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!requested_rule_data->ref_pcc_rule_ids) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + cJSON *ref_pcc_rule_ids = cJSON_AddArrayToObject(item, "refPccRuleIds"); + if (ref_pcc_rule_ids == NULL) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + + OpenAPI_lnode_t *ref_pcc_rule_ids_node; + OpenAPI_list_for_each(requested_rule_data->ref_pcc_rule_ids, ref_pcc_rule_ids_node) { + if (cJSON_AddStringToObject(ref_pcc_rule_ids, "", (char*)ref_pcc_rule_ids_node->data) == NULL) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + } + + if (!requested_rule_data->req_data) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [req_data]"); + goto end; + } + cJSON *req_dataList = cJSON_AddArrayToObject(item, "reqData"); + if (req_dataList == NULL) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [req_data]"); + goto end; + } + + OpenAPI_lnode_t *req_data_node; + if (requested_rule_data->req_data) { + OpenAPI_list_for_each(requested_rule_data->req_data, req_data_node) { + cJSON *itemLocal = OpenAPI_requested_rule_data_type_convertToJSON(req_data_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [req_data]"); + goto end; + } + cJSON_AddItemToArray(req_dataList, itemLocal); + } + } + +end: + return item; +} + +OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_parseFromJSON(cJSON *requested_rule_dataJSON) +{ + OpenAPI_requested_rule_data_t *requested_rule_data_local_var = NULL; + cJSON *ref_pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(requested_rule_dataJSON, "refPccRuleIds"); + if (!ref_pcc_rule_ids) { + ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + + OpenAPI_list_t *ref_pcc_rule_idsList; + + cJSON *ref_pcc_rule_ids_local; + if (!cJSON_IsArray(ref_pcc_rule_ids)) { + ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + ref_pcc_rule_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_pcc_rule_ids_local, ref_pcc_rule_ids) { + if (!cJSON_IsString(ref_pcc_rule_ids_local)) { + ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]"); + goto end; + } + OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup(ref_pcc_rule_ids_local->valuestring)); + } + + cJSON *req_data = cJSON_GetObjectItemCaseSensitive(requested_rule_dataJSON, "reqData"); + if (!req_data) { + ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [req_data]"); + goto end; + } + + OpenAPI_list_t *req_dataList; + + cJSON *req_data_local_nonprimitive; + if (!cJSON_IsArray(req_data)) { + ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [req_data]"); + goto end; + } + + req_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(req_data_local_nonprimitive, req_data ) { + if (!cJSON_IsObject(req_data_local_nonprimitive)) { + ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [req_data]"); + goto end; + } + OpenAPI_requested_rule_data_type_t *req_dataItem = OpenAPI_requested_rule_data_type_parseFromJSON(req_data_local_nonprimitive); + + OpenAPI_list_add(req_dataList, req_dataItem); + } + + requested_rule_data_local_var = OpenAPI_requested_rule_data_create ( + ref_pcc_rule_idsList, + req_dataList + ); + + return requested_rule_data_local_var; +end: + return NULL; +} + +OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_copy(OpenAPI_requested_rule_data_t *dst, OpenAPI_requested_rule_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_requested_rule_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_requested_rule_data_free(dst); + dst = OpenAPI_requested_rule_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/requested_rule_data.h b/lib/sbi/openapi/model/requested_rule_data.h new file mode 100644 index 000000000..2fce38755 --- /dev/null +++ b/lib/sbi/openapi/model/requested_rule_data.h @@ -0,0 +1,41 @@ +/* + * requested_rule_data.h + * + * + */ + +#ifndef _OpenAPI_requested_rule_data_H_ +#define _OpenAPI_requested_rule_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "requested_rule_data_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_requested_rule_data_s OpenAPI_requested_rule_data_t; +typedef struct OpenAPI_requested_rule_data_s { + OpenAPI_list_t *ref_pcc_rule_ids; + OpenAPI_list_t *req_data; +} OpenAPI_requested_rule_data_t; + +OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_create( + OpenAPI_list_t *ref_pcc_rule_ids, + OpenAPI_list_t *req_data + ); +void OpenAPI_requested_rule_data_free(OpenAPI_requested_rule_data_t *requested_rule_data); +OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_parseFromJSON(cJSON *requested_rule_dataJSON); +cJSON *OpenAPI_requested_rule_data_convertToJSON(OpenAPI_requested_rule_data_t *requested_rule_data); +OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_copy(OpenAPI_requested_rule_data_t *dst, OpenAPI_requested_rule_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_requested_rule_data_H_ */ + diff --git a/lib/sbi/openapi/model/requested_rule_data_type.c b/lib/sbi/openapi/model/requested_rule_data_type.c new file mode 100644 index 000000000..06b4c2289 --- /dev/null +++ b/lib/sbi/openapi/model/requested_rule_data_type.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "requested_rule_data_type.h" + +OpenAPI_requested_rule_data_type_t *OpenAPI_requested_rule_data_type_create( + ) +{ + OpenAPI_requested_rule_data_type_t *requested_rule_data_type_local_var = OpenAPI_malloc(sizeof(OpenAPI_requested_rule_data_type_t)); + if (!requested_rule_data_type_local_var) { + return NULL; + } + + return requested_rule_data_type_local_var; +} + +void OpenAPI_requested_rule_data_type_free(OpenAPI_requested_rule_data_type_t *requested_rule_data_type) +{ + if (NULL == requested_rule_data_type) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(requested_rule_data_type); +} + +cJSON *OpenAPI_requested_rule_data_type_convertToJSON(OpenAPI_requested_rule_data_type_t *requested_rule_data_type) +{ + cJSON *item = NULL; + + if (requested_rule_data_type == NULL) { + ogs_error("OpenAPI_requested_rule_data_type_convertToJSON() failed [RequestedRuleDataType]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_requested_rule_data_type_t *OpenAPI_requested_rule_data_type_parseFromJSON(cJSON *requested_rule_data_typeJSON) +{ + OpenAPI_requested_rule_data_type_t *requested_rule_data_type_local_var = NULL; + requested_rule_data_type_local_var = OpenAPI_requested_rule_data_type_create ( + ); + + return requested_rule_data_type_local_var; +end: + return NULL; +} + +OpenAPI_requested_rule_data_type_t *OpenAPI_requested_rule_data_type_copy(OpenAPI_requested_rule_data_type_t *dst, OpenAPI_requested_rule_data_type_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_requested_rule_data_type_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_requested_rule_data_type_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_requested_rule_data_type_free(dst); + dst = OpenAPI_requested_rule_data_type_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/requested_rule_data_type.h b/lib/sbi/openapi/model/requested_rule_data_type.h new file mode 100644 index 000000000..4b92ae1ae --- /dev/null +++ b/lib/sbi/openapi/model/requested_rule_data_type.h @@ -0,0 +1,36 @@ +/* + * requested_rule_data_type.h + * + * Possible values are - CH_ID: Indicates that the requested rule data is the charging identifier. - MS_TIME_ZONE: Indicates that the requested access network info type is the UE's timezone. - USER_LOC_INFO: Indicates that the requested access network info type is the UE's location. - RES_RELEASE: Indicates that the requested rule data is the result of the release of resource. - SUCC_RES_ALLO: Indicates that the requested rule data is the successful resource allocation. - EPS_FALLBACK: Indicates that the requested rule data is the report of QoS flow rejection due to EPS fallback. + */ + +#ifndef _OpenAPI_requested_rule_data_type_H_ +#define _OpenAPI_requested_rule_data_type_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_requested_rule_data_type_s OpenAPI_requested_rule_data_type_t; +typedef struct OpenAPI_requested_rule_data_type_s { +} OpenAPI_requested_rule_data_type_t; + +OpenAPI_requested_rule_data_type_t *OpenAPI_requested_rule_data_type_create( + ); +void OpenAPI_requested_rule_data_type_free(OpenAPI_requested_rule_data_type_t *requested_rule_data_type); +OpenAPI_requested_rule_data_type_t *OpenAPI_requested_rule_data_type_parseFromJSON(cJSON *requested_rule_data_typeJSON); +cJSON *OpenAPI_requested_rule_data_type_convertToJSON(OpenAPI_requested_rule_data_type_t *requested_rule_data_type); +OpenAPI_requested_rule_data_type_t *OpenAPI_requested_rule_data_type_copy(OpenAPI_requested_rule_data_type_t *dst, OpenAPI_requested_rule_data_type_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_requested_rule_data_type_H_ */ + diff --git a/lib/sbi/openapi/model/requested_usage_data.c b/lib/sbi/openapi/model/requested_usage_data.c new file mode 100644 index 000000000..e51f5b662 --- /dev/null +++ b/lib/sbi/openapi/model/requested_usage_data.c @@ -0,0 +1,147 @@ + +#include +#include +#include +#include "requested_usage_data.h" + +OpenAPI_requested_usage_data_t *OpenAPI_requested_usage_data_create( + OpenAPI_list_t *ref_um_ids, + int all_um_ids + ) +{ + OpenAPI_requested_usage_data_t *requested_usage_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_requested_usage_data_t)); + if (!requested_usage_data_local_var) { + return NULL; + } + requested_usage_data_local_var->ref_um_ids = ref_um_ids; + requested_usage_data_local_var->all_um_ids = all_um_ids; + + return requested_usage_data_local_var; +} + +void OpenAPI_requested_usage_data_free(OpenAPI_requested_usage_data_t *requested_usage_data) +{ + if (NULL == requested_usage_data) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(requested_usage_data->ref_um_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(requested_usage_data->ref_um_ids); + ogs_free(requested_usage_data); +} + +cJSON *OpenAPI_requested_usage_data_convertToJSON(OpenAPI_requested_usage_data_t *requested_usage_data) +{ + cJSON *item = NULL; + + if (requested_usage_data == NULL) { + ogs_error("OpenAPI_requested_usage_data_convertToJSON() failed [RequestedUsageData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (requested_usage_data->ref_um_ids) { + cJSON *ref_um_ids = cJSON_AddArrayToObject(item, "refUmIds"); + if (ref_um_ids == NULL) { + ogs_error("OpenAPI_requested_usage_data_convertToJSON() failed [ref_um_ids]"); + goto end; + } + + OpenAPI_lnode_t *ref_um_ids_node; + OpenAPI_list_for_each(requested_usage_data->ref_um_ids, ref_um_ids_node) { + if (cJSON_AddStringToObject(ref_um_ids, "", (char*)ref_um_ids_node->data) == NULL) { + ogs_error("OpenAPI_requested_usage_data_convertToJSON() failed [ref_um_ids]"); + goto end; + } + } + } + + if (requested_usage_data->all_um_ids) { + if (cJSON_AddBoolToObject(item, "allUmIds", requested_usage_data->all_um_ids) == NULL) { + ogs_error("OpenAPI_requested_usage_data_convertToJSON() failed [all_um_ids]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_requested_usage_data_t *OpenAPI_requested_usage_data_parseFromJSON(cJSON *requested_usage_dataJSON) +{ + OpenAPI_requested_usage_data_t *requested_usage_data_local_var = NULL; + cJSON *ref_um_ids = cJSON_GetObjectItemCaseSensitive(requested_usage_dataJSON, "refUmIds"); + + OpenAPI_list_t *ref_um_idsList; + if (ref_um_ids) { + cJSON *ref_um_ids_local; + if (!cJSON_IsArray(ref_um_ids)) { + ogs_error("OpenAPI_requested_usage_data_parseFromJSON() failed [ref_um_ids]"); + goto end; + } + ref_um_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ref_um_ids_local, ref_um_ids) { + if (!cJSON_IsString(ref_um_ids_local)) { + ogs_error("OpenAPI_requested_usage_data_parseFromJSON() failed [ref_um_ids]"); + goto end; + } + OpenAPI_list_add(ref_um_idsList, ogs_strdup(ref_um_ids_local->valuestring)); + } + } + + cJSON *all_um_ids = cJSON_GetObjectItemCaseSensitive(requested_usage_dataJSON, "allUmIds"); + + if (all_um_ids) { + if (!cJSON_IsBool(all_um_ids)) { + ogs_error("OpenAPI_requested_usage_data_parseFromJSON() failed [all_um_ids]"); + goto end; + } + } + + requested_usage_data_local_var = OpenAPI_requested_usage_data_create ( + ref_um_ids ? ref_um_idsList : NULL, + all_um_ids ? all_um_ids->valueint : 0 + ); + + return requested_usage_data_local_var; +end: + return NULL; +} + +OpenAPI_requested_usage_data_t *OpenAPI_requested_usage_data_copy(OpenAPI_requested_usage_data_t *dst, OpenAPI_requested_usage_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_requested_usage_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_requested_usage_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_requested_usage_data_free(dst); + dst = OpenAPI_requested_usage_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/requested_usage_data.h b/lib/sbi/openapi/model/requested_usage_data.h new file mode 100644 index 000000000..7cbeecc5e --- /dev/null +++ b/lib/sbi/openapi/model/requested_usage_data.h @@ -0,0 +1,40 @@ +/* + * requested_usage_data.h + * + * + */ + +#ifndef _OpenAPI_requested_usage_data_H_ +#define _OpenAPI_requested_usage_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_requested_usage_data_s OpenAPI_requested_usage_data_t; +typedef struct OpenAPI_requested_usage_data_s { + OpenAPI_list_t *ref_um_ids; + int all_um_ids; +} OpenAPI_requested_usage_data_t; + +OpenAPI_requested_usage_data_t *OpenAPI_requested_usage_data_create( + OpenAPI_list_t *ref_um_ids, + int all_um_ids + ); +void OpenAPI_requested_usage_data_free(OpenAPI_requested_usage_data_t *requested_usage_data); +OpenAPI_requested_usage_data_t *OpenAPI_requested_usage_data_parseFromJSON(cJSON *requested_usage_dataJSON); +cJSON *OpenAPI_requested_usage_data_convertToJSON(OpenAPI_requested_usage_data_t *requested_usage_data); +OpenAPI_requested_usage_data_t *OpenAPI_requested_usage_data_copy(OpenAPI_requested_usage_data_t *dst, OpenAPI_requested_usage_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_requested_usage_data_H_ */ + diff --git a/lib/sbi/openapi/model/restriction_type.c b/lib/sbi/openapi/model/restriction_type.c index d5652de03..5706f6964 100644 --- a/lib/sbi/openapi/model/restriction_type.c +++ b/lib/sbi/openapi/model/restriction_type.c @@ -4,82 +4,27 @@ #include #include "restriction_type.h" -OpenAPI_restriction_type_t *OpenAPI_restriction_type_create( - ) +char* OpenAPI_restriction_type_ToString(OpenAPI_restriction_type_e restriction_type) { - OpenAPI_restriction_type_t *restriction_type_local_var = OpenAPI_malloc(sizeof(OpenAPI_restriction_type_t)); - if (!restriction_type_local_var) { - return NULL; - } - - return restriction_type_local_var; + const char *restriction_typeArray[] = { "NULL", "ALLOWED_AREAS", "NOT_ALLOWED_AREAS" }; + size_t sizeofArray = sizeof(restriction_typeArray) / sizeof(restriction_typeArray[0]); + if (restriction_type < sizeofArray) + return (char *)restriction_typeArray[restriction_type]; + else + return (char *)"Unknown"; } -void OpenAPI_restriction_type_free(OpenAPI_restriction_type_t *restriction_type) +OpenAPI_restriction_type_e OpenAPI_restriction_type_FromString(char* restriction_type) { - if (NULL == restriction_type) { - return; + int stringToReturn = 0; + const char *restriction_typeArray[] = { "NULL", "ALLOWED_AREAS", "NOT_ALLOWED_AREAS" }; + size_t sizeofArray = sizeof(restriction_typeArray) / sizeof(restriction_typeArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(restriction_type, restriction_typeArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; } - OpenAPI_lnode_t *node; - ogs_free(restriction_type); -} - -cJSON *OpenAPI_restriction_type_convertToJSON(OpenAPI_restriction_type_t *restriction_type) -{ - cJSON *item = NULL; - - if (restriction_type == NULL) { - ogs_error("OpenAPI_restriction_type_convertToJSON() failed [RestrictionType]"); - return NULL; - } - - item = cJSON_CreateObject(); -end: - return item; -} - -OpenAPI_restriction_type_t *OpenAPI_restriction_type_parseFromJSON(cJSON *restriction_typeJSON) -{ - OpenAPI_restriction_type_t *restriction_type_local_var = NULL; - restriction_type_local_var = OpenAPI_restriction_type_create ( - ); - - return restriction_type_local_var; -end: - return NULL; -} - -OpenAPI_restriction_type_t *OpenAPI_restriction_type_copy(OpenAPI_restriction_type_t *dst, OpenAPI_restriction_type_t *src) -{ - cJSON *item = NULL; - char *content = NULL; - - ogs_assert(src); - item = OpenAPI_restriction_type_convertToJSON(src); - if (!item) { - ogs_error("OpenAPI_restriction_type_convertToJSON() failed"); - return NULL; - } - - content = cJSON_Print(item); - cJSON_Delete(item); - - if (!content) { - ogs_error("cJSON_Print() failed"); - return NULL; - } - - item = cJSON_Parse(content); - ogs_free(content); - if (!item) { - ogs_error("cJSON_Parse() failed"); - return NULL; - } - - OpenAPI_restriction_type_free(dst); - dst = OpenAPI_restriction_type_parseFromJSON(item); - cJSON_Delete(item); - - return dst; + return 0; } diff --git a/lib/sbi/openapi/model/restriction_type.h b/lib/sbi/openapi/model/restriction_type.h index 3e84f9060..73ca362e2 100644 --- a/lib/sbi/openapi/model/restriction_type.h +++ b/lib/sbi/openapi/model/restriction_type.h @@ -17,16 +17,11 @@ extern "C" { #endif -typedef struct OpenAPI_restriction_type_s OpenAPI_restriction_type_t; -typedef struct OpenAPI_restriction_type_s { -} OpenAPI_restriction_type_t; +typedef enum { OpenAPI_restriction_type_NULL = 0, OpenAPI_restriction_type_ALLOWED_AREAS, OpenAPI_restriction_type_NOT_ALLOWED_AREAS } OpenAPI_restriction_type_e; -OpenAPI_restriction_type_t *OpenAPI_restriction_type_create( - ); -void OpenAPI_restriction_type_free(OpenAPI_restriction_type_t *restriction_type); -OpenAPI_restriction_type_t *OpenAPI_restriction_type_parseFromJSON(cJSON *restriction_typeJSON); -cJSON *OpenAPI_restriction_type_convertToJSON(OpenAPI_restriction_type_t *restriction_type); -OpenAPI_restriction_type_t *OpenAPI_restriction_type_copy(OpenAPI_restriction_type_t *dst, OpenAPI_restriction_type_t *src); +char* OpenAPI_restriction_type_ToString(OpenAPI_restriction_type_e restriction_type); + +OpenAPI_restriction_type_e OpenAPI_restriction_type_FromString(char* restriction_type); #ifdef __cplusplus } diff --git a/lib/sbi/openapi/model/rule_operation.c b/lib/sbi/openapi/model/rule_operation.c new file mode 100644 index 000000000..c75e87729 --- /dev/null +++ b/lib/sbi/openapi/model/rule_operation.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "rule_operation.h" + +OpenAPI_rule_operation_t *OpenAPI_rule_operation_create( + ) +{ + OpenAPI_rule_operation_t *rule_operation_local_var = OpenAPI_malloc(sizeof(OpenAPI_rule_operation_t)); + if (!rule_operation_local_var) { + return NULL; + } + + return rule_operation_local_var; +} + +void OpenAPI_rule_operation_free(OpenAPI_rule_operation_t *rule_operation) +{ + if (NULL == rule_operation) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(rule_operation); +} + +cJSON *OpenAPI_rule_operation_convertToJSON(OpenAPI_rule_operation_t *rule_operation) +{ + cJSON *item = NULL; + + if (rule_operation == NULL) { + ogs_error("OpenAPI_rule_operation_convertToJSON() failed [RuleOperation]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_rule_operation_t *OpenAPI_rule_operation_parseFromJSON(cJSON *rule_operationJSON) +{ + OpenAPI_rule_operation_t *rule_operation_local_var = NULL; + rule_operation_local_var = OpenAPI_rule_operation_create ( + ); + + return rule_operation_local_var; +end: + return NULL; +} + +OpenAPI_rule_operation_t *OpenAPI_rule_operation_copy(OpenAPI_rule_operation_t *dst, OpenAPI_rule_operation_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_rule_operation_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_rule_operation_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_rule_operation_free(dst); + dst = OpenAPI_rule_operation_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/rule_operation.h b/lib/sbi/openapi/model/rule_operation.h new file mode 100644 index 000000000..6f4f1f5c4 --- /dev/null +++ b/lib/sbi/openapi/model/rule_operation.h @@ -0,0 +1,36 @@ +/* + * rule_operation.h + * + * Possible values are - CREATE_PCC_RULE: Indicates to create a new PCC rule to reserve the resource requested by the UE. - DELETE_PCC_RULE: Indicates to delete a PCC rule corresponding to reserve the resource requested by the UE.. - MODIFY_PCC_RULE_AND_ADD_PACKET_FILTERS: Indicates to modify the PCC rule by adding new packet filter(s). - MODIFY_ PCC_RULE_AND_REPLACE_PACKET_FILTERS: Indicates to modify the PCC rule by replacing the existing packet filter(s). - MODIFY_ PCC_RULE_AND_DELETE_PACKET_FILTERS: Indicates to modify the PCC rule by deleting the existing packet filter(s). - MODIFY_PCC_RULE_WITHOUT_MODIFY_PACKET_FILTERS: Indicates to modify the PCC rule by modifying the QoS of the PCC rule. + */ + +#ifndef _OpenAPI_rule_operation_H_ +#define _OpenAPI_rule_operation_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_rule_operation_s OpenAPI_rule_operation_t; +typedef struct OpenAPI_rule_operation_s { +} OpenAPI_rule_operation_t; + +OpenAPI_rule_operation_t *OpenAPI_rule_operation_create( + ); +void OpenAPI_rule_operation_free(OpenAPI_rule_operation_t *rule_operation); +OpenAPI_rule_operation_t *OpenAPI_rule_operation_parseFromJSON(cJSON *rule_operationJSON); +cJSON *OpenAPI_rule_operation_convertToJSON(OpenAPI_rule_operation_t *rule_operation); +OpenAPI_rule_operation_t *OpenAPI_rule_operation_copy(OpenAPI_rule_operation_t *dst, OpenAPI_rule_operation_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_rule_operation_H_ */ + diff --git a/lib/sbi/openapi/model/rule_report.c b/lib/sbi/openapi/model/rule_report.c new file mode 100644 index 000000000..5f88ab6a2 --- /dev/null +++ b/lib/sbi/openapi/model/rule_report.c @@ -0,0 +1,303 @@ + +#include +#include +#include +#include "rule_report.h" + +OpenAPI_rule_report_t *OpenAPI_rule_report_create( + OpenAPI_list_t *pcc_rule_ids, + OpenAPI_rule_status_t *rule_status, + OpenAPI_list_t *cont_vers, + OpenAPI_failure_code_t *failure_code, + OpenAPI_final_unit_action_t *fin_unit_act, + OpenAPI_list_t *ran_nas_rel_causes + ) +{ + OpenAPI_rule_report_t *rule_report_local_var = OpenAPI_malloc(sizeof(OpenAPI_rule_report_t)); + if (!rule_report_local_var) { + return NULL; + } + rule_report_local_var->pcc_rule_ids = pcc_rule_ids; + rule_report_local_var->rule_status = rule_status; + rule_report_local_var->cont_vers = cont_vers; + rule_report_local_var->failure_code = failure_code; + rule_report_local_var->fin_unit_act = fin_unit_act; + rule_report_local_var->ran_nas_rel_causes = ran_nas_rel_causes; + + return rule_report_local_var; +} + +void OpenAPI_rule_report_free(OpenAPI_rule_report_t *rule_report) +{ + if (NULL == rule_report) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(rule_report->pcc_rule_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(rule_report->pcc_rule_ids); + OpenAPI_rule_status_free(rule_report->rule_status); + OpenAPI_list_for_each(rule_report->cont_vers, node) { + ogs_free(node->data); + } + OpenAPI_list_free(rule_report->cont_vers); + OpenAPI_failure_code_free(rule_report->failure_code); + OpenAPI_final_unit_action_free(rule_report->fin_unit_act); + OpenAPI_list_for_each(rule_report->ran_nas_rel_causes, node) { + OpenAPI_ran_nas_rel_cause_free(node->data); + } + OpenAPI_list_free(rule_report->ran_nas_rel_causes); + ogs_free(rule_report); +} + +cJSON *OpenAPI_rule_report_convertToJSON(OpenAPI_rule_report_t *rule_report) +{ + cJSON *item = NULL; + + if (rule_report == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [RuleReport]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!rule_report->pcc_rule_ids) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [pcc_rule_ids]"); + goto end; + } + cJSON *pcc_rule_ids = cJSON_AddArrayToObject(item, "pccRuleIds"); + if (pcc_rule_ids == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [pcc_rule_ids]"); + goto end; + } + + OpenAPI_lnode_t *pcc_rule_ids_node; + OpenAPI_list_for_each(rule_report->pcc_rule_ids, pcc_rule_ids_node) { + if (cJSON_AddStringToObject(pcc_rule_ids, "", (char*)pcc_rule_ids_node->data) == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [pcc_rule_ids]"); + goto end; + } + } + + if (!rule_report->rule_status) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [rule_status]"); + goto end; + } + cJSON *rule_status_local_JSON = OpenAPI_rule_status_convertToJSON(rule_report->rule_status); + if (rule_status_local_JSON == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [rule_status]"); + goto end; + } + cJSON_AddItemToObject(item, "ruleStatus", rule_status_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [rule_status]"); + goto end; + } + + if (rule_report->cont_vers) { + cJSON *cont_vers = cJSON_AddArrayToObject(item, "contVers"); + if (cont_vers == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [cont_vers]"); + goto end; + } + + OpenAPI_lnode_t *cont_vers_node; + OpenAPI_list_for_each(rule_report->cont_vers, cont_vers_node) { + if (cJSON_AddNumberToObject(cont_vers, "", *(double *)cont_vers_node->data) == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [cont_vers]"); + goto end; + } + } + } + + if (rule_report->failure_code) { + cJSON *failure_code_local_JSON = OpenAPI_failure_code_convertToJSON(rule_report->failure_code); + if (failure_code_local_JSON == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [failure_code]"); + goto end; + } + cJSON_AddItemToObject(item, "failureCode", failure_code_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [failure_code]"); + goto end; + } + } + + if (rule_report->fin_unit_act) { + cJSON *fin_unit_act_local_JSON = OpenAPI_final_unit_action_convertToJSON(rule_report->fin_unit_act); + if (fin_unit_act_local_JSON == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [fin_unit_act]"); + goto end; + } + cJSON_AddItemToObject(item, "finUnitAct", fin_unit_act_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [fin_unit_act]"); + goto end; + } + } + + if (rule_report->ran_nas_rel_causes) { + cJSON *ran_nas_rel_causesList = cJSON_AddArrayToObject(item, "ranNasRelCauses"); + if (ran_nas_rel_causesList == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [ran_nas_rel_causes]"); + goto end; + } + + OpenAPI_lnode_t *ran_nas_rel_causes_node; + if (rule_report->ran_nas_rel_causes) { + OpenAPI_list_for_each(rule_report->ran_nas_rel_causes, ran_nas_rel_causes_node) { + cJSON *itemLocal = OpenAPI_ran_nas_rel_cause_convertToJSON(ran_nas_rel_causes_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed [ran_nas_rel_causes]"); + goto end; + } + cJSON_AddItemToArray(ran_nas_rel_causesList, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_rule_report_t *OpenAPI_rule_report_parseFromJSON(cJSON *rule_reportJSON) +{ + OpenAPI_rule_report_t *rule_report_local_var = NULL; + cJSON *pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(rule_reportJSON, "pccRuleIds"); + if (!pcc_rule_ids) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [pcc_rule_ids]"); + goto end; + } + + OpenAPI_list_t *pcc_rule_idsList; + + cJSON *pcc_rule_ids_local; + if (!cJSON_IsArray(pcc_rule_ids)) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [pcc_rule_ids]"); + goto end; + } + pcc_rule_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(pcc_rule_ids_local, pcc_rule_ids) { + if (!cJSON_IsString(pcc_rule_ids_local)) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [pcc_rule_ids]"); + goto end; + } + OpenAPI_list_add(pcc_rule_idsList, ogs_strdup(pcc_rule_ids_local->valuestring)); + } + + cJSON *rule_status = cJSON_GetObjectItemCaseSensitive(rule_reportJSON, "ruleStatus"); + if (!rule_status) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [rule_status]"); + goto end; + } + + OpenAPI_rule_status_t *rule_status_local_nonprim = NULL; + + rule_status_local_nonprim = OpenAPI_rule_status_parseFromJSON(rule_status); + + cJSON *cont_vers = cJSON_GetObjectItemCaseSensitive(rule_reportJSON, "contVers"); + + OpenAPI_list_t *cont_versList; + if (cont_vers) { + cJSON *cont_vers_local; + if (!cJSON_IsArray(cont_vers)) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [cont_vers]"); + goto end; + } + cont_versList = OpenAPI_list_create(); + + cJSON_ArrayForEach(cont_vers_local, cont_vers) { + if (!cJSON_IsNumber(cont_vers_local)) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [cont_vers]"); + goto end; + } + OpenAPI_list_add(cont_versList, &cont_vers_local->valuedouble); + } + } + + cJSON *failure_code = cJSON_GetObjectItemCaseSensitive(rule_reportJSON, "failureCode"); + + OpenAPI_failure_code_t *failure_code_local_nonprim = NULL; + if (failure_code) { + failure_code_local_nonprim = OpenAPI_failure_code_parseFromJSON(failure_code); + } + + cJSON *fin_unit_act = cJSON_GetObjectItemCaseSensitive(rule_reportJSON, "finUnitAct"); + + OpenAPI_final_unit_action_t *fin_unit_act_local_nonprim = NULL; + if (fin_unit_act) { + fin_unit_act_local_nonprim = OpenAPI_final_unit_action_parseFromJSON(fin_unit_act); + } + + cJSON *ran_nas_rel_causes = cJSON_GetObjectItemCaseSensitive(rule_reportJSON, "ranNasRelCauses"); + + OpenAPI_list_t *ran_nas_rel_causesList; + if (ran_nas_rel_causes) { + cJSON *ran_nas_rel_causes_local_nonprimitive; + if (!cJSON_IsArray(ran_nas_rel_causes)) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [ran_nas_rel_causes]"); + goto end; + } + + ran_nas_rel_causesList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ran_nas_rel_causes_local_nonprimitive, ran_nas_rel_causes ) { + if (!cJSON_IsObject(ran_nas_rel_causes_local_nonprimitive)) { + ogs_error("OpenAPI_rule_report_parseFromJSON() failed [ran_nas_rel_causes]"); + goto end; + } + OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_causesItem = OpenAPI_ran_nas_rel_cause_parseFromJSON(ran_nas_rel_causes_local_nonprimitive); + + OpenAPI_list_add(ran_nas_rel_causesList, ran_nas_rel_causesItem); + } + } + + rule_report_local_var = OpenAPI_rule_report_create ( + pcc_rule_idsList, + rule_status_local_nonprim, + cont_vers ? cont_versList : NULL, + failure_code ? failure_code_local_nonprim : NULL, + fin_unit_act ? fin_unit_act_local_nonprim : NULL, + ran_nas_rel_causes ? ran_nas_rel_causesList : NULL + ); + + return rule_report_local_var; +end: + return NULL; +} + +OpenAPI_rule_report_t *OpenAPI_rule_report_copy(OpenAPI_rule_report_t *dst, OpenAPI_rule_report_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_rule_report_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_rule_report_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_rule_report_free(dst); + dst = OpenAPI_rule_report_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/rule_report.h b/lib/sbi/openapi/model/rule_report.h new file mode 100644 index 000000000..9ab765d83 --- /dev/null +++ b/lib/sbi/openapi/model/rule_report.h @@ -0,0 +1,52 @@ +/* + * rule_report.h + * + * + */ + +#ifndef _OpenAPI_rule_report_H_ +#define _OpenAPI_rule_report_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "failure_code.h" +#include "final_unit_action.h" +#include "ran_nas_rel_cause.h" +#include "rule_status.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_rule_report_s OpenAPI_rule_report_t; +typedef struct OpenAPI_rule_report_s { + OpenAPI_list_t *pcc_rule_ids; + struct OpenAPI_rule_status_s *rule_status; + OpenAPI_list_t *cont_vers; + struct OpenAPI_failure_code_s *failure_code; + struct OpenAPI_final_unit_action_s *fin_unit_act; + OpenAPI_list_t *ran_nas_rel_causes; +} OpenAPI_rule_report_t; + +OpenAPI_rule_report_t *OpenAPI_rule_report_create( + OpenAPI_list_t *pcc_rule_ids, + OpenAPI_rule_status_t *rule_status, + OpenAPI_list_t *cont_vers, + OpenAPI_failure_code_t *failure_code, + OpenAPI_final_unit_action_t *fin_unit_act, + OpenAPI_list_t *ran_nas_rel_causes + ); +void OpenAPI_rule_report_free(OpenAPI_rule_report_t *rule_report); +OpenAPI_rule_report_t *OpenAPI_rule_report_parseFromJSON(cJSON *rule_reportJSON); +cJSON *OpenAPI_rule_report_convertToJSON(OpenAPI_rule_report_t *rule_report); +OpenAPI_rule_report_t *OpenAPI_rule_report_copy(OpenAPI_rule_report_t *dst, OpenAPI_rule_report_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_rule_report_H_ */ + diff --git a/lib/sbi/openapi/model/rule_status.c b/lib/sbi/openapi/model/rule_status.c new file mode 100644 index 000000000..ffd145d07 --- /dev/null +++ b/lib/sbi/openapi/model/rule_status.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "rule_status.h" + +OpenAPI_rule_status_t *OpenAPI_rule_status_create( + ) +{ + OpenAPI_rule_status_t *rule_status_local_var = OpenAPI_malloc(sizeof(OpenAPI_rule_status_t)); + if (!rule_status_local_var) { + return NULL; + } + + return rule_status_local_var; +} + +void OpenAPI_rule_status_free(OpenAPI_rule_status_t *rule_status) +{ + if (NULL == rule_status) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(rule_status); +} + +cJSON *OpenAPI_rule_status_convertToJSON(OpenAPI_rule_status_t *rule_status) +{ + cJSON *item = NULL; + + if (rule_status == NULL) { + ogs_error("OpenAPI_rule_status_convertToJSON() failed [RuleStatus]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_rule_status_t *OpenAPI_rule_status_parseFromJSON(cJSON *rule_statusJSON) +{ + OpenAPI_rule_status_t *rule_status_local_var = NULL; + rule_status_local_var = OpenAPI_rule_status_create ( + ); + + return rule_status_local_var; +end: + return NULL; +} + +OpenAPI_rule_status_t *OpenAPI_rule_status_copy(OpenAPI_rule_status_t *dst, OpenAPI_rule_status_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_rule_status_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_rule_status_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_rule_status_free(dst); + dst = OpenAPI_rule_status_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/rule_status.h b/lib/sbi/openapi/model/rule_status.h new file mode 100644 index 000000000..1c5cdfded --- /dev/null +++ b/lib/sbi/openapi/model/rule_status.h @@ -0,0 +1,36 @@ +/* + * rule_status.h + * + * Possible values are - ACTIVE: Indicates that the PCC rule(s) are successfully installed (for those provisioned from PCF) or activated (for those pre-defined in SMF), or the session rule(s) are successfully installed - INACTIVE: Indicates that the PCC rule(s) are removed (for those provisioned from PCF) or inactive (for those pre-defined in SMF) or the session rule(s) are removed. + */ + +#ifndef _OpenAPI_rule_status_H_ +#define _OpenAPI_rule_status_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_rule_status_s OpenAPI_rule_status_t; +typedef struct OpenAPI_rule_status_s { +} OpenAPI_rule_status_t; + +OpenAPI_rule_status_t *OpenAPI_rule_status_create( + ); +void OpenAPI_rule_status_free(OpenAPI_rule_status_t *rule_status); +OpenAPI_rule_status_t *OpenAPI_rule_status_parseFromJSON(cJSON *rule_statusJSON); +cJSON *OpenAPI_rule_status_convertToJSON(OpenAPI_rule_status_t *rule_status); +OpenAPI_rule_status_t *OpenAPI_rule_status_copy(OpenAPI_rule_status_t *dst, OpenAPI_rule_status_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_rule_status_H_ */ + diff --git a/lib/sbi/openapi/model/scheduled_communication_type.c b/lib/sbi/openapi/model/scheduled_communication_type.c index 66ac1629d..51207a676 100644 --- a/lib/sbi/openapi/model/scheduled_communication_type.c +++ b/lib/sbi/openapi/model/scheduled_communication_type.c @@ -4,82 +4,27 @@ #include #include "scheduled_communication_type.h" -OpenAPI_scheduled_communication_type_t *OpenAPI_scheduled_communication_type_create( - ) +char* OpenAPI_scheduled_communication_type_ToString(OpenAPI_scheduled_communication_type_e scheduled_communication_type) { - OpenAPI_scheduled_communication_type_t *scheduled_communication_type_local_var = OpenAPI_malloc(sizeof(OpenAPI_scheduled_communication_type_t)); - if (!scheduled_communication_type_local_var) { - return NULL; - } - - return scheduled_communication_type_local_var; + const char *scheduled_communication_typeArray[] = { "NULL", "DOWNLINK_ONLY", "UPLINK_ONLY", "BIDIRECTIONAL" }; + size_t sizeofArray = sizeof(scheduled_communication_typeArray) / sizeof(scheduled_communication_typeArray[0]); + if (scheduled_communication_type < sizeofArray) + return (char *)scheduled_communication_typeArray[scheduled_communication_type]; + else + return (char *)"Unknown"; } -void OpenAPI_scheduled_communication_type_free(OpenAPI_scheduled_communication_type_t *scheduled_communication_type) +OpenAPI_scheduled_communication_type_e OpenAPI_scheduled_communication_type_FromString(char* scheduled_communication_type) { - if (NULL == scheduled_communication_type) { - return; + int stringToReturn = 0; + const char *scheduled_communication_typeArray[] = { "NULL", "DOWNLINK_ONLY", "UPLINK_ONLY", "BIDIRECTIONAL" }; + size_t sizeofArray = sizeof(scheduled_communication_typeArray) / sizeof(scheduled_communication_typeArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(scheduled_communication_type, scheduled_communication_typeArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; } - OpenAPI_lnode_t *node; - ogs_free(scheduled_communication_type); -} - -cJSON *OpenAPI_scheduled_communication_type_convertToJSON(OpenAPI_scheduled_communication_type_t *scheduled_communication_type) -{ - cJSON *item = NULL; - - if (scheduled_communication_type == NULL) { - ogs_error("OpenAPI_scheduled_communication_type_convertToJSON() failed [ScheduledCommunicationType]"); - return NULL; - } - - item = cJSON_CreateObject(); -end: - return item; -} - -OpenAPI_scheduled_communication_type_t *OpenAPI_scheduled_communication_type_parseFromJSON(cJSON *scheduled_communication_typeJSON) -{ - OpenAPI_scheduled_communication_type_t *scheduled_communication_type_local_var = NULL; - scheduled_communication_type_local_var = OpenAPI_scheduled_communication_type_create ( - ); - - return scheduled_communication_type_local_var; -end: - return NULL; -} - -OpenAPI_scheduled_communication_type_t *OpenAPI_scheduled_communication_type_copy(OpenAPI_scheduled_communication_type_t *dst, OpenAPI_scheduled_communication_type_t *src) -{ - cJSON *item = NULL; - char *content = NULL; - - ogs_assert(src); - item = OpenAPI_scheduled_communication_type_convertToJSON(src); - if (!item) { - ogs_error("OpenAPI_scheduled_communication_type_convertToJSON() failed"); - return NULL; - } - - content = cJSON_Print(item); - cJSON_Delete(item); - - if (!content) { - ogs_error("cJSON_Print() failed"); - return NULL; - } - - item = cJSON_Parse(content); - ogs_free(content); - if (!item) { - ogs_error("cJSON_Parse() failed"); - return NULL; - } - - OpenAPI_scheduled_communication_type_free(dst); - dst = OpenAPI_scheduled_communication_type_parseFromJSON(item); - cJSON_Delete(item); - - return dst; + return 0; } diff --git a/lib/sbi/openapi/model/scheduled_communication_type.h b/lib/sbi/openapi/model/scheduled_communication_type.h index c962a073a..0453fddcd 100644 --- a/lib/sbi/openapi/model/scheduled_communication_type.h +++ b/lib/sbi/openapi/model/scheduled_communication_type.h @@ -17,16 +17,11 @@ extern "C" { #endif -typedef struct OpenAPI_scheduled_communication_type_s OpenAPI_scheduled_communication_type_t; -typedef struct OpenAPI_scheduled_communication_type_s { -} OpenAPI_scheduled_communication_type_t; +typedef enum { OpenAPI_scheduled_communication_type_NULL = 0, OpenAPI_scheduled_communication_type_DOWNLINK_ONLY, OpenAPI_scheduled_communication_type_UPLINK_ONLY, OpenAPI_scheduled_communication_type_BIDIRECTIONAL } OpenAPI_scheduled_communication_type_e; -OpenAPI_scheduled_communication_type_t *OpenAPI_scheduled_communication_type_create( - ); -void OpenAPI_scheduled_communication_type_free(OpenAPI_scheduled_communication_type_t *scheduled_communication_type); -OpenAPI_scheduled_communication_type_t *OpenAPI_scheduled_communication_type_parseFromJSON(cJSON *scheduled_communication_typeJSON); -cJSON *OpenAPI_scheduled_communication_type_convertToJSON(OpenAPI_scheduled_communication_type_t *scheduled_communication_type); -OpenAPI_scheduled_communication_type_t *OpenAPI_scheduled_communication_type_copy(OpenAPI_scheduled_communication_type_t *dst, OpenAPI_scheduled_communication_type_t *src); +char* OpenAPI_scheduled_communication_type_ToString(OpenAPI_scheduled_communication_type_e scheduled_communication_type); + +OpenAPI_scheduled_communication_type_e OpenAPI_scheduled_communication_type_FromString(char* scheduled_communication_type); #ifdef __cplusplus } diff --git a/lib/sbi/openapi/model/service_area_restriction.c b/lib/sbi/openapi/model/service_area_restriction.c index 5df525493..c8a662e24 100644 --- a/lib/sbi/openapi/model/service_area_restriction.c +++ b/lib/sbi/openapi/model/service_area_restriction.c @@ -5,7 +5,7 @@ #include "service_area_restriction.h" OpenAPI_service_area_restriction_t *OpenAPI_service_area_restriction_create( - OpenAPI_restriction_type_t *restriction_type, + OpenAPI_restriction_type_e restriction_type, OpenAPI_list_t *areas, int max_num_of_t_as, int max_num_of_t_as_for_not_allowed_areas @@ -29,7 +29,6 @@ void OpenAPI_service_area_restriction_free(OpenAPI_service_area_restriction_t *s return; } OpenAPI_lnode_t *node; - OpenAPI_restriction_type_free(service_area_restriction->restriction_type); OpenAPI_list_for_each(service_area_restriction->areas, node) { OpenAPI_area_free(node->data); } @@ -48,13 +47,7 @@ cJSON *OpenAPI_service_area_restriction_convertToJSON(OpenAPI_service_area_restr item = cJSON_CreateObject(); if (service_area_restriction->restriction_type) { - cJSON *restriction_type_local_JSON = OpenAPI_restriction_type_convertToJSON(service_area_restriction->restriction_type); - if (restriction_type_local_JSON == NULL) { - ogs_error("OpenAPI_service_area_restriction_convertToJSON() failed [restriction_type]"); - goto end; - } - cJSON_AddItemToObject(item, "restrictionType", restriction_type_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "restrictionType", OpenAPI_restriction_type_ToString(service_area_restriction->restriction_type)) == NULL) { ogs_error("OpenAPI_service_area_restriction_convertToJSON() failed [restriction_type]"); goto end; } @@ -103,9 +96,13 @@ OpenAPI_service_area_restriction_t *OpenAPI_service_area_restriction_parseFromJS OpenAPI_service_area_restriction_t *service_area_restriction_local_var = NULL; cJSON *restriction_type = cJSON_GetObjectItemCaseSensitive(service_area_restrictionJSON, "restrictionType"); - OpenAPI_restriction_type_t *restriction_type_local_nonprim = NULL; + OpenAPI_restriction_type_e restriction_typeVariable; if (restriction_type) { - restriction_type_local_nonprim = OpenAPI_restriction_type_parseFromJSON(restriction_type); + if (!cJSON_IsString(restriction_type)) { + ogs_error("OpenAPI_service_area_restriction_parseFromJSON() failed [restriction_type]"); + goto end; + } + restriction_typeVariable = OpenAPI_restriction_type_FromString(restriction_type->valuestring); } cJSON *areas = cJSON_GetObjectItemCaseSensitive(service_area_restrictionJSON, "areas"); @@ -150,7 +147,7 @@ OpenAPI_service_area_restriction_t *OpenAPI_service_area_restriction_parseFromJS } service_area_restriction_local_var = OpenAPI_service_area_restriction_create ( - restriction_type ? restriction_type_local_nonprim : NULL, + restriction_type ? restriction_typeVariable : 0, areas ? areasList : NULL, max_num_of_t_as ? max_num_of_t_as->valuedouble : 0, max_num_of_t_as_for_not_allowed_areas ? max_num_of_t_as_for_not_allowed_areas->valuedouble : 0 diff --git a/lib/sbi/openapi/model/service_area_restriction.h b/lib/sbi/openapi/model/service_area_restriction.h index fd7a3150c..c57823cf7 100644 --- a/lib/sbi/openapi/model/service_area_restriction.h +++ b/lib/sbi/openapi/model/service_area_restriction.h @@ -21,14 +21,14 @@ extern "C" { typedef struct OpenAPI_service_area_restriction_s OpenAPI_service_area_restriction_t; typedef struct OpenAPI_service_area_restriction_s { - struct OpenAPI_restriction_type_s *restriction_type; + OpenAPI_restriction_type_e restriction_type; OpenAPI_list_t *areas; int max_num_of_t_as; int max_num_of_t_as_for_not_allowed_areas; } OpenAPI_service_area_restriction_t; OpenAPI_service_area_restriction_t *OpenAPI_service_area_restriction_create( - OpenAPI_restriction_type_t *restriction_type, + OpenAPI_restriction_type_e restriction_type, OpenAPI_list_t *areas, int max_num_of_t_as, int max_num_of_t_as_for_not_allowed_areas diff --git a/lib/sbi/openapi/model/serving_nf_identity.c b/lib/sbi/openapi/model/serving_nf_identity.c new file mode 100644 index 000000000..414f4943a --- /dev/null +++ b/lib/sbi/openapi/model/serving_nf_identity.c @@ -0,0 +1,153 @@ + +#include +#include +#include +#include "serving_nf_identity.h" + +OpenAPI_serving_nf_identity_t *OpenAPI_serving_nf_identity_create( + char *serv_nf_inst_id, + OpenAPI_guami_t *guami, + OpenAPI_an_gw_address_t *an_gw_addr + ) +{ + OpenAPI_serving_nf_identity_t *serving_nf_identity_local_var = OpenAPI_malloc(sizeof(OpenAPI_serving_nf_identity_t)); + if (!serving_nf_identity_local_var) { + return NULL; + } + serving_nf_identity_local_var->serv_nf_inst_id = serv_nf_inst_id; + serving_nf_identity_local_var->guami = guami; + serving_nf_identity_local_var->an_gw_addr = an_gw_addr; + + return serving_nf_identity_local_var; +} + +void OpenAPI_serving_nf_identity_free(OpenAPI_serving_nf_identity_t *serving_nf_identity) +{ + if (NULL == serving_nf_identity) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(serving_nf_identity->serv_nf_inst_id); + OpenAPI_guami_free(serving_nf_identity->guami); + OpenAPI_an_gw_address_free(serving_nf_identity->an_gw_addr); + ogs_free(serving_nf_identity); +} + +cJSON *OpenAPI_serving_nf_identity_convertToJSON(OpenAPI_serving_nf_identity_t *serving_nf_identity) +{ + cJSON *item = NULL; + + if (serving_nf_identity == NULL) { + ogs_error("OpenAPI_serving_nf_identity_convertToJSON() failed [ServingNfIdentity]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (serving_nf_identity->serv_nf_inst_id) { + if (cJSON_AddStringToObject(item, "servNfInstId", serving_nf_identity->serv_nf_inst_id) == NULL) { + ogs_error("OpenAPI_serving_nf_identity_convertToJSON() failed [serv_nf_inst_id]"); + goto end; + } + } + + if (serving_nf_identity->guami) { + cJSON *guami_local_JSON = OpenAPI_guami_convertToJSON(serving_nf_identity->guami); + if (guami_local_JSON == NULL) { + ogs_error("OpenAPI_serving_nf_identity_convertToJSON() failed [guami]"); + goto end; + } + cJSON_AddItemToObject(item, "guami", guami_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_serving_nf_identity_convertToJSON() failed [guami]"); + goto end; + } + } + + if (serving_nf_identity->an_gw_addr) { + cJSON *an_gw_addr_local_JSON = OpenAPI_an_gw_address_convertToJSON(serving_nf_identity->an_gw_addr); + if (an_gw_addr_local_JSON == NULL) { + ogs_error("OpenAPI_serving_nf_identity_convertToJSON() failed [an_gw_addr]"); + goto end; + } + cJSON_AddItemToObject(item, "anGwAddr", an_gw_addr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_serving_nf_identity_convertToJSON() failed [an_gw_addr]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_serving_nf_identity_t *OpenAPI_serving_nf_identity_parseFromJSON(cJSON *serving_nf_identityJSON) +{ + OpenAPI_serving_nf_identity_t *serving_nf_identity_local_var = NULL; + cJSON *serv_nf_inst_id = cJSON_GetObjectItemCaseSensitive(serving_nf_identityJSON, "servNfInstId"); + + if (serv_nf_inst_id) { + if (!cJSON_IsString(serv_nf_inst_id)) { + ogs_error("OpenAPI_serving_nf_identity_parseFromJSON() failed [serv_nf_inst_id]"); + goto end; + } + } + + cJSON *guami = cJSON_GetObjectItemCaseSensitive(serving_nf_identityJSON, "guami"); + + OpenAPI_guami_t *guami_local_nonprim = NULL; + if (guami) { + guami_local_nonprim = OpenAPI_guami_parseFromJSON(guami); + } + + cJSON *an_gw_addr = cJSON_GetObjectItemCaseSensitive(serving_nf_identityJSON, "anGwAddr"); + + OpenAPI_an_gw_address_t *an_gw_addr_local_nonprim = NULL; + if (an_gw_addr) { + an_gw_addr_local_nonprim = OpenAPI_an_gw_address_parseFromJSON(an_gw_addr); + } + + serving_nf_identity_local_var = OpenAPI_serving_nf_identity_create ( + serv_nf_inst_id ? ogs_strdup(serv_nf_inst_id->valuestring) : NULL, + guami ? guami_local_nonprim : NULL, + an_gw_addr ? an_gw_addr_local_nonprim : NULL + ); + + return serving_nf_identity_local_var; +end: + return NULL; +} + +OpenAPI_serving_nf_identity_t *OpenAPI_serving_nf_identity_copy(OpenAPI_serving_nf_identity_t *dst, OpenAPI_serving_nf_identity_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_serving_nf_identity_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_serving_nf_identity_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_serving_nf_identity_free(dst); + dst = OpenAPI_serving_nf_identity_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/serving_nf_identity.h b/lib/sbi/openapi/model/serving_nf_identity.h new file mode 100644 index 000000000..ba5a68ba0 --- /dev/null +++ b/lib/sbi/openapi/model/serving_nf_identity.h @@ -0,0 +1,44 @@ +/* + * serving_nf_identity.h + * + * + */ + +#ifndef _OpenAPI_serving_nf_identity_H_ +#define _OpenAPI_serving_nf_identity_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "an_gw_address.h" +#include "guami.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_serving_nf_identity_s OpenAPI_serving_nf_identity_t; +typedef struct OpenAPI_serving_nf_identity_s { + char *serv_nf_inst_id; + struct OpenAPI_guami_s *guami; + struct OpenAPI_an_gw_address_s *an_gw_addr; +} OpenAPI_serving_nf_identity_t; + +OpenAPI_serving_nf_identity_t *OpenAPI_serving_nf_identity_create( + char *serv_nf_inst_id, + OpenAPI_guami_t *guami, + OpenAPI_an_gw_address_t *an_gw_addr + ); +void OpenAPI_serving_nf_identity_free(OpenAPI_serving_nf_identity_t *serving_nf_identity); +OpenAPI_serving_nf_identity_t *OpenAPI_serving_nf_identity_parseFromJSON(cJSON *serving_nf_identityJSON); +cJSON *OpenAPI_serving_nf_identity_convertToJSON(OpenAPI_serving_nf_identity_t *serving_nf_identity); +OpenAPI_serving_nf_identity_t *OpenAPI_serving_nf_identity_copy(OpenAPI_serving_nf_identity_t *dst, OpenAPI_serving_nf_identity_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_serving_nf_identity_H_ */ + diff --git a/lib/sbi/openapi/model/session_rule.c b/lib/sbi/openapi/model/session_rule.c new file mode 100644 index 000000000..a1979b8a6 --- /dev/null +++ b/lib/sbi/openapi/model/session_rule.c @@ -0,0 +1,218 @@ + +#include +#include +#include +#include "session_rule.h" + +OpenAPI_session_rule_t *OpenAPI_session_rule_create( + OpenAPI_ambr_t *auth_sess_ambr, + OpenAPI_authorized_default_qos_t *auth_def_qos, + char *sess_rule_id, + char *ref_um_data, + char *ref_um_n3g_data, + char *ref_cond_data + ) +{ + OpenAPI_session_rule_t *session_rule_local_var = OpenAPI_malloc(sizeof(OpenAPI_session_rule_t)); + if (!session_rule_local_var) { + return NULL; + } + session_rule_local_var->auth_sess_ambr = auth_sess_ambr; + session_rule_local_var->auth_def_qos = auth_def_qos; + session_rule_local_var->sess_rule_id = sess_rule_id; + session_rule_local_var->ref_um_data = ref_um_data; + session_rule_local_var->ref_um_n3g_data = ref_um_n3g_data; + session_rule_local_var->ref_cond_data = ref_cond_data; + + return session_rule_local_var; +} + +void OpenAPI_session_rule_free(OpenAPI_session_rule_t *session_rule) +{ + if (NULL == session_rule) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_ambr_free(session_rule->auth_sess_ambr); + OpenAPI_authorized_default_qos_free(session_rule->auth_def_qos); + ogs_free(session_rule->sess_rule_id); + ogs_free(session_rule->ref_um_data); + ogs_free(session_rule->ref_um_n3g_data); + ogs_free(session_rule->ref_cond_data); + ogs_free(session_rule); +} + +cJSON *OpenAPI_session_rule_convertToJSON(OpenAPI_session_rule_t *session_rule) +{ + cJSON *item = NULL; + + if (session_rule == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [SessionRule]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (session_rule->auth_sess_ambr) { + cJSON *auth_sess_ambr_local_JSON = OpenAPI_ambr_convertToJSON(session_rule->auth_sess_ambr); + if (auth_sess_ambr_local_JSON == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [auth_sess_ambr]"); + goto end; + } + cJSON_AddItemToObject(item, "authSessAmbr", auth_sess_ambr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [auth_sess_ambr]"); + goto end; + } + } + + if (session_rule->auth_def_qos) { + cJSON *auth_def_qos_local_JSON = OpenAPI_authorized_default_qos_convertToJSON(session_rule->auth_def_qos); + if (auth_def_qos_local_JSON == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [auth_def_qos]"); + goto end; + } + cJSON_AddItemToObject(item, "authDefQos", auth_def_qos_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [auth_def_qos]"); + goto end; + } + } + + if (!session_rule->sess_rule_id) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [sess_rule_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "sessRuleId", session_rule->sess_rule_id) == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [sess_rule_id]"); + goto end; + } + + if (session_rule->ref_um_data) { + if (cJSON_AddStringToObject(item, "refUmData", session_rule->ref_um_data) == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [ref_um_data]"); + goto end; + } + } + + if (session_rule->ref_um_n3g_data) { + if (cJSON_AddStringToObject(item, "refUmN3gData", session_rule->ref_um_n3g_data) == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [ref_um_n3g_data]"); + goto end; + } + } + + if (session_rule->ref_cond_data) { + if (cJSON_AddStringToObject(item, "refCondData", session_rule->ref_cond_data) == NULL) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed [ref_cond_data]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_session_rule_t *OpenAPI_session_rule_parseFromJSON(cJSON *session_ruleJSON) +{ + OpenAPI_session_rule_t *session_rule_local_var = NULL; + cJSON *auth_sess_ambr = cJSON_GetObjectItemCaseSensitive(session_ruleJSON, "authSessAmbr"); + + OpenAPI_ambr_t *auth_sess_ambr_local_nonprim = NULL; + if (auth_sess_ambr) { + auth_sess_ambr_local_nonprim = OpenAPI_ambr_parseFromJSON(auth_sess_ambr); + } + + cJSON *auth_def_qos = cJSON_GetObjectItemCaseSensitive(session_ruleJSON, "authDefQos"); + + OpenAPI_authorized_default_qos_t *auth_def_qos_local_nonprim = NULL; + if (auth_def_qos) { + auth_def_qos_local_nonprim = OpenAPI_authorized_default_qos_parseFromJSON(auth_def_qos); + } + + cJSON *sess_rule_id = cJSON_GetObjectItemCaseSensitive(session_ruleJSON, "sessRuleId"); + if (!sess_rule_id) { + ogs_error("OpenAPI_session_rule_parseFromJSON() failed [sess_rule_id]"); + goto end; + } + + + if (!cJSON_IsString(sess_rule_id)) { + ogs_error("OpenAPI_session_rule_parseFromJSON() failed [sess_rule_id]"); + goto end; + } + + cJSON *ref_um_data = cJSON_GetObjectItemCaseSensitive(session_ruleJSON, "refUmData"); + + if (ref_um_data) { + if (!cJSON_IsString(ref_um_data)) { + ogs_error("OpenAPI_session_rule_parseFromJSON() failed [ref_um_data]"); + goto end; + } + } + + cJSON *ref_um_n3g_data = cJSON_GetObjectItemCaseSensitive(session_ruleJSON, "refUmN3gData"); + + if (ref_um_n3g_data) { + if (!cJSON_IsString(ref_um_n3g_data)) { + ogs_error("OpenAPI_session_rule_parseFromJSON() failed [ref_um_n3g_data]"); + goto end; + } + } + + cJSON *ref_cond_data = cJSON_GetObjectItemCaseSensitive(session_ruleJSON, "refCondData"); + + if (ref_cond_data) { + if (!cJSON_IsString(ref_cond_data)) { + ogs_error("OpenAPI_session_rule_parseFromJSON() failed [ref_cond_data]"); + goto end; + } + } + + session_rule_local_var = OpenAPI_session_rule_create ( + auth_sess_ambr ? auth_sess_ambr_local_nonprim : NULL, + auth_def_qos ? auth_def_qos_local_nonprim : NULL, + ogs_strdup(sess_rule_id->valuestring), + ref_um_data ? ogs_strdup(ref_um_data->valuestring) : NULL, + ref_um_n3g_data ? ogs_strdup(ref_um_n3g_data->valuestring) : NULL, + ref_cond_data ? ogs_strdup(ref_cond_data->valuestring) : NULL + ); + + return session_rule_local_var; +end: + return NULL; +} + +OpenAPI_session_rule_t *OpenAPI_session_rule_copy(OpenAPI_session_rule_t *dst, OpenAPI_session_rule_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_session_rule_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_session_rule_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_session_rule_free(dst); + dst = OpenAPI_session_rule_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/session_rule.h b/lib/sbi/openapi/model/session_rule.h new file mode 100644 index 000000000..c02c3868f --- /dev/null +++ b/lib/sbi/openapi/model/session_rule.h @@ -0,0 +1,50 @@ +/* + * session_rule.h + * + * + */ + +#ifndef _OpenAPI_session_rule_H_ +#define _OpenAPI_session_rule_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "ambr.h" +#include "authorized_default_qos.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_session_rule_s OpenAPI_session_rule_t; +typedef struct OpenAPI_session_rule_s { + struct OpenAPI_ambr_s *auth_sess_ambr; + struct OpenAPI_authorized_default_qos_s *auth_def_qos; + char *sess_rule_id; + char *ref_um_data; + char *ref_um_n3g_data; + char *ref_cond_data; +} OpenAPI_session_rule_t; + +OpenAPI_session_rule_t *OpenAPI_session_rule_create( + OpenAPI_ambr_t *auth_sess_ambr, + OpenAPI_authorized_default_qos_t *auth_def_qos, + char *sess_rule_id, + char *ref_um_data, + char *ref_um_n3g_data, + char *ref_cond_data + ); +void OpenAPI_session_rule_free(OpenAPI_session_rule_t *session_rule); +OpenAPI_session_rule_t *OpenAPI_session_rule_parseFromJSON(cJSON *session_ruleJSON); +cJSON *OpenAPI_session_rule_convertToJSON(OpenAPI_session_rule_t *session_rule); +OpenAPI_session_rule_t *OpenAPI_session_rule_copy(OpenAPI_session_rule_t *dst, OpenAPI_session_rule_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_session_rule_H_ */ + diff --git a/lib/sbi/openapi/model/session_rule_failure_code.c b/lib/sbi/openapi/model/session_rule_failure_code.c new file mode 100644 index 000000000..2abb215e1 --- /dev/null +++ b/lib/sbi/openapi/model/session_rule_failure_code.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "session_rule_failure_code.h" + +OpenAPI_session_rule_failure_code_t *OpenAPI_session_rule_failure_code_create( + ) +{ + OpenAPI_session_rule_failure_code_t *session_rule_failure_code_local_var = OpenAPI_malloc(sizeof(OpenAPI_session_rule_failure_code_t)); + if (!session_rule_failure_code_local_var) { + return NULL; + } + + return session_rule_failure_code_local_var; +} + +void OpenAPI_session_rule_failure_code_free(OpenAPI_session_rule_failure_code_t *session_rule_failure_code) +{ + if (NULL == session_rule_failure_code) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(session_rule_failure_code); +} + +cJSON *OpenAPI_session_rule_failure_code_convertToJSON(OpenAPI_session_rule_failure_code_t *session_rule_failure_code) +{ + cJSON *item = NULL; + + if (session_rule_failure_code == NULL) { + ogs_error("OpenAPI_session_rule_failure_code_convertToJSON() failed [SessionRuleFailureCode]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_session_rule_failure_code_t *OpenAPI_session_rule_failure_code_parseFromJSON(cJSON *session_rule_failure_codeJSON) +{ + OpenAPI_session_rule_failure_code_t *session_rule_failure_code_local_var = NULL; + session_rule_failure_code_local_var = OpenAPI_session_rule_failure_code_create ( + ); + + return session_rule_failure_code_local_var; +end: + return NULL; +} + +OpenAPI_session_rule_failure_code_t *OpenAPI_session_rule_failure_code_copy(OpenAPI_session_rule_failure_code_t *dst, OpenAPI_session_rule_failure_code_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_session_rule_failure_code_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_session_rule_failure_code_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_session_rule_failure_code_free(dst); + dst = OpenAPI_session_rule_failure_code_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/session_rule_failure_code.h b/lib/sbi/openapi/model/session_rule_failure_code.h new file mode 100644 index 000000000..932ee5c90 --- /dev/null +++ b/lib/sbi/openapi/model/session_rule_failure_code.h @@ -0,0 +1,36 @@ +/* + * session_rule_failure_code.h + * + * Possible values are - NF_MAL: Indicate that the PCC rule could not be successfully installed (for those provisioned from the PCF) or activated (for those pre-defined in SMF) or enforced (for those already successfully installed) due to SMF/UPF malfunction. - RES_LIM: Indicate that the PCC rule could not be successfully installed (for those provisioned from PCF) or activated (for those pre-defined in SMF) or enforced (for those already successfully installed) due to a limitation of resources at the SMF/UPF. - UNSUCC_QOS_VAL: indicate that the QoS validation has failed. - UE_STA_SUSP: Indicates that the UE is in suspend state. + */ + +#ifndef _OpenAPI_session_rule_failure_code_H_ +#define _OpenAPI_session_rule_failure_code_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_session_rule_failure_code_s OpenAPI_session_rule_failure_code_t; +typedef struct OpenAPI_session_rule_failure_code_s { +} OpenAPI_session_rule_failure_code_t; + +OpenAPI_session_rule_failure_code_t *OpenAPI_session_rule_failure_code_create( + ); +void OpenAPI_session_rule_failure_code_free(OpenAPI_session_rule_failure_code_t *session_rule_failure_code); +OpenAPI_session_rule_failure_code_t *OpenAPI_session_rule_failure_code_parseFromJSON(cJSON *session_rule_failure_codeJSON); +cJSON *OpenAPI_session_rule_failure_code_convertToJSON(OpenAPI_session_rule_failure_code_t *session_rule_failure_code); +OpenAPI_session_rule_failure_code_t *OpenAPI_session_rule_failure_code_copy(OpenAPI_session_rule_failure_code_t *dst, OpenAPI_session_rule_failure_code_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_session_rule_failure_code_H_ */ + diff --git a/lib/sbi/openapi/model/session_rule_report.c b/lib/sbi/openapi/model/session_rule_report.c new file mode 100644 index 000000000..9e3c0ee20 --- /dev/null +++ b/lib/sbi/openapi/model/session_rule_report.c @@ -0,0 +1,186 @@ + +#include +#include +#include +#include "session_rule_report.h" + +OpenAPI_session_rule_report_t *OpenAPI_session_rule_report_create( + OpenAPI_list_t *rule_ids, + OpenAPI_rule_status_t *rule_status, + OpenAPI_session_rule_failure_code_t *sess_rule_failure_code + ) +{ + OpenAPI_session_rule_report_t *session_rule_report_local_var = OpenAPI_malloc(sizeof(OpenAPI_session_rule_report_t)); + if (!session_rule_report_local_var) { + return NULL; + } + session_rule_report_local_var->rule_ids = rule_ids; + session_rule_report_local_var->rule_status = rule_status; + session_rule_report_local_var->sess_rule_failure_code = sess_rule_failure_code; + + return session_rule_report_local_var; +} + +void OpenAPI_session_rule_report_free(OpenAPI_session_rule_report_t *session_rule_report) +{ + if (NULL == session_rule_report) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(session_rule_report->rule_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(session_rule_report->rule_ids); + OpenAPI_rule_status_free(session_rule_report->rule_status); + OpenAPI_session_rule_failure_code_free(session_rule_report->sess_rule_failure_code); + ogs_free(session_rule_report); +} + +cJSON *OpenAPI_session_rule_report_convertToJSON(OpenAPI_session_rule_report_t *session_rule_report) +{ + cJSON *item = NULL; + + if (session_rule_report == NULL) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [SessionRuleReport]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!session_rule_report->rule_ids) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [rule_ids]"); + goto end; + } + cJSON *rule_ids = cJSON_AddArrayToObject(item, "ruleIds"); + if (rule_ids == NULL) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [rule_ids]"); + goto end; + } + + OpenAPI_lnode_t *rule_ids_node; + OpenAPI_list_for_each(session_rule_report->rule_ids, rule_ids_node) { + if (cJSON_AddStringToObject(rule_ids, "", (char*)rule_ids_node->data) == NULL) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [rule_ids]"); + goto end; + } + } + + if (!session_rule_report->rule_status) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [rule_status]"); + goto end; + } + cJSON *rule_status_local_JSON = OpenAPI_rule_status_convertToJSON(session_rule_report->rule_status); + if (rule_status_local_JSON == NULL) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [rule_status]"); + goto end; + } + cJSON_AddItemToObject(item, "ruleStatus", rule_status_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [rule_status]"); + goto end; + } + + if (session_rule_report->sess_rule_failure_code) { + cJSON *sess_rule_failure_code_local_JSON = OpenAPI_session_rule_failure_code_convertToJSON(session_rule_report->sess_rule_failure_code); + if (sess_rule_failure_code_local_JSON == NULL) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [sess_rule_failure_code]"); + goto end; + } + cJSON_AddItemToObject(item, "sessRuleFailureCode", sess_rule_failure_code_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed [sess_rule_failure_code]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_session_rule_report_t *OpenAPI_session_rule_report_parseFromJSON(cJSON *session_rule_reportJSON) +{ + OpenAPI_session_rule_report_t *session_rule_report_local_var = NULL; + cJSON *rule_ids = cJSON_GetObjectItemCaseSensitive(session_rule_reportJSON, "ruleIds"); + if (!rule_ids) { + ogs_error("OpenAPI_session_rule_report_parseFromJSON() failed [rule_ids]"); + goto end; + } + + OpenAPI_list_t *rule_idsList; + + cJSON *rule_ids_local; + if (!cJSON_IsArray(rule_ids)) { + ogs_error("OpenAPI_session_rule_report_parseFromJSON() failed [rule_ids]"); + goto end; + } + rule_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rule_ids_local, rule_ids) { + if (!cJSON_IsString(rule_ids_local)) { + ogs_error("OpenAPI_session_rule_report_parseFromJSON() failed [rule_ids]"); + goto end; + } + OpenAPI_list_add(rule_idsList, ogs_strdup(rule_ids_local->valuestring)); + } + + cJSON *rule_status = cJSON_GetObjectItemCaseSensitive(session_rule_reportJSON, "ruleStatus"); + if (!rule_status) { + ogs_error("OpenAPI_session_rule_report_parseFromJSON() failed [rule_status]"); + goto end; + } + + OpenAPI_rule_status_t *rule_status_local_nonprim = NULL; + + rule_status_local_nonprim = OpenAPI_rule_status_parseFromJSON(rule_status); + + cJSON *sess_rule_failure_code = cJSON_GetObjectItemCaseSensitive(session_rule_reportJSON, "sessRuleFailureCode"); + + OpenAPI_session_rule_failure_code_t *sess_rule_failure_code_local_nonprim = NULL; + if (sess_rule_failure_code) { + sess_rule_failure_code_local_nonprim = OpenAPI_session_rule_failure_code_parseFromJSON(sess_rule_failure_code); + } + + session_rule_report_local_var = OpenAPI_session_rule_report_create ( + rule_idsList, + rule_status_local_nonprim, + sess_rule_failure_code ? sess_rule_failure_code_local_nonprim : NULL + ); + + return session_rule_report_local_var; +end: + return NULL; +} + +OpenAPI_session_rule_report_t *OpenAPI_session_rule_report_copy(OpenAPI_session_rule_report_t *dst, OpenAPI_session_rule_report_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_session_rule_report_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_session_rule_report_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_session_rule_report_free(dst); + dst = OpenAPI_session_rule_report_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/session_rule_report.h b/lib/sbi/openapi/model/session_rule_report.h new file mode 100644 index 000000000..80f7a9c25 --- /dev/null +++ b/lib/sbi/openapi/model/session_rule_report.h @@ -0,0 +1,44 @@ +/* + * session_rule_report.h + * + * + */ + +#ifndef _OpenAPI_session_rule_report_H_ +#define _OpenAPI_session_rule_report_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "rule_status.h" +#include "session_rule_failure_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_session_rule_report_s OpenAPI_session_rule_report_t; +typedef struct OpenAPI_session_rule_report_s { + OpenAPI_list_t *rule_ids; + struct OpenAPI_rule_status_s *rule_status; + struct OpenAPI_session_rule_failure_code_s *sess_rule_failure_code; +} OpenAPI_session_rule_report_t; + +OpenAPI_session_rule_report_t *OpenAPI_session_rule_report_create( + OpenAPI_list_t *rule_ids, + OpenAPI_rule_status_t *rule_status, + OpenAPI_session_rule_failure_code_t *sess_rule_failure_code + ); +void OpenAPI_session_rule_report_free(OpenAPI_session_rule_report_t *session_rule_report); +OpenAPI_session_rule_report_t *OpenAPI_session_rule_report_parseFromJSON(cJSON *session_rule_reportJSON); +cJSON *OpenAPI_session_rule_report_convertToJSON(OpenAPI_session_rule_report_t *session_rule_report); +OpenAPI_session_rule_report_t *OpenAPI_session_rule_report_copy(OpenAPI_session_rule_report_t *dst, OpenAPI_session_rule_report_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_session_rule_report_H_ */ + diff --git a/lib/sbi/openapi/model/sm_context_create_data.c b/lib/sbi/openapi/model/sm_context_create_data.c index 58bf21ba3..8a33d36ac 100644 --- a/lib/sbi/openapi/model/sm_context_create_data.c +++ b/lib/sbi/openapi/model/sm_context_create_data.c @@ -22,7 +22,7 @@ OpenAPI_sm_context_create_data_t *OpenAPI_sm_context_create_data_create( OpenAPI_access_type_e an_type, OpenAPI_access_type_e additional_an_type, OpenAPI_rat_type_e rat_type, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, OpenAPI_user_location_t *ue_location, char *ue_time_zone, OpenAPI_user_location_t *add_ue_location, @@ -164,7 +164,6 @@ void OpenAPI_sm_context_create_data_free(OpenAPI_sm_context_create_data_t *sm_co ogs_free(sm_context_create_data->service_name); OpenAPI_plmn_id_nid_free(sm_context_create_data->serving_network); OpenAPI_ref_to_binary_data_free(sm_context_create_data->n1_sm_msg); - OpenAPI_presence_state_free(sm_context_create_data->presence_in_ladn); OpenAPI_user_location_free(sm_context_create_data->ue_location); ogs_free(sm_context_create_data->ue_time_zone); OpenAPI_user_location_free(sm_context_create_data->add_ue_location); @@ -378,13 +377,7 @@ cJSON *OpenAPI_sm_context_create_data_convertToJSON(OpenAPI_sm_context_create_da } if (sm_context_create_data->presence_in_ladn) { - cJSON *presence_in_ladn_local_JSON = OpenAPI_presence_state_convertToJSON(sm_context_create_data->presence_in_ladn); - if (presence_in_ladn_local_JSON == NULL) { - ogs_error("OpenAPI_sm_context_create_data_convertToJSON() failed [presence_in_ladn]"); - goto end; - } - cJSON_AddItemToObject(item, "presenceInLadn", presence_in_ladn_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "presenceInLadn", OpenAPI_presence_state_ToString(sm_context_create_data->presence_in_ladn)) == NULL) { ogs_error("OpenAPI_sm_context_create_data_convertToJSON() failed [presence_in_ladn]"); goto end; } @@ -1009,9 +1002,13 @@ OpenAPI_sm_context_create_data_t *OpenAPI_sm_context_create_data_parseFromJSON(c cJSON *presence_in_ladn = cJSON_GetObjectItemCaseSensitive(sm_context_create_dataJSON, "presenceInLadn"); - OpenAPI_presence_state_t *presence_in_ladn_local_nonprim = NULL; + OpenAPI_presence_state_e presence_in_ladnVariable; if (presence_in_ladn) { - presence_in_ladn_local_nonprim = OpenAPI_presence_state_parseFromJSON(presence_in_ladn); + if (!cJSON_IsString(presence_in_ladn)) { + ogs_error("OpenAPI_sm_context_create_data_parseFromJSON() failed [presence_in_ladn]"); + goto end; + } + presence_in_ladnVariable = OpenAPI_presence_state_FromString(presence_in_ladn->valuestring); } cJSON *ue_location = cJSON_GetObjectItemCaseSensitive(sm_context_create_dataJSON, "ueLocation"); @@ -1502,7 +1499,7 @@ OpenAPI_sm_context_create_data_t *OpenAPI_sm_context_create_data_parseFromJSON(c an_typeVariable, additional_an_type ? additional_an_typeVariable : 0, rat_type ? rat_typeVariable : 0, - presence_in_ladn ? presence_in_ladn_local_nonprim : NULL, + presence_in_ladn ? presence_in_ladnVariable : 0, ue_location ? ue_location_local_nonprim : NULL, ue_time_zone ? ogs_strdup(ue_time_zone->valuestring) : NULL, add_ue_location ? add_ue_location_local_nonprim : NULL, diff --git a/lib/sbi/openapi/model/sm_context_create_data.h b/lib/sbi/openapi/model/sm_context_create_data.h index db7482bf9..5a2abaf28 100644 --- a/lib/sbi/openapi/model/sm_context_create_data.h +++ b/lib/sbi/openapi/model/sm_context_create_data.h @@ -59,7 +59,7 @@ typedef struct OpenAPI_sm_context_create_data_s { OpenAPI_access_type_e an_type; OpenAPI_access_type_e additional_an_type; OpenAPI_rat_type_e rat_type; - struct OpenAPI_presence_state_s *presence_in_ladn; + OpenAPI_presence_state_e presence_in_ladn; struct OpenAPI_user_location_s *ue_location; char *ue_time_zone; struct OpenAPI_user_location_s *add_ue_location; @@ -128,7 +128,7 @@ OpenAPI_sm_context_create_data_t *OpenAPI_sm_context_create_data_create( OpenAPI_access_type_e an_type, OpenAPI_access_type_e additional_an_type, OpenAPI_rat_type_e rat_type, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, OpenAPI_user_location_t *ue_location, char *ue_time_zone, OpenAPI_user_location_t *add_ue_location, diff --git a/lib/sbi/openapi/model/sm_context_update_data.c b/lib/sbi/openapi/model/sm_context_update_data.c index 69011a844..b451a1940 100644 --- a/lib/sbi/openapi/model/sm_context_update_data.c +++ b/lib/sbi/openapi/model/sm_context_update_data.c @@ -13,7 +13,7 @@ OpenAPI_sm_context_update_data_t *OpenAPI_sm_context_update_data_create( OpenAPI_access_type_e an_type, OpenAPI_access_type_e additional_an_type, OpenAPI_rat_type_e rat_type, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, OpenAPI_user_location_t *ue_location, char *ue_time_zone, OpenAPI_user_location_t *add_ue_location, @@ -127,7 +127,6 @@ void OpenAPI_sm_context_update_data_free(OpenAPI_sm_context_update_data_t *sm_co OpenAPI_backup_amf_info_free(node->data); } OpenAPI_list_free(sm_context_update_data->backup_amf_info); - OpenAPI_presence_state_free(sm_context_update_data->presence_in_ladn); OpenAPI_user_location_free(sm_context_update_data->ue_location); ogs_free(sm_context_update_data->ue_time_zone); OpenAPI_user_location_free(sm_context_update_data->add_ue_location); @@ -261,13 +260,7 @@ cJSON *OpenAPI_sm_context_update_data_convertToJSON(OpenAPI_sm_context_update_da } if (sm_context_update_data->presence_in_ladn) { - cJSON *presence_in_ladn_local_JSON = OpenAPI_presence_state_convertToJSON(sm_context_update_data->presence_in_ladn); - if (presence_in_ladn_local_JSON == NULL) { - ogs_error("OpenAPI_sm_context_update_data_convertToJSON() failed [presence_in_ladn]"); - goto end; - } - cJSON_AddItemToObject(item, "presenceInLadn", presence_in_ladn_local_JSON); - if (item->child == NULL) { + if (cJSON_AddStringToObject(item, "presenceInLadn", OpenAPI_presence_state_ToString(sm_context_update_data->presence_in_ladn)) == NULL) { ogs_error("OpenAPI_sm_context_update_data_convertToJSON() failed [presence_in_ladn]"); goto end; } @@ -787,9 +780,13 @@ OpenAPI_sm_context_update_data_t *OpenAPI_sm_context_update_data_parseFromJSON(c cJSON *presence_in_ladn = cJSON_GetObjectItemCaseSensitive(sm_context_update_dataJSON, "presenceInLadn"); - OpenAPI_presence_state_t *presence_in_ladn_local_nonprim = NULL; + OpenAPI_presence_state_e presence_in_ladnVariable; if (presence_in_ladn) { - presence_in_ladn_local_nonprim = OpenAPI_presence_state_parseFromJSON(presence_in_ladn); + if (!cJSON_IsString(presence_in_ladn)) { + ogs_error("OpenAPI_sm_context_update_data_parseFromJSON() failed [presence_in_ladn]"); + goto end; + } + presence_in_ladnVariable = OpenAPI_presence_state_FromString(presence_in_ladn->valuestring); } cJSON *ue_location = cJSON_GetObjectItemCaseSensitive(sm_context_update_dataJSON, "ueLocation"); @@ -1208,7 +1205,7 @@ OpenAPI_sm_context_update_data_t *OpenAPI_sm_context_update_data_parseFromJSON(c an_type ? an_typeVariable : 0, additional_an_type ? additional_an_typeVariable : 0, rat_type ? rat_typeVariable : 0, - presence_in_ladn ? presence_in_ladn_local_nonprim : NULL, + presence_in_ladn ? presence_in_ladnVariable : 0, ue_location ? ue_location_local_nonprim : NULL, ue_time_zone ? ogs_strdup(ue_time_zone->valuestring) : NULL, add_ue_location ? add_ue_location_local_nonprim : NULL, diff --git a/lib/sbi/openapi/model/sm_context_update_data.h b/lib/sbi/openapi/model/sm_context_update_data.h index 7f3a1665f..d89e32ce5 100644 --- a/lib/sbi/openapi/model/sm_context_update_data.h +++ b/lib/sbi/openapi/model/sm_context_update_data.h @@ -51,7 +51,7 @@ typedef struct OpenAPI_sm_context_update_data_s { OpenAPI_access_type_e an_type; OpenAPI_access_type_e additional_an_type; OpenAPI_rat_type_e rat_type; - struct OpenAPI_presence_state_s *presence_in_ladn; + OpenAPI_presence_state_e presence_in_ladn; struct OpenAPI_user_location_s *ue_location; char *ue_time_zone; struct OpenAPI_user_location_s *add_ue_location; @@ -103,7 +103,7 @@ OpenAPI_sm_context_update_data_t *OpenAPI_sm_context_update_data_create( OpenAPI_access_type_e an_type, OpenAPI_access_type_e additional_an_type, OpenAPI_rat_type_e rat_type, - OpenAPI_presence_state_t *presence_in_ladn, + OpenAPI_presence_state_e presence_in_ladn, OpenAPI_user_location_t *ue_location, char *ue_time_zone, OpenAPI_user_location_t *add_ue_location, diff --git a/lib/sbi/openapi/model/sm_policy_association_release_cause.c b/lib/sbi/openapi/model/sm_policy_association_release_cause.c new file mode 100644 index 000000000..e13fa88fd --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_association_release_cause.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "sm_policy_association_release_cause.h" + +OpenAPI_sm_policy_association_release_cause_t *OpenAPI_sm_policy_association_release_cause_create( + ) +{ + OpenAPI_sm_policy_association_release_cause_t *sm_policy_association_release_cause_local_var = OpenAPI_malloc(sizeof(OpenAPI_sm_policy_association_release_cause_t)); + if (!sm_policy_association_release_cause_local_var) { + return NULL; + } + + return sm_policy_association_release_cause_local_var; +} + +void OpenAPI_sm_policy_association_release_cause_free(OpenAPI_sm_policy_association_release_cause_t *sm_policy_association_release_cause) +{ + if (NULL == sm_policy_association_release_cause) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(sm_policy_association_release_cause); +} + +cJSON *OpenAPI_sm_policy_association_release_cause_convertToJSON(OpenAPI_sm_policy_association_release_cause_t *sm_policy_association_release_cause) +{ + cJSON *item = NULL; + + if (sm_policy_association_release_cause == NULL) { + ogs_error("OpenAPI_sm_policy_association_release_cause_convertToJSON() failed [SmPolicyAssociationReleaseCause]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_sm_policy_association_release_cause_t *OpenAPI_sm_policy_association_release_cause_parseFromJSON(cJSON *sm_policy_association_release_causeJSON) +{ + OpenAPI_sm_policy_association_release_cause_t *sm_policy_association_release_cause_local_var = NULL; + sm_policy_association_release_cause_local_var = OpenAPI_sm_policy_association_release_cause_create ( + ); + + return sm_policy_association_release_cause_local_var; +end: + return NULL; +} + +OpenAPI_sm_policy_association_release_cause_t *OpenAPI_sm_policy_association_release_cause_copy(OpenAPI_sm_policy_association_release_cause_t *dst, OpenAPI_sm_policy_association_release_cause_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_sm_policy_association_release_cause_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_sm_policy_association_release_cause_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_sm_policy_association_release_cause_free(dst); + dst = OpenAPI_sm_policy_association_release_cause_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/sm_policy_association_release_cause.h b/lib/sbi/openapi/model/sm_policy_association_release_cause.h new file mode 100644 index 000000000..8ba77e8da --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_association_release_cause.h @@ -0,0 +1,36 @@ +/* + * sm_policy_association_release_cause.h + * + * + */ + +#ifndef _OpenAPI_sm_policy_association_release_cause_H_ +#define _OpenAPI_sm_policy_association_release_cause_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_sm_policy_association_release_cause_s OpenAPI_sm_policy_association_release_cause_t; +typedef struct OpenAPI_sm_policy_association_release_cause_s { +} OpenAPI_sm_policy_association_release_cause_t; + +OpenAPI_sm_policy_association_release_cause_t *OpenAPI_sm_policy_association_release_cause_create( + ); +void OpenAPI_sm_policy_association_release_cause_free(OpenAPI_sm_policy_association_release_cause_t *sm_policy_association_release_cause); +OpenAPI_sm_policy_association_release_cause_t *OpenAPI_sm_policy_association_release_cause_parseFromJSON(cJSON *sm_policy_association_release_causeJSON); +cJSON *OpenAPI_sm_policy_association_release_cause_convertToJSON(OpenAPI_sm_policy_association_release_cause_t *sm_policy_association_release_cause); +OpenAPI_sm_policy_association_release_cause_t *OpenAPI_sm_policy_association_release_cause_copy(OpenAPI_sm_policy_association_release_cause_t *dst, OpenAPI_sm_policy_association_release_cause_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_sm_policy_association_release_cause_H_ */ + diff --git a/lib/sbi/openapi/model/sm_policy_context_data.c b/lib/sbi/openapi/model/sm_policy_context_data.c new file mode 100644 index 000000000..0804b6645 --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_context_data.c @@ -0,0 +1,948 @@ + +#include +#include +#include +#include "sm_policy_context_data.h" + +OpenAPI_sm_policy_context_data_t *OpenAPI_sm_policy_context_data_create( + OpenAPI_acc_net_ch_id_t *acc_net_ch_id, + OpenAPI_acc_net_charging_address_t *charg_entity_addr, + char *gpsi, + char *supi, + OpenAPI_list_t *inter_grp_ids, + int pdu_session_id, + OpenAPI_pdu_session_type_e pdu_session_type, + char *chargingcharacteristics, + char *dnn, + OpenAPI_dnn_selection_mode_e dnn_sel_mode, + char *notification_uri, + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type, + OpenAPI_additional_access_info_t *add_access_info, + OpenAPI_plmn_id_nid_t *serving_network, + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone, + char *pei, + char *ipv4_address, + char *ipv6_address_prefix, + char *ip_domain, + OpenAPI_ambr_t *subs_sess_ambr, + char *auth_prof_index, + OpenAPI_subscribed_default_qos_t *subs_def_qos, + int num_of_pack_filter, + int online, + int offline, + int _3gpp_ps_data_off_status, + int ref_qos_indication, + OpenAPI_trace_data_t *trace_req, + OpenAPI_snssai_t *slice_info, + OpenAPI_qos_flow_usage_t *qos_flow_usage, + OpenAPI_serving_nf_identity_t *serv_nf_id, + char *supp_feat, + char *smf_id, + char *recovery_time, + OpenAPI_ma_pdu_indication_t *ma_pdu_ind, + OpenAPI_atsss_capability_t *atsss_capab + ) +{ + OpenAPI_sm_policy_context_data_t *sm_policy_context_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_sm_policy_context_data_t)); + if (!sm_policy_context_data_local_var) { + return NULL; + } + sm_policy_context_data_local_var->acc_net_ch_id = acc_net_ch_id; + sm_policy_context_data_local_var->charg_entity_addr = charg_entity_addr; + sm_policy_context_data_local_var->gpsi = gpsi; + sm_policy_context_data_local_var->supi = supi; + sm_policy_context_data_local_var->inter_grp_ids = inter_grp_ids; + sm_policy_context_data_local_var->pdu_session_id = pdu_session_id; + sm_policy_context_data_local_var->pdu_session_type = pdu_session_type; + sm_policy_context_data_local_var->chargingcharacteristics = chargingcharacteristics; + sm_policy_context_data_local_var->dnn = dnn; + sm_policy_context_data_local_var->dnn_sel_mode = dnn_sel_mode; + sm_policy_context_data_local_var->notification_uri = notification_uri; + sm_policy_context_data_local_var->access_type = access_type; + sm_policy_context_data_local_var->rat_type = rat_type; + sm_policy_context_data_local_var->add_access_info = add_access_info; + sm_policy_context_data_local_var->serving_network = serving_network; + sm_policy_context_data_local_var->user_location_info = user_location_info; + sm_policy_context_data_local_var->ue_time_zone = ue_time_zone; + sm_policy_context_data_local_var->pei = pei; + sm_policy_context_data_local_var->ipv4_address = ipv4_address; + sm_policy_context_data_local_var->ipv6_address_prefix = ipv6_address_prefix; + sm_policy_context_data_local_var->ip_domain = ip_domain; + sm_policy_context_data_local_var->subs_sess_ambr = subs_sess_ambr; + sm_policy_context_data_local_var->auth_prof_index = auth_prof_index; + sm_policy_context_data_local_var->subs_def_qos = subs_def_qos; + sm_policy_context_data_local_var->num_of_pack_filter = num_of_pack_filter; + sm_policy_context_data_local_var->online = online; + sm_policy_context_data_local_var->offline = offline; + sm_policy_context_data_local_var->_3gpp_ps_data_off_status = _3gpp_ps_data_off_status; + sm_policy_context_data_local_var->ref_qos_indication = ref_qos_indication; + sm_policy_context_data_local_var->trace_req = trace_req; + sm_policy_context_data_local_var->slice_info = slice_info; + sm_policy_context_data_local_var->qos_flow_usage = qos_flow_usage; + sm_policy_context_data_local_var->serv_nf_id = serv_nf_id; + sm_policy_context_data_local_var->supp_feat = supp_feat; + sm_policy_context_data_local_var->smf_id = smf_id; + sm_policy_context_data_local_var->recovery_time = recovery_time; + sm_policy_context_data_local_var->ma_pdu_ind = ma_pdu_ind; + sm_policy_context_data_local_var->atsss_capab = atsss_capab; + + return sm_policy_context_data_local_var; +} + +void OpenAPI_sm_policy_context_data_free(OpenAPI_sm_policy_context_data_t *sm_policy_context_data) +{ + if (NULL == sm_policy_context_data) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_acc_net_ch_id_free(sm_policy_context_data->acc_net_ch_id); + OpenAPI_acc_net_charging_address_free(sm_policy_context_data->charg_entity_addr); + ogs_free(sm_policy_context_data->gpsi); + ogs_free(sm_policy_context_data->supi); + OpenAPI_list_for_each(sm_policy_context_data->inter_grp_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(sm_policy_context_data->inter_grp_ids); + ogs_free(sm_policy_context_data->chargingcharacteristics); + ogs_free(sm_policy_context_data->dnn); + ogs_free(sm_policy_context_data->notification_uri); + OpenAPI_additional_access_info_free(sm_policy_context_data->add_access_info); + OpenAPI_plmn_id_nid_free(sm_policy_context_data->serving_network); + OpenAPI_user_location_free(sm_policy_context_data->user_location_info); + ogs_free(sm_policy_context_data->ue_time_zone); + ogs_free(sm_policy_context_data->pei); + ogs_free(sm_policy_context_data->ipv4_address); + ogs_free(sm_policy_context_data->ipv6_address_prefix); + ogs_free(sm_policy_context_data->ip_domain); + OpenAPI_ambr_free(sm_policy_context_data->subs_sess_ambr); + ogs_free(sm_policy_context_data->auth_prof_index); + OpenAPI_subscribed_default_qos_free(sm_policy_context_data->subs_def_qos); + OpenAPI_trace_data_free(sm_policy_context_data->trace_req); + OpenAPI_snssai_free(sm_policy_context_data->slice_info); + OpenAPI_qos_flow_usage_free(sm_policy_context_data->qos_flow_usage); + OpenAPI_serving_nf_identity_free(sm_policy_context_data->serv_nf_id); + ogs_free(sm_policy_context_data->supp_feat); + ogs_free(sm_policy_context_data->smf_id); + ogs_free(sm_policy_context_data->recovery_time); + OpenAPI_ma_pdu_indication_free(sm_policy_context_data->ma_pdu_ind); + OpenAPI_atsss_capability_free(sm_policy_context_data->atsss_capab); + ogs_free(sm_policy_context_data); +} + +cJSON *OpenAPI_sm_policy_context_data_convertToJSON(OpenAPI_sm_policy_context_data_t *sm_policy_context_data) +{ + cJSON *item = NULL; + + if (sm_policy_context_data == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [SmPolicyContextData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (sm_policy_context_data->acc_net_ch_id) { + cJSON *acc_net_ch_id_local_JSON = OpenAPI_acc_net_ch_id_convertToJSON(sm_policy_context_data->acc_net_ch_id); + if (acc_net_ch_id_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [acc_net_ch_id]"); + goto end; + } + cJSON_AddItemToObject(item, "accNetChId", acc_net_ch_id_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [acc_net_ch_id]"); + goto end; + } + } + + if (sm_policy_context_data->charg_entity_addr) { + cJSON *charg_entity_addr_local_JSON = OpenAPI_acc_net_charging_address_convertToJSON(sm_policy_context_data->charg_entity_addr); + if (charg_entity_addr_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [charg_entity_addr]"); + goto end; + } + cJSON_AddItemToObject(item, "chargEntityAddr", charg_entity_addr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [charg_entity_addr]"); + goto end; + } + } + + if (sm_policy_context_data->gpsi) { + if (cJSON_AddStringToObject(item, "gpsi", sm_policy_context_data->gpsi) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [gpsi]"); + goto end; + } + } + + if (!sm_policy_context_data->supi) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [supi]"); + goto end; + } + if (cJSON_AddStringToObject(item, "supi", sm_policy_context_data->supi) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [supi]"); + goto end; + } + + if (sm_policy_context_data->inter_grp_ids) { + cJSON *inter_grp_ids = cJSON_AddArrayToObject(item, "interGrpIds"); + if (inter_grp_ids == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [inter_grp_ids]"); + goto end; + } + + OpenAPI_lnode_t *inter_grp_ids_node; + OpenAPI_list_for_each(sm_policy_context_data->inter_grp_ids, inter_grp_ids_node) { + if (cJSON_AddStringToObject(inter_grp_ids, "", (char*)inter_grp_ids_node->data) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [inter_grp_ids]"); + goto end; + } + } + } + + if (!sm_policy_context_data->pdu_session_id) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [pdu_session_id]"); + goto end; + } + if (cJSON_AddNumberToObject(item, "pduSessionId", sm_policy_context_data->pdu_session_id) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [pdu_session_id]"); + goto end; + } + + if (!sm_policy_context_data->pdu_session_type) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [pdu_session_type]"); + goto end; + } + if (cJSON_AddStringToObject(item, "pduSessionType", OpenAPI_pdu_session_type_ToString(sm_policy_context_data->pdu_session_type)) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [pdu_session_type]"); + goto end; + } + + if (sm_policy_context_data->chargingcharacteristics) { + if (cJSON_AddStringToObject(item, "chargingcharacteristics", sm_policy_context_data->chargingcharacteristics) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [chargingcharacteristics]"); + goto end; + } + } + + if (!sm_policy_context_data->dnn) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [dnn]"); + goto end; + } + if (cJSON_AddStringToObject(item, "dnn", sm_policy_context_data->dnn) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [dnn]"); + goto end; + } + + if (sm_policy_context_data->dnn_sel_mode) { + if (cJSON_AddStringToObject(item, "dnnSelMode", OpenAPI_dnn_selection_mode_ToString(sm_policy_context_data->dnn_sel_mode)) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [dnn_sel_mode]"); + goto end; + } + } + + if (!sm_policy_context_data->notification_uri) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [notification_uri]"); + goto end; + } + if (cJSON_AddStringToObject(item, "notificationUri", sm_policy_context_data->notification_uri) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [notification_uri]"); + goto end; + } + + if (sm_policy_context_data->access_type) { + if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(sm_policy_context_data->access_type)) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [access_type]"); + goto end; + } + } + + if (sm_policy_context_data->rat_type) { + if (cJSON_AddStringToObject(item, "ratType", OpenAPI_rat_type_ToString(sm_policy_context_data->rat_type)) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [rat_type]"); + goto end; + } + } + + if (sm_policy_context_data->add_access_info) { + cJSON *add_access_info_local_JSON = OpenAPI_additional_access_info_convertToJSON(sm_policy_context_data->add_access_info); + if (add_access_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [add_access_info]"); + goto end; + } + cJSON_AddItemToObject(item, "addAccessInfo", add_access_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [add_access_info]"); + goto end; + } + } + + if (sm_policy_context_data->serving_network) { + cJSON *serving_network_local_JSON = OpenAPI_plmn_id_nid_convertToJSON(sm_policy_context_data->serving_network); + if (serving_network_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [serving_network]"); + goto end; + } + cJSON_AddItemToObject(item, "servingNetwork", serving_network_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [serving_network]"); + goto end; + } + } + + if (sm_policy_context_data->user_location_info) { + cJSON *user_location_info_local_JSON = OpenAPI_user_location_convertToJSON(sm_policy_context_data->user_location_info); + if (user_location_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [user_location_info]"); + goto end; + } + cJSON_AddItemToObject(item, "userLocationInfo", user_location_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [user_location_info]"); + goto end; + } + } + + if (sm_policy_context_data->ue_time_zone) { + if (cJSON_AddStringToObject(item, "ueTimeZone", sm_policy_context_data->ue_time_zone) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [ue_time_zone]"); + goto end; + } + } + + if (sm_policy_context_data->pei) { + if (cJSON_AddStringToObject(item, "pei", sm_policy_context_data->pei) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [pei]"); + goto end; + } + } + + if (sm_policy_context_data->ipv4_address) { + if (cJSON_AddStringToObject(item, "ipv4Address", sm_policy_context_data->ipv4_address) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [ipv4_address]"); + goto end; + } + } + + if (sm_policy_context_data->ipv6_address_prefix) { + if (cJSON_AddStringToObject(item, "ipv6AddressPrefix", sm_policy_context_data->ipv6_address_prefix) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [ipv6_address_prefix]"); + goto end; + } + } + + if (sm_policy_context_data->ip_domain) { + if (cJSON_AddStringToObject(item, "ipDomain", sm_policy_context_data->ip_domain) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [ip_domain]"); + goto end; + } + } + + if (sm_policy_context_data->subs_sess_ambr) { + cJSON *subs_sess_ambr_local_JSON = OpenAPI_ambr_convertToJSON(sm_policy_context_data->subs_sess_ambr); + if (subs_sess_ambr_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [subs_sess_ambr]"); + goto end; + } + cJSON_AddItemToObject(item, "subsSessAmbr", subs_sess_ambr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [subs_sess_ambr]"); + goto end; + } + } + + if (sm_policy_context_data->auth_prof_index) { + if (cJSON_AddStringToObject(item, "authProfIndex", sm_policy_context_data->auth_prof_index) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [auth_prof_index]"); + goto end; + } + } + + if (sm_policy_context_data->subs_def_qos) { + cJSON *subs_def_qos_local_JSON = OpenAPI_subscribed_default_qos_convertToJSON(sm_policy_context_data->subs_def_qos); + if (subs_def_qos_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [subs_def_qos]"); + goto end; + } + cJSON_AddItemToObject(item, "subsDefQos", subs_def_qos_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [subs_def_qos]"); + goto end; + } + } + + if (sm_policy_context_data->num_of_pack_filter) { + if (cJSON_AddNumberToObject(item, "numOfPackFilter", sm_policy_context_data->num_of_pack_filter) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [num_of_pack_filter]"); + goto end; + } + } + + if (sm_policy_context_data->online) { + if (cJSON_AddBoolToObject(item, "online", sm_policy_context_data->online) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [online]"); + goto end; + } + } + + if (sm_policy_context_data->offline) { + if (cJSON_AddBoolToObject(item, "offline", sm_policy_context_data->offline) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [offline]"); + goto end; + } + } + + if (sm_policy_context_data->_3gpp_ps_data_off_status) { + if (cJSON_AddBoolToObject(item, "3gppPsDataOffStatus", sm_policy_context_data->_3gpp_ps_data_off_status) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [_3gpp_ps_data_off_status]"); + goto end; + } + } + + if (sm_policy_context_data->ref_qos_indication) { + if (cJSON_AddBoolToObject(item, "refQosIndication", sm_policy_context_data->ref_qos_indication) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [ref_qos_indication]"); + goto end; + } + } + + if (sm_policy_context_data->trace_req) { + cJSON *trace_req_local_JSON = OpenAPI_trace_data_convertToJSON(sm_policy_context_data->trace_req); + if (trace_req_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [trace_req]"); + goto end; + } + cJSON_AddItemToObject(item, "traceReq", trace_req_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [trace_req]"); + goto end; + } + } + + if (!sm_policy_context_data->slice_info) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [slice_info]"); + goto end; + } + cJSON *slice_info_local_JSON = OpenAPI_snssai_convertToJSON(sm_policy_context_data->slice_info); + if (slice_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [slice_info]"); + goto end; + } + cJSON_AddItemToObject(item, "sliceInfo", slice_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [slice_info]"); + goto end; + } + + if (sm_policy_context_data->qos_flow_usage) { + cJSON *qos_flow_usage_local_JSON = OpenAPI_qos_flow_usage_convertToJSON(sm_policy_context_data->qos_flow_usage); + if (qos_flow_usage_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [qos_flow_usage]"); + goto end; + } + cJSON_AddItemToObject(item, "qosFlowUsage", qos_flow_usage_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [qos_flow_usage]"); + goto end; + } + } + + if (sm_policy_context_data->serv_nf_id) { + cJSON *serv_nf_id_local_JSON = OpenAPI_serving_nf_identity_convertToJSON(sm_policy_context_data->serv_nf_id); + if (serv_nf_id_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [serv_nf_id]"); + goto end; + } + cJSON_AddItemToObject(item, "servNfId", serv_nf_id_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [serv_nf_id]"); + goto end; + } + } + + if (sm_policy_context_data->supp_feat) { + if (cJSON_AddStringToObject(item, "suppFeat", sm_policy_context_data->supp_feat) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [supp_feat]"); + goto end; + } + } + + if (sm_policy_context_data->smf_id) { + if (cJSON_AddStringToObject(item, "smfId", sm_policy_context_data->smf_id) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [smf_id]"); + goto end; + } + } + + if (sm_policy_context_data->recovery_time) { + if (cJSON_AddStringToObject(item, "recoveryTime", sm_policy_context_data->recovery_time) == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [recovery_time]"); + goto end; + } + } + + if (sm_policy_context_data->ma_pdu_ind) { + cJSON *ma_pdu_ind_local_JSON = OpenAPI_ma_pdu_indication_convertToJSON(sm_policy_context_data->ma_pdu_ind); + if (ma_pdu_ind_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [ma_pdu_ind]"); + goto end; + } + cJSON_AddItemToObject(item, "maPduInd", ma_pdu_ind_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [ma_pdu_ind]"); + goto end; + } + } + + if (sm_policy_context_data->atsss_capab) { + cJSON *atsss_capab_local_JSON = OpenAPI_atsss_capability_convertToJSON(sm_policy_context_data->atsss_capab); + if (atsss_capab_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [atsss_capab]"); + goto end; + } + cJSON_AddItemToObject(item, "atsssCapab", atsss_capab_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed [atsss_capab]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_sm_policy_context_data_t *OpenAPI_sm_policy_context_data_parseFromJSON(cJSON *sm_policy_context_dataJSON) +{ + OpenAPI_sm_policy_context_data_t *sm_policy_context_data_local_var = NULL; + cJSON *acc_net_ch_id = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "accNetChId"); + + OpenAPI_acc_net_ch_id_t *acc_net_ch_id_local_nonprim = NULL; + if (acc_net_ch_id) { + acc_net_ch_id_local_nonprim = OpenAPI_acc_net_ch_id_parseFromJSON(acc_net_ch_id); + } + + cJSON *charg_entity_addr = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "chargEntityAddr"); + + OpenAPI_acc_net_charging_address_t *charg_entity_addr_local_nonprim = NULL; + if (charg_entity_addr) { + charg_entity_addr_local_nonprim = OpenAPI_acc_net_charging_address_parseFromJSON(charg_entity_addr); + } + + cJSON *gpsi = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "gpsi"); + + if (gpsi) { + if (!cJSON_IsString(gpsi)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [gpsi]"); + goto end; + } + } + + cJSON *supi = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "supi"); + if (!supi) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [supi]"); + goto end; + } + + + if (!cJSON_IsString(supi)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [supi]"); + goto end; + } + + cJSON *inter_grp_ids = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "interGrpIds"); + + OpenAPI_list_t *inter_grp_idsList; + if (inter_grp_ids) { + cJSON *inter_grp_ids_local; + if (!cJSON_IsArray(inter_grp_ids)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [inter_grp_ids]"); + goto end; + } + inter_grp_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(inter_grp_ids_local, inter_grp_ids) { + if (!cJSON_IsString(inter_grp_ids_local)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [inter_grp_ids]"); + goto end; + } + OpenAPI_list_add(inter_grp_idsList, ogs_strdup(inter_grp_ids_local->valuestring)); + } + } + + cJSON *pdu_session_id = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "pduSessionId"); + if (!pdu_session_id) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [pdu_session_id]"); + goto end; + } + + + if (!cJSON_IsNumber(pdu_session_id)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [pdu_session_id]"); + goto end; + } + + cJSON *pdu_session_type = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "pduSessionType"); + if (!pdu_session_type) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [pdu_session_type]"); + goto end; + } + + OpenAPI_pdu_session_type_e pdu_session_typeVariable; + + if (!cJSON_IsString(pdu_session_type)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [pdu_session_type]"); + goto end; + } + pdu_session_typeVariable = OpenAPI_pdu_session_type_FromString(pdu_session_type->valuestring); + + cJSON *chargingcharacteristics = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "chargingcharacteristics"); + + if (chargingcharacteristics) { + if (!cJSON_IsString(chargingcharacteristics)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [chargingcharacteristics]"); + goto end; + } + } + + cJSON *dnn = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "dnn"); + if (!dnn) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [dnn]"); + goto end; + } + + + if (!cJSON_IsString(dnn)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [dnn]"); + goto end; + } + + cJSON *dnn_sel_mode = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "dnnSelMode"); + + OpenAPI_dnn_selection_mode_e dnn_sel_modeVariable; + if (dnn_sel_mode) { + if (!cJSON_IsString(dnn_sel_mode)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [dnn_sel_mode]"); + goto end; + } + dnn_sel_modeVariable = OpenAPI_dnn_selection_mode_FromString(dnn_sel_mode->valuestring); + } + + cJSON *notification_uri = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "notificationUri"); + if (!notification_uri) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [notification_uri]"); + goto end; + } + + + if (!cJSON_IsString(notification_uri)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [notification_uri]"); + goto end; + } + + cJSON *access_type = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "accessType"); + + OpenAPI_access_type_e access_typeVariable; + if (access_type) { + if (!cJSON_IsString(access_type)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [access_type]"); + goto end; + } + access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring); + } + + cJSON *rat_type = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "ratType"); + + OpenAPI_rat_type_e rat_typeVariable; + if (rat_type) { + if (!cJSON_IsString(rat_type)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [rat_type]"); + goto end; + } + rat_typeVariable = OpenAPI_rat_type_FromString(rat_type->valuestring); + } + + cJSON *add_access_info = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "addAccessInfo"); + + OpenAPI_additional_access_info_t *add_access_info_local_nonprim = NULL; + if (add_access_info) { + add_access_info_local_nonprim = OpenAPI_additional_access_info_parseFromJSON(add_access_info); + } + + cJSON *serving_network = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "servingNetwork"); + + OpenAPI_plmn_id_nid_t *serving_network_local_nonprim = NULL; + if (serving_network) { + serving_network_local_nonprim = OpenAPI_plmn_id_nid_parseFromJSON(serving_network); + } + + cJSON *user_location_info = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "userLocationInfo"); + + OpenAPI_user_location_t *user_location_info_local_nonprim = NULL; + if (user_location_info) { + user_location_info_local_nonprim = OpenAPI_user_location_parseFromJSON(user_location_info); + } + + cJSON *ue_time_zone = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "ueTimeZone"); + + if (ue_time_zone) { + if (!cJSON_IsString(ue_time_zone)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [ue_time_zone]"); + goto end; + } + } + + cJSON *pei = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "pei"); + + if (pei) { + if (!cJSON_IsString(pei)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [pei]"); + goto end; + } + } + + cJSON *ipv4_address = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "ipv4Address"); + + if (ipv4_address) { + if (!cJSON_IsString(ipv4_address)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [ipv4_address]"); + goto end; + } + } + + cJSON *ipv6_address_prefix = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "ipv6AddressPrefix"); + + if (ipv6_address_prefix) { + if (!cJSON_IsString(ipv6_address_prefix)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [ipv6_address_prefix]"); + goto end; + } + } + + cJSON *ip_domain = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "ipDomain"); + + if (ip_domain) { + if (!cJSON_IsString(ip_domain)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [ip_domain]"); + goto end; + } + } + + cJSON *subs_sess_ambr = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "subsSessAmbr"); + + OpenAPI_ambr_t *subs_sess_ambr_local_nonprim = NULL; + if (subs_sess_ambr) { + subs_sess_ambr_local_nonprim = OpenAPI_ambr_parseFromJSON(subs_sess_ambr); + } + + cJSON *auth_prof_index = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "authProfIndex"); + + if (auth_prof_index) { + if (!cJSON_IsString(auth_prof_index)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [auth_prof_index]"); + goto end; + } + } + + cJSON *subs_def_qos = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "subsDefQos"); + + OpenAPI_subscribed_default_qos_t *subs_def_qos_local_nonprim = NULL; + if (subs_def_qos) { + subs_def_qos_local_nonprim = OpenAPI_subscribed_default_qos_parseFromJSON(subs_def_qos); + } + + cJSON *num_of_pack_filter = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "numOfPackFilter"); + + if (num_of_pack_filter) { + if (!cJSON_IsNumber(num_of_pack_filter)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [num_of_pack_filter]"); + goto end; + } + } + + cJSON *online = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "online"); + + if (online) { + if (!cJSON_IsBool(online)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [online]"); + goto end; + } + } + + cJSON *offline = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "offline"); + + if (offline) { + if (!cJSON_IsBool(offline)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [offline]"); + goto end; + } + } + + cJSON *_3gpp_ps_data_off_status = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "3gppPsDataOffStatus"); + + if (_3gpp_ps_data_off_status) { + if (!cJSON_IsBool(_3gpp_ps_data_off_status)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [_3gpp_ps_data_off_status]"); + goto end; + } + } + + cJSON *ref_qos_indication = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "refQosIndication"); + + if (ref_qos_indication) { + if (!cJSON_IsBool(ref_qos_indication)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [ref_qos_indication]"); + goto end; + } + } + + cJSON *trace_req = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "traceReq"); + + OpenAPI_trace_data_t *trace_req_local_nonprim = NULL; + if (trace_req) { + trace_req_local_nonprim = OpenAPI_trace_data_parseFromJSON(trace_req); + } + + cJSON *slice_info = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "sliceInfo"); + if (!slice_info) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [slice_info]"); + goto end; + } + + OpenAPI_snssai_t *slice_info_local_nonprim = NULL; + + slice_info_local_nonprim = OpenAPI_snssai_parseFromJSON(slice_info); + + cJSON *qos_flow_usage = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "qosFlowUsage"); + + OpenAPI_qos_flow_usage_t *qos_flow_usage_local_nonprim = NULL; + if (qos_flow_usage) { + qos_flow_usage_local_nonprim = OpenAPI_qos_flow_usage_parseFromJSON(qos_flow_usage); + } + + cJSON *serv_nf_id = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "servNfId"); + + OpenAPI_serving_nf_identity_t *serv_nf_id_local_nonprim = NULL; + if (serv_nf_id) { + serv_nf_id_local_nonprim = OpenAPI_serving_nf_identity_parseFromJSON(serv_nf_id); + } + + cJSON *supp_feat = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "suppFeat"); + + if (supp_feat) { + if (!cJSON_IsString(supp_feat)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [supp_feat]"); + goto end; + } + } + + cJSON *smf_id = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "smfId"); + + if (smf_id) { + if (!cJSON_IsString(smf_id)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [smf_id]"); + goto end; + } + } + + cJSON *recovery_time = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "recoveryTime"); + + if (recovery_time) { + if (!cJSON_IsString(recovery_time)) { + ogs_error("OpenAPI_sm_policy_context_data_parseFromJSON() failed [recovery_time]"); + goto end; + } + } + + cJSON *ma_pdu_ind = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "maPduInd"); + + OpenAPI_ma_pdu_indication_t *ma_pdu_ind_local_nonprim = NULL; + if (ma_pdu_ind) { + ma_pdu_ind_local_nonprim = OpenAPI_ma_pdu_indication_parseFromJSON(ma_pdu_ind); + } + + cJSON *atsss_capab = cJSON_GetObjectItemCaseSensitive(sm_policy_context_dataJSON, "atsssCapab"); + + OpenAPI_atsss_capability_t *atsss_capab_local_nonprim = NULL; + if (atsss_capab) { + atsss_capab_local_nonprim = OpenAPI_atsss_capability_parseFromJSON(atsss_capab); + } + + sm_policy_context_data_local_var = OpenAPI_sm_policy_context_data_create ( + acc_net_ch_id ? acc_net_ch_id_local_nonprim : NULL, + charg_entity_addr ? charg_entity_addr_local_nonprim : NULL, + gpsi ? ogs_strdup(gpsi->valuestring) : NULL, + ogs_strdup(supi->valuestring), + inter_grp_ids ? inter_grp_idsList : NULL, + pdu_session_id->valuedouble, + pdu_session_typeVariable, + chargingcharacteristics ? ogs_strdup(chargingcharacteristics->valuestring) : NULL, + ogs_strdup(dnn->valuestring), + dnn_sel_mode ? dnn_sel_modeVariable : 0, + ogs_strdup(notification_uri->valuestring), + access_type ? access_typeVariable : 0, + rat_type ? rat_typeVariable : 0, + add_access_info ? add_access_info_local_nonprim : NULL, + serving_network ? serving_network_local_nonprim : NULL, + user_location_info ? user_location_info_local_nonprim : NULL, + ue_time_zone ? ogs_strdup(ue_time_zone->valuestring) : NULL, + pei ? ogs_strdup(pei->valuestring) : NULL, + ipv4_address ? ogs_strdup(ipv4_address->valuestring) : NULL, + ipv6_address_prefix ? ogs_strdup(ipv6_address_prefix->valuestring) : NULL, + ip_domain ? ogs_strdup(ip_domain->valuestring) : NULL, + subs_sess_ambr ? subs_sess_ambr_local_nonprim : NULL, + auth_prof_index ? ogs_strdup(auth_prof_index->valuestring) : NULL, + subs_def_qos ? subs_def_qos_local_nonprim : NULL, + num_of_pack_filter ? num_of_pack_filter->valuedouble : 0, + online ? online->valueint : 0, + offline ? offline->valueint : 0, + _3gpp_ps_data_off_status ? _3gpp_ps_data_off_status->valueint : 0, + ref_qos_indication ? ref_qos_indication->valueint : 0, + trace_req ? trace_req_local_nonprim : NULL, + slice_info_local_nonprim, + qos_flow_usage ? qos_flow_usage_local_nonprim : NULL, + serv_nf_id ? serv_nf_id_local_nonprim : NULL, + supp_feat ? ogs_strdup(supp_feat->valuestring) : NULL, + smf_id ? ogs_strdup(smf_id->valuestring) : NULL, + recovery_time ? ogs_strdup(recovery_time->valuestring) : NULL, + ma_pdu_ind ? ma_pdu_ind_local_nonprim : NULL, + atsss_capab ? atsss_capab_local_nonprim : NULL + ); + + return sm_policy_context_data_local_var; +end: + return NULL; +} + +OpenAPI_sm_policy_context_data_t *OpenAPI_sm_policy_context_data_copy(OpenAPI_sm_policy_context_data_t *dst, OpenAPI_sm_policy_context_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_sm_policy_context_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_sm_policy_context_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_sm_policy_context_data_free(dst); + dst = OpenAPI_sm_policy_context_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/sm_policy_context_data.h b/lib/sbi/openapi/model/sm_policy_context_data.h new file mode 100644 index 000000000..25da1689d --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_context_data.h @@ -0,0 +1,129 @@ +/* + * sm_policy_context_data.h + * + * + */ + +#ifndef _OpenAPI_sm_policy_context_data_H_ +#define _OpenAPI_sm_policy_context_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "acc_net_ch_id.h" +#include "acc_net_charging_address.h" +#include "access_type.h" +#include "additional_access_info.h" +#include "ambr.h" +#include "atsss_capability.h" +#include "dnn_selection_mode.h" +#include "ma_pdu_indication.h" +#include "pdu_session_type.h" +#include "plmn_id_nid.h" +#include "qos_flow_usage.h" +#include "rat_type.h" +#include "serving_nf_identity.h" +#include "snssai.h" +#include "subscribed_default_qos.h" +#include "trace_data.h" +#include "user_location.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_sm_policy_context_data_s OpenAPI_sm_policy_context_data_t; +typedef struct OpenAPI_sm_policy_context_data_s { + struct OpenAPI_acc_net_ch_id_s *acc_net_ch_id; + struct OpenAPI_acc_net_charging_address_s *charg_entity_addr; + char *gpsi; + char *supi; + OpenAPI_list_t *inter_grp_ids; + int pdu_session_id; + OpenAPI_pdu_session_type_e pdu_session_type; + char *chargingcharacteristics; + char *dnn; + OpenAPI_dnn_selection_mode_e dnn_sel_mode; + char *notification_uri; + OpenAPI_access_type_e access_type; + OpenAPI_rat_type_e rat_type; + struct OpenAPI_additional_access_info_s *add_access_info; + struct OpenAPI_plmn_id_nid_s *serving_network; + struct OpenAPI_user_location_s *user_location_info; + char *ue_time_zone; + char *pei; + char *ipv4_address; + char *ipv6_address_prefix; + char *ip_domain; + struct OpenAPI_ambr_s *subs_sess_ambr; + char *auth_prof_index; + struct OpenAPI_subscribed_default_qos_s *subs_def_qos; + int num_of_pack_filter; + int online; + int offline; + int _3gpp_ps_data_off_status; + int ref_qos_indication; + struct OpenAPI_trace_data_s *trace_req; + struct OpenAPI_snssai_s *slice_info; + struct OpenAPI_qos_flow_usage_s *qos_flow_usage; + struct OpenAPI_serving_nf_identity_s *serv_nf_id; + char *supp_feat; + char *smf_id; + char *recovery_time; + struct OpenAPI_ma_pdu_indication_s *ma_pdu_ind; + struct OpenAPI_atsss_capability_s *atsss_capab; +} OpenAPI_sm_policy_context_data_t; + +OpenAPI_sm_policy_context_data_t *OpenAPI_sm_policy_context_data_create( + OpenAPI_acc_net_ch_id_t *acc_net_ch_id, + OpenAPI_acc_net_charging_address_t *charg_entity_addr, + char *gpsi, + char *supi, + OpenAPI_list_t *inter_grp_ids, + int pdu_session_id, + OpenAPI_pdu_session_type_e pdu_session_type, + char *chargingcharacteristics, + char *dnn, + OpenAPI_dnn_selection_mode_e dnn_sel_mode, + char *notification_uri, + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type, + OpenAPI_additional_access_info_t *add_access_info, + OpenAPI_plmn_id_nid_t *serving_network, + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone, + char *pei, + char *ipv4_address, + char *ipv6_address_prefix, + char *ip_domain, + OpenAPI_ambr_t *subs_sess_ambr, + char *auth_prof_index, + OpenAPI_subscribed_default_qos_t *subs_def_qos, + int num_of_pack_filter, + int online, + int offline, + int _3gpp_ps_data_off_status, + int ref_qos_indication, + OpenAPI_trace_data_t *trace_req, + OpenAPI_snssai_t *slice_info, + OpenAPI_qos_flow_usage_t *qos_flow_usage, + OpenAPI_serving_nf_identity_t *serv_nf_id, + char *supp_feat, + char *smf_id, + char *recovery_time, + OpenAPI_ma_pdu_indication_t *ma_pdu_ind, + OpenAPI_atsss_capability_t *atsss_capab + ); +void OpenAPI_sm_policy_context_data_free(OpenAPI_sm_policy_context_data_t *sm_policy_context_data); +OpenAPI_sm_policy_context_data_t *OpenAPI_sm_policy_context_data_parseFromJSON(cJSON *sm_policy_context_dataJSON); +cJSON *OpenAPI_sm_policy_context_data_convertToJSON(OpenAPI_sm_policy_context_data_t *sm_policy_context_data); +OpenAPI_sm_policy_context_data_t *OpenAPI_sm_policy_context_data_copy(OpenAPI_sm_policy_context_data_t *dst, OpenAPI_sm_policy_context_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_sm_policy_context_data_H_ */ + diff --git a/lib/sbi/openapi/model/sm_policy_control.c b/lib/sbi/openapi/model/sm_policy_control.c new file mode 100644 index 000000000..04d2e263d --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_control.c @@ -0,0 +1,143 @@ + +#include +#include +#include +#include "sm_policy_control.h" + +OpenAPI_sm_policy_control_t *OpenAPI_sm_policy_control_create( + OpenAPI_sm_policy_context_data_t *context, + OpenAPI_sm_policy_decision_t *policy + ) +{ + OpenAPI_sm_policy_control_t *sm_policy_control_local_var = OpenAPI_malloc(sizeof(OpenAPI_sm_policy_control_t)); + if (!sm_policy_control_local_var) { + return NULL; + } + sm_policy_control_local_var->context = context; + sm_policy_control_local_var->policy = policy; + + return sm_policy_control_local_var; +} + +void OpenAPI_sm_policy_control_free(OpenAPI_sm_policy_control_t *sm_policy_control) +{ + if (NULL == sm_policy_control) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_sm_policy_context_data_free(sm_policy_control->context); + OpenAPI_sm_policy_decision_free(sm_policy_control->policy); + ogs_free(sm_policy_control); +} + +cJSON *OpenAPI_sm_policy_control_convertToJSON(OpenAPI_sm_policy_control_t *sm_policy_control) +{ + cJSON *item = NULL; + + if (sm_policy_control == NULL) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed [SmPolicyControl]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!sm_policy_control->context) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed [context]"); + goto end; + } + cJSON *context_local_JSON = OpenAPI_sm_policy_context_data_convertToJSON(sm_policy_control->context); + if (context_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed [context]"); + goto end; + } + cJSON_AddItemToObject(item, "context", context_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed [context]"); + goto end; + } + + if (!sm_policy_control->policy) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed [policy]"); + goto end; + } + cJSON *policy_local_JSON = OpenAPI_sm_policy_decision_convertToJSON(sm_policy_control->policy); + if (policy_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed [policy]"); + goto end; + } + cJSON_AddItemToObject(item, "policy", policy_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed [policy]"); + goto end; + } + +end: + return item; +} + +OpenAPI_sm_policy_control_t *OpenAPI_sm_policy_control_parseFromJSON(cJSON *sm_policy_controlJSON) +{ + OpenAPI_sm_policy_control_t *sm_policy_control_local_var = NULL; + cJSON *context = cJSON_GetObjectItemCaseSensitive(sm_policy_controlJSON, "context"); + if (!context) { + ogs_error("OpenAPI_sm_policy_control_parseFromJSON() failed [context]"); + goto end; + } + + OpenAPI_sm_policy_context_data_t *context_local_nonprim = NULL; + + context_local_nonprim = OpenAPI_sm_policy_context_data_parseFromJSON(context); + + cJSON *policy = cJSON_GetObjectItemCaseSensitive(sm_policy_controlJSON, "policy"); + if (!policy) { + ogs_error("OpenAPI_sm_policy_control_parseFromJSON() failed [policy]"); + goto end; + } + + OpenAPI_sm_policy_decision_t *policy_local_nonprim = NULL; + + policy_local_nonprim = OpenAPI_sm_policy_decision_parseFromJSON(policy); + + sm_policy_control_local_var = OpenAPI_sm_policy_control_create ( + context_local_nonprim, + policy_local_nonprim + ); + + return sm_policy_control_local_var; +end: + return NULL; +} + +OpenAPI_sm_policy_control_t *OpenAPI_sm_policy_control_copy(OpenAPI_sm_policy_control_t *dst, OpenAPI_sm_policy_control_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_sm_policy_control_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_sm_policy_control_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_sm_policy_control_free(dst); + dst = OpenAPI_sm_policy_control_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/sm_policy_control.h b/lib/sbi/openapi/model/sm_policy_control.h new file mode 100644 index 000000000..2dfccd409 --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_control.h @@ -0,0 +1,42 @@ +/* + * sm_policy_control.h + * + * + */ + +#ifndef _OpenAPI_sm_policy_control_H_ +#define _OpenAPI_sm_policy_control_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "sm_policy_context_data.h" +#include "sm_policy_decision.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_sm_policy_control_s OpenAPI_sm_policy_control_t; +typedef struct OpenAPI_sm_policy_control_s { + struct OpenAPI_sm_policy_context_data_s *context; + struct OpenAPI_sm_policy_decision_s *policy; +} OpenAPI_sm_policy_control_t; + +OpenAPI_sm_policy_control_t *OpenAPI_sm_policy_control_create( + OpenAPI_sm_policy_context_data_t *context, + OpenAPI_sm_policy_decision_t *policy + ); +void OpenAPI_sm_policy_control_free(OpenAPI_sm_policy_control_t *sm_policy_control); +OpenAPI_sm_policy_control_t *OpenAPI_sm_policy_control_parseFromJSON(cJSON *sm_policy_controlJSON); +cJSON *OpenAPI_sm_policy_control_convertToJSON(OpenAPI_sm_policy_control_t *sm_policy_control); +OpenAPI_sm_policy_control_t *OpenAPI_sm_policy_control_copy(OpenAPI_sm_policy_control_t *dst, OpenAPI_sm_policy_control_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_sm_policy_control_H_ */ + diff --git a/lib/sbi/openapi/model/sm_policy_decision.c b/lib/sbi/openapi/model/sm_policy_decision.c new file mode 100644 index 000000000..699927b3b --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_decision.c @@ -0,0 +1,1039 @@ + +#include +#include +#include +#include "sm_policy_decision.h" + +OpenAPI_sm_policy_decision_t *OpenAPI_sm_policy_decision_create( + OpenAPI_list_t* sess_rules, + OpenAPI_list_t* pcc_rules, + int pcscf_rest_indication, + OpenAPI_list_t* qos_decs, + OpenAPI_list_t* chg_decs, + OpenAPI_charging_information_t *charging_info, + OpenAPI_list_t* traff_cont_decs, + OpenAPI_list_t* um_decs, + OpenAPI_list_t* qos_chars, + OpenAPI_list_t* qos_mon_decs, + int reflective_qo_s_timer, + OpenAPI_list_t* conds, + char *revalidation_time, + int offline, + int online, + OpenAPI_list_t *policy_ctrl_req_triggers, + OpenAPI_list_t *last_req_rule_data, + OpenAPI_requested_usage_data_t *last_req_usage_data, + OpenAPI_list_t* pra_infos, + int ipv4_index, + int ipv6_index, + OpenAPI_qos_flow_usage_t *qos_flow_usage, + OpenAPI_sm_policy_association_release_cause_t *rel_cause, + char *supp_feat, + OpenAPI_port_management_container_t *tsn_port_man_cont_dstt, + OpenAPI_list_t *tsn_port_man_cont_nwtts + ) +{ + OpenAPI_sm_policy_decision_t *sm_policy_decision_local_var = OpenAPI_malloc(sizeof(OpenAPI_sm_policy_decision_t)); + if (!sm_policy_decision_local_var) { + return NULL; + } + sm_policy_decision_local_var->sess_rules = sess_rules; + sm_policy_decision_local_var->pcc_rules = pcc_rules; + sm_policy_decision_local_var->pcscf_rest_indication = pcscf_rest_indication; + sm_policy_decision_local_var->qos_decs = qos_decs; + sm_policy_decision_local_var->chg_decs = chg_decs; + sm_policy_decision_local_var->charging_info = charging_info; + sm_policy_decision_local_var->traff_cont_decs = traff_cont_decs; + sm_policy_decision_local_var->um_decs = um_decs; + sm_policy_decision_local_var->qos_chars = qos_chars; + sm_policy_decision_local_var->qos_mon_decs = qos_mon_decs; + sm_policy_decision_local_var->reflective_qo_s_timer = reflective_qo_s_timer; + sm_policy_decision_local_var->conds = conds; + sm_policy_decision_local_var->revalidation_time = revalidation_time; + sm_policy_decision_local_var->offline = offline; + sm_policy_decision_local_var->online = online; + sm_policy_decision_local_var->policy_ctrl_req_triggers = policy_ctrl_req_triggers; + sm_policy_decision_local_var->last_req_rule_data = last_req_rule_data; + sm_policy_decision_local_var->last_req_usage_data = last_req_usage_data; + sm_policy_decision_local_var->pra_infos = pra_infos; + sm_policy_decision_local_var->ipv4_index = ipv4_index; + sm_policy_decision_local_var->ipv6_index = ipv6_index; + sm_policy_decision_local_var->qos_flow_usage = qos_flow_usage; + sm_policy_decision_local_var->rel_cause = rel_cause; + sm_policy_decision_local_var->supp_feat = supp_feat; + sm_policy_decision_local_var->tsn_port_man_cont_dstt = tsn_port_man_cont_dstt; + sm_policy_decision_local_var->tsn_port_man_cont_nwtts = tsn_port_man_cont_nwtts; + + return sm_policy_decision_local_var; +} + +void OpenAPI_sm_policy_decision_free(OpenAPI_sm_policy_decision_t *sm_policy_decision) +{ + if (NULL == sm_policy_decision) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(sm_policy_decision->sess_rules, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_session_rule_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->sess_rules); + OpenAPI_list_for_each(sm_policy_decision->pcc_rules, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_pcc_rule_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->pcc_rules); + OpenAPI_list_for_each(sm_policy_decision->qos_decs, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_qos_data_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->qos_decs); + OpenAPI_list_for_each(sm_policy_decision->chg_decs, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_charging_data_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->chg_decs); + OpenAPI_charging_information_free(sm_policy_decision->charging_info); + OpenAPI_list_for_each(sm_policy_decision->traff_cont_decs, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_traffic_control_data_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->traff_cont_decs); + OpenAPI_list_for_each(sm_policy_decision->um_decs, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_usage_monitoring_data_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->um_decs); + OpenAPI_list_for_each(sm_policy_decision->qos_chars, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_qos_characteristics_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->qos_chars); + OpenAPI_list_for_each(sm_policy_decision->qos_mon_decs, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_qos_monitoring_data_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->qos_mon_decs); + OpenAPI_list_for_each(sm_policy_decision->conds, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_condition_data_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->conds); + ogs_free(sm_policy_decision->revalidation_time); + OpenAPI_list_for_each(sm_policy_decision->policy_ctrl_req_triggers, node) { + OpenAPI_policy_control_request_trigger_free(node->data); + } + OpenAPI_list_free(sm_policy_decision->policy_ctrl_req_triggers); + OpenAPI_list_for_each(sm_policy_decision->last_req_rule_data, node) { + OpenAPI_requested_rule_data_free(node->data); + } + OpenAPI_list_free(sm_policy_decision->last_req_rule_data); + OpenAPI_requested_usage_data_free(sm_policy_decision->last_req_usage_data); + OpenAPI_list_for_each(sm_policy_decision->pra_infos, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_presence_info_rm_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_decision->pra_infos); + OpenAPI_qos_flow_usage_free(sm_policy_decision->qos_flow_usage); + OpenAPI_sm_policy_association_release_cause_free(sm_policy_decision->rel_cause); + ogs_free(sm_policy_decision->supp_feat); + OpenAPI_port_management_container_free(sm_policy_decision->tsn_port_man_cont_dstt); + OpenAPI_list_for_each(sm_policy_decision->tsn_port_man_cont_nwtts, node) { + OpenAPI_port_management_container_free(node->data); + } + OpenAPI_list_free(sm_policy_decision->tsn_port_man_cont_nwtts); + ogs_free(sm_policy_decision); +} + +cJSON *OpenAPI_sm_policy_decision_convertToJSON(OpenAPI_sm_policy_decision_t *sm_policy_decision) +{ + cJSON *item = NULL; + + if (sm_policy_decision == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [SmPolicyDecision]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (sm_policy_decision->sess_rules) { + cJSON *sess_rules = cJSON_AddObjectToObject(item, "sessRules"); + if (sess_rules == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [sess_rules]"); + goto end; + } + cJSON *localMapObject = sess_rules; + OpenAPI_lnode_t *sess_rules_node; + if (sm_policy_decision->sess_rules) { + OpenAPI_list_for_each(sm_policy_decision->sess_rules, sess_rules_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)sess_rules_node->data; + cJSON *itemLocal = OpenAPI_session_rule_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [sess_rules]"); + goto end; + } + cJSON_AddItemToObject(sess_rules, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->pcc_rules) { + cJSON *pcc_rules = cJSON_AddObjectToObject(item, "pccRules"); + if (pcc_rules == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [pcc_rules]"); + goto end; + } + cJSON *localMapObject = pcc_rules; + OpenAPI_lnode_t *pcc_rules_node; + if (sm_policy_decision->pcc_rules) { + OpenAPI_list_for_each(sm_policy_decision->pcc_rules, pcc_rules_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)pcc_rules_node->data; + cJSON *itemLocal = OpenAPI_pcc_rule_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [pcc_rules]"); + goto end; + } + cJSON_AddItemToObject(pcc_rules, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->pcscf_rest_indication) { + if (cJSON_AddBoolToObject(item, "pcscfRestIndication", sm_policy_decision->pcscf_rest_indication) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [pcscf_rest_indication]"); + goto end; + } + } + + if (sm_policy_decision->qos_decs) { + cJSON *qos_decs = cJSON_AddObjectToObject(item, "qosDecs"); + if (qos_decs == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_decs]"); + goto end; + } + cJSON *localMapObject = qos_decs; + OpenAPI_lnode_t *qos_decs_node; + if (sm_policy_decision->qos_decs) { + OpenAPI_list_for_each(sm_policy_decision->qos_decs, qos_decs_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)qos_decs_node->data; + cJSON *itemLocal = OpenAPI_qos_data_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_decs]"); + goto end; + } + cJSON_AddItemToObject(qos_decs, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->chg_decs) { + cJSON *chg_decs = cJSON_AddObjectToObject(item, "chgDecs"); + if (chg_decs == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [chg_decs]"); + goto end; + } + cJSON *localMapObject = chg_decs; + OpenAPI_lnode_t *chg_decs_node; + if (sm_policy_decision->chg_decs) { + OpenAPI_list_for_each(sm_policy_decision->chg_decs, chg_decs_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)chg_decs_node->data; + cJSON *itemLocal = OpenAPI_charging_data_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [chg_decs]"); + goto end; + } + cJSON_AddItemToObject(chg_decs, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->charging_info) { + cJSON *charging_info_local_JSON = OpenAPI_charging_information_convertToJSON(sm_policy_decision->charging_info); + if (charging_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [charging_info]"); + goto end; + } + cJSON_AddItemToObject(item, "chargingInfo", charging_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [charging_info]"); + goto end; + } + } + + if (sm_policy_decision->traff_cont_decs) { + cJSON *traff_cont_decs = cJSON_AddObjectToObject(item, "traffContDecs"); + if (traff_cont_decs == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [traff_cont_decs]"); + goto end; + } + cJSON *localMapObject = traff_cont_decs; + OpenAPI_lnode_t *traff_cont_decs_node; + if (sm_policy_decision->traff_cont_decs) { + OpenAPI_list_for_each(sm_policy_decision->traff_cont_decs, traff_cont_decs_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)traff_cont_decs_node->data; + cJSON *itemLocal = OpenAPI_traffic_control_data_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [traff_cont_decs]"); + goto end; + } + cJSON_AddItemToObject(traff_cont_decs, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->um_decs) { + cJSON *um_decs = cJSON_AddObjectToObject(item, "umDecs"); + if (um_decs == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [um_decs]"); + goto end; + } + cJSON *localMapObject = um_decs; + OpenAPI_lnode_t *um_decs_node; + if (sm_policy_decision->um_decs) { + OpenAPI_list_for_each(sm_policy_decision->um_decs, um_decs_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)um_decs_node->data; + cJSON *itemLocal = OpenAPI_usage_monitoring_data_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [um_decs]"); + goto end; + } + cJSON_AddItemToObject(um_decs, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->qos_chars) { + cJSON *qos_chars = cJSON_AddObjectToObject(item, "qosChars"); + if (qos_chars == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_chars]"); + goto end; + } + cJSON *localMapObject = qos_chars; + OpenAPI_lnode_t *qos_chars_node; + if (sm_policy_decision->qos_chars) { + OpenAPI_list_for_each(sm_policy_decision->qos_chars, qos_chars_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)qos_chars_node->data; + cJSON *itemLocal = OpenAPI_qos_characteristics_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_chars]"); + goto end; + } + cJSON_AddItemToObject(qos_chars, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->qos_mon_decs) { + cJSON *qos_mon_decs = cJSON_AddObjectToObject(item, "qosMonDecs"); + if (qos_mon_decs == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_mon_decs]"); + goto end; + } + cJSON *localMapObject = qos_mon_decs; + OpenAPI_lnode_t *qos_mon_decs_node; + if (sm_policy_decision->qos_mon_decs) { + OpenAPI_list_for_each(sm_policy_decision->qos_mon_decs, qos_mon_decs_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)qos_mon_decs_node->data; + cJSON *itemLocal = OpenAPI_qos_monitoring_data_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_mon_decs]"); + goto end; + } + cJSON_AddItemToObject(qos_mon_decs, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->reflective_qo_s_timer) { + if (cJSON_AddNumberToObject(item, "reflectiveQoSTimer", sm_policy_decision->reflective_qo_s_timer) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [reflective_qo_s_timer]"); + goto end; + } + } + + if (sm_policy_decision->conds) { + cJSON *conds = cJSON_AddObjectToObject(item, "conds"); + if (conds == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [conds]"); + goto end; + } + cJSON *localMapObject = conds; + OpenAPI_lnode_t *conds_node; + if (sm_policy_decision->conds) { + OpenAPI_list_for_each(sm_policy_decision->conds, conds_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)conds_node->data; + cJSON *itemLocal = OpenAPI_condition_data_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [conds]"); + goto end; + } + cJSON_AddItemToObject(conds, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->revalidation_time) { + if (cJSON_AddStringToObject(item, "revalidationTime", sm_policy_decision->revalidation_time) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [revalidation_time]"); + goto end; + } + } + + if (sm_policy_decision->offline) { + if (cJSON_AddBoolToObject(item, "offline", sm_policy_decision->offline) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [offline]"); + goto end; + } + } + + if (sm_policy_decision->online) { + if (cJSON_AddBoolToObject(item, "online", sm_policy_decision->online) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [online]"); + goto end; + } + } + + if (sm_policy_decision->policy_ctrl_req_triggers) { + cJSON *policy_ctrl_req_triggersList = cJSON_AddArrayToObject(item, "policyCtrlReqTriggers"); + if (policy_ctrl_req_triggersList == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [policy_ctrl_req_triggers]"); + goto end; + } + + OpenAPI_lnode_t *policy_ctrl_req_triggers_node; + if (sm_policy_decision->policy_ctrl_req_triggers) { + OpenAPI_list_for_each(sm_policy_decision->policy_ctrl_req_triggers, policy_ctrl_req_triggers_node) { + cJSON *itemLocal = OpenAPI_policy_control_request_trigger_convertToJSON(policy_ctrl_req_triggers_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [policy_ctrl_req_triggers]"); + goto end; + } + cJSON_AddItemToArray(policy_ctrl_req_triggersList, itemLocal); + } + } + } + + if (sm_policy_decision->last_req_rule_data) { + cJSON *last_req_rule_dataList = cJSON_AddArrayToObject(item, "lastReqRuleData"); + if (last_req_rule_dataList == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [last_req_rule_data]"); + goto end; + } + + OpenAPI_lnode_t *last_req_rule_data_node; + if (sm_policy_decision->last_req_rule_data) { + OpenAPI_list_for_each(sm_policy_decision->last_req_rule_data, last_req_rule_data_node) { + cJSON *itemLocal = OpenAPI_requested_rule_data_convertToJSON(last_req_rule_data_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [last_req_rule_data]"); + goto end; + } + cJSON_AddItemToArray(last_req_rule_dataList, itemLocal); + } + } + } + + if (sm_policy_decision->last_req_usage_data) { + cJSON *last_req_usage_data_local_JSON = OpenAPI_requested_usage_data_convertToJSON(sm_policy_decision->last_req_usage_data); + if (last_req_usage_data_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [last_req_usage_data]"); + goto end; + } + cJSON_AddItemToObject(item, "lastReqUsageData", last_req_usage_data_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [last_req_usage_data]"); + goto end; + } + } + + if (sm_policy_decision->pra_infos) { + cJSON *pra_infos = cJSON_AddObjectToObject(item, "praInfos"); + if (pra_infos == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [pra_infos]"); + goto end; + } + cJSON *localMapObject = pra_infos; + OpenAPI_lnode_t *pra_infos_node; + if (sm_policy_decision->pra_infos) { + OpenAPI_list_for_each(sm_policy_decision->pra_infos, pra_infos_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)pra_infos_node->data; + cJSON *itemLocal = OpenAPI_presence_info_rm_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [pra_infos]"); + goto end; + } + cJSON_AddItemToObject(pra_infos, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_decision->ipv4_index) { + if (cJSON_AddNumberToObject(item, "ipv4Index", sm_policy_decision->ipv4_index) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [ipv4_index]"); + goto end; + } + } + + if (sm_policy_decision->ipv6_index) { + if (cJSON_AddNumberToObject(item, "ipv6Index", sm_policy_decision->ipv6_index) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [ipv6_index]"); + goto end; + } + } + + if (sm_policy_decision->qos_flow_usage) { + cJSON *qos_flow_usage_local_JSON = OpenAPI_qos_flow_usage_convertToJSON(sm_policy_decision->qos_flow_usage); + if (qos_flow_usage_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_flow_usage]"); + goto end; + } + cJSON_AddItemToObject(item, "qosFlowUsage", qos_flow_usage_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [qos_flow_usage]"); + goto end; + } + } + + if (sm_policy_decision->rel_cause) { + cJSON *rel_cause_local_JSON = OpenAPI_sm_policy_association_release_cause_convertToJSON(sm_policy_decision->rel_cause); + if (rel_cause_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [rel_cause]"); + goto end; + } + cJSON_AddItemToObject(item, "relCause", rel_cause_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [rel_cause]"); + goto end; + } + } + + if (sm_policy_decision->supp_feat) { + if (cJSON_AddStringToObject(item, "suppFeat", sm_policy_decision->supp_feat) == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [supp_feat]"); + goto end; + } + } + + if (sm_policy_decision->tsn_port_man_cont_dstt) { + cJSON *tsn_port_man_cont_dstt_local_JSON = OpenAPI_port_management_container_convertToJSON(sm_policy_decision->tsn_port_man_cont_dstt); + if (tsn_port_man_cont_dstt_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [tsn_port_man_cont_dstt]"); + goto end; + } + cJSON_AddItemToObject(item, "tsnPortManContDstt", tsn_port_man_cont_dstt_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [tsn_port_man_cont_dstt]"); + goto end; + } + } + + if (sm_policy_decision->tsn_port_man_cont_nwtts) { + cJSON *tsn_port_man_cont_nwttsList = cJSON_AddArrayToObject(item, "tsnPortManContNwtts"); + if (tsn_port_man_cont_nwttsList == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + + OpenAPI_lnode_t *tsn_port_man_cont_nwtts_node; + if (sm_policy_decision->tsn_port_man_cont_nwtts) { + OpenAPI_list_for_each(sm_policy_decision->tsn_port_man_cont_nwtts, tsn_port_man_cont_nwtts_node) { + cJSON *itemLocal = OpenAPI_port_management_container_convertToJSON(tsn_port_man_cont_nwtts_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + cJSON_AddItemToArray(tsn_port_man_cont_nwttsList, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_sm_policy_decision_t *OpenAPI_sm_policy_decision_parseFromJSON(cJSON *sm_policy_decisionJSON) +{ + OpenAPI_sm_policy_decision_t *sm_policy_decision_local_var = NULL; + cJSON *sess_rules = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "sessRules"); + + OpenAPI_list_t *sess_rulesList; + if (sess_rules) { + cJSON *sess_rules_local_map; + if (!cJSON_IsObject(sess_rules)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [sess_rules]"); + goto end; + } + sess_rulesList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(sess_rules_local_map, sess_rules) { + cJSON *localMapObject = sess_rules_local_map; + if (!cJSON_IsObject(sess_rules_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [sess_rules]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_session_rule_parseFromJSON(localMapObject)); + OpenAPI_list_add(sess_rulesList, localMapKeyPair); + } + } + + cJSON *pcc_rules = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "pccRules"); + + OpenAPI_list_t *pcc_rulesList; + if (pcc_rules) { + cJSON *pcc_rules_local_map; + if (!cJSON_IsObject(pcc_rules)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [pcc_rules]"); + goto end; + } + pcc_rulesList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(pcc_rules_local_map, pcc_rules) { + cJSON *localMapObject = pcc_rules_local_map; + if (!cJSON_IsObject(pcc_rules_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [pcc_rules]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_pcc_rule_parseFromJSON(localMapObject)); + OpenAPI_list_add(pcc_rulesList, localMapKeyPair); + } + } + + cJSON *pcscf_rest_indication = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "pcscfRestIndication"); + + if (pcscf_rest_indication) { + if (!cJSON_IsBool(pcscf_rest_indication)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [pcscf_rest_indication]"); + goto end; + } + } + + cJSON *qos_decs = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "qosDecs"); + + OpenAPI_list_t *qos_decsList; + if (qos_decs) { + cJSON *qos_decs_local_map; + if (!cJSON_IsObject(qos_decs)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [qos_decs]"); + goto end; + } + qos_decsList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(qos_decs_local_map, qos_decs) { + cJSON *localMapObject = qos_decs_local_map; + if (!cJSON_IsObject(qos_decs_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [qos_decs]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_qos_data_parseFromJSON(localMapObject)); + OpenAPI_list_add(qos_decsList, localMapKeyPair); + } + } + + cJSON *chg_decs = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "chgDecs"); + + OpenAPI_list_t *chg_decsList; + if (chg_decs) { + cJSON *chg_decs_local_map; + if (!cJSON_IsObject(chg_decs)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [chg_decs]"); + goto end; + } + chg_decsList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(chg_decs_local_map, chg_decs) { + cJSON *localMapObject = chg_decs_local_map; + if (!cJSON_IsObject(chg_decs_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [chg_decs]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_charging_data_parseFromJSON(localMapObject)); + OpenAPI_list_add(chg_decsList, localMapKeyPair); + } + } + + cJSON *charging_info = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "chargingInfo"); + + OpenAPI_charging_information_t *charging_info_local_nonprim = NULL; + if (charging_info) { + charging_info_local_nonprim = OpenAPI_charging_information_parseFromJSON(charging_info); + } + + cJSON *traff_cont_decs = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "traffContDecs"); + + OpenAPI_list_t *traff_cont_decsList; + if (traff_cont_decs) { + cJSON *traff_cont_decs_local_map; + if (!cJSON_IsObject(traff_cont_decs)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [traff_cont_decs]"); + goto end; + } + traff_cont_decsList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(traff_cont_decs_local_map, traff_cont_decs) { + cJSON *localMapObject = traff_cont_decs_local_map; + if (!cJSON_IsObject(traff_cont_decs_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [traff_cont_decs]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_traffic_control_data_parseFromJSON(localMapObject)); + OpenAPI_list_add(traff_cont_decsList, localMapKeyPair); + } + } + + cJSON *um_decs = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "umDecs"); + + OpenAPI_list_t *um_decsList; + if (um_decs) { + cJSON *um_decs_local_map; + if (!cJSON_IsObject(um_decs)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [um_decs]"); + goto end; + } + um_decsList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(um_decs_local_map, um_decs) { + cJSON *localMapObject = um_decs_local_map; + if (!cJSON_IsObject(um_decs_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [um_decs]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_usage_monitoring_data_parseFromJSON(localMapObject)); + OpenAPI_list_add(um_decsList, localMapKeyPair); + } + } + + cJSON *qos_chars = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "qosChars"); + + OpenAPI_list_t *qos_charsList; + if (qos_chars) { + cJSON *qos_chars_local_map; + if (!cJSON_IsObject(qos_chars)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [qos_chars]"); + goto end; + } + qos_charsList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(qos_chars_local_map, qos_chars) { + cJSON *localMapObject = qos_chars_local_map; + if (!cJSON_IsObject(qos_chars_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [qos_chars]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_qos_characteristics_parseFromJSON(localMapObject)); + OpenAPI_list_add(qos_charsList, localMapKeyPair); + } + } + + cJSON *qos_mon_decs = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "qosMonDecs"); + + OpenAPI_list_t *qos_mon_decsList; + if (qos_mon_decs) { + cJSON *qos_mon_decs_local_map; + if (!cJSON_IsObject(qos_mon_decs)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [qos_mon_decs]"); + goto end; + } + qos_mon_decsList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(qos_mon_decs_local_map, qos_mon_decs) { + cJSON *localMapObject = qos_mon_decs_local_map; + if (!cJSON_IsObject(qos_mon_decs_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [qos_mon_decs]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_qos_monitoring_data_parseFromJSON(localMapObject)); + OpenAPI_list_add(qos_mon_decsList, localMapKeyPair); + } + } + + cJSON *reflective_qo_s_timer = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "reflectiveQoSTimer"); + + if (reflective_qo_s_timer) { + if (!cJSON_IsNumber(reflective_qo_s_timer)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [reflective_qo_s_timer]"); + goto end; + } + } + + cJSON *conds = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "conds"); + + OpenAPI_list_t *condsList; + if (conds) { + cJSON *conds_local_map; + if (!cJSON_IsObject(conds)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [conds]"); + goto end; + } + condsList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(conds_local_map, conds) { + cJSON *localMapObject = conds_local_map; + if (!cJSON_IsObject(conds_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [conds]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_condition_data_parseFromJSON(localMapObject)); + OpenAPI_list_add(condsList, localMapKeyPair); + } + } + + cJSON *revalidation_time = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "revalidationTime"); + + if (revalidation_time) { + if (!cJSON_IsString(revalidation_time)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [revalidation_time]"); + goto end; + } + } + + cJSON *offline = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "offline"); + + if (offline) { + if (!cJSON_IsBool(offline)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [offline]"); + goto end; + } + } + + cJSON *online = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "online"); + + if (online) { + if (!cJSON_IsBool(online)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [online]"); + goto end; + } + } + + cJSON *policy_ctrl_req_triggers = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "policyCtrlReqTriggers"); + + OpenAPI_list_t *policy_ctrl_req_triggersList; + if (policy_ctrl_req_triggers) { + cJSON *policy_ctrl_req_triggers_local_nonprimitive; + if (!cJSON_IsArray(policy_ctrl_req_triggers)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [policy_ctrl_req_triggers]"); + goto end; + } + + policy_ctrl_req_triggersList = OpenAPI_list_create(); + + cJSON_ArrayForEach(policy_ctrl_req_triggers_local_nonprimitive, policy_ctrl_req_triggers ) { + if (!cJSON_IsObject(policy_ctrl_req_triggers_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [policy_ctrl_req_triggers]"); + goto end; + } + OpenAPI_policy_control_request_trigger_t *policy_ctrl_req_triggersItem = OpenAPI_policy_control_request_trigger_parseFromJSON(policy_ctrl_req_triggers_local_nonprimitive); + + OpenAPI_list_add(policy_ctrl_req_triggersList, policy_ctrl_req_triggersItem); + } + } + + cJSON *last_req_rule_data = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "lastReqRuleData"); + + OpenAPI_list_t *last_req_rule_dataList; + if (last_req_rule_data) { + cJSON *last_req_rule_data_local_nonprimitive; + if (!cJSON_IsArray(last_req_rule_data)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [last_req_rule_data]"); + goto end; + } + + last_req_rule_dataList = OpenAPI_list_create(); + + cJSON_ArrayForEach(last_req_rule_data_local_nonprimitive, last_req_rule_data ) { + if (!cJSON_IsObject(last_req_rule_data_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [last_req_rule_data]"); + goto end; + } + OpenAPI_requested_rule_data_t *last_req_rule_dataItem = OpenAPI_requested_rule_data_parseFromJSON(last_req_rule_data_local_nonprimitive); + + OpenAPI_list_add(last_req_rule_dataList, last_req_rule_dataItem); + } + } + + cJSON *last_req_usage_data = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "lastReqUsageData"); + + OpenAPI_requested_usage_data_t *last_req_usage_data_local_nonprim = NULL; + if (last_req_usage_data) { + last_req_usage_data_local_nonprim = OpenAPI_requested_usage_data_parseFromJSON(last_req_usage_data); + } + + cJSON *pra_infos = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "praInfos"); + + OpenAPI_list_t *pra_infosList; + if (pra_infos) { + cJSON *pra_infos_local_map; + if (!cJSON_IsObject(pra_infos)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [pra_infos]"); + goto end; + } + pra_infosList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(pra_infos_local_map, pra_infos) { + cJSON *localMapObject = pra_infos_local_map; + if (!cJSON_IsObject(pra_infos_local_map)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [pra_infos]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_presence_info_rm_parseFromJSON(localMapObject)); + OpenAPI_list_add(pra_infosList, localMapKeyPair); + } + } + + cJSON *ipv4_index = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "ipv4Index"); + + if (ipv4_index) { + if (!cJSON_IsNumber(ipv4_index)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [ipv4_index]"); + goto end; + } + } + + cJSON *ipv6_index = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "ipv6Index"); + + if (ipv6_index) { + if (!cJSON_IsNumber(ipv6_index)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [ipv6_index]"); + goto end; + } + } + + cJSON *qos_flow_usage = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "qosFlowUsage"); + + OpenAPI_qos_flow_usage_t *qos_flow_usage_local_nonprim = NULL; + if (qos_flow_usage) { + qos_flow_usage_local_nonprim = OpenAPI_qos_flow_usage_parseFromJSON(qos_flow_usage); + } + + cJSON *rel_cause = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "relCause"); + + OpenAPI_sm_policy_association_release_cause_t *rel_cause_local_nonprim = NULL; + if (rel_cause) { + rel_cause_local_nonprim = OpenAPI_sm_policy_association_release_cause_parseFromJSON(rel_cause); + } + + cJSON *supp_feat = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "suppFeat"); + + if (supp_feat) { + if (!cJSON_IsString(supp_feat)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [supp_feat]"); + goto end; + } + } + + cJSON *tsn_port_man_cont_dstt = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "tsnPortManContDstt"); + + OpenAPI_port_management_container_t *tsn_port_man_cont_dstt_local_nonprim = NULL; + if (tsn_port_man_cont_dstt) { + tsn_port_man_cont_dstt_local_nonprim = OpenAPI_port_management_container_parseFromJSON(tsn_port_man_cont_dstt); + } + + cJSON *tsn_port_man_cont_nwtts = cJSON_GetObjectItemCaseSensitive(sm_policy_decisionJSON, "tsnPortManContNwtts"); + + OpenAPI_list_t *tsn_port_man_cont_nwttsList; + if (tsn_port_man_cont_nwtts) { + cJSON *tsn_port_man_cont_nwtts_local_nonprimitive; + if (!cJSON_IsArray(tsn_port_man_cont_nwtts)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + + tsn_port_man_cont_nwttsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(tsn_port_man_cont_nwtts_local_nonprimitive, tsn_port_man_cont_nwtts ) { + if (!cJSON_IsObject(tsn_port_man_cont_nwtts_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_decision_parseFromJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + OpenAPI_port_management_container_t *tsn_port_man_cont_nwttsItem = OpenAPI_port_management_container_parseFromJSON(tsn_port_man_cont_nwtts_local_nonprimitive); + + OpenAPI_list_add(tsn_port_man_cont_nwttsList, tsn_port_man_cont_nwttsItem); + } + } + + sm_policy_decision_local_var = OpenAPI_sm_policy_decision_create ( + sess_rules ? sess_rulesList : NULL, + pcc_rules ? pcc_rulesList : NULL, + pcscf_rest_indication ? pcscf_rest_indication->valueint : 0, + qos_decs ? qos_decsList : NULL, + chg_decs ? chg_decsList : NULL, + charging_info ? charging_info_local_nonprim : NULL, + traff_cont_decs ? traff_cont_decsList : NULL, + um_decs ? um_decsList : NULL, + qos_chars ? qos_charsList : NULL, + qos_mon_decs ? qos_mon_decsList : NULL, + reflective_qo_s_timer ? reflective_qo_s_timer->valuedouble : 0, + conds ? condsList : NULL, + revalidation_time ? ogs_strdup(revalidation_time->valuestring) : NULL, + offline ? offline->valueint : 0, + online ? online->valueint : 0, + policy_ctrl_req_triggers ? policy_ctrl_req_triggersList : NULL, + last_req_rule_data ? last_req_rule_dataList : NULL, + last_req_usage_data ? last_req_usage_data_local_nonprim : NULL, + pra_infos ? pra_infosList : NULL, + ipv4_index ? ipv4_index->valuedouble : 0, + ipv6_index ? ipv6_index->valuedouble : 0, + qos_flow_usage ? qos_flow_usage_local_nonprim : NULL, + rel_cause ? rel_cause_local_nonprim : NULL, + supp_feat ? ogs_strdup(supp_feat->valuestring) : NULL, + tsn_port_man_cont_dstt ? tsn_port_man_cont_dstt_local_nonprim : NULL, + tsn_port_man_cont_nwtts ? tsn_port_man_cont_nwttsList : NULL + ); + + return sm_policy_decision_local_var; +end: + return NULL; +} + +OpenAPI_sm_policy_decision_t *OpenAPI_sm_policy_decision_copy(OpenAPI_sm_policy_decision_t *dst, OpenAPI_sm_policy_decision_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_sm_policy_decision_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_sm_policy_decision_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_sm_policy_decision_free(dst); + dst = OpenAPI_sm_policy_decision_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/sm_policy_decision.h b/lib/sbi/openapi/model/sm_policy_decision.h new file mode 100644 index 000000000..325e54ab1 --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_decision.h @@ -0,0 +1,105 @@ +/* + * sm_policy_decision.h + * + * + */ + +#ifndef _OpenAPI_sm_policy_decision_H_ +#define _OpenAPI_sm_policy_decision_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "charging_data.h" +#include "charging_information.h" +#include "condition_data.h" +#include "pcc_rule.h" +#include "policy_control_request_trigger.h" +#include "port_management_container.h" +#include "presence_info_rm.h" +#include "qos_characteristics.h" +#include "qos_data.h" +#include "qos_flow_usage.h" +#include "qos_monitoring_data.h" +#include "requested_rule_data.h" +#include "requested_usage_data.h" +#include "session_rule.h" +#include "sm_policy_association_release_cause.h" +#include "traffic_control_data.h" +#include "usage_monitoring_data.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_sm_policy_decision_s OpenAPI_sm_policy_decision_t; +typedef struct OpenAPI_sm_policy_decision_s { + OpenAPI_list_t* sess_rules; + OpenAPI_list_t* pcc_rules; + int pcscf_rest_indication; + OpenAPI_list_t* qos_decs; + OpenAPI_list_t* chg_decs; + struct OpenAPI_charging_information_s *charging_info; + OpenAPI_list_t* traff_cont_decs; + OpenAPI_list_t* um_decs; + OpenAPI_list_t* qos_chars; + OpenAPI_list_t* qos_mon_decs; + int reflective_qo_s_timer; + OpenAPI_list_t* conds; + char *revalidation_time; + int offline; + int online; + OpenAPI_list_t *policy_ctrl_req_triggers; + OpenAPI_list_t *last_req_rule_data; + struct OpenAPI_requested_usage_data_s *last_req_usage_data; + OpenAPI_list_t* pra_infos; + int ipv4_index; + int ipv6_index; + struct OpenAPI_qos_flow_usage_s *qos_flow_usage; + struct OpenAPI_sm_policy_association_release_cause_s *rel_cause; + char *supp_feat; + struct OpenAPI_port_management_container_s *tsn_port_man_cont_dstt; + OpenAPI_list_t *tsn_port_man_cont_nwtts; +} OpenAPI_sm_policy_decision_t; + +OpenAPI_sm_policy_decision_t *OpenAPI_sm_policy_decision_create( + OpenAPI_list_t* sess_rules, + OpenAPI_list_t* pcc_rules, + int pcscf_rest_indication, + OpenAPI_list_t* qos_decs, + OpenAPI_list_t* chg_decs, + OpenAPI_charging_information_t *charging_info, + OpenAPI_list_t* traff_cont_decs, + OpenAPI_list_t* um_decs, + OpenAPI_list_t* qos_chars, + OpenAPI_list_t* qos_mon_decs, + int reflective_qo_s_timer, + OpenAPI_list_t* conds, + char *revalidation_time, + int offline, + int online, + OpenAPI_list_t *policy_ctrl_req_triggers, + OpenAPI_list_t *last_req_rule_data, + OpenAPI_requested_usage_data_t *last_req_usage_data, + OpenAPI_list_t* pra_infos, + int ipv4_index, + int ipv6_index, + OpenAPI_qos_flow_usage_t *qos_flow_usage, + OpenAPI_sm_policy_association_release_cause_t *rel_cause, + char *supp_feat, + OpenAPI_port_management_container_t *tsn_port_man_cont_dstt, + OpenAPI_list_t *tsn_port_man_cont_nwtts + ); +void OpenAPI_sm_policy_decision_free(OpenAPI_sm_policy_decision_t *sm_policy_decision); +OpenAPI_sm_policy_decision_t *OpenAPI_sm_policy_decision_parseFromJSON(cJSON *sm_policy_decisionJSON); +cJSON *OpenAPI_sm_policy_decision_convertToJSON(OpenAPI_sm_policy_decision_t *sm_policy_decision); +OpenAPI_sm_policy_decision_t *OpenAPI_sm_policy_decision_copy(OpenAPI_sm_policy_decision_t *dst, OpenAPI_sm_policy_decision_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_sm_policy_decision_H_ */ + diff --git a/lib/sbi/openapi/model/sm_policy_delete_data.c b/lib/sbi/openapi/model/sm_policy_delete_data.c new file mode 100644 index 000000000..04909137d --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_delete_data.c @@ -0,0 +1,297 @@ + +#include +#include +#include +#include "sm_policy_delete_data.h" + +OpenAPI_sm_policy_delete_data_t *OpenAPI_sm_policy_delete_data_create( + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone, + OpenAPI_plmn_id_nid_t *serving_network, + char *user_location_info_time, + OpenAPI_list_t *ran_nas_rel_causes, + OpenAPI_list_t *accu_usage_reports, + OpenAPI_pdu_session_rel_cause_t *pdu_sess_rel_cause + ) +{ + OpenAPI_sm_policy_delete_data_t *sm_policy_delete_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_sm_policy_delete_data_t)); + if (!sm_policy_delete_data_local_var) { + return NULL; + } + sm_policy_delete_data_local_var->user_location_info = user_location_info; + sm_policy_delete_data_local_var->ue_time_zone = ue_time_zone; + sm_policy_delete_data_local_var->serving_network = serving_network; + sm_policy_delete_data_local_var->user_location_info_time = user_location_info_time; + sm_policy_delete_data_local_var->ran_nas_rel_causes = ran_nas_rel_causes; + sm_policy_delete_data_local_var->accu_usage_reports = accu_usage_reports; + sm_policy_delete_data_local_var->pdu_sess_rel_cause = pdu_sess_rel_cause; + + return sm_policy_delete_data_local_var; +} + +void OpenAPI_sm_policy_delete_data_free(OpenAPI_sm_policy_delete_data_t *sm_policy_delete_data) +{ + if (NULL == sm_policy_delete_data) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_user_location_free(sm_policy_delete_data->user_location_info); + ogs_free(sm_policy_delete_data->ue_time_zone); + OpenAPI_plmn_id_nid_free(sm_policy_delete_data->serving_network); + ogs_free(sm_policy_delete_data->user_location_info_time); + OpenAPI_list_for_each(sm_policy_delete_data->ran_nas_rel_causes, node) { + OpenAPI_ran_nas_rel_cause_free(node->data); + } + OpenAPI_list_free(sm_policy_delete_data->ran_nas_rel_causes); + OpenAPI_list_for_each(sm_policy_delete_data->accu_usage_reports, node) { + OpenAPI_accu_usage_report_free(node->data); + } + OpenAPI_list_free(sm_policy_delete_data->accu_usage_reports); + OpenAPI_pdu_session_rel_cause_free(sm_policy_delete_data->pdu_sess_rel_cause); + ogs_free(sm_policy_delete_data); +} + +cJSON *OpenAPI_sm_policy_delete_data_convertToJSON(OpenAPI_sm_policy_delete_data_t *sm_policy_delete_data) +{ + cJSON *item = NULL; + + if (sm_policy_delete_data == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [SmPolicyDeleteData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (sm_policy_delete_data->user_location_info) { + cJSON *user_location_info_local_JSON = OpenAPI_user_location_convertToJSON(sm_policy_delete_data->user_location_info); + if (user_location_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [user_location_info]"); + goto end; + } + cJSON_AddItemToObject(item, "userLocationInfo", user_location_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [user_location_info]"); + goto end; + } + } + + if (sm_policy_delete_data->ue_time_zone) { + if (cJSON_AddStringToObject(item, "ueTimeZone", sm_policy_delete_data->ue_time_zone) == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [ue_time_zone]"); + goto end; + } + } + + if (sm_policy_delete_data->serving_network) { + cJSON *serving_network_local_JSON = OpenAPI_plmn_id_nid_convertToJSON(sm_policy_delete_data->serving_network); + if (serving_network_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [serving_network]"); + goto end; + } + cJSON_AddItemToObject(item, "servingNetwork", serving_network_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [serving_network]"); + goto end; + } + } + + if (sm_policy_delete_data->user_location_info_time) { + if (cJSON_AddStringToObject(item, "userLocationInfoTime", sm_policy_delete_data->user_location_info_time) == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [user_location_info_time]"); + goto end; + } + } + + if (sm_policy_delete_data->ran_nas_rel_causes) { + cJSON *ran_nas_rel_causesList = cJSON_AddArrayToObject(item, "ranNasRelCauses"); + if (ran_nas_rel_causesList == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [ran_nas_rel_causes]"); + goto end; + } + + OpenAPI_lnode_t *ran_nas_rel_causes_node; + if (sm_policy_delete_data->ran_nas_rel_causes) { + OpenAPI_list_for_each(sm_policy_delete_data->ran_nas_rel_causes, ran_nas_rel_causes_node) { + cJSON *itemLocal = OpenAPI_ran_nas_rel_cause_convertToJSON(ran_nas_rel_causes_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [ran_nas_rel_causes]"); + goto end; + } + cJSON_AddItemToArray(ran_nas_rel_causesList, itemLocal); + } + } + } + + if (sm_policy_delete_data->accu_usage_reports) { + cJSON *accu_usage_reportsList = cJSON_AddArrayToObject(item, "accuUsageReports"); + if (accu_usage_reportsList == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [accu_usage_reports]"); + goto end; + } + + OpenAPI_lnode_t *accu_usage_reports_node; + if (sm_policy_delete_data->accu_usage_reports) { + OpenAPI_list_for_each(sm_policy_delete_data->accu_usage_reports, accu_usage_reports_node) { + cJSON *itemLocal = OpenAPI_accu_usage_report_convertToJSON(accu_usage_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [accu_usage_reports]"); + goto end; + } + cJSON_AddItemToArray(accu_usage_reportsList, itemLocal); + } + } + } + + if (sm_policy_delete_data->pdu_sess_rel_cause) { + cJSON *pdu_sess_rel_cause_local_JSON = OpenAPI_pdu_session_rel_cause_convertToJSON(sm_policy_delete_data->pdu_sess_rel_cause); + if (pdu_sess_rel_cause_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [pdu_sess_rel_cause]"); + goto end; + } + cJSON_AddItemToObject(item, "pduSessRelCause", pdu_sess_rel_cause_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed [pdu_sess_rel_cause]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_sm_policy_delete_data_t *OpenAPI_sm_policy_delete_data_parseFromJSON(cJSON *sm_policy_delete_dataJSON) +{ + OpenAPI_sm_policy_delete_data_t *sm_policy_delete_data_local_var = NULL; + cJSON *user_location_info = cJSON_GetObjectItemCaseSensitive(sm_policy_delete_dataJSON, "userLocationInfo"); + + OpenAPI_user_location_t *user_location_info_local_nonprim = NULL; + if (user_location_info) { + user_location_info_local_nonprim = OpenAPI_user_location_parseFromJSON(user_location_info); + } + + cJSON *ue_time_zone = cJSON_GetObjectItemCaseSensitive(sm_policy_delete_dataJSON, "ueTimeZone"); + + if (ue_time_zone) { + if (!cJSON_IsString(ue_time_zone)) { + ogs_error("OpenAPI_sm_policy_delete_data_parseFromJSON() failed [ue_time_zone]"); + goto end; + } + } + + cJSON *serving_network = cJSON_GetObjectItemCaseSensitive(sm_policy_delete_dataJSON, "servingNetwork"); + + OpenAPI_plmn_id_nid_t *serving_network_local_nonprim = NULL; + if (serving_network) { + serving_network_local_nonprim = OpenAPI_plmn_id_nid_parseFromJSON(serving_network); + } + + cJSON *user_location_info_time = cJSON_GetObjectItemCaseSensitive(sm_policy_delete_dataJSON, "userLocationInfoTime"); + + if (user_location_info_time) { + if (!cJSON_IsString(user_location_info_time)) { + ogs_error("OpenAPI_sm_policy_delete_data_parseFromJSON() failed [user_location_info_time]"); + goto end; + } + } + + cJSON *ran_nas_rel_causes = cJSON_GetObjectItemCaseSensitive(sm_policy_delete_dataJSON, "ranNasRelCauses"); + + OpenAPI_list_t *ran_nas_rel_causesList; + if (ran_nas_rel_causes) { + cJSON *ran_nas_rel_causes_local_nonprimitive; + if (!cJSON_IsArray(ran_nas_rel_causes)) { + ogs_error("OpenAPI_sm_policy_delete_data_parseFromJSON() failed [ran_nas_rel_causes]"); + goto end; + } + + ran_nas_rel_causesList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ran_nas_rel_causes_local_nonprimitive, ran_nas_rel_causes ) { + if (!cJSON_IsObject(ran_nas_rel_causes_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_delete_data_parseFromJSON() failed [ran_nas_rel_causes]"); + goto end; + } + OpenAPI_ran_nas_rel_cause_t *ran_nas_rel_causesItem = OpenAPI_ran_nas_rel_cause_parseFromJSON(ran_nas_rel_causes_local_nonprimitive); + + OpenAPI_list_add(ran_nas_rel_causesList, ran_nas_rel_causesItem); + } + } + + cJSON *accu_usage_reports = cJSON_GetObjectItemCaseSensitive(sm_policy_delete_dataJSON, "accuUsageReports"); + + OpenAPI_list_t *accu_usage_reportsList; + if (accu_usage_reports) { + cJSON *accu_usage_reports_local_nonprimitive; + if (!cJSON_IsArray(accu_usage_reports)) { + ogs_error("OpenAPI_sm_policy_delete_data_parseFromJSON() failed [accu_usage_reports]"); + goto end; + } + + accu_usage_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(accu_usage_reports_local_nonprimitive, accu_usage_reports ) { + if (!cJSON_IsObject(accu_usage_reports_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_delete_data_parseFromJSON() failed [accu_usage_reports]"); + goto end; + } + OpenAPI_accu_usage_report_t *accu_usage_reportsItem = OpenAPI_accu_usage_report_parseFromJSON(accu_usage_reports_local_nonprimitive); + + OpenAPI_list_add(accu_usage_reportsList, accu_usage_reportsItem); + } + } + + cJSON *pdu_sess_rel_cause = cJSON_GetObjectItemCaseSensitive(sm_policy_delete_dataJSON, "pduSessRelCause"); + + OpenAPI_pdu_session_rel_cause_t *pdu_sess_rel_cause_local_nonprim = NULL; + if (pdu_sess_rel_cause) { + pdu_sess_rel_cause_local_nonprim = OpenAPI_pdu_session_rel_cause_parseFromJSON(pdu_sess_rel_cause); + } + + sm_policy_delete_data_local_var = OpenAPI_sm_policy_delete_data_create ( + user_location_info ? user_location_info_local_nonprim : NULL, + ue_time_zone ? ogs_strdup(ue_time_zone->valuestring) : NULL, + serving_network ? serving_network_local_nonprim : NULL, + user_location_info_time ? ogs_strdup(user_location_info_time->valuestring) : NULL, + ran_nas_rel_causes ? ran_nas_rel_causesList : NULL, + accu_usage_reports ? accu_usage_reportsList : NULL, + pdu_sess_rel_cause ? pdu_sess_rel_cause_local_nonprim : NULL + ); + + return sm_policy_delete_data_local_var; +end: + return NULL; +} + +OpenAPI_sm_policy_delete_data_t *OpenAPI_sm_policy_delete_data_copy(OpenAPI_sm_policy_delete_data_t *dst, OpenAPI_sm_policy_delete_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_sm_policy_delete_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_sm_policy_delete_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_sm_policy_delete_data_free(dst); + dst = OpenAPI_sm_policy_delete_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/sm_policy_delete_data.h b/lib/sbi/openapi/model/sm_policy_delete_data.h new file mode 100644 index 000000000..ca05df7f3 --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_delete_data.h @@ -0,0 +1,55 @@ +/* + * sm_policy_delete_data.h + * + * + */ + +#ifndef _OpenAPI_sm_policy_delete_data_H_ +#define _OpenAPI_sm_policy_delete_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "accu_usage_report.h" +#include "pdu_session_rel_cause.h" +#include "plmn_id_nid.h" +#include "ran_nas_rel_cause.h" +#include "user_location.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_sm_policy_delete_data_s OpenAPI_sm_policy_delete_data_t; +typedef struct OpenAPI_sm_policy_delete_data_s { + struct OpenAPI_user_location_s *user_location_info; + char *ue_time_zone; + struct OpenAPI_plmn_id_nid_s *serving_network; + char *user_location_info_time; + OpenAPI_list_t *ran_nas_rel_causes; + OpenAPI_list_t *accu_usage_reports; + struct OpenAPI_pdu_session_rel_cause_s *pdu_sess_rel_cause; +} OpenAPI_sm_policy_delete_data_t; + +OpenAPI_sm_policy_delete_data_t *OpenAPI_sm_policy_delete_data_create( + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone, + OpenAPI_plmn_id_nid_t *serving_network, + char *user_location_info_time, + OpenAPI_list_t *ran_nas_rel_causes, + OpenAPI_list_t *accu_usage_reports, + OpenAPI_pdu_session_rel_cause_t *pdu_sess_rel_cause + ); +void OpenAPI_sm_policy_delete_data_free(OpenAPI_sm_policy_delete_data_t *sm_policy_delete_data); +OpenAPI_sm_policy_delete_data_t *OpenAPI_sm_policy_delete_data_parseFromJSON(cJSON *sm_policy_delete_dataJSON); +cJSON *OpenAPI_sm_policy_delete_data_convertToJSON(OpenAPI_sm_policy_delete_data_t *sm_policy_delete_data); +OpenAPI_sm_policy_delete_data_t *OpenAPI_sm_policy_delete_data_copy(OpenAPI_sm_policy_delete_data_t *dst, OpenAPI_sm_policy_delete_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_sm_policy_delete_data_H_ */ + diff --git a/lib/sbi/openapi/model/sm_policy_notification.c b/lib/sbi/openapi/model/sm_policy_notification.c new file mode 100644 index 000000000..9097f246c --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_notification.c @@ -0,0 +1,129 @@ + +#include +#include +#include +#include "sm_policy_notification.h" + +OpenAPI_sm_policy_notification_t *OpenAPI_sm_policy_notification_create( + char *resource_uri, + OpenAPI_sm_policy_decision_t *sm_policy_decision + ) +{ + OpenAPI_sm_policy_notification_t *sm_policy_notification_local_var = OpenAPI_malloc(sizeof(OpenAPI_sm_policy_notification_t)); + if (!sm_policy_notification_local_var) { + return NULL; + } + sm_policy_notification_local_var->resource_uri = resource_uri; + sm_policy_notification_local_var->sm_policy_decision = sm_policy_decision; + + return sm_policy_notification_local_var; +} + +void OpenAPI_sm_policy_notification_free(OpenAPI_sm_policy_notification_t *sm_policy_notification) +{ + if (NULL == sm_policy_notification) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(sm_policy_notification->resource_uri); + OpenAPI_sm_policy_decision_free(sm_policy_notification->sm_policy_decision); + ogs_free(sm_policy_notification); +} + +cJSON *OpenAPI_sm_policy_notification_convertToJSON(OpenAPI_sm_policy_notification_t *sm_policy_notification) +{ + cJSON *item = NULL; + + if (sm_policy_notification == NULL) { + ogs_error("OpenAPI_sm_policy_notification_convertToJSON() failed [SmPolicyNotification]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (sm_policy_notification->resource_uri) { + if (cJSON_AddStringToObject(item, "resourceUri", sm_policy_notification->resource_uri) == NULL) { + ogs_error("OpenAPI_sm_policy_notification_convertToJSON() failed [resource_uri]"); + goto end; + } + } + + if (sm_policy_notification->sm_policy_decision) { + cJSON *sm_policy_decision_local_JSON = OpenAPI_sm_policy_decision_convertToJSON(sm_policy_notification->sm_policy_decision); + if (sm_policy_decision_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_notification_convertToJSON() failed [sm_policy_decision]"); + goto end; + } + cJSON_AddItemToObject(item, "smPolicyDecision", sm_policy_decision_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_notification_convertToJSON() failed [sm_policy_decision]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_sm_policy_notification_t *OpenAPI_sm_policy_notification_parseFromJSON(cJSON *sm_policy_notificationJSON) +{ + OpenAPI_sm_policy_notification_t *sm_policy_notification_local_var = NULL; + cJSON *resource_uri = cJSON_GetObjectItemCaseSensitive(sm_policy_notificationJSON, "resourceUri"); + + if (resource_uri) { + if (!cJSON_IsString(resource_uri)) { + ogs_error("OpenAPI_sm_policy_notification_parseFromJSON() failed [resource_uri]"); + goto end; + } + } + + cJSON *sm_policy_decision = cJSON_GetObjectItemCaseSensitive(sm_policy_notificationJSON, "smPolicyDecision"); + + OpenAPI_sm_policy_decision_t *sm_policy_decision_local_nonprim = NULL; + if (sm_policy_decision) { + sm_policy_decision_local_nonprim = OpenAPI_sm_policy_decision_parseFromJSON(sm_policy_decision); + } + + sm_policy_notification_local_var = OpenAPI_sm_policy_notification_create ( + resource_uri ? ogs_strdup(resource_uri->valuestring) : NULL, + sm_policy_decision ? sm_policy_decision_local_nonprim : NULL + ); + + return sm_policy_notification_local_var; +end: + return NULL; +} + +OpenAPI_sm_policy_notification_t *OpenAPI_sm_policy_notification_copy(OpenAPI_sm_policy_notification_t *dst, OpenAPI_sm_policy_notification_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_sm_policy_notification_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_sm_policy_notification_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_sm_policy_notification_free(dst); + dst = OpenAPI_sm_policy_notification_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/sm_policy_notification.h b/lib/sbi/openapi/model/sm_policy_notification.h new file mode 100644 index 000000000..c38124eec --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_notification.h @@ -0,0 +1,41 @@ +/* + * sm_policy_notification.h + * + * + */ + +#ifndef _OpenAPI_sm_policy_notification_H_ +#define _OpenAPI_sm_policy_notification_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "sm_policy_decision.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_sm_policy_notification_s OpenAPI_sm_policy_notification_t; +typedef struct OpenAPI_sm_policy_notification_s { + char *resource_uri; + struct OpenAPI_sm_policy_decision_s *sm_policy_decision; +} OpenAPI_sm_policy_notification_t; + +OpenAPI_sm_policy_notification_t *OpenAPI_sm_policy_notification_create( + char *resource_uri, + OpenAPI_sm_policy_decision_t *sm_policy_decision + ); +void OpenAPI_sm_policy_notification_free(OpenAPI_sm_policy_notification_t *sm_policy_notification); +OpenAPI_sm_policy_notification_t *OpenAPI_sm_policy_notification_parseFromJSON(cJSON *sm_policy_notificationJSON); +cJSON *OpenAPI_sm_policy_notification_convertToJSON(OpenAPI_sm_policy_notification_t *sm_policy_notification); +OpenAPI_sm_policy_notification_t *OpenAPI_sm_policy_notification_copy(OpenAPI_sm_policy_notification_t *dst, OpenAPI_sm_policy_notification_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_sm_policy_notification_H_ */ + diff --git a/lib/sbi/openapi/model/sm_policy_update_context_data.c b/lib/sbi/openapi/model/sm_policy_update_context_data.c new file mode 100644 index 000000000..eb2dd31e3 --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_update_context_data.c @@ -0,0 +1,1337 @@ + +#include +#include +#include +#include "sm_policy_update_context_data.h" + +OpenAPI_sm_policy_update_context_data_t *OpenAPI_sm_policy_update_context_data_create( + OpenAPI_list_t *rep_policy_ctrl_req_triggers, + OpenAPI_list_t *acc_net_ch_ids, + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type, + OpenAPI_additional_access_info_t *add_access_info, + OpenAPI_additional_access_info_t *rel_access_info, + OpenAPI_plmn_id_nid_t *serving_network, + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone, + char *rel_ipv4_address, + char *ipv4_address, + char *ip_domain, + char *ipv6_address_prefix, + char *rel_ipv6_address_prefix, + char *add_ipv6_addr_prefixes, + char *add_rel_ipv6_addr_prefixes, + char *rel_ue_mac, + char *ue_mac, + OpenAPI_ambr_t *subs_sess_ambr, + char *auth_prof_index, + OpenAPI_subscribed_default_qos_t *subs_def_qos, + int num_of_pack_filter, + OpenAPI_list_t *accu_usage_reports, + int _3gpp_ps_data_off_status, + OpenAPI_list_t *app_detection_infos, + OpenAPI_list_t *rule_reports, + OpenAPI_list_t *sess_rule_reports, + OpenAPI_list_t *qnc_reports, + OpenAPI_list_t *qos_mon_reports, + char *user_location_info_time, + OpenAPI_list_t* rep_pra_infos, + OpenAPI_ue_initiated_resource_request_t *ue_init_res_req, + int ref_qos_indication, + OpenAPI_qos_flow_usage_t *qos_flow_usage, + OpenAPI_credit_management_status_t *credit_manage_status, + OpenAPI_serving_nf_identity_t *serv_nf_id, + OpenAPI_trace_data_t *trace_req, + OpenAPI_ma_pdu_indication_t *ma_pdu_ind, + OpenAPI_atsss_capability_t *atsss_capab, + OpenAPI_tsn_bridge_info_t *tsn_bridge_info, + OpenAPI_port_management_container_t *tsn_port_man_cont_dstt, + OpenAPI_list_t *tsn_port_man_cont_nwtts, + OpenAPI_list_t *mul_addr_infos + ) +{ + OpenAPI_sm_policy_update_context_data_t *sm_policy_update_context_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_sm_policy_update_context_data_t)); + if (!sm_policy_update_context_data_local_var) { + return NULL; + } + sm_policy_update_context_data_local_var->rep_policy_ctrl_req_triggers = rep_policy_ctrl_req_triggers; + sm_policy_update_context_data_local_var->acc_net_ch_ids = acc_net_ch_ids; + sm_policy_update_context_data_local_var->access_type = access_type; + sm_policy_update_context_data_local_var->rat_type = rat_type; + sm_policy_update_context_data_local_var->add_access_info = add_access_info; + sm_policy_update_context_data_local_var->rel_access_info = rel_access_info; + sm_policy_update_context_data_local_var->serving_network = serving_network; + sm_policy_update_context_data_local_var->user_location_info = user_location_info; + sm_policy_update_context_data_local_var->ue_time_zone = ue_time_zone; + sm_policy_update_context_data_local_var->rel_ipv4_address = rel_ipv4_address; + sm_policy_update_context_data_local_var->ipv4_address = ipv4_address; + sm_policy_update_context_data_local_var->ip_domain = ip_domain; + sm_policy_update_context_data_local_var->ipv6_address_prefix = ipv6_address_prefix; + sm_policy_update_context_data_local_var->rel_ipv6_address_prefix = rel_ipv6_address_prefix; + sm_policy_update_context_data_local_var->add_ipv6_addr_prefixes = add_ipv6_addr_prefixes; + sm_policy_update_context_data_local_var->add_rel_ipv6_addr_prefixes = add_rel_ipv6_addr_prefixes; + sm_policy_update_context_data_local_var->rel_ue_mac = rel_ue_mac; + sm_policy_update_context_data_local_var->ue_mac = ue_mac; + sm_policy_update_context_data_local_var->subs_sess_ambr = subs_sess_ambr; + sm_policy_update_context_data_local_var->auth_prof_index = auth_prof_index; + sm_policy_update_context_data_local_var->subs_def_qos = subs_def_qos; + sm_policy_update_context_data_local_var->num_of_pack_filter = num_of_pack_filter; + sm_policy_update_context_data_local_var->accu_usage_reports = accu_usage_reports; + sm_policy_update_context_data_local_var->_3gpp_ps_data_off_status = _3gpp_ps_data_off_status; + sm_policy_update_context_data_local_var->app_detection_infos = app_detection_infos; + sm_policy_update_context_data_local_var->rule_reports = rule_reports; + sm_policy_update_context_data_local_var->sess_rule_reports = sess_rule_reports; + sm_policy_update_context_data_local_var->qnc_reports = qnc_reports; + sm_policy_update_context_data_local_var->qos_mon_reports = qos_mon_reports; + sm_policy_update_context_data_local_var->user_location_info_time = user_location_info_time; + sm_policy_update_context_data_local_var->rep_pra_infos = rep_pra_infos; + sm_policy_update_context_data_local_var->ue_init_res_req = ue_init_res_req; + sm_policy_update_context_data_local_var->ref_qos_indication = ref_qos_indication; + sm_policy_update_context_data_local_var->qos_flow_usage = qos_flow_usage; + sm_policy_update_context_data_local_var->credit_manage_status = credit_manage_status; + sm_policy_update_context_data_local_var->serv_nf_id = serv_nf_id; + sm_policy_update_context_data_local_var->trace_req = trace_req; + sm_policy_update_context_data_local_var->ma_pdu_ind = ma_pdu_ind; + sm_policy_update_context_data_local_var->atsss_capab = atsss_capab; + sm_policy_update_context_data_local_var->tsn_bridge_info = tsn_bridge_info; + sm_policy_update_context_data_local_var->tsn_port_man_cont_dstt = tsn_port_man_cont_dstt; + sm_policy_update_context_data_local_var->tsn_port_man_cont_nwtts = tsn_port_man_cont_nwtts; + sm_policy_update_context_data_local_var->mul_addr_infos = mul_addr_infos; + + return sm_policy_update_context_data_local_var; +} + +void OpenAPI_sm_policy_update_context_data_free(OpenAPI_sm_policy_update_context_data_t *sm_policy_update_context_data) +{ + if (NULL == sm_policy_update_context_data) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(sm_policy_update_context_data->rep_policy_ctrl_req_triggers, node) { + OpenAPI_policy_control_request_trigger_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->rep_policy_ctrl_req_triggers); + OpenAPI_list_for_each(sm_policy_update_context_data->acc_net_ch_ids, node) { + OpenAPI_acc_net_ch_id_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->acc_net_ch_ids); + OpenAPI_additional_access_info_free(sm_policy_update_context_data->add_access_info); + OpenAPI_additional_access_info_free(sm_policy_update_context_data->rel_access_info); + OpenAPI_plmn_id_nid_free(sm_policy_update_context_data->serving_network); + OpenAPI_user_location_free(sm_policy_update_context_data->user_location_info); + ogs_free(sm_policy_update_context_data->ue_time_zone); + ogs_free(sm_policy_update_context_data->rel_ipv4_address); + ogs_free(sm_policy_update_context_data->ipv4_address); + ogs_free(sm_policy_update_context_data->ip_domain); + ogs_free(sm_policy_update_context_data->ipv6_address_prefix); + ogs_free(sm_policy_update_context_data->rel_ipv6_address_prefix); + ogs_free(sm_policy_update_context_data->add_ipv6_addr_prefixes); + ogs_free(sm_policy_update_context_data->add_rel_ipv6_addr_prefixes); + ogs_free(sm_policy_update_context_data->rel_ue_mac); + ogs_free(sm_policy_update_context_data->ue_mac); + OpenAPI_ambr_free(sm_policy_update_context_data->subs_sess_ambr); + ogs_free(sm_policy_update_context_data->auth_prof_index); + OpenAPI_subscribed_default_qos_free(sm_policy_update_context_data->subs_def_qos); + OpenAPI_list_for_each(sm_policy_update_context_data->accu_usage_reports, node) { + OpenAPI_accu_usage_report_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->accu_usage_reports); + OpenAPI_list_for_each(sm_policy_update_context_data->app_detection_infos, node) { + OpenAPI_app_detection_info_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->app_detection_infos); + OpenAPI_list_for_each(sm_policy_update_context_data->rule_reports, node) { + OpenAPI_rule_report_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->rule_reports); + OpenAPI_list_for_each(sm_policy_update_context_data->sess_rule_reports, node) { + OpenAPI_session_rule_report_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->sess_rule_reports); + OpenAPI_list_for_each(sm_policy_update_context_data->qnc_reports, node) { + OpenAPI_qos_notification_control_info_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->qnc_reports); + OpenAPI_list_for_each(sm_policy_update_context_data->qos_mon_reports, node) { + OpenAPI_qos_monitoring_report_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->qos_mon_reports); + ogs_free(sm_policy_update_context_data->user_location_info_time); + OpenAPI_list_for_each(sm_policy_update_context_data->rep_pra_infos, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_presence_info_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(sm_policy_update_context_data->rep_pra_infos); + OpenAPI_ue_initiated_resource_request_free(sm_policy_update_context_data->ue_init_res_req); + OpenAPI_qos_flow_usage_free(sm_policy_update_context_data->qos_flow_usage); + OpenAPI_credit_management_status_free(sm_policy_update_context_data->credit_manage_status); + OpenAPI_serving_nf_identity_free(sm_policy_update_context_data->serv_nf_id); + OpenAPI_trace_data_free(sm_policy_update_context_data->trace_req); + OpenAPI_ma_pdu_indication_free(sm_policy_update_context_data->ma_pdu_ind); + OpenAPI_atsss_capability_free(sm_policy_update_context_data->atsss_capab); + OpenAPI_tsn_bridge_info_free(sm_policy_update_context_data->tsn_bridge_info); + OpenAPI_port_management_container_free(sm_policy_update_context_data->tsn_port_man_cont_dstt); + OpenAPI_list_for_each(sm_policy_update_context_data->tsn_port_man_cont_nwtts, node) { + OpenAPI_port_management_container_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->tsn_port_man_cont_nwtts); + OpenAPI_list_for_each(sm_policy_update_context_data->mul_addr_infos, node) { + OpenAPI_ip_multicast_address_info_free(node->data); + } + OpenAPI_list_free(sm_policy_update_context_data->mul_addr_infos); + ogs_free(sm_policy_update_context_data); +} + +cJSON *OpenAPI_sm_policy_update_context_data_convertToJSON(OpenAPI_sm_policy_update_context_data_t *sm_policy_update_context_data) +{ + cJSON *item = NULL; + + if (sm_policy_update_context_data == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [SmPolicyUpdateContextData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (sm_policy_update_context_data->rep_policy_ctrl_req_triggers) { + cJSON *rep_policy_ctrl_req_triggersList = cJSON_AddArrayToObject(item, "repPolicyCtrlReqTriggers"); + if (rep_policy_ctrl_req_triggersList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rep_policy_ctrl_req_triggers]"); + goto end; + } + + OpenAPI_lnode_t *rep_policy_ctrl_req_triggers_node; + if (sm_policy_update_context_data->rep_policy_ctrl_req_triggers) { + OpenAPI_list_for_each(sm_policy_update_context_data->rep_policy_ctrl_req_triggers, rep_policy_ctrl_req_triggers_node) { + cJSON *itemLocal = OpenAPI_policy_control_request_trigger_convertToJSON(rep_policy_ctrl_req_triggers_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rep_policy_ctrl_req_triggers]"); + goto end; + } + cJSON_AddItemToArray(rep_policy_ctrl_req_triggersList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->acc_net_ch_ids) { + cJSON *acc_net_ch_idsList = cJSON_AddArrayToObject(item, "accNetChIds"); + if (acc_net_ch_idsList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [acc_net_ch_ids]"); + goto end; + } + + OpenAPI_lnode_t *acc_net_ch_ids_node; + if (sm_policy_update_context_data->acc_net_ch_ids) { + OpenAPI_list_for_each(sm_policy_update_context_data->acc_net_ch_ids, acc_net_ch_ids_node) { + cJSON *itemLocal = OpenAPI_acc_net_ch_id_convertToJSON(acc_net_ch_ids_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [acc_net_ch_ids]"); + goto end; + } + cJSON_AddItemToArray(acc_net_ch_idsList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->access_type) { + if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(sm_policy_update_context_data->access_type)) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [access_type]"); + goto end; + } + } + + if (sm_policy_update_context_data->rat_type) { + if (cJSON_AddStringToObject(item, "ratType", OpenAPI_rat_type_ToString(sm_policy_update_context_data->rat_type)) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rat_type]"); + goto end; + } + } + + if (sm_policy_update_context_data->add_access_info) { + cJSON *add_access_info_local_JSON = OpenAPI_additional_access_info_convertToJSON(sm_policy_update_context_data->add_access_info); + if (add_access_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [add_access_info]"); + goto end; + } + cJSON_AddItemToObject(item, "addAccessInfo", add_access_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [add_access_info]"); + goto end; + } + } + + if (sm_policy_update_context_data->rel_access_info) { + cJSON *rel_access_info_local_JSON = OpenAPI_additional_access_info_convertToJSON(sm_policy_update_context_data->rel_access_info); + if (rel_access_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rel_access_info]"); + goto end; + } + cJSON_AddItemToObject(item, "relAccessInfo", rel_access_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rel_access_info]"); + goto end; + } + } + + if (sm_policy_update_context_data->serving_network) { + cJSON *serving_network_local_JSON = OpenAPI_plmn_id_nid_convertToJSON(sm_policy_update_context_data->serving_network); + if (serving_network_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [serving_network]"); + goto end; + } + cJSON_AddItemToObject(item, "servingNetwork", serving_network_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [serving_network]"); + goto end; + } + } + + if (sm_policy_update_context_data->user_location_info) { + cJSON *user_location_info_local_JSON = OpenAPI_user_location_convertToJSON(sm_policy_update_context_data->user_location_info); + if (user_location_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [user_location_info]"); + goto end; + } + cJSON_AddItemToObject(item, "userLocationInfo", user_location_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [user_location_info]"); + goto end; + } + } + + if (sm_policy_update_context_data->ue_time_zone) { + if (cJSON_AddStringToObject(item, "ueTimeZone", sm_policy_update_context_data->ue_time_zone) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ue_time_zone]"); + goto end; + } + } + + if (sm_policy_update_context_data->rel_ipv4_address) { + if (cJSON_AddStringToObject(item, "relIpv4Address", sm_policy_update_context_data->rel_ipv4_address) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rel_ipv4_address]"); + goto end; + } + } + + if (sm_policy_update_context_data->ipv4_address) { + if (cJSON_AddStringToObject(item, "ipv4Address", sm_policy_update_context_data->ipv4_address) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ipv4_address]"); + goto end; + } + } + + if (sm_policy_update_context_data->ip_domain) { + if (cJSON_AddStringToObject(item, "ipDomain", sm_policy_update_context_data->ip_domain) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ip_domain]"); + goto end; + } + } + + if (sm_policy_update_context_data->ipv6_address_prefix) { + if (cJSON_AddStringToObject(item, "ipv6AddressPrefix", sm_policy_update_context_data->ipv6_address_prefix) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ipv6_address_prefix]"); + goto end; + } + } + + if (sm_policy_update_context_data->rel_ipv6_address_prefix) { + if (cJSON_AddStringToObject(item, "relIpv6AddressPrefix", sm_policy_update_context_data->rel_ipv6_address_prefix) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rel_ipv6_address_prefix]"); + goto end; + } + } + + if (sm_policy_update_context_data->add_ipv6_addr_prefixes) { + if (cJSON_AddStringToObject(item, "addIpv6AddrPrefixes", sm_policy_update_context_data->add_ipv6_addr_prefixes) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [add_ipv6_addr_prefixes]"); + goto end; + } + } + + if (sm_policy_update_context_data->add_rel_ipv6_addr_prefixes) { + if (cJSON_AddStringToObject(item, "addRelIpv6AddrPrefixes", sm_policy_update_context_data->add_rel_ipv6_addr_prefixes) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [add_rel_ipv6_addr_prefixes]"); + goto end; + } + } + + if (sm_policy_update_context_data->rel_ue_mac) { + if (cJSON_AddStringToObject(item, "relUeMac", sm_policy_update_context_data->rel_ue_mac) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rel_ue_mac]"); + goto end; + } + } + + if (sm_policy_update_context_data->ue_mac) { + if (cJSON_AddStringToObject(item, "ueMac", sm_policy_update_context_data->ue_mac) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ue_mac]"); + goto end; + } + } + + if (sm_policy_update_context_data->subs_sess_ambr) { + cJSON *subs_sess_ambr_local_JSON = OpenAPI_ambr_convertToJSON(sm_policy_update_context_data->subs_sess_ambr); + if (subs_sess_ambr_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [subs_sess_ambr]"); + goto end; + } + cJSON_AddItemToObject(item, "subsSessAmbr", subs_sess_ambr_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [subs_sess_ambr]"); + goto end; + } + } + + if (sm_policy_update_context_data->auth_prof_index) { + if (cJSON_AddStringToObject(item, "authProfIndex", sm_policy_update_context_data->auth_prof_index) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [auth_prof_index]"); + goto end; + } + } + + if (sm_policy_update_context_data->subs_def_qos) { + cJSON *subs_def_qos_local_JSON = OpenAPI_subscribed_default_qos_convertToJSON(sm_policy_update_context_data->subs_def_qos); + if (subs_def_qos_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [subs_def_qos]"); + goto end; + } + cJSON_AddItemToObject(item, "subsDefQos", subs_def_qos_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [subs_def_qos]"); + goto end; + } + } + + if (sm_policy_update_context_data->num_of_pack_filter) { + if (cJSON_AddNumberToObject(item, "numOfPackFilter", sm_policy_update_context_data->num_of_pack_filter) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [num_of_pack_filter]"); + goto end; + } + } + + if (sm_policy_update_context_data->accu_usage_reports) { + cJSON *accu_usage_reportsList = cJSON_AddArrayToObject(item, "accuUsageReports"); + if (accu_usage_reportsList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [accu_usage_reports]"); + goto end; + } + + OpenAPI_lnode_t *accu_usage_reports_node; + if (sm_policy_update_context_data->accu_usage_reports) { + OpenAPI_list_for_each(sm_policy_update_context_data->accu_usage_reports, accu_usage_reports_node) { + cJSON *itemLocal = OpenAPI_accu_usage_report_convertToJSON(accu_usage_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [accu_usage_reports]"); + goto end; + } + cJSON_AddItemToArray(accu_usage_reportsList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->_3gpp_ps_data_off_status) { + if (cJSON_AddBoolToObject(item, "3gppPsDataOffStatus", sm_policy_update_context_data->_3gpp_ps_data_off_status) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [_3gpp_ps_data_off_status]"); + goto end; + } + } + + if (sm_policy_update_context_data->app_detection_infos) { + cJSON *app_detection_infosList = cJSON_AddArrayToObject(item, "appDetectionInfos"); + if (app_detection_infosList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [app_detection_infos]"); + goto end; + } + + OpenAPI_lnode_t *app_detection_infos_node; + if (sm_policy_update_context_data->app_detection_infos) { + OpenAPI_list_for_each(sm_policy_update_context_data->app_detection_infos, app_detection_infos_node) { + cJSON *itemLocal = OpenAPI_app_detection_info_convertToJSON(app_detection_infos_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [app_detection_infos]"); + goto end; + } + cJSON_AddItemToArray(app_detection_infosList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->rule_reports) { + cJSON *rule_reportsList = cJSON_AddArrayToObject(item, "ruleReports"); + if (rule_reportsList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rule_reports]"); + goto end; + } + + OpenAPI_lnode_t *rule_reports_node; + if (sm_policy_update_context_data->rule_reports) { + OpenAPI_list_for_each(sm_policy_update_context_data->rule_reports, rule_reports_node) { + cJSON *itemLocal = OpenAPI_rule_report_convertToJSON(rule_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rule_reports]"); + goto end; + } + cJSON_AddItemToArray(rule_reportsList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->sess_rule_reports) { + cJSON *sess_rule_reportsList = cJSON_AddArrayToObject(item, "sessRuleReports"); + if (sess_rule_reportsList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [sess_rule_reports]"); + goto end; + } + + OpenAPI_lnode_t *sess_rule_reports_node; + if (sm_policy_update_context_data->sess_rule_reports) { + OpenAPI_list_for_each(sm_policy_update_context_data->sess_rule_reports, sess_rule_reports_node) { + cJSON *itemLocal = OpenAPI_session_rule_report_convertToJSON(sess_rule_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [sess_rule_reports]"); + goto end; + } + cJSON_AddItemToArray(sess_rule_reportsList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->qnc_reports) { + cJSON *qnc_reportsList = cJSON_AddArrayToObject(item, "qncReports"); + if (qnc_reportsList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [qnc_reports]"); + goto end; + } + + OpenAPI_lnode_t *qnc_reports_node; + if (sm_policy_update_context_data->qnc_reports) { + OpenAPI_list_for_each(sm_policy_update_context_data->qnc_reports, qnc_reports_node) { + cJSON *itemLocal = OpenAPI_qos_notification_control_info_convertToJSON(qnc_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [qnc_reports]"); + goto end; + } + cJSON_AddItemToArray(qnc_reportsList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->qos_mon_reports) { + cJSON *qos_mon_reportsList = cJSON_AddArrayToObject(item, "qosMonReports"); + if (qos_mon_reportsList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [qos_mon_reports]"); + goto end; + } + + OpenAPI_lnode_t *qos_mon_reports_node; + if (sm_policy_update_context_data->qos_mon_reports) { + OpenAPI_list_for_each(sm_policy_update_context_data->qos_mon_reports, qos_mon_reports_node) { + cJSON *itemLocal = OpenAPI_qos_monitoring_report_convertToJSON(qos_mon_reports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [qos_mon_reports]"); + goto end; + } + cJSON_AddItemToArray(qos_mon_reportsList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->user_location_info_time) { + if (cJSON_AddStringToObject(item, "userLocationInfoTime", sm_policy_update_context_data->user_location_info_time) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [user_location_info_time]"); + goto end; + } + } + + if (sm_policy_update_context_data->rep_pra_infos) { + cJSON *rep_pra_infos = cJSON_AddObjectToObject(item, "repPraInfos"); + if (rep_pra_infos == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rep_pra_infos]"); + goto end; + } + cJSON *localMapObject = rep_pra_infos; + OpenAPI_lnode_t *rep_pra_infos_node; + if (sm_policy_update_context_data->rep_pra_infos) { + OpenAPI_list_for_each(sm_policy_update_context_data->rep_pra_infos, rep_pra_infos_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)rep_pra_infos_node->data; + cJSON *itemLocal = OpenAPI_presence_info_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [rep_pra_infos]"); + goto end; + } + cJSON_AddItemToObject(rep_pra_infos, localKeyValue->key, itemLocal); + } + } + } + + if (sm_policy_update_context_data->ue_init_res_req) { + cJSON *ue_init_res_req_local_JSON = OpenAPI_ue_initiated_resource_request_convertToJSON(sm_policy_update_context_data->ue_init_res_req); + if (ue_init_res_req_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ue_init_res_req]"); + goto end; + } + cJSON_AddItemToObject(item, "ueInitResReq", ue_init_res_req_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ue_init_res_req]"); + goto end; + } + } + + if (sm_policy_update_context_data->ref_qos_indication) { + if (cJSON_AddBoolToObject(item, "refQosIndication", sm_policy_update_context_data->ref_qos_indication) == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ref_qos_indication]"); + goto end; + } + } + + if (sm_policy_update_context_data->qos_flow_usage) { + cJSON *qos_flow_usage_local_JSON = OpenAPI_qos_flow_usage_convertToJSON(sm_policy_update_context_data->qos_flow_usage); + if (qos_flow_usage_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [qos_flow_usage]"); + goto end; + } + cJSON_AddItemToObject(item, "qosFlowUsage", qos_flow_usage_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [qos_flow_usage]"); + goto end; + } + } + + if (sm_policy_update_context_data->credit_manage_status) { + cJSON *credit_manage_status_local_JSON = OpenAPI_credit_management_status_convertToJSON(sm_policy_update_context_data->credit_manage_status); + if (credit_manage_status_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [credit_manage_status]"); + goto end; + } + cJSON_AddItemToObject(item, "creditManageStatus", credit_manage_status_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [credit_manage_status]"); + goto end; + } + } + + if (sm_policy_update_context_data->serv_nf_id) { + cJSON *serv_nf_id_local_JSON = OpenAPI_serving_nf_identity_convertToJSON(sm_policy_update_context_data->serv_nf_id); + if (serv_nf_id_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [serv_nf_id]"); + goto end; + } + cJSON_AddItemToObject(item, "servNfId", serv_nf_id_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [serv_nf_id]"); + goto end; + } + } + + if (sm_policy_update_context_data->trace_req) { + cJSON *trace_req_local_JSON = OpenAPI_trace_data_convertToJSON(sm_policy_update_context_data->trace_req); + if (trace_req_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [trace_req]"); + goto end; + } + cJSON_AddItemToObject(item, "traceReq", trace_req_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [trace_req]"); + goto end; + } + } + + if (sm_policy_update_context_data->ma_pdu_ind) { + cJSON *ma_pdu_ind_local_JSON = OpenAPI_ma_pdu_indication_convertToJSON(sm_policy_update_context_data->ma_pdu_ind); + if (ma_pdu_ind_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ma_pdu_ind]"); + goto end; + } + cJSON_AddItemToObject(item, "maPduInd", ma_pdu_ind_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [ma_pdu_ind]"); + goto end; + } + } + + if (sm_policy_update_context_data->atsss_capab) { + cJSON *atsss_capab_local_JSON = OpenAPI_atsss_capability_convertToJSON(sm_policy_update_context_data->atsss_capab); + if (atsss_capab_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [atsss_capab]"); + goto end; + } + cJSON_AddItemToObject(item, "atsssCapab", atsss_capab_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [atsss_capab]"); + goto end; + } + } + + if (sm_policy_update_context_data->tsn_bridge_info) { + cJSON *tsn_bridge_info_local_JSON = OpenAPI_tsn_bridge_info_convertToJSON(sm_policy_update_context_data->tsn_bridge_info); + if (tsn_bridge_info_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [tsn_bridge_info]"); + goto end; + } + cJSON_AddItemToObject(item, "tsnBridgeInfo", tsn_bridge_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [tsn_bridge_info]"); + goto end; + } + } + + if (sm_policy_update_context_data->tsn_port_man_cont_dstt) { + cJSON *tsn_port_man_cont_dstt_local_JSON = OpenAPI_port_management_container_convertToJSON(sm_policy_update_context_data->tsn_port_man_cont_dstt); + if (tsn_port_man_cont_dstt_local_JSON == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [tsn_port_man_cont_dstt]"); + goto end; + } + cJSON_AddItemToObject(item, "tsnPortManContDstt", tsn_port_man_cont_dstt_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [tsn_port_man_cont_dstt]"); + goto end; + } + } + + if (sm_policy_update_context_data->tsn_port_man_cont_nwtts) { + cJSON *tsn_port_man_cont_nwttsList = cJSON_AddArrayToObject(item, "tsnPortManContNwtts"); + if (tsn_port_man_cont_nwttsList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + + OpenAPI_lnode_t *tsn_port_man_cont_nwtts_node; + if (sm_policy_update_context_data->tsn_port_man_cont_nwtts) { + OpenAPI_list_for_each(sm_policy_update_context_data->tsn_port_man_cont_nwtts, tsn_port_man_cont_nwtts_node) { + cJSON *itemLocal = OpenAPI_port_management_container_convertToJSON(tsn_port_man_cont_nwtts_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + cJSON_AddItemToArray(tsn_port_man_cont_nwttsList, itemLocal); + } + } + } + + if (sm_policy_update_context_data->mul_addr_infos) { + cJSON *mul_addr_infosList = cJSON_AddArrayToObject(item, "mulAddrInfos"); + if (mul_addr_infosList == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [mul_addr_infos]"); + goto end; + } + + OpenAPI_lnode_t *mul_addr_infos_node; + if (sm_policy_update_context_data->mul_addr_infos) { + OpenAPI_list_for_each(sm_policy_update_context_data->mul_addr_infos, mul_addr_infos_node) { + cJSON *itemLocal = OpenAPI_ip_multicast_address_info_convertToJSON(mul_addr_infos_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed [mul_addr_infos]"); + goto end; + } + cJSON_AddItemToArray(mul_addr_infosList, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_sm_policy_update_context_data_t *OpenAPI_sm_policy_update_context_data_parseFromJSON(cJSON *sm_policy_update_context_dataJSON) +{ + OpenAPI_sm_policy_update_context_data_t *sm_policy_update_context_data_local_var = NULL; + cJSON *rep_policy_ctrl_req_triggers = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "repPolicyCtrlReqTriggers"); + + OpenAPI_list_t *rep_policy_ctrl_req_triggersList; + if (rep_policy_ctrl_req_triggers) { + cJSON *rep_policy_ctrl_req_triggers_local_nonprimitive; + if (!cJSON_IsArray(rep_policy_ctrl_req_triggers)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rep_policy_ctrl_req_triggers]"); + goto end; + } + + rep_policy_ctrl_req_triggersList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rep_policy_ctrl_req_triggers_local_nonprimitive, rep_policy_ctrl_req_triggers ) { + if (!cJSON_IsObject(rep_policy_ctrl_req_triggers_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rep_policy_ctrl_req_triggers]"); + goto end; + } + OpenAPI_policy_control_request_trigger_t *rep_policy_ctrl_req_triggersItem = OpenAPI_policy_control_request_trigger_parseFromJSON(rep_policy_ctrl_req_triggers_local_nonprimitive); + + OpenAPI_list_add(rep_policy_ctrl_req_triggersList, rep_policy_ctrl_req_triggersItem); + } + } + + cJSON *acc_net_ch_ids = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "accNetChIds"); + + OpenAPI_list_t *acc_net_ch_idsList; + if (acc_net_ch_ids) { + cJSON *acc_net_ch_ids_local_nonprimitive; + if (!cJSON_IsArray(acc_net_ch_ids)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [acc_net_ch_ids]"); + goto end; + } + + acc_net_ch_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(acc_net_ch_ids_local_nonprimitive, acc_net_ch_ids ) { + if (!cJSON_IsObject(acc_net_ch_ids_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [acc_net_ch_ids]"); + goto end; + } + OpenAPI_acc_net_ch_id_t *acc_net_ch_idsItem = OpenAPI_acc_net_ch_id_parseFromJSON(acc_net_ch_ids_local_nonprimitive); + + OpenAPI_list_add(acc_net_ch_idsList, acc_net_ch_idsItem); + } + } + + cJSON *access_type = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "accessType"); + + OpenAPI_access_type_e access_typeVariable; + if (access_type) { + if (!cJSON_IsString(access_type)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [access_type]"); + goto end; + } + access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring); + } + + cJSON *rat_type = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ratType"); + + OpenAPI_rat_type_e rat_typeVariable; + if (rat_type) { + if (!cJSON_IsString(rat_type)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rat_type]"); + goto end; + } + rat_typeVariable = OpenAPI_rat_type_FromString(rat_type->valuestring); + } + + cJSON *add_access_info = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "addAccessInfo"); + + OpenAPI_additional_access_info_t *add_access_info_local_nonprim = NULL; + if (add_access_info) { + add_access_info_local_nonprim = OpenAPI_additional_access_info_parseFromJSON(add_access_info); + } + + cJSON *rel_access_info = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "relAccessInfo"); + + OpenAPI_additional_access_info_t *rel_access_info_local_nonprim = NULL; + if (rel_access_info) { + rel_access_info_local_nonprim = OpenAPI_additional_access_info_parseFromJSON(rel_access_info); + } + + cJSON *serving_network = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "servingNetwork"); + + OpenAPI_plmn_id_nid_t *serving_network_local_nonprim = NULL; + if (serving_network) { + serving_network_local_nonprim = OpenAPI_plmn_id_nid_parseFromJSON(serving_network); + } + + cJSON *user_location_info = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "userLocationInfo"); + + OpenAPI_user_location_t *user_location_info_local_nonprim = NULL; + if (user_location_info) { + user_location_info_local_nonprim = OpenAPI_user_location_parseFromJSON(user_location_info); + } + + cJSON *ue_time_zone = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ueTimeZone"); + + if (ue_time_zone) { + if (!cJSON_IsString(ue_time_zone)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [ue_time_zone]"); + goto end; + } + } + + cJSON *rel_ipv4_address = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "relIpv4Address"); + + if (rel_ipv4_address) { + if (!cJSON_IsString(rel_ipv4_address)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rel_ipv4_address]"); + goto end; + } + } + + cJSON *ipv4_address = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ipv4Address"); + + if (ipv4_address) { + if (!cJSON_IsString(ipv4_address)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [ipv4_address]"); + goto end; + } + } + + cJSON *ip_domain = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ipDomain"); + + if (ip_domain) { + if (!cJSON_IsString(ip_domain)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [ip_domain]"); + goto end; + } + } + + cJSON *ipv6_address_prefix = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ipv6AddressPrefix"); + + if (ipv6_address_prefix) { + if (!cJSON_IsString(ipv6_address_prefix)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [ipv6_address_prefix]"); + goto end; + } + } + + cJSON *rel_ipv6_address_prefix = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "relIpv6AddressPrefix"); + + if (rel_ipv6_address_prefix) { + if (!cJSON_IsString(rel_ipv6_address_prefix)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rel_ipv6_address_prefix]"); + goto end; + } + } + + cJSON *add_ipv6_addr_prefixes = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "addIpv6AddrPrefixes"); + + if (add_ipv6_addr_prefixes) { + if (!cJSON_IsString(add_ipv6_addr_prefixes)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [add_ipv6_addr_prefixes]"); + goto end; + } + } + + cJSON *add_rel_ipv6_addr_prefixes = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "addRelIpv6AddrPrefixes"); + + if (add_rel_ipv6_addr_prefixes) { + if (!cJSON_IsString(add_rel_ipv6_addr_prefixes)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [add_rel_ipv6_addr_prefixes]"); + goto end; + } + } + + cJSON *rel_ue_mac = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "relUeMac"); + + if (rel_ue_mac) { + if (!cJSON_IsString(rel_ue_mac)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rel_ue_mac]"); + goto end; + } + } + + cJSON *ue_mac = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ueMac"); + + if (ue_mac) { + if (!cJSON_IsString(ue_mac)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [ue_mac]"); + goto end; + } + } + + cJSON *subs_sess_ambr = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "subsSessAmbr"); + + OpenAPI_ambr_t *subs_sess_ambr_local_nonprim = NULL; + if (subs_sess_ambr) { + subs_sess_ambr_local_nonprim = OpenAPI_ambr_parseFromJSON(subs_sess_ambr); + } + + cJSON *auth_prof_index = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "authProfIndex"); + + if (auth_prof_index) { + if (!cJSON_IsString(auth_prof_index)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [auth_prof_index]"); + goto end; + } + } + + cJSON *subs_def_qos = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "subsDefQos"); + + OpenAPI_subscribed_default_qos_t *subs_def_qos_local_nonprim = NULL; + if (subs_def_qos) { + subs_def_qos_local_nonprim = OpenAPI_subscribed_default_qos_parseFromJSON(subs_def_qos); + } + + cJSON *num_of_pack_filter = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "numOfPackFilter"); + + if (num_of_pack_filter) { + if (!cJSON_IsNumber(num_of_pack_filter)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [num_of_pack_filter]"); + goto end; + } + } + + cJSON *accu_usage_reports = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "accuUsageReports"); + + OpenAPI_list_t *accu_usage_reportsList; + if (accu_usage_reports) { + cJSON *accu_usage_reports_local_nonprimitive; + if (!cJSON_IsArray(accu_usage_reports)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [accu_usage_reports]"); + goto end; + } + + accu_usage_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(accu_usage_reports_local_nonprimitive, accu_usage_reports ) { + if (!cJSON_IsObject(accu_usage_reports_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [accu_usage_reports]"); + goto end; + } + OpenAPI_accu_usage_report_t *accu_usage_reportsItem = OpenAPI_accu_usage_report_parseFromJSON(accu_usage_reports_local_nonprimitive); + + OpenAPI_list_add(accu_usage_reportsList, accu_usage_reportsItem); + } + } + + cJSON *_3gpp_ps_data_off_status = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "3gppPsDataOffStatus"); + + if (_3gpp_ps_data_off_status) { + if (!cJSON_IsBool(_3gpp_ps_data_off_status)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [_3gpp_ps_data_off_status]"); + goto end; + } + } + + cJSON *app_detection_infos = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "appDetectionInfos"); + + OpenAPI_list_t *app_detection_infosList; + if (app_detection_infos) { + cJSON *app_detection_infos_local_nonprimitive; + if (!cJSON_IsArray(app_detection_infos)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [app_detection_infos]"); + goto end; + } + + app_detection_infosList = OpenAPI_list_create(); + + cJSON_ArrayForEach(app_detection_infos_local_nonprimitive, app_detection_infos ) { + if (!cJSON_IsObject(app_detection_infos_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [app_detection_infos]"); + goto end; + } + OpenAPI_app_detection_info_t *app_detection_infosItem = OpenAPI_app_detection_info_parseFromJSON(app_detection_infos_local_nonprimitive); + + OpenAPI_list_add(app_detection_infosList, app_detection_infosItem); + } + } + + cJSON *rule_reports = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ruleReports"); + + OpenAPI_list_t *rule_reportsList; + if (rule_reports) { + cJSON *rule_reports_local_nonprimitive; + if (!cJSON_IsArray(rule_reports)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rule_reports]"); + goto end; + } + + rule_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(rule_reports_local_nonprimitive, rule_reports ) { + if (!cJSON_IsObject(rule_reports_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rule_reports]"); + goto end; + } + OpenAPI_rule_report_t *rule_reportsItem = OpenAPI_rule_report_parseFromJSON(rule_reports_local_nonprimitive); + + OpenAPI_list_add(rule_reportsList, rule_reportsItem); + } + } + + cJSON *sess_rule_reports = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "sessRuleReports"); + + OpenAPI_list_t *sess_rule_reportsList; + if (sess_rule_reports) { + cJSON *sess_rule_reports_local_nonprimitive; + if (!cJSON_IsArray(sess_rule_reports)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [sess_rule_reports]"); + goto end; + } + + sess_rule_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(sess_rule_reports_local_nonprimitive, sess_rule_reports ) { + if (!cJSON_IsObject(sess_rule_reports_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [sess_rule_reports]"); + goto end; + } + OpenAPI_session_rule_report_t *sess_rule_reportsItem = OpenAPI_session_rule_report_parseFromJSON(sess_rule_reports_local_nonprimitive); + + OpenAPI_list_add(sess_rule_reportsList, sess_rule_reportsItem); + } + } + + cJSON *qnc_reports = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "qncReports"); + + OpenAPI_list_t *qnc_reportsList; + if (qnc_reports) { + cJSON *qnc_reports_local_nonprimitive; + if (!cJSON_IsArray(qnc_reports)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [qnc_reports]"); + goto end; + } + + qnc_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(qnc_reports_local_nonprimitive, qnc_reports ) { + if (!cJSON_IsObject(qnc_reports_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [qnc_reports]"); + goto end; + } + OpenAPI_qos_notification_control_info_t *qnc_reportsItem = OpenAPI_qos_notification_control_info_parseFromJSON(qnc_reports_local_nonprimitive); + + OpenAPI_list_add(qnc_reportsList, qnc_reportsItem); + } + } + + cJSON *qos_mon_reports = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "qosMonReports"); + + OpenAPI_list_t *qos_mon_reportsList; + if (qos_mon_reports) { + cJSON *qos_mon_reports_local_nonprimitive; + if (!cJSON_IsArray(qos_mon_reports)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [qos_mon_reports]"); + goto end; + } + + qos_mon_reportsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(qos_mon_reports_local_nonprimitive, qos_mon_reports ) { + if (!cJSON_IsObject(qos_mon_reports_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [qos_mon_reports]"); + goto end; + } + OpenAPI_qos_monitoring_report_t *qos_mon_reportsItem = OpenAPI_qos_monitoring_report_parseFromJSON(qos_mon_reports_local_nonprimitive); + + OpenAPI_list_add(qos_mon_reportsList, qos_mon_reportsItem); + } + } + + cJSON *user_location_info_time = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "userLocationInfoTime"); + + if (user_location_info_time) { + if (!cJSON_IsString(user_location_info_time)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [user_location_info_time]"); + goto end; + } + } + + cJSON *rep_pra_infos = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "repPraInfos"); + + OpenAPI_list_t *rep_pra_infosList; + if (rep_pra_infos) { + cJSON *rep_pra_infos_local_map; + if (!cJSON_IsObject(rep_pra_infos)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rep_pra_infos]"); + goto end; + } + rep_pra_infosList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(rep_pra_infos_local_map, rep_pra_infos) { + cJSON *localMapObject = rep_pra_infos_local_map; + if (!cJSON_IsObject(rep_pra_infos_local_map)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [rep_pra_infos]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_presence_info_parseFromJSON(localMapObject)); + OpenAPI_list_add(rep_pra_infosList, localMapKeyPair); + } + } + + cJSON *ue_init_res_req = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "ueInitResReq"); + + OpenAPI_ue_initiated_resource_request_t *ue_init_res_req_local_nonprim = NULL; + if (ue_init_res_req) { + ue_init_res_req_local_nonprim = OpenAPI_ue_initiated_resource_request_parseFromJSON(ue_init_res_req); + } + + cJSON *ref_qos_indication = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "refQosIndication"); + + if (ref_qos_indication) { + if (!cJSON_IsBool(ref_qos_indication)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [ref_qos_indication]"); + goto end; + } + } + + cJSON *qos_flow_usage = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "qosFlowUsage"); + + OpenAPI_qos_flow_usage_t *qos_flow_usage_local_nonprim = NULL; + if (qos_flow_usage) { + qos_flow_usage_local_nonprim = OpenAPI_qos_flow_usage_parseFromJSON(qos_flow_usage); + } + + cJSON *credit_manage_status = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "creditManageStatus"); + + OpenAPI_credit_management_status_t *credit_manage_status_local_nonprim = NULL; + if (credit_manage_status) { + credit_manage_status_local_nonprim = OpenAPI_credit_management_status_parseFromJSON(credit_manage_status); + } + + cJSON *serv_nf_id = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "servNfId"); + + OpenAPI_serving_nf_identity_t *serv_nf_id_local_nonprim = NULL; + if (serv_nf_id) { + serv_nf_id_local_nonprim = OpenAPI_serving_nf_identity_parseFromJSON(serv_nf_id); + } + + cJSON *trace_req = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "traceReq"); + + OpenAPI_trace_data_t *trace_req_local_nonprim = NULL; + if (trace_req) { + trace_req_local_nonprim = OpenAPI_trace_data_parseFromJSON(trace_req); + } + + cJSON *ma_pdu_ind = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "maPduInd"); + + OpenAPI_ma_pdu_indication_t *ma_pdu_ind_local_nonprim = NULL; + if (ma_pdu_ind) { + ma_pdu_ind_local_nonprim = OpenAPI_ma_pdu_indication_parseFromJSON(ma_pdu_ind); + } + + cJSON *atsss_capab = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "atsssCapab"); + + OpenAPI_atsss_capability_t *atsss_capab_local_nonprim = NULL; + if (atsss_capab) { + atsss_capab_local_nonprim = OpenAPI_atsss_capability_parseFromJSON(atsss_capab); + } + + cJSON *tsn_bridge_info = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "tsnBridgeInfo"); + + OpenAPI_tsn_bridge_info_t *tsn_bridge_info_local_nonprim = NULL; + if (tsn_bridge_info) { + tsn_bridge_info_local_nonprim = OpenAPI_tsn_bridge_info_parseFromJSON(tsn_bridge_info); + } + + cJSON *tsn_port_man_cont_dstt = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "tsnPortManContDstt"); + + OpenAPI_port_management_container_t *tsn_port_man_cont_dstt_local_nonprim = NULL; + if (tsn_port_man_cont_dstt) { + tsn_port_man_cont_dstt_local_nonprim = OpenAPI_port_management_container_parseFromJSON(tsn_port_man_cont_dstt); + } + + cJSON *tsn_port_man_cont_nwtts = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "tsnPortManContNwtts"); + + OpenAPI_list_t *tsn_port_man_cont_nwttsList; + if (tsn_port_man_cont_nwtts) { + cJSON *tsn_port_man_cont_nwtts_local_nonprimitive; + if (!cJSON_IsArray(tsn_port_man_cont_nwtts)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + + tsn_port_man_cont_nwttsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(tsn_port_man_cont_nwtts_local_nonprimitive, tsn_port_man_cont_nwtts ) { + if (!cJSON_IsObject(tsn_port_man_cont_nwtts_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [tsn_port_man_cont_nwtts]"); + goto end; + } + OpenAPI_port_management_container_t *tsn_port_man_cont_nwttsItem = OpenAPI_port_management_container_parseFromJSON(tsn_port_man_cont_nwtts_local_nonprimitive); + + OpenAPI_list_add(tsn_port_man_cont_nwttsList, tsn_port_man_cont_nwttsItem); + } + } + + cJSON *mul_addr_infos = cJSON_GetObjectItemCaseSensitive(sm_policy_update_context_dataJSON, "mulAddrInfos"); + + OpenAPI_list_t *mul_addr_infosList; + if (mul_addr_infos) { + cJSON *mul_addr_infos_local_nonprimitive; + if (!cJSON_IsArray(mul_addr_infos)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [mul_addr_infos]"); + goto end; + } + + mul_addr_infosList = OpenAPI_list_create(); + + cJSON_ArrayForEach(mul_addr_infos_local_nonprimitive, mul_addr_infos ) { + if (!cJSON_IsObject(mul_addr_infos_local_nonprimitive)) { + ogs_error("OpenAPI_sm_policy_update_context_data_parseFromJSON() failed [mul_addr_infos]"); + goto end; + } + OpenAPI_ip_multicast_address_info_t *mul_addr_infosItem = OpenAPI_ip_multicast_address_info_parseFromJSON(mul_addr_infos_local_nonprimitive); + + OpenAPI_list_add(mul_addr_infosList, mul_addr_infosItem); + } + } + + sm_policy_update_context_data_local_var = OpenAPI_sm_policy_update_context_data_create ( + rep_policy_ctrl_req_triggers ? rep_policy_ctrl_req_triggersList : NULL, + acc_net_ch_ids ? acc_net_ch_idsList : NULL, + access_type ? access_typeVariable : 0, + rat_type ? rat_typeVariable : 0, + add_access_info ? add_access_info_local_nonprim : NULL, + rel_access_info ? rel_access_info_local_nonprim : NULL, + serving_network ? serving_network_local_nonprim : NULL, + user_location_info ? user_location_info_local_nonprim : NULL, + ue_time_zone ? ogs_strdup(ue_time_zone->valuestring) : NULL, + rel_ipv4_address ? ogs_strdup(rel_ipv4_address->valuestring) : NULL, + ipv4_address ? ogs_strdup(ipv4_address->valuestring) : NULL, + ip_domain ? ogs_strdup(ip_domain->valuestring) : NULL, + ipv6_address_prefix ? ogs_strdup(ipv6_address_prefix->valuestring) : NULL, + rel_ipv6_address_prefix ? ogs_strdup(rel_ipv6_address_prefix->valuestring) : NULL, + add_ipv6_addr_prefixes ? ogs_strdup(add_ipv6_addr_prefixes->valuestring) : NULL, + add_rel_ipv6_addr_prefixes ? ogs_strdup(add_rel_ipv6_addr_prefixes->valuestring) : NULL, + rel_ue_mac ? ogs_strdup(rel_ue_mac->valuestring) : NULL, + ue_mac ? ogs_strdup(ue_mac->valuestring) : NULL, + subs_sess_ambr ? subs_sess_ambr_local_nonprim : NULL, + auth_prof_index ? ogs_strdup(auth_prof_index->valuestring) : NULL, + subs_def_qos ? subs_def_qos_local_nonprim : NULL, + num_of_pack_filter ? num_of_pack_filter->valuedouble : 0, + accu_usage_reports ? accu_usage_reportsList : NULL, + _3gpp_ps_data_off_status ? _3gpp_ps_data_off_status->valueint : 0, + app_detection_infos ? app_detection_infosList : NULL, + rule_reports ? rule_reportsList : NULL, + sess_rule_reports ? sess_rule_reportsList : NULL, + qnc_reports ? qnc_reportsList : NULL, + qos_mon_reports ? qos_mon_reportsList : NULL, + user_location_info_time ? ogs_strdup(user_location_info_time->valuestring) : NULL, + rep_pra_infos ? rep_pra_infosList : NULL, + ue_init_res_req ? ue_init_res_req_local_nonprim : NULL, + ref_qos_indication ? ref_qos_indication->valueint : 0, + qos_flow_usage ? qos_flow_usage_local_nonprim : NULL, + credit_manage_status ? credit_manage_status_local_nonprim : NULL, + serv_nf_id ? serv_nf_id_local_nonprim : NULL, + trace_req ? trace_req_local_nonprim : NULL, + ma_pdu_ind ? ma_pdu_ind_local_nonprim : NULL, + atsss_capab ? atsss_capab_local_nonprim : NULL, + tsn_bridge_info ? tsn_bridge_info_local_nonprim : NULL, + tsn_port_man_cont_dstt ? tsn_port_man_cont_dstt_local_nonprim : NULL, + tsn_port_man_cont_nwtts ? tsn_port_man_cont_nwttsList : NULL, + mul_addr_infos ? mul_addr_infosList : NULL + ); + + return sm_policy_update_context_data_local_var; +end: + return NULL; +} + +OpenAPI_sm_policy_update_context_data_t *OpenAPI_sm_policy_update_context_data_copy(OpenAPI_sm_policy_update_context_data_t *dst, OpenAPI_sm_policy_update_context_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_sm_policy_update_context_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_sm_policy_update_context_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_sm_policy_update_context_data_free(dst); + dst = OpenAPI_sm_policy_update_context_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/sm_policy_update_context_data.h b/lib/sbi/openapi/model/sm_policy_update_context_data.h new file mode 100644 index 000000000..483fc346e --- /dev/null +++ b/lib/sbi/openapi/model/sm_policy_update_context_data.h @@ -0,0 +1,148 @@ +/* + * sm_policy_update_context_data.h + * + * + */ + +#ifndef _OpenAPI_sm_policy_update_context_data_H_ +#define _OpenAPI_sm_policy_update_context_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "acc_net_ch_id.h" +#include "access_type.h" +#include "accu_usage_report.h" +#include "additional_access_info.h" +#include "ambr.h" +#include "app_detection_info.h" +#include "atsss_capability.h" +#include "credit_management_status.h" +#include "ip_multicast_address_info.h" +#include "ma_pdu_indication.h" +#include "plmn_id_nid.h" +#include "policy_control_request_trigger.h" +#include "port_management_container.h" +#include "presence_info.h" +#include "qos_flow_usage.h" +#include "qos_monitoring_report.h" +#include "qos_notification_control_info.h" +#include "rat_type.h" +#include "rule_report.h" +#include "serving_nf_identity.h" +#include "session_rule_report.h" +#include "subscribed_default_qos.h" +#include "trace_data.h" +#include "tsn_bridge_info.h" +#include "ue_initiated_resource_request.h" +#include "user_location.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_sm_policy_update_context_data_s OpenAPI_sm_policy_update_context_data_t; +typedef struct OpenAPI_sm_policy_update_context_data_s { + OpenAPI_list_t *rep_policy_ctrl_req_triggers; + OpenAPI_list_t *acc_net_ch_ids; + OpenAPI_access_type_e access_type; + OpenAPI_rat_type_e rat_type; + struct OpenAPI_additional_access_info_s *add_access_info; + struct OpenAPI_additional_access_info_s *rel_access_info; + struct OpenAPI_plmn_id_nid_s *serving_network; + struct OpenAPI_user_location_s *user_location_info; + char *ue_time_zone; + char *rel_ipv4_address; + char *ipv4_address; + char *ip_domain; + char *ipv6_address_prefix; + char *rel_ipv6_address_prefix; + char *add_ipv6_addr_prefixes; + char *add_rel_ipv6_addr_prefixes; + char *rel_ue_mac; + char *ue_mac; + struct OpenAPI_ambr_s *subs_sess_ambr; + char *auth_prof_index; + struct OpenAPI_subscribed_default_qos_s *subs_def_qos; + int num_of_pack_filter; + OpenAPI_list_t *accu_usage_reports; + int _3gpp_ps_data_off_status; + OpenAPI_list_t *app_detection_infos; + OpenAPI_list_t *rule_reports; + OpenAPI_list_t *sess_rule_reports; + OpenAPI_list_t *qnc_reports; + OpenAPI_list_t *qos_mon_reports; + char *user_location_info_time; + OpenAPI_list_t* rep_pra_infos; + struct OpenAPI_ue_initiated_resource_request_s *ue_init_res_req; + int ref_qos_indication; + struct OpenAPI_qos_flow_usage_s *qos_flow_usage; + struct OpenAPI_credit_management_status_s *credit_manage_status; + struct OpenAPI_serving_nf_identity_s *serv_nf_id; + struct OpenAPI_trace_data_s *trace_req; + struct OpenAPI_ma_pdu_indication_s *ma_pdu_ind; + struct OpenAPI_atsss_capability_s *atsss_capab; + struct OpenAPI_tsn_bridge_info_s *tsn_bridge_info; + struct OpenAPI_port_management_container_s *tsn_port_man_cont_dstt; + OpenAPI_list_t *tsn_port_man_cont_nwtts; + OpenAPI_list_t *mul_addr_infos; +} OpenAPI_sm_policy_update_context_data_t; + +OpenAPI_sm_policy_update_context_data_t *OpenAPI_sm_policy_update_context_data_create( + OpenAPI_list_t *rep_policy_ctrl_req_triggers, + OpenAPI_list_t *acc_net_ch_ids, + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type, + OpenAPI_additional_access_info_t *add_access_info, + OpenAPI_additional_access_info_t *rel_access_info, + OpenAPI_plmn_id_nid_t *serving_network, + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone, + char *rel_ipv4_address, + char *ipv4_address, + char *ip_domain, + char *ipv6_address_prefix, + char *rel_ipv6_address_prefix, + char *add_ipv6_addr_prefixes, + char *add_rel_ipv6_addr_prefixes, + char *rel_ue_mac, + char *ue_mac, + OpenAPI_ambr_t *subs_sess_ambr, + char *auth_prof_index, + OpenAPI_subscribed_default_qos_t *subs_def_qos, + int num_of_pack_filter, + OpenAPI_list_t *accu_usage_reports, + int _3gpp_ps_data_off_status, + OpenAPI_list_t *app_detection_infos, + OpenAPI_list_t *rule_reports, + OpenAPI_list_t *sess_rule_reports, + OpenAPI_list_t *qnc_reports, + OpenAPI_list_t *qos_mon_reports, + char *user_location_info_time, + OpenAPI_list_t* rep_pra_infos, + OpenAPI_ue_initiated_resource_request_t *ue_init_res_req, + int ref_qos_indication, + OpenAPI_qos_flow_usage_t *qos_flow_usage, + OpenAPI_credit_management_status_t *credit_manage_status, + OpenAPI_serving_nf_identity_t *serv_nf_id, + OpenAPI_trace_data_t *trace_req, + OpenAPI_ma_pdu_indication_t *ma_pdu_ind, + OpenAPI_atsss_capability_t *atsss_capab, + OpenAPI_tsn_bridge_info_t *tsn_bridge_info, + OpenAPI_port_management_container_t *tsn_port_man_cont_dstt, + OpenAPI_list_t *tsn_port_man_cont_nwtts, + OpenAPI_list_t *mul_addr_infos + ); +void OpenAPI_sm_policy_update_context_data_free(OpenAPI_sm_policy_update_context_data_t *sm_policy_update_context_data); +OpenAPI_sm_policy_update_context_data_t *OpenAPI_sm_policy_update_context_data_parseFromJSON(cJSON *sm_policy_update_context_dataJSON); +cJSON *OpenAPI_sm_policy_update_context_data_convertToJSON(OpenAPI_sm_policy_update_context_data_t *sm_policy_update_context_data); +OpenAPI_sm_policy_update_context_data_t *OpenAPI_sm_policy_update_context_data_copy(OpenAPI_sm_policy_update_context_data_t *dst, OpenAPI_sm_policy_update_context_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_sm_policy_update_context_data_H_ */ + diff --git a/lib/sbi/openapi/model/smf_selection_data.c b/lib/sbi/openapi/model/smf_selection_data.c new file mode 100644 index 000000000..74b1e290b --- /dev/null +++ b/lib/sbi/openapi/model/smf_selection_data.c @@ -0,0 +1,225 @@ + +#include +#include +#include +#include "smf_selection_data.h" + +OpenAPI_smf_selection_data_t *OpenAPI_smf_selection_data_create( + int unsupp_dnn, + OpenAPI_list_t* candidates, + OpenAPI_snssai_t *snssai, + OpenAPI_snssai_t *mapping_snssai, + char *dnn + ) +{ + OpenAPI_smf_selection_data_t *smf_selection_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_smf_selection_data_t)); + if (!smf_selection_data_local_var) { + return NULL; + } + smf_selection_data_local_var->unsupp_dnn = unsupp_dnn; + smf_selection_data_local_var->candidates = candidates; + smf_selection_data_local_var->snssai = snssai; + smf_selection_data_local_var->mapping_snssai = mapping_snssai; + smf_selection_data_local_var->dnn = dnn; + + return smf_selection_data_local_var; +} + +void OpenAPI_smf_selection_data_free(OpenAPI_smf_selection_data_t *smf_selection_data) +{ + if (NULL == smf_selection_data) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(smf_selection_data->candidates, node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; + OpenAPI_candidate_for_replacement_free(localKeyValue->value); + ogs_free(localKeyValue); + } + OpenAPI_list_free(smf_selection_data->candidates); + OpenAPI_snssai_free(smf_selection_data->snssai); + OpenAPI_snssai_free(smf_selection_data->mapping_snssai); + ogs_free(smf_selection_data->dnn); + ogs_free(smf_selection_data); +} + +cJSON *OpenAPI_smf_selection_data_convertToJSON(OpenAPI_smf_selection_data_t *smf_selection_data) +{ + cJSON *item = NULL; + + if (smf_selection_data == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [SmfSelectionData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (smf_selection_data->unsupp_dnn) { + if (cJSON_AddBoolToObject(item, "unsuppDnn", smf_selection_data->unsupp_dnn) == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [unsupp_dnn]"); + goto end; + } + } + + if (smf_selection_data->candidates) { + cJSON *candidates = cJSON_AddObjectToObject(item, "candidates"); + if (candidates == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [candidates]"); + goto end; + } + cJSON *localMapObject = candidates; + OpenAPI_lnode_t *candidates_node; + if (smf_selection_data->candidates) { + OpenAPI_list_for_each(smf_selection_data->candidates, candidates_node) { + OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)candidates_node->data; + cJSON *itemLocal = OpenAPI_candidate_for_replacement_convertToJSON(localKeyValue->value); + if (itemLocal == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [candidates]"); + goto end; + } + cJSON_AddItemToObject(candidates, localKeyValue->key, itemLocal); + } + } + } + + if (smf_selection_data->snssai) { + cJSON *snssai_local_JSON = OpenAPI_snssai_convertToJSON(smf_selection_data->snssai); + if (snssai_local_JSON == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [snssai]"); + goto end; + } + cJSON_AddItemToObject(item, "snssai", snssai_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [snssai]"); + goto end; + } + } + + if (smf_selection_data->mapping_snssai) { + cJSON *mapping_snssai_local_JSON = OpenAPI_snssai_convertToJSON(smf_selection_data->mapping_snssai); + if (mapping_snssai_local_JSON == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [mapping_snssai]"); + goto end; + } + cJSON_AddItemToObject(item, "mappingSnssai", mapping_snssai_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [mapping_snssai]"); + goto end; + } + } + + if (smf_selection_data->dnn) { + if (cJSON_AddStringToObject(item, "dnn", smf_selection_data->dnn) == NULL) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed [dnn]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_smf_selection_data_t *OpenAPI_smf_selection_data_parseFromJSON(cJSON *smf_selection_dataJSON) +{ + OpenAPI_smf_selection_data_t *smf_selection_data_local_var = NULL; + cJSON *unsupp_dnn = cJSON_GetObjectItemCaseSensitive(smf_selection_dataJSON, "unsuppDnn"); + + if (unsupp_dnn) { + if (!cJSON_IsBool(unsupp_dnn)) { + ogs_error("OpenAPI_smf_selection_data_parseFromJSON() failed [unsupp_dnn]"); + goto end; + } + } + + cJSON *candidates = cJSON_GetObjectItemCaseSensitive(smf_selection_dataJSON, "candidates"); + + OpenAPI_list_t *candidatesList; + if (candidates) { + cJSON *candidates_local_map; + if (!cJSON_IsObject(candidates)) { + ogs_error("OpenAPI_smf_selection_data_parseFromJSON() failed [candidates]"); + goto end; + } + candidatesList = OpenAPI_list_create(); + OpenAPI_map_t *localMapKeyPair = NULL; + cJSON_ArrayForEach(candidates_local_map, candidates) { + cJSON *localMapObject = candidates_local_map; + if (!cJSON_IsObject(candidates_local_map)) { + ogs_error("OpenAPI_smf_selection_data_parseFromJSON() failed [candidates]"); + goto end; + } + localMapKeyPair = OpenAPI_map_create( + localMapObject->string, OpenAPI_candidate_for_replacement_parseFromJSON(localMapObject)); + OpenAPI_list_add(candidatesList, localMapKeyPair); + } + } + + cJSON *snssai = cJSON_GetObjectItemCaseSensitive(smf_selection_dataJSON, "snssai"); + + OpenAPI_snssai_t *snssai_local_nonprim = NULL; + if (snssai) { + snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(snssai); + } + + cJSON *mapping_snssai = cJSON_GetObjectItemCaseSensitive(smf_selection_dataJSON, "mappingSnssai"); + + OpenAPI_snssai_t *mapping_snssai_local_nonprim = NULL; + if (mapping_snssai) { + mapping_snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(mapping_snssai); + } + + cJSON *dnn = cJSON_GetObjectItemCaseSensitive(smf_selection_dataJSON, "dnn"); + + if (dnn) { + if (!cJSON_IsString(dnn)) { + ogs_error("OpenAPI_smf_selection_data_parseFromJSON() failed [dnn]"); + goto end; + } + } + + smf_selection_data_local_var = OpenAPI_smf_selection_data_create ( + unsupp_dnn ? unsupp_dnn->valueint : 0, + candidates ? candidatesList : NULL, + snssai ? snssai_local_nonprim : NULL, + mapping_snssai ? mapping_snssai_local_nonprim : NULL, + dnn ? ogs_strdup(dnn->valuestring) : NULL + ); + + return smf_selection_data_local_var; +end: + return NULL; +} + +OpenAPI_smf_selection_data_t *OpenAPI_smf_selection_data_copy(OpenAPI_smf_selection_data_t *dst, OpenAPI_smf_selection_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_smf_selection_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_smf_selection_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_smf_selection_data_free(dst); + dst = OpenAPI_smf_selection_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/smf_selection_data.h b/lib/sbi/openapi/model/smf_selection_data.h new file mode 100644 index 000000000..0dff0e5f0 --- /dev/null +++ b/lib/sbi/openapi/model/smf_selection_data.h @@ -0,0 +1,48 @@ +/* + * smf_selection_data.h + * + * + */ + +#ifndef _OpenAPI_smf_selection_data_H_ +#define _OpenAPI_smf_selection_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "candidate_for_replacement.h" +#include "snssai.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_smf_selection_data_s OpenAPI_smf_selection_data_t; +typedef struct OpenAPI_smf_selection_data_s { + int unsupp_dnn; + OpenAPI_list_t* candidates; + struct OpenAPI_snssai_s *snssai; + struct OpenAPI_snssai_s *mapping_snssai; + char *dnn; +} OpenAPI_smf_selection_data_t; + +OpenAPI_smf_selection_data_t *OpenAPI_smf_selection_data_create( + int unsupp_dnn, + OpenAPI_list_t* candidates, + OpenAPI_snssai_t *snssai, + OpenAPI_snssai_t *mapping_snssai, + char *dnn + ); +void OpenAPI_smf_selection_data_free(OpenAPI_smf_selection_data_t *smf_selection_data); +OpenAPI_smf_selection_data_t *OpenAPI_smf_selection_data_parseFromJSON(cJSON *smf_selection_dataJSON); +cJSON *OpenAPI_smf_selection_data_convertToJSON(OpenAPI_smf_selection_data_t *smf_selection_data); +OpenAPI_smf_selection_data_t *OpenAPI_smf_selection_data_copy(OpenAPI_smf_selection_data_t *dst, OpenAPI_smf_selection_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_smf_selection_data_H_ */ + diff --git a/lib/sbi/openapi/model/stationary_indication.c b/lib/sbi/openapi/model/stationary_indication.c index db6a091fa..bfa390384 100644 --- a/lib/sbi/openapi/model/stationary_indication.c +++ b/lib/sbi/openapi/model/stationary_indication.c @@ -4,82 +4,27 @@ #include #include "stationary_indication.h" -OpenAPI_stationary_indication_t *OpenAPI_stationary_indication_create( - ) +char* OpenAPI_stationary_indication_ToString(OpenAPI_stationary_indication_e stationary_indication) { - OpenAPI_stationary_indication_t *stationary_indication_local_var = OpenAPI_malloc(sizeof(OpenAPI_stationary_indication_t)); - if (!stationary_indication_local_var) { - return NULL; - } - - return stationary_indication_local_var; + const char *stationary_indicationArray[] = { "NULL", "STATIONARY", "MOBILE" }; + size_t sizeofArray = sizeof(stationary_indicationArray) / sizeof(stationary_indicationArray[0]); + if (stationary_indication < sizeofArray) + return (char *)stationary_indicationArray[stationary_indication]; + else + return (char *)"Unknown"; } -void OpenAPI_stationary_indication_free(OpenAPI_stationary_indication_t *stationary_indication) +OpenAPI_stationary_indication_e OpenAPI_stationary_indication_FromString(char* stationary_indication) { - if (NULL == stationary_indication) { - return; + int stringToReturn = 0; + const char *stationary_indicationArray[] = { "NULL", "STATIONARY", "MOBILE" }; + size_t sizeofArray = sizeof(stationary_indicationArray) / sizeof(stationary_indicationArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(stationary_indication, stationary_indicationArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; } - OpenAPI_lnode_t *node; - ogs_free(stationary_indication); -} - -cJSON *OpenAPI_stationary_indication_convertToJSON(OpenAPI_stationary_indication_t *stationary_indication) -{ - cJSON *item = NULL; - - if (stationary_indication == NULL) { - ogs_error("OpenAPI_stationary_indication_convertToJSON() failed [StationaryIndication]"); - return NULL; - } - - item = cJSON_CreateObject(); -end: - return item; -} - -OpenAPI_stationary_indication_t *OpenAPI_stationary_indication_parseFromJSON(cJSON *stationary_indicationJSON) -{ - OpenAPI_stationary_indication_t *stationary_indication_local_var = NULL; - stationary_indication_local_var = OpenAPI_stationary_indication_create ( - ); - - return stationary_indication_local_var; -end: - return NULL; -} - -OpenAPI_stationary_indication_t *OpenAPI_stationary_indication_copy(OpenAPI_stationary_indication_t *dst, OpenAPI_stationary_indication_t *src) -{ - cJSON *item = NULL; - char *content = NULL; - - ogs_assert(src); - item = OpenAPI_stationary_indication_convertToJSON(src); - if (!item) { - ogs_error("OpenAPI_stationary_indication_convertToJSON() failed"); - return NULL; - } - - content = cJSON_Print(item); - cJSON_Delete(item); - - if (!content) { - ogs_error("cJSON_Print() failed"); - return NULL; - } - - item = cJSON_Parse(content); - ogs_free(content); - if (!item) { - ogs_error("cJSON_Parse() failed"); - return NULL; - } - - OpenAPI_stationary_indication_free(dst); - dst = OpenAPI_stationary_indication_parseFromJSON(item); - cJSON_Delete(item); - - return dst; + return 0; } diff --git a/lib/sbi/openapi/model/stationary_indication.h b/lib/sbi/openapi/model/stationary_indication.h index 6987d2e4f..ad44f0b72 100644 --- a/lib/sbi/openapi/model/stationary_indication.h +++ b/lib/sbi/openapi/model/stationary_indication.h @@ -1,7 +1,7 @@ /* * stationary_indication.h * - * Possible values are - STATIONARY: Identifies the UE is stationary - MOBILE: Identifies the UE is mobile + * */ #ifndef _OpenAPI_stationary_indication_H_ @@ -17,16 +17,11 @@ extern "C" { #endif -typedef struct OpenAPI_stationary_indication_s OpenAPI_stationary_indication_t; -typedef struct OpenAPI_stationary_indication_s { -} OpenAPI_stationary_indication_t; +typedef enum { OpenAPI_stationary_indication_NULL = 0, OpenAPI_stationary_indication_STATIONARY, OpenAPI_stationary_indication_MOBILE } OpenAPI_stationary_indication_e; -OpenAPI_stationary_indication_t *OpenAPI_stationary_indication_create( - ); -void OpenAPI_stationary_indication_free(OpenAPI_stationary_indication_t *stationary_indication); -OpenAPI_stationary_indication_t *OpenAPI_stationary_indication_parseFromJSON(cJSON *stationary_indicationJSON); -cJSON *OpenAPI_stationary_indication_convertToJSON(OpenAPI_stationary_indication_t *stationary_indication); -OpenAPI_stationary_indication_t *OpenAPI_stationary_indication_copy(OpenAPI_stationary_indication_t *dst, OpenAPI_stationary_indication_t *src); +char* OpenAPI_stationary_indication_ToString(OpenAPI_stationary_indication_e stationary_indication); + +OpenAPI_stationary_indication_e OpenAPI_stationary_indication_FromString(char* stationary_indication); #ifdef __cplusplus } diff --git a/lib/sbi/openapi/model/steer_mode_value.c b/lib/sbi/openapi/model/steer_mode_value.c new file mode 100644 index 000000000..3bf63805b --- /dev/null +++ b/lib/sbi/openapi/model/steer_mode_value.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "steer_mode_value.h" + +OpenAPI_steer_mode_value_t *OpenAPI_steer_mode_value_create( + ) +{ + OpenAPI_steer_mode_value_t *steer_mode_value_local_var = OpenAPI_malloc(sizeof(OpenAPI_steer_mode_value_t)); + if (!steer_mode_value_local_var) { + return NULL; + } + + return steer_mode_value_local_var; +} + +void OpenAPI_steer_mode_value_free(OpenAPI_steer_mode_value_t *steer_mode_value) +{ + if (NULL == steer_mode_value) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(steer_mode_value); +} + +cJSON *OpenAPI_steer_mode_value_convertToJSON(OpenAPI_steer_mode_value_t *steer_mode_value) +{ + cJSON *item = NULL; + + if (steer_mode_value == NULL) { + ogs_error("OpenAPI_steer_mode_value_convertToJSON() failed [SteerModeValue]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_steer_mode_value_t *OpenAPI_steer_mode_value_parseFromJSON(cJSON *steer_mode_valueJSON) +{ + OpenAPI_steer_mode_value_t *steer_mode_value_local_var = NULL; + steer_mode_value_local_var = OpenAPI_steer_mode_value_create ( + ); + + return steer_mode_value_local_var; +end: + return NULL; +} + +OpenAPI_steer_mode_value_t *OpenAPI_steer_mode_value_copy(OpenAPI_steer_mode_value_t *dst, OpenAPI_steer_mode_value_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_steer_mode_value_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_steer_mode_value_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_steer_mode_value_free(dst); + dst = OpenAPI_steer_mode_value_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/steer_mode_value.h b/lib/sbi/openapi/model/steer_mode_value.h new file mode 100644 index 000000000..0aaa5ca75 --- /dev/null +++ b/lib/sbi/openapi/model/steer_mode_value.h @@ -0,0 +1,36 @@ +/* + * steer_mode_value.h + * + * + */ + +#ifndef _OpenAPI_steer_mode_value_H_ +#define _OpenAPI_steer_mode_value_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_steer_mode_value_s OpenAPI_steer_mode_value_t; +typedef struct OpenAPI_steer_mode_value_s { +} OpenAPI_steer_mode_value_t; + +OpenAPI_steer_mode_value_t *OpenAPI_steer_mode_value_create( + ); +void OpenAPI_steer_mode_value_free(OpenAPI_steer_mode_value_t *steer_mode_value); +OpenAPI_steer_mode_value_t *OpenAPI_steer_mode_value_parseFromJSON(cJSON *steer_mode_valueJSON); +cJSON *OpenAPI_steer_mode_value_convertToJSON(OpenAPI_steer_mode_value_t *steer_mode_value); +OpenAPI_steer_mode_value_t *OpenAPI_steer_mode_value_copy(OpenAPI_steer_mode_value_t *dst, OpenAPI_steer_mode_value_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_steer_mode_value_H_ */ + diff --git a/lib/sbi/openapi/model/steering_functionality.c b/lib/sbi/openapi/model/steering_functionality.c new file mode 100644 index 000000000..d1445fb32 --- /dev/null +++ b/lib/sbi/openapi/model/steering_functionality.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include "steering_functionality.h" + +OpenAPI_steering_functionality_t *OpenAPI_steering_functionality_create( + ) +{ + OpenAPI_steering_functionality_t *steering_functionality_local_var = OpenAPI_malloc(sizeof(OpenAPI_steering_functionality_t)); + if (!steering_functionality_local_var) { + return NULL; + } + + return steering_functionality_local_var; +} + +void OpenAPI_steering_functionality_free(OpenAPI_steering_functionality_t *steering_functionality) +{ + if (NULL == steering_functionality) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(steering_functionality); +} + +cJSON *OpenAPI_steering_functionality_convertToJSON(OpenAPI_steering_functionality_t *steering_functionality) +{ + cJSON *item = NULL; + + if (steering_functionality == NULL) { + ogs_error("OpenAPI_steering_functionality_convertToJSON() failed [SteeringFunctionality]"); + return NULL; + } + + item = cJSON_CreateObject(); +end: + return item; +} + +OpenAPI_steering_functionality_t *OpenAPI_steering_functionality_parseFromJSON(cJSON *steering_functionalityJSON) +{ + OpenAPI_steering_functionality_t *steering_functionality_local_var = NULL; + steering_functionality_local_var = OpenAPI_steering_functionality_create ( + ); + + return steering_functionality_local_var; +end: + return NULL; +} + +OpenAPI_steering_functionality_t *OpenAPI_steering_functionality_copy(OpenAPI_steering_functionality_t *dst, OpenAPI_steering_functionality_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_steering_functionality_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_steering_functionality_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_steering_functionality_free(dst); + dst = OpenAPI_steering_functionality_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/steering_functionality.h b/lib/sbi/openapi/model/steering_functionality.h new file mode 100644 index 000000000..91bd4fd33 --- /dev/null +++ b/lib/sbi/openapi/model/steering_functionality.h @@ -0,0 +1,36 @@ +/* + * steering_functionality.h + * + * Possible values are - MPTCP: Indicates that PCF authorizes the MPTCP functionality to support traffic steering, switching and splitting. - ATSSS_LL: Indicates that PCF authorizes the ATSSS-LL functionality to support traffic steering, switching and splitting. + */ + +#ifndef _OpenAPI_steering_functionality_H_ +#define _OpenAPI_steering_functionality_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_steering_functionality_s OpenAPI_steering_functionality_t; +typedef struct OpenAPI_steering_functionality_s { +} OpenAPI_steering_functionality_t; + +OpenAPI_steering_functionality_t *OpenAPI_steering_functionality_create( + ); +void OpenAPI_steering_functionality_free(OpenAPI_steering_functionality_t *steering_functionality); +OpenAPI_steering_functionality_t *OpenAPI_steering_functionality_parseFromJSON(cJSON *steering_functionalityJSON); +cJSON *OpenAPI_steering_functionality_convertToJSON(OpenAPI_steering_functionality_t *steering_functionality); +OpenAPI_steering_functionality_t *OpenAPI_steering_functionality_copy(OpenAPI_steering_functionality_t *dst, OpenAPI_steering_functionality_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_steering_functionality_H_ */ + diff --git a/lib/sbi/openapi/model/steering_mode.c b/lib/sbi/openapi/model/steering_mode.c new file mode 100644 index 000000000..5762a5eda --- /dev/null +++ b/lib/sbi/openapi/model/steering_mode.c @@ -0,0 +1,196 @@ + +#include +#include +#include +#include "steering_mode.h" + +OpenAPI_steering_mode_t *OpenAPI_steering_mode_create( + OpenAPI_steer_mode_value_t *steer_mode_value, + OpenAPI_access_type_e active, + OpenAPI_access_type_e standby, + int _3g_load, + OpenAPI_access_type_e prio_acc + ) +{ + OpenAPI_steering_mode_t *steering_mode_local_var = OpenAPI_malloc(sizeof(OpenAPI_steering_mode_t)); + if (!steering_mode_local_var) { + return NULL; + } + steering_mode_local_var->steer_mode_value = steer_mode_value; + steering_mode_local_var->active = active; + steering_mode_local_var->standby = standby; + steering_mode_local_var->_3g_load = _3g_load; + steering_mode_local_var->prio_acc = prio_acc; + + return steering_mode_local_var; +} + +void OpenAPI_steering_mode_free(OpenAPI_steering_mode_t *steering_mode) +{ + if (NULL == steering_mode) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_steer_mode_value_free(steering_mode->steer_mode_value); + ogs_free(steering_mode); +} + +cJSON *OpenAPI_steering_mode_convertToJSON(OpenAPI_steering_mode_t *steering_mode) +{ + cJSON *item = NULL; + + if (steering_mode == NULL) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [SteeringMode]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!steering_mode->steer_mode_value) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [steer_mode_value]"); + goto end; + } + cJSON *steer_mode_value_local_JSON = OpenAPI_steer_mode_value_convertToJSON(steering_mode->steer_mode_value); + if (steer_mode_value_local_JSON == NULL) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [steer_mode_value]"); + goto end; + } + cJSON_AddItemToObject(item, "steerModeValue", steer_mode_value_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [steer_mode_value]"); + goto end; + } + + if (steering_mode->active) { + if (cJSON_AddStringToObject(item, "active", OpenAPI_access_type_ToString(steering_mode->active)) == NULL) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [active]"); + goto end; + } + } + + if (steering_mode->standby) { + if (cJSON_AddStringToObject(item, "standby", OpenAPI_access_type_ToString(steering_mode->standby)) == NULL) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [standby]"); + goto end; + } + } + + if (steering_mode->_3g_load) { + if (cJSON_AddNumberToObject(item, "3gLoad", steering_mode->_3g_load) == NULL) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [_3g_load]"); + goto end; + } + } + + if (steering_mode->prio_acc) { + if (cJSON_AddStringToObject(item, "prioAcc", OpenAPI_access_type_ToString(steering_mode->prio_acc)) == NULL) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed [prio_acc]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_steering_mode_t *OpenAPI_steering_mode_parseFromJSON(cJSON *steering_modeJSON) +{ + OpenAPI_steering_mode_t *steering_mode_local_var = NULL; + cJSON *steer_mode_value = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "steerModeValue"); + if (!steer_mode_value) { + ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [steer_mode_value]"); + goto end; + } + + OpenAPI_steer_mode_value_t *steer_mode_value_local_nonprim = NULL; + + steer_mode_value_local_nonprim = OpenAPI_steer_mode_value_parseFromJSON(steer_mode_value); + + cJSON *active = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "active"); + + OpenAPI_access_type_e activeVariable; + if (active) { + if (!cJSON_IsString(active)) { + ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [active]"); + goto end; + } + activeVariable = OpenAPI_access_type_FromString(active->valuestring); + } + + cJSON *standby = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "standby"); + + OpenAPI_access_type_e standbyVariable; + if (standby) { + if (!cJSON_IsString(standby)) { + ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [standby]"); + goto end; + } + standbyVariable = OpenAPI_access_type_FromString(standby->valuestring); + } + + cJSON *_3g_load = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "3gLoad"); + + if (_3g_load) { + if (!cJSON_IsNumber(_3g_load)) { + ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [_3g_load]"); + goto end; + } + } + + cJSON *prio_acc = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "prioAcc"); + + OpenAPI_access_type_e prio_accVariable; + if (prio_acc) { + if (!cJSON_IsString(prio_acc)) { + ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [prio_acc]"); + goto end; + } + prio_accVariable = OpenAPI_access_type_FromString(prio_acc->valuestring); + } + + steering_mode_local_var = OpenAPI_steering_mode_create ( + steer_mode_value_local_nonprim, + active ? activeVariable : 0, + standby ? standbyVariable : 0, + _3g_load ? _3g_load->valuedouble : 0, + prio_acc ? prio_accVariable : 0 + ); + + return steering_mode_local_var; +end: + return NULL; +} + +OpenAPI_steering_mode_t *OpenAPI_steering_mode_copy(OpenAPI_steering_mode_t *dst, OpenAPI_steering_mode_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_steering_mode_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_steering_mode_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_steering_mode_free(dst); + dst = OpenAPI_steering_mode_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/steering_mode.h b/lib/sbi/openapi/model/steering_mode.h new file mode 100644 index 000000000..f48e93737 --- /dev/null +++ b/lib/sbi/openapi/model/steering_mode.h @@ -0,0 +1,48 @@ +/* + * steering_mode.h + * + * + */ + +#ifndef _OpenAPI_steering_mode_H_ +#define _OpenAPI_steering_mode_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "access_type.h" +#include "steer_mode_value.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_steering_mode_s OpenAPI_steering_mode_t; +typedef struct OpenAPI_steering_mode_s { + struct OpenAPI_steer_mode_value_s *steer_mode_value; + OpenAPI_access_type_e active; + OpenAPI_access_type_e standby; + int _3g_load; + OpenAPI_access_type_e prio_acc; +} OpenAPI_steering_mode_t; + +OpenAPI_steering_mode_t *OpenAPI_steering_mode_create( + OpenAPI_steer_mode_value_t *steer_mode_value, + OpenAPI_access_type_e active, + OpenAPI_access_type_e standby, + int _3g_load, + OpenAPI_access_type_e prio_acc + ); +void OpenAPI_steering_mode_free(OpenAPI_steering_mode_t *steering_mode); +OpenAPI_steering_mode_t *OpenAPI_steering_mode_parseFromJSON(cJSON *steering_modeJSON); +cJSON *OpenAPI_steering_mode_convertToJSON(OpenAPI_steering_mode_t *steering_mode); +OpenAPI_steering_mode_t *OpenAPI_steering_mode_copy(OpenAPI_steering_mode_t *dst, OpenAPI_steering_mode_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_steering_mode_H_ */ + diff --git a/lib/sbi/openapi/model/termination_notification.c b/lib/sbi/openapi/model/termination_notification.c new file mode 100644 index 000000000..e207ecee6 --- /dev/null +++ b/lib/sbi/openapi/model/termination_notification.c @@ -0,0 +1,139 @@ + +#include +#include +#include +#include "termination_notification.h" + +OpenAPI_termination_notification_t *OpenAPI_termination_notification_create( + char *resource_uri, + OpenAPI_sm_policy_association_release_cause_t *cause + ) +{ + OpenAPI_termination_notification_t *termination_notification_local_var = OpenAPI_malloc(sizeof(OpenAPI_termination_notification_t)); + if (!termination_notification_local_var) { + return NULL; + } + termination_notification_local_var->resource_uri = resource_uri; + termination_notification_local_var->cause = cause; + + return termination_notification_local_var; +} + +void OpenAPI_termination_notification_free(OpenAPI_termination_notification_t *termination_notification) +{ + if (NULL == termination_notification) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(termination_notification->resource_uri); + OpenAPI_sm_policy_association_release_cause_free(termination_notification->cause); + ogs_free(termination_notification); +} + +cJSON *OpenAPI_termination_notification_convertToJSON(OpenAPI_termination_notification_t *termination_notification) +{ + cJSON *item = NULL; + + if (termination_notification == NULL) { + ogs_error("OpenAPI_termination_notification_convertToJSON() failed [TerminationNotification]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!termination_notification->resource_uri) { + ogs_error("OpenAPI_termination_notification_convertToJSON() failed [resource_uri]"); + goto end; + } + if (cJSON_AddStringToObject(item, "resourceUri", termination_notification->resource_uri) == NULL) { + ogs_error("OpenAPI_termination_notification_convertToJSON() failed [resource_uri]"); + goto end; + } + + if (!termination_notification->cause) { + ogs_error("OpenAPI_termination_notification_convertToJSON() failed [cause]"); + goto end; + } + cJSON *cause_local_JSON = OpenAPI_sm_policy_association_release_cause_convertToJSON(termination_notification->cause); + if (cause_local_JSON == NULL) { + ogs_error("OpenAPI_termination_notification_convertToJSON() failed [cause]"); + goto end; + } + cJSON_AddItemToObject(item, "cause", cause_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_termination_notification_convertToJSON() failed [cause]"); + goto end; + } + +end: + return item; +} + +OpenAPI_termination_notification_t *OpenAPI_termination_notification_parseFromJSON(cJSON *termination_notificationJSON) +{ + OpenAPI_termination_notification_t *termination_notification_local_var = NULL; + cJSON *resource_uri = cJSON_GetObjectItemCaseSensitive(termination_notificationJSON, "resourceUri"); + if (!resource_uri) { + ogs_error("OpenAPI_termination_notification_parseFromJSON() failed [resource_uri]"); + goto end; + } + + + if (!cJSON_IsString(resource_uri)) { + ogs_error("OpenAPI_termination_notification_parseFromJSON() failed [resource_uri]"); + goto end; + } + + cJSON *cause = cJSON_GetObjectItemCaseSensitive(termination_notificationJSON, "cause"); + if (!cause) { + ogs_error("OpenAPI_termination_notification_parseFromJSON() failed [cause]"); + goto end; + } + + OpenAPI_sm_policy_association_release_cause_t *cause_local_nonprim = NULL; + + cause_local_nonprim = OpenAPI_sm_policy_association_release_cause_parseFromJSON(cause); + + termination_notification_local_var = OpenAPI_termination_notification_create ( + ogs_strdup(resource_uri->valuestring), + cause_local_nonprim + ); + + return termination_notification_local_var; +end: + return NULL; +} + +OpenAPI_termination_notification_t *OpenAPI_termination_notification_copy(OpenAPI_termination_notification_t *dst, OpenAPI_termination_notification_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_termination_notification_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_termination_notification_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_termination_notification_free(dst); + dst = OpenAPI_termination_notification_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/termination_notification.h b/lib/sbi/openapi/model/termination_notification.h new file mode 100644 index 000000000..1e3b63cdf --- /dev/null +++ b/lib/sbi/openapi/model/termination_notification.h @@ -0,0 +1,41 @@ +/* + * termination_notification.h + * + * + */ + +#ifndef _OpenAPI_termination_notification_H_ +#define _OpenAPI_termination_notification_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "sm_policy_association_release_cause.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_termination_notification_s OpenAPI_termination_notification_t; +typedef struct OpenAPI_termination_notification_s { + char *resource_uri; + struct OpenAPI_sm_policy_association_release_cause_s *cause; +} OpenAPI_termination_notification_t; + +OpenAPI_termination_notification_t *OpenAPI_termination_notification_create( + char *resource_uri, + OpenAPI_sm_policy_association_release_cause_t *cause + ); +void OpenAPI_termination_notification_free(OpenAPI_termination_notification_t *termination_notification); +OpenAPI_termination_notification_t *OpenAPI_termination_notification_parseFromJSON(cJSON *termination_notificationJSON); +cJSON *OpenAPI_termination_notification_convertToJSON(OpenAPI_termination_notification_t *termination_notification); +OpenAPI_termination_notification_t *OpenAPI_termination_notification_copy(OpenAPI_termination_notification_t *dst, OpenAPI_termination_notification_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_termination_notification_H_ */ + diff --git a/lib/sbi/openapi/model/traffic_control_data.c b/lib/sbi/openapi/model/traffic_control_data.c new file mode 100644 index 000000000..cbe43e87e --- /dev/null +++ b/lib/sbi/openapi/model/traffic_control_data.c @@ -0,0 +1,456 @@ + +#include +#include +#include +#include "traffic_control_data.h" + +OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_create( + char *tc_id, + OpenAPI_flow_status_t *flow_status, + OpenAPI_redirect_information_t *redirect_info, + OpenAPI_list_t *add_redirect_info, + int mute_notif, + char *traffic_steering_pol_id_dl, + char *traffic_steering_pol_id_ul, + OpenAPI_list_t *route_to_locs, + int traff_corre_ind, + OpenAPI_up_path_chg_event_t *up_path_chg_event, + OpenAPI_steering_functionality_t *steer_fun, + OpenAPI_steering_mode_t *steer_mode_dl, + OpenAPI_steering_mode_t *steer_mode_ul, + OpenAPI_multicast_access_control_t *mul_acc_ctrl + ) +{ + OpenAPI_traffic_control_data_t *traffic_control_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_traffic_control_data_t)); + if (!traffic_control_data_local_var) { + return NULL; + } + traffic_control_data_local_var->tc_id = tc_id; + traffic_control_data_local_var->flow_status = flow_status; + traffic_control_data_local_var->redirect_info = redirect_info; + traffic_control_data_local_var->add_redirect_info = add_redirect_info; + traffic_control_data_local_var->mute_notif = mute_notif; + traffic_control_data_local_var->traffic_steering_pol_id_dl = traffic_steering_pol_id_dl; + traffic_control_data_local_var->traffic_steering_pol_id_ul = traffic_steering_pol_id_ul; + traffic_control_data_local_var->route_to_locs = route_to_locs; + traffic_control_data_local_var->traff_corre_ind = traff_corre_ind; + traffic_control_data_local_var->up_path_chg_event = up_path_chg_event; + traffic_control_data_local_var->steer_fun = steer_fun; + traffic_control_data_local_var->steer_mode_dl = steer_mode_dl; + traffic_control_data_local_var->steer_mode_ul = steer_mode_ul; + traffic_control_data_local_var->mul_acc_ctrl = mul_acc_ctrl; + + return traffic_control_data_local_var; +} + +void OpenAPI_traffic_control_data_free(OpenAPI_traffic_control_data_t *traffic_control_data) +{ + if (NULL == traffic_control_data) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(traffic_control_data->tc_id); + OpenAPI_flow_status_free(traffic_control_data->flow_status); + OpenAPI_redirect_information_free(traffic_control_data->redirect_info); + OpenAPI_list_for_each(traffic_control_data->add_redirect_info, node) { + OpenAPI_redirect_information_free(node->data); + } + OpenAPI_list_free(traffic_control_data->add_redirect_info); + ogs_free(traffic_control_data->traffic_steering_pol_id_dl); + ogs_free(traffic_control_data->traffic_steering_pol_id_ul); + OpenAPI_list_for_each(traffic_control_data->route_to_locs, node) { + OpenAPI_route_to_location_free(node->data); + } + OpenAPI_list_free(traffic_control_data->route_to_locs); + OpenAPI_up_path_chg_event_free(traffic_control_data->up_path_chg_event); + OpenAPI_steering_functionality_free(traffic_control_data->steer_fun); + OpenAPI_steering_mode_free(traffic_control_data->steer_mode_dl); + OpenAPI_steering_mode_free(traffic_control_data->steer_mode_ul); + OpenAPI_multicast_access_control_free(traffic_control_data->mul_acc_ctrl); + ogs_free(traffic_control_data); +} + +cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t *traffic_control_data) +{ + cJSON *item = NULL; + + if (traffic_control_data == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [TrafficControlData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!traffic_control_data->tc_id) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [tc_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "tcId", traffic_control_data->tc_id) == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [tc_id]"); + goto end; + } + + if (traffic_control_data->flow_status) { + cJSON *flow_status_local_JSON = OpenAPI_flow_status_convertToJSON(traffic_control_data->flow_status); + if (flow_status_local_JSON == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [flow_status]"); + goto end; + } + cJSON_AddItemToObject(item, "flowStatus", flow_status_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [flow_status]"); + goto end; + } + } + + if (traffic_control_data->redirect_info) { + cJSON *redirect_info_local_JSON = OpenAPI_redirect_information_convertToJSON(traffic_control_data->redirect_info); + if (redirect_info_local_JSON == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [redirect_info]"); + goto end; + } + cJSON_AddItemToObject(item, "redirectInfo", redirect_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [redirect_info]"); + goto end; + } + } + + if (traffic_control_data->add_redirect_info) { + cJSON *add_redirect_infoList = cJSON_AddArrayToObject(item, "addRedirectInfo"); + if (add_redirect_infoList == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [add_redirect_info]"); + goto end; + } + + OpenAPI_lnode_t *add_redirect_info_node; + if (traffic_control_data->add_redirect_info) { + OpenAPI_list_for_each(traffic_control_data->add_redirect_info, add_redirect_info_node) { + cJSON *itemLocal = OpenAPI_redirect_information_convertToJSON(add_redirect_info_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [add_redirect_info]"); + goto end; + } + cJSON_AddItemToArray(add_redirect_infoList, itemLocal); + } + } + } + + if (traffic_control_data->mute_notif) { + if (cJSON_AddBoolToObject(item, "muteNotif", traffic_control_data->mute_notif) == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [mute_notif]"); + goto end; + } + } + + if (traffic_control_data->traffic_steering_pol_id_dl) { + if (cJSON_AddStringToObject(item, "trafficSteeringPolIdDl", traffic_control_data->traffic_steering_pol_id_dl) == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [traffic_steering_pol_id_dl]"); + goto end; + } + } + + if (traffic_control_data->traffic_steering_pol_id_ul) { + if (cJSON_AddStringToObject(item, "trafficSteeringPolIdUl", traffic_control_data->traffic_steering_pol_id_ul) == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [traffic_steering_pol_id_ul]"); + goto end; + } + } + + if (traffic_control_data->route_to_locs) { + cJSON *route_to_locsList = cJSON_AddArrayToObject(item, "routeToLocs"); + if (route_to_locsList == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [route_to_locs]"); + goto end; + } + + OpenAPI_lnode_t *route_to_locs_node; + if (traffic_control_data->route_to_locs) { + OpenAPI_list_for_each(traffic_control_data->route_to_locs, route_to_locs_node) { + cJSON *itemLocal = OpenAPI_route_to_location_convertToJSON(route_to_locs_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [route_to_locs]"); + goto end; + } + cJSON_AddItemToArray(route_to_locsList, itemLocal); + } + } + } + + if (traffic_control_data->traff_corre_ind) { + if (cJSON_AddBoolToObject(item, "traffCorreInd", traffic_control_data->traff_corre_ind) == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [traff_corre_ind]"); + goto end; + } + } + + if (traffic_control_data->up_path_chg_event) { + cJSON *up_path_chg_event_local_JSON = OpenAPI_up_path_chg_event_convertToJSON(traffic_control_data->up_path_chg_event); + if (up_path_chg_event_local_JSON == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [up_path_chg_event]"); + goto end; + } + cJSON_AddItemToObject(item, "upPathChgEvent", up_path_chg_event_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [up_path_chg_event]"); + goto end; + } + } + + if (traffic_control_data->steer_fun) { + cJSON *steer_fun_local_JSON = OpenAPI_steering_functionality_convertToJSON(traffic_control_data->steer_fun); + if (steer_fun_local_JSON == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [steer_fun]"); + goto end; + } + cJSON_AddItemToObject(item, "steerFun", steer_fun_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [steer_fun]"); + goto end; + } + } + + if (traffic_control_data->steer_mode_dl) { + cJSON *steer_mode_dl_local_JSON = OpenAPI_steering_mode_convertToJSON(traffic_control_data->steer_mode_dl); + if (steer_mode_dl_local_JSON == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [steer_mode_dl]"); + goto end; + } + cJSON_AddItemToObject(item, "steerModeDl", steer_mode_dl_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [steer_mode_dl]"); + goto end; + } + } + + if (traffic_control_data->steer_mode_ul) { + cJSON *steer_mode_ul_local_JSON = OpenAPI_steering_mode_convertToJSON(traffic_control_data->steer_mode_ul); + if (steer_mode_ul_local_JSON == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [steer_mode_ul]"); + goto end; + } + cJSON_AddItemToObject(item, "steerModeUl", steer_mode_ul_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [steer_mode_ul]"); + goto end; + } + } + + if (traffic_control_data->mul_acc_ctrl) { + cJSON *mul_acc_ctrl_local_JSON = OpenAPI_multicast_access_control_convertToJSON(traffic_control_data->mul_acc_ctrl); + if (mul_acc_ctrl_local_JSON == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [mul_acc_ctrl]"); + goto end; + } + cJSON_AddItemToObject(item, "mulAccCtrl", mul_acc_ctrl_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [mul_acc_ctrl]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON *traffic_control_dataJSON) +{ + OpenAPI_traffic_control_data_t *traffic_control_data_local_var = NULL; + cJSON *tc_id = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "tcId"); + if (!tc_id) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [tc_id]"); + goto end; + } + + + if (!cJSON_IsString(tc_id)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [tc_id]"); + goto end; + } + + cJSON *flow_status = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "flowStatus"); + + OpenAPI_flow_status_t *flow_status_local_nonprim = NULL; + if (flow_status) { + flow_status_local_nonprim = OpenAPI_flow_status_parseFromJSON(flow_status); + } + + cJSON *redirect_info = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "redirectInfo"); + + OpenAPI_redirect_information_t *redirect_info_local_nonprim = NULL; + if (redirect_info) { + redirect_info_local_nonprim = OpenAPI_redirect_information_parseFromJSON(redirect_info); + } + + cJSON *add_redirect_info = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "addRedirectInfo"); + + OpenAPI_list_t *add_redirect_infoList; + if (add_redirect_info) { + cJSON *add_redirect_info_local_nonprimitive; + if (!cJSON_IsArray(add_redirect_info)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [add_redirect_info]"); + goto end; + } + + add_redirect_infoList = OpenAPI_list_create(); + + cJSON_ArrayForEach(add_redirect_info_local_nonprimitive, add_redirect_info ) { + if (!cJSON_IsObject(add_redirect_info_local_nonprimitive)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [add_redirect_info]"); + goto end; + } + OpenAPI_redirect_information_t *add_redirect_infoItem = OpenAPI_redirect_information_parseFromJSON(add_redirect_info_local_nonprimitive); + + OpenAPI_list_add(add_redirect_infoList, add_redirect_infoItem); + } + } + + cJSON *mute_notif = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "muteNotif"); + + if (mute_notif) { + if (!cJSON_IsBool(mute_notif)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [mute_notif]"); + goto end; + } + } + + cJSON *traffic_steering_pol_id_dl = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "trafficSteeringPolIdDl"); + + if (traffic_steering_pol_id_dl) { + if (!cJSON_IsString(traffic_steering_pol_id_dl)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [traffic_steering_pol_id_dl]"); + goto end; + } + } + + cJSON *traffic_steering_pol_id_ul = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "trafficSteeringPolIdUl"); + + if (traffic_steering_pol_id_ul) { + if (!cJSON_IsString(traffic_steering_pol_id_ul)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [traffic_steering_pol_id_ul]"); + goto end; + } + } + + cJSON *route_to_locs = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "routeToLocs"); + + OpenAPI_list_t *route_to_locsList; + if (route_to_locs) { + cJSON *route_to_locs_local_nonprimitive; + if (!cJSON_IsArray(route_to_locs)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [route_to_locs]"); + goto end; + } + + route_to_locsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(route_to_locs_local_nonprimitive, route_to_locs ) { + if (!cJSON_IsObject(route_to_locs_local_nonprimitive)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [route_to_locs]"); + goto end; + } + OpenAPI_route_to_location_t *route_to_locsItem = OpenAPI_route_to_location_parseFromJSON(route_to_locs_local_nonprimitive); + + OpenAPI_list_add(route_to_locsList, route_to_locsItem); + } + } + + cJSON *traff_corre_ind = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "traffCorreInd"); + + if (traff_corre_ind) { + if (!cJSON_IsBool(traff_corre_ind)) { + ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [traff_corre_ind]"); + goto end; + } + } + + cJSON *up_path_chg_event = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "upPathChgEvent"); + + OpenAPI_up_path_chg_event_t *up_path_chg_event_local_nonprim = NULL; + if (up_path_chg_event) { + up_path_chg_event_local_nonprim = OpenAPI_up_path_chg_event_parseFromJSON(up_path_chg_event); + } + + cJSON *steer_fun = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "steerFun"); + + OpenAPI_steering_functionality_t *steer_fun_local_nonprim = NULL; + if (steer_fun) { + steer_fun_local_nonprim = OpenAPI_steering_functionality_parseFromJSON(steer_fun); + } + + cJSON *steer_mode_dl = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "steerModeDl"); + + OpenAPI_steering_mode_t *steer_mode_dl_local_nonprim = NULL; + if (steer_mode_dl) { + steer_mode_dl_local_nonprim = OpenAPI_steering_mode_parseFromJSON(steer_mode_dl); + } + + cJSON *steer_mode_ul = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "steerModeUl"); + + OpenAPI_steering_mode_t *steer_mode_ul_local_nonprim = NULL; + if (steer_mode_ul) { + steer_mode_ul_local_nonprim = OpenAPI_steering_mode_parseFromJSON(steer_mode_ul); + } + + cJSON *mul_acc_ctrl = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "mulAccCtrl"); + + OpenAPI_multicast_access_control_t *mul_acc_ctrl_local_nonprim = NULL; + if (mul_acc_ctrl) { + mul_acc_ctrl_local_nonprim = OpenAPI_multicast_access_control_parseFromJSON(mul_acc_ctrl); + } + + traffic_control_data_local_var = OpenAPI_traffic_control_data_create ( + ogs_strdup(tc_id->valuestring), + flow_status ? flow_status_local_nonprim : NULL, + redirect_info ? redirect_info_local_nonprim : NULL, + add_redirect_info ? add_redirect_infoList : NULL, + mute_notif ? mute_notif->valueint : 0, + traffic_steering_pol_id_dl ? ogs_strdup(traffic_steering_pol_id_dl->valuestring) : NULL, + traffic_steering_pol_id_ul ? ogs_strdup(traffic_steering_pol_id_ul->valuestring) : NULL, + route_to_locs ? route_to_locsList : NULL, + traff_corre_ind ? traff_corre_ind->valueint : 0, + up_path_chg_event ? up_path_chg_event_local_nonprim : NULL, + steer_fun ? steer_fun_local_nonprim : NULL, + steer_mode_dl ? steer_mode_dl_local_nonprim : NULL, + steer_mode_ul ? steer_mode_ul_local_nonprim : NULL, + mul_acc_ctrl ? mul_acc_ctrl_local_nonprim : NULL + ); + + return traffic_control_data_local_var; +end: + return NULL; +} + +OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_copy(OpenAPI_traffic_control_data_t *dst, OpenAPI_traffic_control_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_traffic_control_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_traffic_control_data_free(dst); + dst = OpenAPI_traffic_control_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/traffic_control_data.h b/lib/sbi/openapi/model/traffic_control_data.h new file mode 100644 index 000000000..0c8132bee --- /dev/null +++ b/lib/sbi/openapi/model/traffic_control_data.h @@ -0,0 +1,71 @@ +/* + * traffic_control_data.h + * + * + */ + +#ifndef _OpenAPI_traffic_control_data_H_ +#define _OpenAPI_traffic_control_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "flow_status.h" +#include "multicast_access_control.h" +#include "redirect_information.h" +#include "route_to_location.h" +#include "steering_functionality.h" +#include "steering_mode.h" +#include "up_path_chg_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_traffic_control_data_s OpenAPI_traffic_control_data_t; +typedef struct OpenAPI_traffic_control_data_s { + char *tc_id; + struct OpenAPI_flow_status_s *flow_status; + struct OpenAPI_redirect_information_s *redirect_info; + OpenAPI_list_t *add_redirect_info; + int mute_notif; + char *traffic_steering_pol_id_dl; + char *traffic_steering_pol_id_ul; + OpenAPI_list_t *route_to_locs; + int traff_corre_ind; + struct OpenAPI_up_path_chg_event_s *up_path_chg_event; + struct OpenAPI_steering_functionality_s *steer_fun; + struct OpenAPI_steering_mode_s *steer_mode_dl; + struct OpenAPI_steering_mode_s *steer_mode_ul; + struct OpenAPI_multicast_access_control_s *mul_acc_ctrl; +} OpenAPI_traffic_control_data_t; + +OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_create( + char *tc_id, + OpenAPI_flow_status_t *flow_status, + OpenAPI_redirect_information_t *redirect_info, + OpenAPI_list_t *add_redirect_info, + int mute_notif, + char *traffic_steering_pol_id_dl, + char *traffic_steering_pol_id_ul, + OpenAPI_list_t *route_to_locs, + int traff_corre_ind, + OpenAPI_up_path_chg_event_t *up_path_chg_event, + OpenAPI_steering_functionality_t *steer_fun, + OpenAPI_steering_mode_t *steer_mode_dl, + OpenAPI_steering_mode_t *steer_mode_ul, + OpenAPI_multicast_access_control_t *mul_acc_ctrl + ); +void OpenAPI_traffic_control_data_free(OpenAPI_traffic_control_data_t *traffic_control_data); +OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON *traffic_control_dataJSON); +cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t *traffic_control_data); +OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_copy(OpenAPI_traffic_control_data_t *dst, OpenAPI_traffic_control_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_traffic_control_data_H_ */ + diff --git a/lib/sbi/openapi/model/traffic_profile.c b/lib/sbi/openapi/model/traffic_profile.c index 01b541836..4b5c3d696 100644 --- a/lib/sbi/openapi/model/traffic_profile.c +++ b/lib/sbi/openapi/model/traffic_profile.c @@ -4,82 +4,27 @@ #include #include "traffic_profile.h" -OpenAPI_traffic_profile_t *OpenAPI_traffic_profile_create( - ) +char* OpenAPI_traffic_profile_ToString(OpenAPI_traffic_profile_e traffic_profile) { - OpenAPI_traffic_profile_t *traffic_profile_local_var = OpenAPI_malloc(sizeof(OpenAPI_traffic_profile_t)); - if (!traffic_profile_local_var) { - return NULL; - } - - return traffic_profile_local_var; + const char *traffic_profileArray[] = { "NULL", "SINGLE_TRANS_UL", "SINGLE_TRANS_DL", "DUAL_TRANS_UL_FIRST", "DUAL_TRANS_DL_FIRST", "MULTI_TRANS" }; + size_t sizeofArray = sizeof(traffic_profileArray) / sizeof(traffic_profileArray[0]); + if (traffic_profile < sizeofArray) + return (char *)traffic_profileArray[traffic_profile]; + else + return (char *)"Unknown"; } -void OpenAPI_traffic_profile_free(OpenAPI_traffic_profile_t *traffic_profile) +OpenAPI_traffic_profile_e OpenAPI_traffic_profile_FromString(char* traffic_profile) { - if (NULL == traffic_profile) { - return; + int stringToReturn = 0; + const char *traffic_profileArray[] = { "NULL", "SINGLE_TRANS_UL", "SINGLE_TRANS_DL", "DUAL_TRANS_UL_FIRST", "DUAL_TRANS_DL_FIRST", "MULTI_TRANS" }; + size_t sizeofArray = sizeof(traffic_profileArray) / sizeof(traffic_profileArray[0]); + while (stringToReturn < sizeofArray) { + if (strcmp(traffic_profile, traffic_profileArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; } - OpenAPI_lnode_t *node; - ogs_free(traffic_profile); -} - -cJSON *OpenAPI_traffic_profile_convertToJSON(OpenAPI_traffic_profile_t *traffic_profile) -{ - cJSON *item = NULL; - - if (traffic_profile == NULL) { - ogs_error("OpenAPI_traffic_profile_convertToJSON() failed [TrafficProfile]"); - return NULL; - } - - item = cJSON_CreateObject(); -end: - return item; -} - -OpenAPI_traffic_profile_t *OpenAPI_traffic_profile_parseFromJSON(cJSON *traffic_profileJSON) -{ - OpenAPI_traffic_profile_t *traffic_profile_local_var = NULL; - traffic_profile_local_var = OpenAPI_traffic_profile_create ( - ); - - return traffic_profile_local_var; -end: - return NULL; -} - -OpenAPI_traffic_profile_t *OpenAPI_traffic_profile_copy(OpenAPI_traffic_profile_t *dst, OpenAPI_traffic_profile_t *src) -{ - cJSON *item = NULL; - char *content = NULL; - - ogs_assert(src); - item = OpenAPI_traffic_profile_convertToJSON(src); - if (!item) { - ogs_error("OpenAPI_traffic_profile_convertToJSON() failed"); - return NULL; - } - - content = cJSON_Print(item); - cJSON_Delete(item); - - if (!content) { - ogs_error("cJSON_Print() failed"); - return NULL; - } - - item = cJSON_Parse(content); - ogs_free(content); - if (!item) { - ogs_error("cJSON_Parse() failed"); - return NULL; - } - - OpenAPI_traffic_profile_free(dst); - dst = OpenAPI_traffic_profile_parseFromJSON(item); - cJSON_Delete(item); - - return dst; + return 0; } diff --git a/lib/sbi/openapi/model/traffic_profile.h b/lib/sbi/openapi/model/traffic_profile.h index b559def14..5352cd408 100644 --- a/lib/sbi/openapi/model/traffic_profile.h +++ b/lib/sbi/openapi/model/traffic_profile.h @@ -1,7 +1,7 @@ /* * traffic_profile.h * - * Possible values are - SINGLE_TRANS_UL: Uplink single packet transmission. - SINGLE_TRANS_DL: Downlink single packet transmission. - DUAL_TRANS_UL_FIRST: Dual packet transmission, firstly uplink packet transmission with subsequent downlink packet transmission. - DUAL_TRANS_DL_FIRST: Dual packet transmission, firstly downlink packet transmission with subsequent uplink packet transmission. + * */ #ifndef _OpenAPI_traffic_profile_H_ @@ -17,16 +17,11 @@ extern "C" { #endif -typedef struct OpenAPI_traffic_profile_s OpenAPI_traffic_profile_t; -typedef struct OpenAPI_traffic_profile_s { -} OpenAPI_traffic_profile_t; +typedef enum { OpenAPI_traffic_profile_NULL = 0, OpenAPI_traffic_profile_SINGLE_TRANS_UL, OpenAPI_traffic_profile_SINGLE_TRANS_DL, OpenAPI_traffic_profile_DUAL_TRANS_UL_FIRST, OpenAPI_traffic_profile_DUAL_TRANS_DL_FIRST, OpenAPI_traffic_profile_MULTI_TRANS } OpenAPI_traffic_profile_e; -OpenAPI_traffic_profile_t *OpenAPI_traffic_profile_create( - ); -void OpenAPI_traffic_profile_free(OpenAPI_traffic_profile_t *traffic_profile); -OpenAPI_traffic_profile_t *OpenAPI_traffic_profile_parseFromJSON(cJSON *traffic_profileJSON); -cJSON *OpenAPI_traffic_profile_convertToJSON(OpenAPI_traffic_profile_t *traffic_profile); -OpenAPI_traffic_profile_t *OpenAPI_traffic_profile_copy(OpenAPI_traffic_profile_t *dst, OpenAPI_traffic_profile_t *src); +char* OpenAPI_traffic_profile_ToString(OpenAPI_traffic_profile_e traffic_profile); + +OpenAPI_traffic_profile_e OpenAPI_traffic_profile_FromString(char* traffic_profile); #ifdef __cplusplus } diff --git a/lib/sbi/openapi/model/tscai_input_container.c b/lib/sbi/openapi/model/tscai_input_container.c new file mode 100644 index 000000000..4b40a6c08 --- /dev/null +++ b/lib/sbi/openapi/model/tscai_input_container.c @@ -0,0 +1,124 @@ + +#include +#include +#include +#include "tscai_input_container.h" + +OpenAPI_tscai_input_container_t *OpenAPI_tscai_input_container_create( + int periodicity, + char *burst_arrival_time + ) +{ + OpenAPI_tscai_input_container_t *tscai_input_container_local_var = OpenAPI_malloc(sizeof(OpenAPI_tscai_input_container_t)); + if (!tscai_input_container_local_var) { + return NULL; + } + tscai_input_container_local_var->periodicity = periodicity; + tscai_input_container_local_var->burst_arrival_time = burst_arrival_time; + + return tscai_input_container_local_var; +} + +void OpenAPI_tscai_input_container_free(OpenAPI_tscai_input_container_t *tscai_input_container) +{ + if (NULL == tscai_input_container) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(tscai_input_container->burst_arrival_time); + ogs_free(tscai_input_container); +} + +cJSON *OpenAPI_tscai_input_container_convertToJSON(OpenAPI_tscai_input_container_t *tscai_input_container) +{ + cJSON *item = NULL; + + if (tscai_input_container == NULL) { + ogs_error("OpenAPI_tscai_input_container_convertToJSON() failed [TscaiInputContainer]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (tscai_input_container->periodicity) { + if (cJSON_AddNumberToObject(item, "periodicity", tscai_input_container->periodicity) == NULL) { + ogs_error("OpenAPI_tscai_input_container_convertToJSON() failed [periodicity]"); + goto end; + } + } + + if (tscai_input_container->burst_arrival_time) { + if (cJSON_AddStringToObject(item, "burstArrivalTime", tscai_input_container->burst_arrival_time) == NULL) { + ogs_error("OpenAPI_tscai_input_container_convertToJSON() failed [burst_arrival_time]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_tscai_input_container_t *OpenAPI_tscai_input_container_parseFromJSON(cJSON *tscai_input_containerJSON) +{ + OpenAPI_tscai_input_container_t *tscai_input_container_local_var = NULL; + cJSON *periodicity = cJSON_GetObjectItemCaseSensitive(tscai_input_containerJSON, "periodicity"); + + if (periodicity) { + if (!cJSON_IsNumber(periodicity)) { + ogs_error("OpenAPI_tscai_input_container_parseFromJSON() failed [periodicity]"); + goto end; + } + } + + cJSON *burst_arrival_time = cJSON_GetObjectItemCaseSensitive(tscai_input_containerJSON, "burstArrivalTime"); + + if (burst_arrival_time) { + if (!cJSON_IsString(burst_arrival_time)) { + ogs_error("OpenAPI_tscai_input_container_parseFromJSON() failed [burst_arrival_time]"); + goto end; + } + } + + tscai_input_container_local_var = OpenAPI_tscai_input_container_create ( + periodicity ? periodicity->valuedouble : 0, + burst_arrival_time ? ogs_strdup(burst_arrival_time->valuestring) : NULL + ); + + return tscai_input_container_local_var; +end: + return NULL; +} + +OpenAPI_tscai_input_container_t *OpenAPI_tscai_input_container_copy(OpenAPI_tscai_input_container_t *dst, OpenAPI_tscai_input_container_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_tscai_input_container_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_tscai_input_container_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_tscai_input_container_free(dst); + dst = OpenAPI_tscai_input_container_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/tscai_input_container.h b/lib/sbi/openapi/model/tscai_input_container.h new file mode 100644 index 000000000..b87efb592 --- /dev/null +++ b/lib/sbi/openapi/model/tscai_input_container.h @@ -0,0 +1,40 @@ +/* + * tscai_input_container.h + * + * Indicates TSC Traffic pattern. + */ + +#ifndef _OpenAPI_tscai_input_container_H_ +#define _OpenAPI_tscai_input_container_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_tscai_input_container_s OpenAPI_tscai_input_container_t; +typedef struct OpenAPI_tscai_input_container_s { + int periodicity; + char *burst_arrival_time; +} OpenAPI_tscai_input_container_t; + +OpenAPI_tscai_input_container_t *OpenAPI_tscai_input_container_create( + int periodicity, + char *burst_arrival_time + ); +void OpenAPI_tscai_input_container_free(OpenAPI_tscai_input_container_t *tscai_input_container); +OpenAPI_tscai_input_container_t *OpenAPI_tscai_input_container_parseFromJSON(cJSON *tscai_input_containerJSON); +cJSON *OpenAPI_tscai_input_container_convertToJSON(OpenAPI_tscai_input_container_t *tscai_input_container); +OpenAPI_tscai_input_container_t *OpenAPI_tscai_input_container_copy(OpenAPI_tscai_input_container_t *dst, OpenAPI_tscai_input_container_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_tscai_input_container_H_ */ + diff --git a/lib/sbi/openapi/model/tsn_bridge_info.c b/lib/sbi/openapi/model/tsn_bridge_info.c new file mode 100644 index 000000000..0c127d951 --- /dev/null +++ b/lib/sbi/openapi/model/tsn_bridge_info.c @@ -0,0 +1,218 @@ + +#include +#include +#include +#include "tsn_bridge_info.h" + +OpenAPI_tsn_bridge_info_t *OpenAPI_tsn_bridge_info_create( + char *bridge_name, + char *bridge_mac, + OpenAPI_list_t *nwtt_ports, + OpenAPI_tsn_port_identifier_t *dstt_port, + int dstt_resid_time + ) +{ + OpenAPI_tsn_bridge_info_t *tsn_bridge_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_tsn_bridge_info_t)); + if (!tsn_bridge_info_local_var) { + return NULL; + } + tsn_bridge_info_local_var->bridge_name = bridge_name; + tsn_bridge_info_local_var->bridge_mac = bridge_mac; + tsn_bridge_info_local_var->nwtt_ports = nwtt_ports; + tsn_bridge_info_local_var->dstt_port = dstt_port; + tsn_bridge_info_local_var->dstt_resid_time = dstt_resid_time; + + return tsn_bridge_info_local_var; +} + +void OpenAPI_tsn_bridge_info_free(OpenAPI_tsn_bridge_info_t *tsn_bridge_info) +{ + if (NULL == tsn_bridge_info) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(tsn_bridge_info->bridge_name); + ogs_free(tsn_bridge_info->bridge_mac); + OpenAPI_list_for_each(tsn_bridge_info->nwtt_ports, node) { + OpenAPI_tsn_port_identifier_free(node->data); + } + OpenAPI_list_free(tsn_bridge_info->nwtt_ports); + OpenAPI_tsn_port_identifier_free(tsn_bridge_info->dstt_port); + ogs_free(tsn_bridge_info); +} + +cJSON *OpenAPI_tsn_bridge_info_convertToJSON(OpenAPI_tsn_bridge_info_t *tsn_bridge_info) +{ + cJSON *item = NULL; + + if (tsn_bridge_info == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [TsnBridgeInfo]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (tsn_bridge_info->bridge_name) { + if (cJSON_AddStringToObject(item, "bridgeName", tsn_bridge_info->bridge_name) == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [bridge_name]"); + goto end; + } + } + + if (tsn_bridge_info->bridge_mac) { + if (cJSON_AddStringToObject(item, "bridgeMac", tsn_bridge_info->bridge_mac) == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [bridge_mac]"); + goto end; + } + } + + if (tsn_bridge_info->nwtt_ports) { + cJSON *nwtt_portsList = cJSON_AddArrayToObject(item, "nwttPorts"); + if (nwtt_portsList == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [nwtt_ports]"); + goto end; + } + + OpenAPI_lnode_t *nwtt_ports_node; + if (tsn_bridge_info->nwtt_ports) { + OpenAPI_list_for_each(tsn_bridge_info->nwtt_ports, nwtt_ports_node) { + cJSON *itemLocal = OpenAPI_tsn_port_identifier_convertToJSON(nwtt_ports_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [nwtt_ports]"); + goto end; + } + cJSON_AddItemToArray(nwtt_portsList, itemLocal); + } + } + } + + if (tsn_bridge_info->dstt_port) { + cJSON *dstt_port_local_JSON = OpenAPI_tsn_port_identifier_convertToJSON(tsn_bridge_info->dstt_port); + if (dstt_port_local_JSON == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [dstt_port]"); + goto end; + } + cJSON_AddItemToObject(item, "dsttPort", dstt_port_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [dstt_port]"); + goto end; + } + } + + if (tsn_bridge_info->dstt_resid_time) { + if (cJSON_AddNumberToObject(item, "dsttResidTime", tsn_bridge_info->dstt_resid_time) == NULL) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed [dstt_resid_time]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_tsn_bridge_info_t *OpenAPI_tsn_bridge_info_parseFromJSON(cJSON *tsn_bridge_infoJSON) +{ + OpenAPI_tsn_bridge_info_t *tsn_bridge_info_local_var = NULL; + cJSON *bridge_name = cJSON_GetObjectItemCaseSensitive(tsn_bridge_infoJSON, "bridgeName"); + + if (bridge_name) { + if (!cJSON_IsString(bridge_name)) { + ogs_error("OpenAPI_tsn_bridge_info_parseFromJSON() failed [bridge_name]"); + goto end; + } + } + + cJSON *bridge_mac = cJSON_GetObjectItemCaseSensitive(tsn_bridge_infoJSON, "bridgeMac"); + + if (bridge_mac) { + if (!cJSON_IsString(bridge_mac)) { + ogs_error("OpenAPI_tsn_bridge_info_parseFromJSON() failed [bridge_mac]"); + goto end; + } + } + + cJSON *nwtt_ports = cJSON_GetObjectItemCaseSensitive(tsn_bridge_infoJSON, "nwttPorts"); + + OpenAPI_list_t *nwtt_portsList; + if (nwtt_ports) { + cJSON *nwtt_ports_local_nonprimitive; + if (!cJSON_IsArray(nwtt_ports)) { + ogs_error("OpenAPI_tsn_bridge_info_parseFromJSON() failed [nwtt_ports]"); + goto end; + } + + nwtt_portsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(nwtt_ports_local_nonprimitive, nwtt_ports ) { + if (!cJSON_IsObject(nwtt_ports_local_nonprimitive)) { + ogs_error("OpenAPI_tsn_bridge_info_parseFromJSON() failed [nwtt_ports]"); + goto end; + } + OpenAPI_tsn_port_identifier_t *nwtt_portsItem = OpenAPI_tsn_port_identifier_parseFromJSON(nwtt_ports_local_nonprimitive); + + OpenAPI_list_add(nwtt_portsList, nwtt_portsItem); + } + } + + cJSON *dstt_port = cJSON_GetObjectItemCaseSensitive(tsn_bridge_infoJSON, "dsttPort"); + + OpenAPI_tsn_port_identifier_t *dstt_port_local_nonprim = NULL; + if (dstt_port) { + dstt_port_local_nonprim = OpenAPI_tsn_port_identifier_parseFromJSON(dstt_port); + } + + cJSON *dstt_resid_time = cJSON_GetObjectItemCaseSensitive(tsn_bridge_infoJSON, "dsttResidTime"); + + if (dstt_resid_time) { + if (!cJSON_IsNumber(dstt_resid_time)) { + ogs_error("OpenAPI_tsn_bridge_info_parseFromJSON() failed [dstt_resid_time]"); + goto end; + } + } + + tsn_bridge_info_local_var = OpenAPI_tsn_bridge_info_create ( + bridge_name ? ogs_strdup(bridge_name->valuestring) : NULL, + bridge_mac ? ogs_strdup(bridge_mac->valuestring) : NULL, + nwtt_ports ? nwtt_portsList : NULL, + dstt_port ? dstt_port_local_nonprim : NULL, + dstt_resid_time ? dstt_resid_time->valuedouble : 0 + ); + + return tsn_bridge_info_local_var; +end: + return NULL; +} + +OpenAPI_tsn_bridge_info_t *OpenAPI_tsn_bridge_info_copy(OpenAPI_tsn_bridge_info_t *dst, OpenAPI_tsn_bridge_info_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_tsn_bridge_info_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_tsn_bridge_info_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_tsn_bridge_info_free(dst); + dst = OpenAPI_tsn_bridge_info_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/tsn_bridge_info.h b/lib/sbi/openapi/model/tsn_bridge_info.h new file mode 100644 index 000000000..aa94684be --- /dev/null +++ b/lib/sbi/openapi/model/tsn_bridge_info.h @@ -0,0 +1,47 @@ +/* + * tsn_bridge_info.h + * + * + */ + +#ifndef _OpenAPI_tsn_bridge_info_H_ +#define _OpenAPI_tsn_bridge_info_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "tsn_port_identifier.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_tsn_bridge_info_s OpenAPI_tsn_bridge_info_t; +typedef struct OpenAPI_tsn_bridge_info_s { + char *bridge_name; + char *bridge_mac; + OpenAPI_list_t *nwtt_ports; + struct OpenAPI_tsn_port_identifier_s *dstt_port; + int dstt_resid_time; +} OpenAPI_tsn_bridge_info_t; + +OpenAPI_tsn_bridge_info_t *OpenAPI_tsn_bridge_info_create( + char *bridge_name, + char *bridge_mac, + OpenAPI_list_t *nwtt_ports, + OpenAPI_tsn_port_identifier_t *dstt_port, + int dstt_resid_time + ); +void OpenAPI_tsn_bridge_info_free(OpenAPI_tsn_bridge_info_t *tsn_bridge_info); +OpenAPI_tsn_bridge_info_t *OpenAPI_tsn_bridge_info_parseFromJSON(cJSON *tsn_bridge_infoJSON); +cJSON *OpenAPI_tsn_bridge_info_convertToJSON(OpenAPI_tsn_bridge_info_t *tsn_bridge_info); +OpenAPI_tsn_bridge_info_t *OpenAPI_tsn_bridge_info_copy(OpenAPI_tsn_bridge_info_t *dst, OpenAPI_tsn_bridge_info_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_tsn_bridge_info_H_ */ + diff --git a/lib/sbi/openapi/model/tsn_port_identifier.c b/lib/sbi/openapi/model/tsn_port_identifier.c new file mode 100644 index 000000000..f1c52d937 --- /dev/null +++ b/lib/sbi/openapi/model/tsn_port_identifier.c @@ -0,0 +1,129 @@ + +#include +#include +#include +#include "tsn_port_identifier.h" + +OpenAPI_tsn_port_identifier_t *OpenAPI_tsn_port_identifier_create( + char *port_mac, + int port_number + ) +{ + OpenAPI_tsn_port_identifier_t *tsn_port_identifier_local_var = OpenAPI_malloc(sizeof(OpenAPI_tsn_port_identifier_t)); + if (!tsn_port_identifier_local_var) { + return NULL; + } + tsn_port_identifier_local_var->port_mac = port_mac; + tsn_port_identifier_local_var->port_number = port_number; + + return tsn_port_identifier_local_var; +} + +void OpenAPI_tsn_port_identifier_free(OpenAPI_tsn_port_identifier_t *tsn_port_identifier) +{ + if (NULL == tsn_port_identifier) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(tsn_port_identifier->port_mac); + ogs_free(tsn_port_identifier); +} + +cJSON *OpenAPI_tsn_port_identifier_convertToJSON(OpenAPI_tsn_port_identifier_t *tsn_port_identifier) +{ + cJSON *item = NULL; + + if (tsn_port_identifier == NULL) { + ogs_error("OpenAPI_tsn_port_identifier_convertToJSON() failed [TsnPortIdentifier]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!tsn_port_identifier->port_mac) { + ogs_error("OpenAPI_tsn_port_identifier_convertToJSON() failed [port_mac]"); + goto end; + } + if (cJSON_AddStringToObject(item, "portMac", tsn_port_identifier->port_mac) == NULL) { + ogs_error("OpenAPI_tsn_port_identifier_convertToJSON() failed [port_mac]"); + goto end; + } + + if (tsn_port_identifier->port_number) { + if (cJSON_AddNumberToObject(item, "portNumber", tsn_port_identifier->port_number) == NULL) { + ogs_error("OpenAPI_tsn_port_identifier_convertToJSON() failed [port_number]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_tsn_port_identifier_t *OpenAPI_tsn_port_identifier_parseFromJSON(cJSON *tsn_port_identifierJSON) +{ + OpenAPI_tsn_port_identifier_t *tsn_port_identifier_local_var = NULL; + cJSON *port_mac = cJSON_GetObjectItemCaseSensitive(tsn_port_identifierJSON, "portMac"); + if (!port_mac) { + ogs_error("OpenAPI_tsn_port_identifier_parseFromJSON() failed [port_mac]"); + goto end; + } + + + if (!cJSON_IsString(port_mac)) { + ogs_error("OpenAPI_tsn_port_identifier_parseFromJSON() failed [port_mac]"); + goto end; + } + + cJSON *port_number = cJSON_GetObjectItemCaseSensitive(tsn_port_identifierJSON, "portNumber"); + + if (port_number) { + if (!cJSON_IsNumber(port_number)) { + ogs_error("OpenAPI_tsn_port_identifier_parseFromJSON() failed [port_number]"); + goto end; + } + } + + tsn_port_identifier_local_var = OpenAPI_tsn_port_identifier_create ( + ogs_strdup(port_mac->valuestring), + port_number ? port_number->valuedouble : 0 + ); + + return tsn_port_identifier_local_var; +end: + return NULL; +} + +OpenAPI_tsn_port_identifier_t *OpenAPI_tsn_port_identifier_copy(OpenAPI_tsn_port_identifier_t *dst, OpenAPI_tsn_port_identifier_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_tsn_port_identifier_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_tsn_port_identifier_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_tsn_port_identifier_free(dst); + dst = OpenAPI_tsn_port_identifier_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/tsn_port_identifier.h b/lib/sbi/openapi/model/tsn_port_identifier.h new file mode 100644 index 000000000..17ad64533 --- /dev/null +++ b/lib/sbi/openapi/model/tsn_port_identifier.h @@ -0,0 +1,40 @@ +/* + * tsn_port_identifier.h + * + * + */ + +#ifndef _OpenAPI_tsn_port_identifier_H_ +#define _OpenAPI_tsn_port_identifier_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_tsn_port_identifier_s OpenAPI_tsn_port_identifier_t; +typedef struct OpenAPI_tsn_port_identifier_s { + char *port_mac; + int port_number; +} OpenAPI_tsn_port_identifier_t; + +OpenAPI_tsn_port_identifier_t *OpenAPI_tsn_port_identifier_create( + char *port_mac, + int port_number + ); +void OpenAPI_tsn_port_identifier_free(OpenAPI_tsn_port_identifier_t *tsn_port_identifier); +OpenAPI_tsn_port_identifier_t *OpenAPI_tsn_port_identifier_parseFromJSON(cJSON *tsn_port_identifierJSON); +cJSON *OpenAPI_tsn_port_identifier_convertToJSON(OpenAPI_tsn_port_identifier_t *tsn_port_identifier); +OpenAPI_tsn_port_identifier_t *OpenAPI_tsn_port_identifier_copy(OpenAPI_tsn_port_identifier_t *dst, OpenAPI_tsn_port_identifier_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_tsn_port_identifier_H_ */ + diff --git a/lib/sbi/openapi/model/ue_camping_rep.c b/lib/sbi/openapi/model/ue_camping_rep.c new file mode 100644 index 000000000..dcdb8eae4 --- /dev/null +++ b/lib/sbi/openapi/model/ue_camping_rep.c @@ -0,0 +1,219 @@ + +#include +#include +#include +#include "ue_camping_rep.h" + +OpenAPI_ue_camping_rep_t *OpenAPI_ue_camping_rep_create( + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type, + OpenAPI_serving_nf_identity_t *serv_nf_id, + OpenAPI_plmn_id_nid_t *serving_network, + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone + ) +{ + OpenAPI_ue_camping_rep_t *ue_camping_rep_local_var = OpenAPI_malloc(sizeof(OpenAPI_ue_camping_rep_t)); + if (!ue_camping_rep_local_var) { + return NULL; + } + ue_camping_rep_local_var->access_type = access_type; + ue_camping_rep_local_var->rat_type = rat_type; + ue_camping_rep_local_var->serv_nf_id = serv_nf_id; + ue_camping_rep_local_var->serving_network = serving_network; + ue_camping_rep_local_var->user_location_info = user_location_info; + ue_camping_rep_local_var->ue_time_zone = ue_time_zone; + + return ue_camping_rep_local_var; +} + +void OpenAPI_ue_camping_rep_free(OpenAPI_ue_camping_rep_t *ue_camping_rep) +{ + if (NULL == ue_camping_rep) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_serving_nf_identity_free(ue_camping_rep->serv_nf_id); + OpenAPI_plmn_id_nid_free(ue_camping_rep->serving_network); + OpenAPI_user_location_free(ue_camping_rep->user_location_info); + ogs_free(ue_camping_rep->ue_time_zone); + ogs_free(ue_camping_rep); +} + +cJSON *OpenAPI_ue_camping_rep_convertToJSON(OpenAPI_ue_camping_rep_t *ue_camping_rep) +{ + cJSON *item = NULL; + + if (ue_camping_rep == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [UeCampingRep]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (ue_camping_rep->access_type) { + if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(ue_camping_rep->access_type)) == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [access_type]"); + goto end; + } + } + + if (ue_camping_rep->rat_type) { + if (cJSON_AddStringToObject(item, "ratType", OpenAPI_rat_type_ToString(ue_camping_rep->rat_type)) == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [rat_type]"); + goto end; + } + } + + if (ue_camping_rep->serv_nf_id) { + cJSON *serv_nf_id_local_JSON = OpenAPI_serving_nf_identity_convertToJSON(ue_camping_rep->serv_nf_id); + if (serv_nf_id_local_JSON == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [serv_nf_id]"); + goto end; + } + cJSON_AddItemToObject(item, "servNfId", serv_nf_id_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [serv_nf_id]"); + goto end; + } + } + + if (ue_camping_rep->serving_network) { + cJSON *serving_network_local_JSON = OpenAPI_plmn_id_nid_convertToJSON(ue_camping_rep->serving_network); + if (serving_network_local_JSON == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [serving_network]"); + goto end; + } + cJSON_AddItemToObject(item, "servingNetwork", serving_network_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [serving_network]"); + goto end; + } + } + + if (ue_camping_rep->user_location_info) { + cJSON *user_location_info_local_JSON = OpenAPI_user_location_convertToJSON(ue_camping_rep->user_location_info); + if (user_location_info_local_JSON == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [user_location_info]"); + goto end; + } + cJSON_AddItemToObject(item, "userLocationInfo", user_location_info_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [user_location_info]"); + goto end; + } + } + + if (ue_camping_rep->ue_time_zone) { + if (cJSON_AddStringToObject(item, "ueTimeZone", ue_camping_rep->ue_time_zone) == NULL) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed [ue_time_zone]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_ue_camping_rep_t *OpenAPI_ue_camping_rep_parseFromJSON(cJSON *ue_camping_repJSON) +{ + OpenAPI_ue_camping_rep_t *ue_camping_rep_local_var = NULL; + cJSON *access_type = cJSON_GetObjectItemCaseSensitive(ue_camping_repJSON, "accessType"); + + OpenAPI_access_type_e access_typeVariable; + if (access_type) { + if (!cJSON_IsString(access_type)) { + ogs_error("OpenAPI_ue_camping_rep_parseFromJSON() failed [access_type]"); + goto end; + } + access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring); + } + + cJSON *rat_type = cJSON_GetObjectItemCaseSensitive(ue_camping_repJSON, "ratType"); + + OpenAPI_rat_type_e rat_typeVariable; + if (rat_type) { + if (!cJSON_IsString(rat_type)) { + ogs_error("OpenAPI_ue_camping_rep_parseFromJSON() failed [rat_type]"); + goto end; + } + rat_typeVariable = OpenAPI_rat_type_FromString(rat_type->valuestring); + } + + cJSON *serv_nf_id = cJSON_GetObjectItemCaseSensitive(ue_camping_repJSON, "servNfId"); + + OpenAPI_serving_nf_identity_t *serv_nf_id_local_nonprim = NULL; + if (serv_nf_id) { + serv_nf_id_local_nonprim = OpenAPI_serving_nf_identity_parseFromJSON(serv_nf_id); + } + + cJSON *serving_network = cJSON_GetObjectItemCaseSensitive(ue_camping_repJSON, "servingNetwork"); + + OpenAPI_plmn_id_nid_t *serving_network_local_nonprim = NULL; + if (serving_network) { + serving_network_local_nonprim = OpenAPI_plmn_id_nid_parseFromJSON(serving_network); + } + + cJSON *user_location_info = cJSON_GetObjectItemCaseSensitive(ue_camping_repJSON, "userLocationInfo"); + + OpenAPI_user_location_t *user_location_info_local_nonprim = NULL; + if (user_location_info) { + user_location_info_local_nonprim = OpenAPI_user_location_parseFromJSON(user_location_info); + } + + cJSON *ue_time_zone = cJSON_GetObjectItemCaseSensitive(ue_camping_repJSON, "ueTimeZone"); + + if (ue_time_zone) { + if (!cJSON_IsString(ue_time_zone)) { + ogs_error("OpenAPI_ue_camping_rep_parseFromJSON() failed [ue_time_zone]"); + goto end; + } + } + + ue_camping_rep_local_var = OpenAPI_ue_camping_rep_create ( + access_type ? access_typeVariable : 0, + rat_type ? rat_typeVariable : 0, + serv_nf_id ? serv_nf_id_local_nonprim : NULL, + serving_network ? serving_network_local_nonprim : NULL, + user_location_info ? user_location_info_local_nonprim : NULL, + ue_time_zone ? ogs_strdup(ue_time_zone->valuestring) : NULL + ); + + return ue_camping_rep_local_var; +end: + return NULL; +} + +OpenAPI_ue_camping_rep_t *OpenAPI_ue_camping_rep_copy(OpenAPI_ue_camping_rep_t *dst, OpenAPI_ue_camping_rep_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_ue_camping_rep_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_ue_camping_rep_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_ue_camping_rep_free(dst); + dst = OpenAPI_ue_camping_rep_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/ue_camping_rep.h b/lib/sbi/openapi/model/ue_camping_rep.h new file mode 100644 index 000000000..78c76f48f --- /dev/null +++ b/lib/sbi/openapi/model/ue_camping_rep.h @@ -0,0 +1,53 @@ +/* + * ue_camping_rep.h + * + * + */ + +#ifndef _OpenAPI_ue_camping_rep_H_ +#define _OpenAPI_ue_camping_rep_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "access_type.h" +#include "plmn_id_nid.h" +#include "rat_type.h" +#include "serving_nf_identity.h" +#include "user_location.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_ue_camping_rep_s OpenAPI_ue_camping_rep_t; +typedef struct OpenAPI_ue_camping_rep_s { + OpenAPI_access_type_e access_type; + OpenAPI_rat_type_e rat_type; + struct OpenAPI_serving_nf_identity_s *serv_nf_id; + struct OpenAPI_plmn_id_nid_s *serving_network; + struct OpenAPI_user_location_s *user_location_info; + char *ue_time_zone; +} OpenAPI_ue_camping_rep_t; + +OpenAPI_ue_camping_rep_t *OpenAPI_ue_camping_rep_create( + OpenAPI_access_type_e access_type, + OpenAPI_rat_type_e rat_type, + OpenAPI_serving_nf_identity_t *serv_nf_id, + OpenAPI_plmn_id_nid_t *serving_network, + OpenAPI_user_location_t *user_location_info, + char *ue_time_zone + ); +void OpenAPI_ue_camping_rep_free(OpenAPI_ue_camping_rep_t *ue_camping_rep); +OpenAPI_ue_camping_rep_t *OpenAPI_ue_camping_rep_parseFromJSON(cJSON *ue_camping_repJSON); +cJSON *OpenAPI_ue_camping_rep_convertToJSON(OpenAPI_ue_camping_rep_t *ue_camping_rep); +OpenAPI_ue_camping_rep_t *OpenAPI_ue_camping_rep_copy(OpenAPI_ue_camping_rep_t *dst, OpenAPI_ue_camping_rep_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_ue_camping_rep_H_ */ + diff --git a/lib/sbi/openapi/model/ue_context.c b/lib/sbi/openapi/model/ue_context.c index e92a1dce6..cd1f374b9 100644 --- a/lib/sbi/openapi/model/ue_context.c +++ b/lib/sbi/openapi/model/ue_context.c @@ -140,9 +140,6 @@ void OpenAPI_ue_context_free(OpenAPI_ue_context_t *ue_context) } OpenAPI_list_free(ue_context->forbidden_area_list); OpenAPI_service_area_restriction_free(ue_context->service_area_restriction); - OpenAPI_list_for_each(ue_context->restricted_core_nw_type_list, node) { - OpenAPI_core_network_type_free(node->data); - } OpenAPI_list_free(ue_context->restricted_core_nw_type_list); OpenAPI_list_for_each(ue_context->event_subscription_list, node) { OpenAPI_amf_event_subscription_free(node->data); @@ -458,21 +455,16 @@ cJSON *OpenAPI_ue_context_convertToJSON(OpenAPI_ue_context_t *ue_context) } if (ue_context->restricted_core_nw_type_list) { - cJSON *restricted_core_nw_type_listList = cJSON_AddArrayToObject(item, "restrictedCoreNwTypeList"); - if (restricted_core_nw_type_listList == NULL) { + cJSON *restricted_core_nw_type_list = cJSON_AddArrayToObject(item, "restrictedCoreNwTypeList"); + if (restricted_core_nw_type_list == NULL) { ogs_error("OpenAPI_ue_context_convertToJSON() failed [restricted_core_nw_type_list]"); goto end; } - OpenAPI_lnode_t *restricted_core_nw_type_list_node; - if (ue_context->restricted_core_nw_type_list) { - OpenAPI_list_for_each(ue_context->restricted_core_nw_type_list, restricted_core_nw_type_list_node) { - cJSON *itemLocal = OpenAPI_core_network_type_convertToJSON(restricted_core_nw_type_list_node->data); - if (itemLocal == NULL) { - ogs_error("OpenAPI_ue_context_convertToJSON() failed [restricted_core_nw_type_list]"); - goto end; - } - cJSON_AddItemToArray(restricted_core_nw_type_listList, itemLocal); + OpenAPI_list_for_each(ue_context->restricted_core_nw_type_list, restricted_core_nw_type_list_node) { + if (cJSON_AddStringToObject(restricted_core_nw_type_list, "", OpenAPI_core_network_type_ToString((OpenAPI_core_network_type_e)restricted_core_nw_type_list_node->data)) == NULL) { + ogs_error("OpenAPI_ue_context_convertToJSON() failed [restricted_core_nw_type_list]"); + goto end; } } } @@ -1023,13 +1015,12 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_parseFromJSON(cJSON *ue_contextJSON) restricted_core_nw_type_listList = OpenAPI_list_create(); cJSON_ArrayForEach(restricted_core_nw_type_list_local_nonprimitive, restricted_core_nw_type_list ) { - if (!cJSON_IsObject(restricted_core_nw_type_list_local_nonprimitive)) { + if (!cJSON_IsString(restricted_core_nw_type_list_local_nonprimitive)) { ogs_error("OpenAPI_ue_context_parseFromJSON() failed [restricted_core_nw_type_list]"); goto end; } - OpenAPI_core_network_type_t *restricted_core_nw_type_listItem = OpenAPI_core_network_type_parseFromJSON(restricted_core_nw_type_list_local_nonprimitive); - OpenAPI_list_add(restricted_core_nw_type_listList, restricted_core_nw_type_listItem); + OpenAPI_list_add(restricted_core_nw_type_listList, (void *)OpenAPI_core_network_type_FromString(restricted_core_nw_type_list_local_nonprimitive->valuestring)); } } diff --git a/lib/sbi/openapi/model/ue_initiated_resource_request.c b/lib/sbi/openapi/model/ue_initiated_resource_request.c new file mode 100644 index 000000000..7c4d6faf8 --- /dev/null +++ b/lib/sbi/openapi/model/ue_initiated_resource_request.c @@ -0,0 +1,232 @@ + +#include +#include +#include +#include "ue_initiated_resource_request.h" + +OpenAPI_ue_initiated_resource_request_t *OpenAPI_ue_initiated_resource_request_create( + char *pcc_rule_id, + OpenAPI_rule_operation_t *rule_op, + int precedence, + OpenAPI_list_t *pack_filt_info, + OpenAPI_requested_qos_t *req_qos + ) +{ + OpenAPI_ue_initiated_resource_request_t *ue_initiated_resource_request_local_var = OpenAPI_malloc(sizeof(OpenAPI_ue_initiated_resource_request_t)); + if (!ue_initiated_resource_request_local_var) { + return NULL; + } + ue_initiated_resource_request_local_var->pcc_rule_id = pcc_rule_id; + ue_initiated_resource_request_local_var->rule_op = rule_op; + ue_initiated_resource_request_local_var->precedence = precedence; + ue_initiated_resource_request_local_var->pack_filt_info = pack_filt_info; + ue_initiated_resource_request_local_var->req_qos = req_qos; + + return ue_initiated_resource_request_local_var; +} + +void OpenAPI_ue_initiated_resource_request_free(OpenAPI_ue_initiated_resource_request_t *ue_initiated_resource_request) +{ + if (NULL == ue_initiated_resource_request) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(ue_initiated_resource_request->pcc_rule_id); + OpenAPI_rule_operation_free(ue_initiated_resource_request->rule_op); + OpenAPI_list_for_each(ue_initiated_resource_request->pack_filt_info, node) { + OpenAPI_packet_filter_info_free(node->data); + } + OpenAPI_list_free(ue_initiated_resource_request->pack_filt_info); + OpenAPI_requested_qos_free(ue_initiated_resource_request->req_qos); + ogs_free(ue_initiated_resource_request); +} + +cJSON *OpenAPI_ue_initiated_resource_request_convertToJSON(OpenAPI_ue_initiated_resource_request_t *ue_initiated_resource_request) +{ + cJSON *item = NULL; + + if (ue_initiated_resource_request == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [UeInitiatedResourceRequest]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (ue_initiated_resource_request->pcc_rule_id) { + if (cJSON_AddStringToObject(item, "pccRuleId", ue_initiated_resource_request->pcc_rule_id) == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [pcc_rule_id]"); + goto end; + } + } + + if (!ue_initiated_resource_request->rule_op) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [rule_op]"); + goto end; + } + cJSON *rule_op_local_JSON = OpenAPI_rule_operation_convertToJSON(ue_initiated_resource_request->rule_op); + if (rule_op_local_JSON == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [rule_op]"); + goto end; + } + cJSON_AddItemToObject(item, "ruleOp", rule_op_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [rule_op]"); + goto end; + } + + if (ue_initiated_resource_request->precedence) { + if (cJSON_AddNumberToObject(item, "precedence", ue_initiated_resource_request->precedence) == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [precedence]"); + goto end; + } + } + + if (!ue_initiated_resource_request->pack_filt_info) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [pack_filt_info]"); + goto end; + } + cJSON *pack_filt_infoList = cJSON_AddArrayToObject(item, "packFiltInfo"); + if (pack_filt_infoList == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [pack_filt_info]"); + goto end; + } + + OpenAPI_lnode_t *pack_filt_info_node; + if (ue_initiated_resource_request->pack_filt_info) { + OpenAPI_list_for_each(ue_initiated_resource_request->pack_filt_info, pack_filt_info_node) { + cJSON *itemLocal = OpenAPI_packet_filter_info_convertToJSON(pack_filt_info_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [pack_filt_info]"); + goto end; + } + cJSON_AddItemToArray(pack_filt_infoList, itemLocal); + } + } + + if (ue_initiated_resource_request->req_qos) { + cJSON *req_qos_local_JSON = OpenAPI_requested_qos_convertToJSON(ue_initiated_resource_request->req_qos); + if (req_qos_local_JSON == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [req_qos]"); + goto end; + } + cJSON_AddItemToObject(item, "reqQos", req_qos_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed [req_qos]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_ue_initiated_resource_request_t *OpenAPI_ue_initiated_resource_request_parseFromJSON(cJSON *ue_initiated_resource_requestJSON) +{ + OpenAPI_ue_initiated_resource_request_t *ue_initiated_resource_request_local_var = NULL; + cJSON *pcc_rule_id = cJSON_GetObjectItemCaseSensitive(ue_initiated_resource_requestJSON, "pccRuleId"); + + if (pcc_rule_id) { + if (!cJSON_IsString(pcc_rule_id)) { + ogs_error("OpenAPI_ue_initiated_resource_request_parseFromJSON() failed [pcc_rule_id]"); + goto end; + } + } + + cJSON *rule_op = cJSON_GetObjectItemCaseSensitive(ue_initiated_resource_requestJSON, "ruleOp"); + if (!rule_op) { + ogs_error("OpenAPI_ue_initiated_resource_request_parseFromJSON() failed [rule_op]"); + goto end; + } + + OpenAPI_rule_operation_t *rule_op_local_nonprim = NULL; + + rule_op_local_nonprim = OpenAPI_rule_operation_parseFromJSON(rule_op); + + cJSON *precedence = cJSON_GetObjectItemCaseSensitive(ue_initiated_resource_requestJSON, "precedence"); + + if (precedence) { + if (!cJSON_IsNumber(precedence)) { + ogs_error("OpenAPI_ue_initiated_resource_request_parseFromJSON() failed [precedence]"); + goto end; + } + } + + cJSON *pack_filt_info = cJSON_GetObjectItemCaseSensitive(ue_initiated_resource_requestJSON, "packFiltInfo"); + if (!pack_filt_info) { + ogs_error("OpenAPI_ue_initiated_resource_request_parseFromJSON() failed [pack_filt_info]"); + goto end; + } + + OpenAPI_list_t *pack_filt_infoList; + + cJSON *pack_filt_info_local_nonprimitive; + if (!cJSON_IsArray(pack_filt_info)) { + ogs_error("OpenAPI_ue_initiated_resource_request_parseFromJSON() failed [pack_filt_info]"); + goto end; + } + + pack_filt_infoList = OpenAPI_list_create(); + + cJSON_ArrayForEach(pack_filt_info_local_nonprimitive, pack_filt_info ) { + if (!cJSON_IsObject(pack_filt_info_local_nonprimitive)) { + ogs_error("OpenAPI_ue_initiated_resource_request_parseFromJSON() failed [pack_filt_info]"); + goto end; + } + OpenAPI_packet_filter_info_t *pack_filt_infoItem = OpenAPI_packet_filter_info_parseFromJSON(pack_filt_info_local_nonprimitive); + + OpenAPI_list_add(pack_filt_infoList, pack_filt_infoItem); + } + + cJSON *req_qos = cJSON_GetObjectItemCaseSensitive(ue_initiated_resource_requestJSON, "reqQos"); + + OpenAPI_requested_qos_t *req_qos_local_nonprim = NULL; + if (req_qos) { + req_qos_local_nonprim = OpenAPI_requested_qos_parseFromJSON(req_qos); + } + + ue_initiated_resource_request_local_var = OpenAPI_ue_initiated_resource_request_create ( + pcc_rule_id ? ogs_strdup(pcc_rule_id->valuestring) : NULL, + rule_op_local_nonprim, + precedence ? precedence->valuedouble : 0, + pack_filt_infoList, + req_qos ? req_qos_local_nonprim : NULL + ); + + return ue_initiated_resource_request_local_var; +end: + return NULL; +} + +OpenAPI_ue_initiated_resource_request_t *OpenAPI_ue_initiated_resource_request_copy(OpenAPI_ue_initiated_resource_request_t *dst, OpenAPI_ue_initiated_resource_request_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_ue_initiated_resource_request_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_ue_initiated_resource_request_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_ue_initiated_resource_request_free(dst); + dst = OpenAPI_ue_initiated_resource_request_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/ue_initiated_resource_request.h b/lib/sbi/openapi/model/ue_initiated_resource_request.h new file mode 100644 index 000000000..5f1985afe --- /dev/null +++ b/lib/sbi/openapi/model/ue_initiated_resource_request.h @@ -0,0 +1,49 @@ +/* + * ue_initiated_resource_request.h + * + * + */ + +#ifndef _OpenAPI_ue_initiated_resource_request_H_ +#define _OpenAPI_ue_initiated_resource_request_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "packet_filter_info.h" +#include "requested_qos.h" +#include "rule_operation.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_ue_initiated_resource_request_s OpenAPI_ue_initiated_resource_request_t; +typedef struct OpenAPI_ue_initiated_resource_request_s { + char *pcc_rule_id; + struct OpenAPI_rule_operation_s *rule_op; + int precedence; + OpenAPI_list_t *pack_filt_info; + struct OpenAPI_requested_qos_s *req_qos; +} OpenAPI_ue_initiated_resource_request_t; + +OpenAPI_ue_initiated_resource_request_t *OpenAPI_ue_initiated_resource_request_create( + char *pcc_rule_id, + OpenAPI_rule_operation_t *rule_op, + int precedence, + OpenAPI_list_t *pack_filt_info, + OpenAPI_requested_qos_t *req_qos + ); +void OpenAPI_ue_initiated_resource_request_free(OpenAPI_ue_initiated_resource_request_t *ue_initiated_resource_request); +OpenAPI_ue_initiated_resource_request_t *OpenAPI_ue_initiated_resource_request_parseFromJSON(cJSON *ue_initiated_resource_requestJSON); +cJSON *OpenAPI_ue_initiated_resource_request_convertToJSON(OpenAPI_ue_initiated_resource_request_t *ue_initiated_resource_request); +OpenAPI_ue_initiated_resource_request_t *OpenAPI_ue_initiated_resource_request_copy(OpenAPI_ue_initiated_resource_request_t *dst, OpenAPI_ue_initiated_resource_request_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_ue_initiated_resource_request_H_ */ + diff --git a/lib/sbi/openapi/model/up_path_chg_event.c b/lib/sbi/openapi/model/up_path_chg_event.c new file mode 100644 index 000000000..e55e5b6e3 --- /dev/null +++ b/lib/sbi/openapi/model/up_path_chg_event.c @@ -0,0 +1,183 @@ + +#include +#include +#include +#include "up_path_chg_event.h" + +OpenAPI_up_path_chg_event_t *OpenAPI_up_path_chg_event_create( + char *notification_uri, + char *notif_corre_id, + OpenAPI_dnai_change_type_t *dnai_chg_type, + int af_ack_ind + ) +{ + OpenAPI_up_path_chg_event_t *up_path_chg_event_local_var = OpenAPI_malloc(sizeof(OpenAPI_up_path_chg_event_t)); + if (!up_path_chg_event_local_var) { + return NULL; + } + up_path_chg_event_local_var->notification_uri = notification_uri; + up_path_chg_event_local_var->notif_corre_id = notif_corre_id; + up_path_chg_event_local_var->dnai_chg_type = dnai_chg_type; + up_path_chg_event_local_var->af_ack_ind = af_ack_ind; + + return up_path_chg_event_local_var; +} + +void OpenAPI_up_path_chg_event_free(OpenAPI_up_path_chg_event_t *up_path_chg_event) +{ + if (NULL == up_path_chg_event) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(up_path_chg_event->notification_uri); + ogs_free(up_path_chg_event->notif_corre_id); + OpenAPI_dnai_change_type_free(up_path_chg_event->dnai_chg_type); + ogs_free(up_path_chg_event); +} + +cJSON *OpenAPI_up_path_chg_event_convertToJSON(OpenAPI_up_path_chg_event_t *up_path_chg_event) +{ + cJSON *item = NULL; + + if (up_path_chg_event == NULL) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [UpPathChgEvent]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!up_path_chg_event->notification_uri) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [notification_uri]"); + goto end; + } + if (cJSON_AddStringToObject(item, "notificationUri", up_path_chg_event->notification_uri) == NULL) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [notification_uri]"); + goto end; + } + + if (!up_path_chg_event->notif_corre_id) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [notif_corre_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "notifCorreId", up_path_chg_event->notif_corre_id) == NULL) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [notif_corre_id]"); + goto end; + } + + if (!up_path_chg_event->dnai_chg_type) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [dnai_chg_type]"); + goto end; + } + cJSON *dnai_chg_type_local_JSON = OpenAPI_dnai_change_type_convertToJSON(up_path_chg_event->dnai_chg_type); + if (dnai_chg_type_local_JSON == NULL) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [dnai_chg_type]"); + goto end; + } + cJSON_AddItemToObject(item, "dnaiChgType", dnai_chg_type_local_JSON); + if (item->child == NULL) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [dnai_chg_type]"); + goto end; + } + + if (up_path_chg_event->af_ack_ind) { + if (cJSON_AddBoolToObject(item, "afAckInd", up_path_chg_event->af_ack_ind) == NULL) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed [af_ack_ind]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_up_path_chg_event_t *OpenAPI_up_path_chg_event_parseFromJSON(cJSON *up_path_chg_eventJSON) +{ + OpenAPI_up_path_chg_event_t *up_path_chg_event_local_var = NULL; + cJSON *notification_uri = cJSON_GetObjectItemCaseSensitive(up_path_chg_eventJSON, "notificationUri"); + if (!notification_uri) { + ogs_error("OpenAPI_up_path_chg_event_parseFromJSON() failed [notification_uri]"); + goto end; + } + + + if (!cJSON_IsString(notification_uri)) { + ogs_error("OpenAPI_up_path_chg_event_parseFromJSON() failed [notification_uri]"); + goto end; + } + + cJSON *notif_corre_id = cJSON_GetObjectItemCaseSensitive(up_path_chg_eventJSON, "notifCorreId"); + if (!notif_corre_id) { + ogs_error("OpenAPI_up_path_chg_event_parseFromJSON() failed [notif_corre_id]"); + goto end; + } + + + if (!cJSON_IsString(notif_corre_id)) { + ogs_error("OpenAPI_up_path_chg_event_parseFromJSON() failed [notif_corre_id]"); + goto end; + } + + cJSON *dnai_chg_type = cJSON_GetObjectItemCaseSensitive(up_path_chg_eventJSON, "dnaiChgType"); + if (!dnai_chg_type) { + ogs_error("OpenAPI_up_path_chg_event_parseFromJSON() failed [dnai_chg_type]"); + goto end; + } + + OpenAPI_dnai_change_type_t *dnai_chg_type_local_nonprim = NULL; + + dnai_chg_type_local_nonprim = OpenAPI_dnai_change_type_parseFromJSON(dnai_chg_type); + + cJSON *af_ack_ind = cJSON_GetObjectItemCaseSensitive(up_path_chg_eventJSON, "afAckInd"); + + if (af_ack_ind) { + if (!cJSON_IsBool(af_ack_ind)) { + ogs_error("OpenAPI_up_path_chg_event_parseFromJSON() failed [af_ack_ind]"); + goto end; + } + } + + up_path_chg_event_local_var = OpenAPI_up_path_chg_event_create ( + ogs_strdup(notification_uri->valuestring), + ogs_strdup(notif_corre_id->valuestring), + dnai_chg_type_local_nonprim, + af_ack_ind ? af_ack_ind->valueint : 0 + ); + + return up_path_chg_event_local_var; +end: + return NULL; +} + +OpenAPI_up_path_chg_event_t *OpenAPI_up_path_chg_event_copy(OpenAPI_up_path_chg_event_t *dst, OpenAPI_up_path_chg_event_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_up_path_chg_event_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_up_path_chg_event_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_up_path_chg_event_free(dst); + dst = OpenAPI_up_path_chg_event_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/up_path_chg_event.h b/lib/sbi/openapi/model/up_path_chg_event.h new file mode 100644 index 000000000..0d62501aa --- /dev/null +++ b/lib/sbi/openapi/model/up_path_chg_event.h @@ -0,0 +1,45 @@ +/* + * up_path_chg_event.h + * + * + */ + +#ifndef _OpenAPI_up_path_chg_event_H_ +#define _OpenAPI_up_path_chg_event_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "dnai_change_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_up_path_chg_event_s OpenAPI_up_path_chg_event_t; +typedef struct OpenAPI_up_path_chg_event_s { + char *notification_uri; + char *notif_corre_id; + struct OpenAPI_dnai_change_type_s *dnai_chg_type; + int af_ack_ind; +} OpenAPI_up_path_chg_event_t; + +OpenAPI_up_path_chg_event_t *OpenAPI_up_path_chg_event_create( + char *notification_uri, + char *notif_corre_id, + OpenAPI_dnai_change_type_t *dnai_chg_type, + int af_ack_ind + ); +void OpenAPI_up_path_chg_event_free(OpenAPI_up_path_chg_event_t *up_path_chg_event); +OpenAPI_up_path_chg_event_t *OpenAPI_up_path_chg_event_parseFromJSON(cJSON *up_path_chg_eventJSON); +cJSON *OpenAPI_up_path_chg_event_convertToJSON(OpenAPI_up_path_chg_event_t *up_path_chg_event); +OpenAPI_up_path_chg_event_t *OpenAPI_up_path_chg_event_copy(OpenAPI_up_path_chg_event_t *dst, OpenAPI_up_path_chg_event_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_up_path_chg_event_H_ */ + diff --git a/lib/sbi/openapi/model/usage_monitoring_data.c b/lib/sbi/openapi/model/usage_monitoring_data.c new file mode 100644 index 000000000..0562c0a45 --- /dev/null +++ b/lib/sbi/openapi/model/usage_monitoring_data.c @@ -0,0 +1,344 @@ + +#include +#include +#include +#include "usage_monitoring_data.h" + +OpenAPI_usage_monitoring_data_t *OpenAPI_usage_monitoring_data_create( + char *um_id, + long volume_threshold, + long volume_threshold_uplink, + long volume_threshold_downlink, + int time_threshold, + char *monitoring_time, + long next_vol_threshold, + long next_vol_threshold_uplink, + long next_vol_threshold_downlink, + int next_time_threshold, + int inactivity_time, + OpenAPI_list_t *ex_usage_pcc_rule_ids + ) +{ + OpenAPI_usage_monitoring_data_t *usage_monitoring_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_usage_monitoring_data_t)); + if (!usage_monitoring_data_local_var) { + return NULL; + } + usage_monitoring_data_local_var->um_id = um_id; + usage_monitoring_data_local_var->volume_threshold = volume_threshold; + usage_monitoring_data_local_var->volume_threshold_uplink = volume_threshold_uplink; + usage_monitoring_data_local_var->volume_threshold_downlink = volume_threshold_downlink; + usage_monitoring_data_local_var->time_threshold = time_threshold; + usage_monitoring_data_local_var->monitoring_time = monitoring_time; + usage_monitoring_data_local_var->next_vol_threshold = next_vol_threshold; + usage_monitoring_data_local_var->next_vol_threshold_uplink = next_vol_threshold_uplink; + usage_monitoring_data_local_var->next_vol_threshold_downlink = next_vol_threshold_downlink; + usage_monitoring_data_local_var->next_time_threshold = next_time_threshold; + usage_monitoring_data_local_var->inactivity_time = inactivity_time; + usage_monitoring_data_local_var->ex_usage_pcc_rule_ids = ex_usage_pcc_rule_ids; + + return usage_monitoring_data_local_var; +} + +void OpenAPI_usage_monitoring_data_free(OpenAPI_usage_monitoring_data_t *usage_monitoring_data) +{ + if (NULL == usage_monitoring_data) { + return; + } + OpenAPI_lnode_t *node; + ogs_free(usage_monitoring_data->um_id); + ogs_free(usage_monitoring_data->monitoring_time); + OpenAPI_list_for_each(usage_monitoring_data->ex_usage_pcc_rule_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(usage_monitoring_data->ex_usage_pcc_rule_ids); + ogs_free(usage_monitoring_data); +} + +cJSON *OpenAPI_usage_monitoring_data_convertToJSON(OpenAPI_usage_monitoring_data_t *usage_monitoring_data) +{ + cJSON *item = NULL; + + if (usage_monitoring_data == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [UsageMonitoringData]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (!usage_monitoring_data->um_id) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [um_id]"); + goto end; + } + if (cJSON_AddStringToObject(item, "umId", usage_monitoring_data->um_id) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [um_id]"); + goto end; + } + + if (usage_monitoring_data->volume_threshold) { + if (cJSON_AddNumberToObject(item, "volumeThreshold", usage_monitoring_data->volume_threshold) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [volume_threshold]"); + goto end; + } + } + + if (usage_monitoring_data->volume_threshold_uplink) { + if (cJSON_AddNumberToObject(item, "volumeThresholdUplink", usage_monitoring_data->volume_threshold_uplink) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [volume_threshold_uplink]"); + goto end; + } + } + + if (usage_monitoring_data->volume_threshold_downlink) { + if (cJSON_AddNumberToObject(item, "volumeThresholdDownlink", usage_monitoring_data->volume_threshold_downlink) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [volume_threshold_downlink]"); + goto end; + } + } + + if (usage_monitoring_data->time_threshold) { + if (cJSON_AddNumberToObject(item, "timeThreshold", usage_monitoring_data->time_threshold) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [time_threshold]"); + goto end; + } + } + + if (usage_monitoring_data->monitoring_time) { + if (cJSON_AddStringToObject(item, "monitoringTime", usage_monitoring_data->monitoring_time) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [monitoring_time]"); + goto end; + } + } + + if (usage_monitoring_data->next_vol_threshold) { + if (cJSON_AddNumberToObject(item, "nextVolThreshold", usage_monitoring_data->next_vol_threshold) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [next_vol_threshold]"); + goto end; + } + } + + if (usage_monitoring_data->next_vol_threshold_uplink) { + if (cJSON_AddNumberToObject(item, "nextVolThresholdUplink", usage_monitoring_data->next_vol_threshold_uplink) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [next_vol_threshold_uplink]"); + goto end; + } + } + + if (usage_monitoring_data->next_vol_threshold_downlink) { + if (cJSON_AddNumberToObject(item, "nextVolThresholdDownlink", usage_monitoring_data->next_vol_threshold_downlink) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [next_vol_threshold_downlink]"); + goto end; + } + } + + if (usage_monitoring_data->next_time_threshold) { + if (cJSON_AddNumberToObject(item, "nextTimeThreshold", usage_monitoring_data->next_time_threshold) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [next_time_threshold]"); + goto end; + } + } + + if (usage_monitoring_data->inactivity_time) { + if (cJSON_AddNumberToObject(item, "inactivityTime", usage_monitoring_data->inactivity_time) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [inactivity_time]"); + goto end; + } + } + + if (usage_monitoring_data->ex_usage_pcc_rule_ids) { + cJSON *ex_usage_pcc_rule_ids = cJSON_AddArrayToObject(item, "exUsagePccRuleIds"); + if (ex_usage_pcc_rule_ids == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [ex_usage_pcc_rule_ids]"); + goto end; + } + + OpenAPI_lnode_t *ex_usage_pcc_rule_ids_node; + OpenAPI_list_for_each(usage_monitoring_data->ex_usage_pcc_rule_ids, ex_usage_pcc_rule_ids_node) { + if (cJSON_AddStringToObject(ex_usage_pcc_rule_ids, "", (char*)ex_usage_pcc_rule_ids_node->data) == NULL) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed [ex_usage_pcc_rule_ids]"); + goto end; + } + } + } + +end: + return item; +} + +OpenAPI_usage_monitoring_data_t *OpenAPI_usage_monitoring_data_parseFromJSON(cJSON *usage_monitoring_dataJSON) +{ + OpenAPI_usage_monitoring_data_t *usage_monitoring_data_local_var = NULL; + cJSON *um_id = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "umId"); + if (!um_id) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [um_id]"); + goto end; + } + + + if (!cJSON_IsString(um_id)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [um_id]"); + goto end; + } + + cJSON *volume_threshold = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "volumeThreshold"); + + if (volume_threshold) { + if (!cJSON_IsNumber(volume_threshold)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [volume_threshold]"); + goto end; + } + } + + cJSON *volume_threshold_uplink = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "volumeThresholdUplink"); + + if (volume_threshold_uplink) { + if (!cJSON_IsNumber(volume_threshold_uplink)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [volume_threshold_uplink]"); + goto end; + } + } + + cJSON *volume_threshold_downlink = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "volumeThresholdDownlink"); + + if (volume_threshold_downlink) { + if (!cJSON_IsNumber(volume_threshold_downlink)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [volume_threshold_downlink]"); + goto end; + } + } + + cJSON *time_threshold = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "timeThreshold"); + + if (time_threshold) { + if (!cJSON_IsNumber(time_threshold)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [time_threshold]"); + goto end; + } + } + + cJSON *monitoring_time = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "monitoringTime"); + + if (monitoring_time) { + if (!cJSON_IsString(monitoring_time)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [monitoring_time]"); + goto end; + } + } + + cJSON *next_vol_threshold = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "nextVolThreshold"); + + if (next_vol_threshold) { + if (!cJSON_IsNumber(next_vol_threshold)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [next_vol_threshold]"); + goto end; + } + } + + cJSON *next_vol_threshold_uplink = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "nextVolThresholdUplink"); + + if (next_vol_threshold_uplink) { + if (!cJSON_IsNumber(next_vol_threshold_uplink)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [next_vol_threshold_uplink]"); + goto end; + } + } + + cJSON *next_vol_threshold_downlink = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "nextVolThresholdDownlink"); + + if (next_vol_threshold_downlink) { + if (!cJSON_IsNumber(next_vol_threshold_downlink)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [next_vol_threshold_downlink]"); + goto end; + } + } + + cJSON *next_time_threshold = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "nextTimeThreshold"); + + if (next_time_threshold) { + if (!cJSON_IsNumber(next_time_threshold)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [next_time_threshold]"); + goto end; + } + } + + cJSON *inactivity_time = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "inactivityTime"); + + if (inactivity_time) { + if (!cJSON_IsNumber(inactivity_time)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [inactivity_time]"); + goto end; + } + } + + cJSON *ex_usage_pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(usage_monitoring_dataJSON, "exUsagePccRuleIds"); + + OpenAPI_list_t *ex_usage_pcc_rule_idsList; + if (ex_usage_pcc_rule_ids) { + cJSON *ex_usage_pcc_rule_ids_local; + if (!cJSON_IsArray(ex_usage_pcc_rule_ids)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [ex_usage_pcc_rule_ids]"); + goto end; + } + ex_usage_pcc_rule_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(ex_usage_pcc_rule_ids_local, ex_usage_pcc_rule_ids) { + if (!cJSON_IsString(ex_usage_pcc_rule_ids_local)) { + ogs_error("OpenAPI_usage_monitoring_data_parseFromJSON() failed [ex_usage_pcc_rule_ids]"); + goto end; + } + OpenAPI_list_add(ex_usage_pcc_rule_idsList, ogs_strdup(ex_usage_pcc_rule_ids_local->valuestring)); + } + } + + usage_monitoring_data_local_var = OpenAPI_usage_monitoring_data_create ( + ogs_strdup(um_id->valuestring), + volume_threshold ? volume_threshold->valuedouble : 0, + volume_threshold_uplink ? volume_threshold_uplink->valuedouble : 0, + volume_threshold_downlink ? volume_threshold_downlink->valuedouble : 0, + time_threshold ? time_threshold->valuedouble : 0, + monitoring_time ? ogs_strdup(monitoring_time->valuestring) : NULL, + next_vol_threshold ? next_vol_threshold->valuedouble : 0, + next_vol_threshold_uplink ? next_vol_threshold_uplink->valuedouble : 0, + next_vol_threshold_downlink ? next_vol_threshold_downlink->valuedouble : 0, + next_time_threshold ? next_time_threshold->valuedouble : 0, + inactivity_time ? inactivity_time->valuedouble : 0, + ex_usage_pcc_rule_ids ? ex_usage_pcc_rule_idsList : NULL + ); + + return usage_monitoring_data_local_var; +end: + return NULL; +} + +OpenAPI_usage_monitoring_data_t *OpenAPI_usage_monitoring_data_copy(OpenAPI_usage_monitoring_data_t *dst, OpenAPI_usage_monitoring_data_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_usage_monitoring_data_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_usage_monitoring_data_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_usage_monitoring_data_free(dst); + dst = OpenAPI_usage_monitoring_data_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/usage_monitoring_data.h b/lib/sbi/openapi/model/usage_monitoring_data.h new file mode 100644 index 000000000..59445f18a --- /dev/null +++ b/lib/sbi/openapi/model/usage_monitoring_data.h @@ -0,0 +1,60 @@ +/* + * usage_monitoring_data.h + * + * + */ + +#ifndef _OpenAPI_usage_monitoring_data_H_ +#define _OpenAPI_usage_monitoring_data_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_usage_monitoring_data_s OpenAPI_usage_monitoring_data_t; +typedef struct OpenAPI_usage_monitoring_data_s { + char *um_id; + long volume_threshold; + long volume_threshold_uplink; + long volume_threshold_downlink; + int time_threshold; + char *monitoring_time; + long next_vol_threshold; + long next_vol_threshold_uplink; + long next_vol_threshold_downlink; + int next_time_threshold; + int inactivity_time; + OpenAPI_list_t *ex_usage_pcc_rule_ids; +} OpenAPI_usage_monitoring_data_t; + +OpenAPI_usage_monitoring_data_t *OpenAPI_usage_monitoring_data_create( + char *um_id, + long volume_threshold, + long volume_threshold_uplink, + long volume_threshold_downlink, + int time_threshold, + char *monitoring_time, + long next_vol_threshold, + long next_vol_threshold_uplink, + long next_vol_threshold_downlink, + int next_time_threshold, + int inactivity_time, + OpenAPI_list_t *ex_usage_pcc_rule_ids + ); +void OpenAPI_usage_monitoring_data_free(OpenAPI_usage_monitoring_data_t *usage_monitoring_data); +OpenAPI_usage_monitoring_data_t *OpenAPI_usage_monitoring_data_parseFromJSON(cJSON *usage_monitoring_dataJSON); +cJSON *OpenAPI_usage_monitoring_data_convertToJSON(OpenAPI_usage_monitoring_data_t *usage_monitoring_data); +OpenAPI_usage_monitoring_data_t *OpenAPI_usage_monitoring_data_copy(OpenAPI_usage_monitoring_data_t *dst, OpenAPI_usage_monitoring_data_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_usage_monitoring_data_H_ */ + diff --git a/lib/sbi/openapi/model/wireline_area.c b/lib/sbi/openapi/model/wireline_area.c new file mode 100644 index 000000000..6f32c1327 --- /dev/null +++ b/lib/sbi/openapi/model/wireline_area.c @@ -0,0 +1,202 @@ + +#include +#include +#include +#include "wireline_area.h" + +OpenAPI_wireline_area_t *OpenAPI_wireline_area_create( + OpenAPI_list_t *global_line_ids, + OpenAPI_list_t *hfc_n_ids, + char *area_code_b, + char *area_code_c + ) +{ + OpenAPI_wireline_area_t *wireline_area_local_var = OpenAPI_malloc(sizeof(OpenAPI_wireline_area_t)); + if (!wireline_area_local_var) { + return NULL; + } + wireline_area_local_var->global_line_ids = global_line_ids; + wireline_area_local_var->hfc_n_ids = hfc_n_ids; + wireline_area_local_var->area_code_b = area_code_b; + wireline_area_local_var->area_code_c = area_code_c; + + return wireline_area_local_var; +} + +void OpenAPI_wireline_area_free(OpenAPI_wireline_area_t *wireline_area) +{ + if (NULL == wireline_area) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(wireline_area->global_line_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(wireline_area->global_line_ids); + OpenAPI_list_for_each(wireline_area->hfc_n_ids, node) { + ogs_free(node->data); + } + OpenAPI_list_free(wireline_area->hfc_n_ids); + ogs_free(wireline_area->area_code_b); + ogs_free(wireline_area->area_code_c); + ogs_free(wireline_area); +} + +cJSON *OpenAPI_wireline_area_convertToJSON(OpenAPI_wireline_area_t *wireline_area) +{ + cJSON *item = NULL; + + if (wireline_area == NULL) { + ogs_error("OpenAPI_wireline_area_convertToJSON() failed [WirelineArea]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (wireline_area->global_line_ids) { + cJSON *global_line_ids = cJSON_AddArrayToObject(item, "globalLineIds"); + if (global_line_ids == NULL) { + ogs_error("OpenAPI_wireline_area_convertToJSON() failed [global_line_ids]"); + goto end; + } + + OpenAPI_lnode_t *global_line_ids_node; + OpenAPI_list_for_each(wireline_area->global_line_ids, global_line_ids_node) { + } + } + + if (wireline_area->hfc_n_ids) { + cJSON *hfc_n_ids = cJSON_AddArrayToObject(item, "hfcNIds"); + if (hfc_n_ids == NULL) { + ogs_error("OpenAPI_wireline_area_convertToJSON() failed [hfc_n_ids]"); + goto end; + } + + OpenAPI_lnode_t *hfc_n_ids_node; + OpenAPI_list_for_each(wireline_area->hfc_n_ids, hfc_n_ids_node) { + if (cJSON_AddStringToObject(hfc_n_ids, "", (char*)hfc_n_ids_node->data) == NULL) { + ogs_error("OpenAPI_wireline_area_convertToJSON() failed [hfc_n_ids]"); + goto end; + } + } + } + + if (wireline_area->area_code_b) { + if (cJSON_AddStringToObject(item, "areaCodeB", wireline_area->area_code_b) == NULL) { + ogs_error("OpenAPI_wireline_area_convertToJSON() failed [area_code_b]"); + goto end; + } + } + + if (wireline_area->area_code_c) { + if (cJSON_AddStringToObject(item, "areaCodeC", wireline_area->area_code_c) == NULL) { + ogs_error("OpenAPI_wireline_area_convertToJSON() failed [area_code_c]"); + goto end; + } + } + +end: + return item; +} + +OpenAPI_wireline_area_t *OpenAPI_wireline_area_parseFromJSON(cJSON *wireline_areaJSON) +{ + OpenAPI_wireline_area_t *wireline_area_local_var = NULL; + cJSON *global_line_ids = cJSON_GetObjectItemCaseSensitive(wireline_areaJSON, "globalLineIds"); + + OpenAPI_list_t *global_line_idsList; + if (global_line_ids) { + cJSON *global_line_ids_local; + if (!cJSON_IsArray(global_line_ids)) { + ogs_error("OpenAPI_wireline_area_parseFromJSON() failed [global_line_ids]"); + goto end; + } + global_line_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(global_line_ids_local, global_line_ids) { + } + } + + cJSON *hfc_n_ids = cJSON_GetObjectItemCaseSensitive(wireline_areaJSON, "hfcNIds"); + + OpenAPI_list_t *hfc_n_idsList; + if (hfc_n_ids) { + cJSON *hfc_n_ids_local; + if (!cJSON_IsArray(hfc_n_ids)) { + ogs_error("OpenAPI_wireline_area_parseFromJSON() failed [hfc_n_ids]"); + goto end; + } + hfc_n_idsList = OpenAPI_list_create(); + + cJSON_ArrayForEach(hfc_n_ids_local, hfc_n_ids) { + if (!cJSON_IsString(hfc_n_ids_local)) { + ogs_error("OpenAPI_wireline_area_parseFromJSON() failed [hfc_n_ids]"); + goto end; + } + OpenAPI_list_add(hfc_n_idsList, ogs_strdup(hfc_n_ids_local->valuestring)); + } + } + + cJSON *area_code_b = cJSON_GetObjectItemCaseSensitive(wireline_areaJSON, "areaCodeB"); + + if (area_code_b) { + if (!cJSON_IsString(area_code_b)) { + ogs_error("OpenAPI_wireline_area_parseFromJSON() failed [area_code_b]"); + goto end; + } + } + + cJSON *area_code_c = cJSON_GetObjectItemCaseSensitive(wireline_areaJSON, "areaCodeC"); + + if (area_code_c) { + if (!cJSON_IsString(area_code_c)) { + ogs_error("OpenAPI_wireline_area_parseFromJSON() failed [area_code_c]"); + goto end; + } + } + + wireline_area_local_var = OpenAPI_wireline_area_create ( + global_line_ids ? global_line_idsList : NULL, + hfc_n_ids ? hfc_n_idsList : NULL, + area_code_b ? ogs_strdup(area_code_b->valuestring) : NULL, + area_code_c ? ogs_strdup(area_code_c->valuestring) : NULL + ); + + return wireline_area_local_var; +end: + return NULL; +} + +OpenAPI_wireline_area_t *OpenAPI_wireline_area_copy(OpenAPI_wireline_area_t *dst, OpenAPI_wireline_area_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_wireline_area_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_wireline_area_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_wireline_area_free(dst); + dst = OpenAPI_wireline_area_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/wireline_area.h b/lib/sbi/openapi/model/wireline_area.h new file mode 100644 index 000000000..7b65e7d06 --- /dev/null +++ b/lib/sbi/openapi/model/wireline_area.h @@ -0,0 +1,44 @@ +/* + * wireline_area.h + * + * + */ + +#ifndef _OpenAPI_wireline_area_H_ +#define _OpenAPI_wireline_area_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_wireline_area_s OpenAPI_wireline_area_t; +typedef struct OpenAPI_wireline_area_s { + OpenAPI_list_t *global_line_ids; + OpenAPI_list_t *hfc_n_ids; + char *area_code_b; + char *area_code_c; +} OpenAPI_wireline_area_t; + +OpenAPI_wireline_area_t *OpenAPI_wireline_area_create( + OpenAPI_list_t *global_line_ids, + OpenAPI_list_t *hfc_n_ids, + char *area_code_b, + char *area_code_c + ); +void OpenAPI_wireline_area_free(OpenAPI_wireline_area_t *wireline_area); +OpenAPI_wireline_area_t *OpenAPI_wireline_area_parseFromJSON(cJSON *wireline_areaJSON); +cJSON *OpenAPI_wireline_area_convertToJSON(OpenAPI_wireline_area_t *wireline_area); +OpenAPI_wireline_area_t *OpenAPI_wireline_area_copy(OpenAPI_wireline_area_t *dst, OpenAPI_wireline_area_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_wireline_area_H_ */ + diff --git a/lib/sbi/openapi/model/wireline_service_area_restriction.c b/lib/sbi/openapi/model/wireline_service_area_restriction.c new file mode 100644 index 000000000..e9e49857f --- /dev/null +++ b/lib/sbi/openapi/model/wireline_service_area_restriction.c @@ -0,0 +1,156 @@ + +#include +#include +#include +#include "wireline_service_area_restriction.h" + +OpenAPI_wireline_service_area_restriction_t *OpenAPI_wireline_service_area_restriction_create( + OpenAPI_restriction_type_e restriction_type, + OpenAPI_list_t *areas + ) +{ + OpenAPI_wireline_service_area_restriction_t *wireline_service_area_restriction_local_var = OpenAPI_malloc(sizeof(OpenAPI_wireline_service_area_restriction_t)); + if (!wireline_service_area_restriction_local_var) { + return NULL; + } + wireline_service_area_restriction_local_var->restriction_type = restriction_type; + wireline_service_area_restriction_local_var->areas = areas; + + return wireline_service_area_restriction_local_var; +} + +void OpenAPI_wireline_service_area_restriction_free(OpenAPI_wireline_service_area_restriction_t *wireline_service_area_restriction) +{ + if (NULL == wireline_service_area_restriction) { + return; + } + OpenAPI_lnode_t *node; + OpenAPI_list_for_each(wireline_service_area_restriction->areas, node) { + OpenAPI_wireline_area_free(node->data); + } + OpenAPI_list_free(wireline_service_area_restriction->areas); + ogs_free(wireline_service_area_restriction); +} + +cJSON *OpenAPI_wireline_service_area_restriction_convertToJSON(OpenAPI_wireline_service_area_restriction_t *wireline_service_area_restriction) +{ + cJSON *item = NULL; + + if (wireline_service_area_restriction == NULL) { + ogs_error("OpenAPI_wireline_service_area_restriction_convertToJSON() failed [WirelineServiceAreaRestriction]"); + return NULL; + } + + item = cJSON_CreateObject(); + if (wireline_service_area_restriction->restriction_type) { + if (cJSON_AddStringToObject(item, "restrictionType", OpenAPI_restriction_type_ToString(wireline_service_area_restriction->restriction_type)) == NULL) { + ogs_error("OpenAPI_wireline_service_area_restriction_convertToJSON() failed [restriction_type]"); + goto end; + } + } + + if (wireline_service_area_restriction->areas) { + cJSON *areasList = cJSON_AddArrayToObject(item, "areas"); + if (areasList == NULL) { + ogs_error("OpenAPI_wireline_service_area_restriction_convertToJSON() failed [areas]"); + goto end; + } + + OpenAPI_lnode_t *areas_node; + if (wireline_service_area_restriction->areas) { + OpenAPI_list_for_each(wireline_service_area_restriction->areas, areas_node) { + cJSON *itemLocal = OpenAPI_wireline_area_convertToJSON(areas_node->data); + if (itemLocal == NULL) { + ogs_error("OpenAPI_wireline_service_area_restriction_convertToJSON() failed [areas]"); + goto end; + } + cJSON_AddItemToArray(areasList, itemLocal); + } + } + } + +end: + return item; +} + +OpenAPI_wireline_service_area_restriction_t *OpenAPI_wireline_service_area_restriction_parseFromJSON(cJSON *wireline_service_area_restrictionJSON) +{ + OpenAPI_wireline_service_area_restriction_t *wireline_service_area_restriction_local_var = NULL; + cJSON *restriction_type = cJSON_GetObjectItemCaseSensitive(wireline_service_area_restrictionJSON, "restrictionType"); + + OpenAPI_restriction_type_e restriction_typeVariable; + if (restriction_type) { + if (!cJSON_IsString(restriction_type)) { + ogs_error("OpenAPI_wireline_service_area_restriction_parseFromJSON() failed [restriction_type]"); + goto end; + } + restriction_typeVariable = OpenAPI_restriction_type_FromString(restriction_type->valuestring); + } + + cJSON *areas = cJSON_GetObjectItemCaseSensitive(wireline_service_area_restrictionJSON, "areas"); + + OpenAPI_list_t *areasList; + if (areas) { + cJSON *areas_local_nonprimitive; + if (!cJSON_IsArray(areas)) { + ogs_error("OpenAPI_wireline_service_area_restriction_parseFromJSON() failed [areas]"); + goto end; + } + + areasList = OpenAPI_list_create(); + + cJSON_ArrayForEach(areas_local_nonprimitive, areas ) { + if (!cJSON_IsObject(areas_local_nonprimitive)) { + ogs_error("OpenAPI_wireline_service_area_restriction_parseFromJSON() failed [areas]"); + goto end; + } + OpenAPI_wireline_area_t *areasItem = OpenAPI_wireline_area_parseFromJSON(areas_local_nonprimitive); + + OpenAPI_list_add(areasList, areasItem); + } + } + + wireline_service_area_restriction_local_var = OpenAPI_wireline_service_area_restriction_create ( + restriction_type ? restriction_typeVariable : 0, + areas ? areasList : NULL + ); + + return wireline_service_area_restriction_local_var; +end: + return NULL; +} + +OpenAPI_wireline_service_area_restriction_t *OpenAPI_wireline_service_area_restriction_copy(OpenAPI_wireline_service_area_restriction_t *dst, OpenAPI_wireline_service_area_restriction_t *src) +{ + cJSON *item = NULL; + char *content = NULL; + + ogs_assert(src); + item = OpenAPI_wireline_service_area_restriction_convertToJSON(src); + if (!item) { + ogs_error("OpenAPI_wireline_service_area_restriction_convertToJSON() failed"); + return NULL; + } + + content = cJSON_Print(item); + cJSON_Delete(item); + + if (!content) { + ogs_error("cJSON_Print() failed"); + return NULL; + } + + item = cJSON_Parse(content); + ogs_free(content); + if (!item) { + ogs_error("cJSON_Parse() failed"); + return NULL; + } + + OpenAPI_wireline_service_area_restriction_free(dst); + dst = OpenAPI_wireline_service_area_restriction_parseFromJSON(item); + cJSON_Delete(item); + + return dst; +} + diff --git a/lib/sbi/openapi/model/wireline_service_area_restriction.h b/lib/sbi/openapi/model/wireline_service_area_restriction.h new file mode 100644 index 000000000..12a892edf --- /dev/null +++ b/lib/sbi/openapi/model/wireline_service_area_restriction.h @@ -0,0 +1,42 @@ +/* + * wireline_service_area_restriction.h + * + * + */ + +#ifndef _OpenAPI_wireline_service_area_restriction_H_ +#define _OpenAPI_wireline_service_area_restriction_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" +#include "restriction_type.h" +#include "wireline_area.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OpenAPI_wireline_service_area_restriction_s OpenAPI_wireline_service_area_restriction_t; +typedef struct OpenAPI_wireline_service_area_restriction_s { + OpenAPI_restriction_type_e restriction_type; + OpenAPI_list_t *areas; +} OpenAPI_wireline_service_area_restriction_t; + +OpenAPI_wireline_service_area_restriction_t *OpenAPI_wireline_service_area_restriction_create( + OpenAPI_restriction_type_e restriction_type, + OpenAPI_list_t *areas + ); +void OpenAPI_wireline_service_area_restriction_free(OpenAPI_wireline_service_area_restriction_t *wireline_service_area_restriction); +OpenAPI_wireline_service_area_restriction_t *OpenAPI_wireline_service_area_restriction_parseFromJSON(cJSON *wireline_service_area_restrictionJSON); +cJSON *OpenAPI_wireline_service_area_restriction_convertToJSON(OpenAPI_wireline_service_area_restriction_t *wireline_service_area_restriction); +OpenAPI_wireline_service_area_restriction_t *OpenAPI_wireline_service_area_restriction_copy(OpenAPI_wireline_service_area_restriction_t *dst, OpenAPI_wireline_service_area_restriction_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* _OpenAPI_wireline_service_area_restriction_H_ */ + diff --git a/lib/sbi/support/README.md b/lib/sbi/support/README.md index e41f0dd31..4b53e9a6e 100644 --- a/lib/sbi/support/README.md +++ b/lib/sbi/support/README.md @@ -1,11 +1,25 @@ -* Install JDK, maven, cmake and uncrustify +* You can use the built package. + $ sudo apt install default-jdk maven cmake uncrustify +$ npm install @openapitools/openapi-generator-cli -g -* Using Source Code + + +* Open5GS uses the source code instead of packages. + +- VERSION: 4.3.1-SNAPSHOT $ git clone https://github.com/OpenAPITools/openapi-generator.git $ cd openapi-generator +$ git checkoutt 15d58dc89b11d17f52c2daadfae9736e442f3b1a $ mvn clean package -* Using NPM -$ npm install @openapitools/openapi-generator-cli -g +- VERSION: 0.69.1 +$ git clone https://github.com/uncrustify/uncrustify.git +$ cd uncrustify +$ git tag uncrustify-0.69.1 +$ mkdir build +$ cd build +$ cmake .. +$ make -j 8 + diff --git a/lib/sbi/support/generator.sh b/lib/sbi/support/generator.sh index 9b76c2e9d..1b85f563e 100755 --- a/lib/sbi/support/generator.sh +++ b/lib/sbi/support/generator.sh @@ -1,9 +1,14 @@ #!/bin/sh -export C_POST_PROCESS_FILE="/usr/bin/uncrustify --no-backup" -export UNCRUSTIFY_CONFIG=../openapi/.openapi-generator/uncrustify.cfg +### Ubuntu 20.04(focal) is not working +#export C_POST_PROCESS_FILE="/usr/bin/uncrustify --no-backup" + +export C_POST_PROCESS_FILE="${HOME}/Documents/git/my/uncrustify/build/uncrustify --no-backup" +export UNCRUSTIFY_CONFIG=../openapi/.openapi-generator/uncrustify-0.66.1.cfg openapi_generator_cli="java -jar ${HOME}/Documents/git/my/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" +$openapi_generator_cli generate -i ./modified/TS29507_Npcf_AMPolicyControl.yaml -c ../openapi/.openapi-generator/config.yaml -g c -o ../openapi +$openapi_generator_cli generate -i ./modified/TS29512_Npcf_SMPolicyControl.yaml -c ../openapi/.openapi-generator/config.yaml -g c -o ../openapi $openapi_generator_cli generate -i ./modified/TS29503_Nudm_SDM.yaml -c ../openapi/.openapi-generator/config.yaml -g c -o ../openapi $openapi_generator_cli generate -i ./modified/TS29503_Nudm_UECM.yaml -c ../openapi/.openapi-generator/config.yaml -g c -o ../openapi $openapi_generator_cli generate -i ./modified/TS29503_Nudm_UEAU.yaml -c ../openapi/.openapi-generator/config.yaml -g c -o ../openapi diff --git a/lib/sbi/support/modified/TS29507_Npcf_AMPolicyControl.yaml b/lib/sbi/support/modified/TS29507_Npcf_AMPolicyControl.yaml new file mode 100644 index 000000000..86229fa96 --- /dev/null +++ b/lib/sbi/support/modified/TS29507_Npcf_AMPolicyControl.yaml @@ -0,0 +1,586 @@ +openapi: 3.0.0 +info: + version: 1.1.0.alpha-4 + title: Npcf_AMPolicyControl + description: | + Access and Mobility Policy Control Service. + © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). + All rights reserved. +externalDocs: + description: 3GPP TS 29.507 V16.3.0; 5G System; Access and Mobility Policy Control Service. + url: 'http://www.3gpp.org/ftp/Specs/archive/29_series/29.507/' +servers: + - url: '{apiRoot}/npcf-am-policy-control/v1' + variables: + apiRoot: + default: https://example.com + description: apiRoot as defined in subclause subclause 4.4 of 3GPP TS 29.501 +security: + - {} + - oAuth2ClientCredentials: + - npcf-am-policy-control +paths: + /policies: + post: + operationId: CreateIndividualAMPolicyAssociation + summary: Create individual AM policy association. + tags: + - AM Policy Associations (Collection) + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyAssociationRequest' + responses: + '201': + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyAssociation' + headers: + Location: + description: 'Contains the URI of the newly created resource, according to the structure: {apiRoot}/npcf-am-policy-control/v1/policies/{polAssoId}' + required: true + schema: + type: string + '400': + $ref: 'TS29571_CommonData.yaml#/components/responses/400' + '401': + $ref: 'TS29571_CommonData.yaml#/components/responses/401' + '403': + $ref: 'TS29571_CommonData.yaml#/components/responses/403' + '404': + $ref: 'TS29571_CommonData.yaml#/components/responses/404' + '411': + $ref: 'TS29571_CommonData.yaml#/components/responses/411' + '413': + $ref: 'TS29571_CommonData.yaml#/components/responses/413' + '415': + $ref: 'TS29571_CommonData.yaml#/components/responses/415' + '429': + $ref: 'TS29571_CommonData.yaml#/components/responses/429' + '500': + $ref: 'TS29571_CommonData.yaml#/components/responses/500' + '503': + $ref: 'TS29571_CommonData.yaml#/components/responses/503' + default: + $ref: 'TS29571_CommonData.yaml#/components/responses/default' + callbacks: + policyUpdateNotification: + '{$request.body#/notificationUri}/update': + post: + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyUpdate' + responses: + '204': + description: No Content, Notification was succesfull + '307': + description: temporary redirect + '400': + $ref: 'TS29571_CommonData.yaml#/components/responses/400' + '401': + $ref: 'TS29571_CommonData.yaml#/components/responses/401' + '403': + $ref: 'TS29571_CommonData.yaml#/components/responses/403' + '404': + $ref: 'TS29571_CommonData.yaml#/components/responses/404' + '411': + $ref: 'TS29571_CommonData.yaml#/components/responses/411' + '413': + $ref: 'TS29571_CommonData.yaml#/components/responses/413' + '415': + $ref: 'TS29571_CommonData.yaml#/components/responses/415' + '429': + $ref: 'TS29571_CommonData.yaml#/components/responses/429' + '500': + $ref: 'TS29571_CommonData.yaml#/components/responses/500' + '503': + $ref: 'TS29571_CommonData.yaml#/components/responses/503' + default: + $ref: 'TS29571_CommonData.yaml#/components/responses/default' + policyAssocitionTerminationRequestNotification: + '{$request.body#/notificationUri}/terminate': + post: + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/TerminationNotification' + responses: + '204': + description: No Content, Notification was succesfull + '307': + description: temporary redirect + '400': + $ref: 'TS29571_CommonData.yaml#/components/responses/400' + '401': + $ref: 'TS29571_CommonData.yaml#/components/responses/401' + '403': + $ref: 'TS29571_CommonData.yaml#/components/responses/403' + '404': + $ref: 'TS29571_CommonData.yaml#/components/responses/404' + '411': + $ref: 'TS29571_CommonData.yaml#/components/responses/411' + '413': + $ref: 'TS29571_CommonData.yaml#/components/responses/413' + '415': + $ref: 'TS29571_CommonData.yaml#/components/responses/415' + '429': + $ref: 'TS29571_CommonData.yaml#/components/responses/429' + '500': + $ref: 'TS29571_CommonData.yaml#/components/responses/500' + '503': + $ref: 'TS29571_CommonData.yaml#/components/responses/503' + default: + $ref: 'TS29571_CommonData.yaml#/components/responses/default' + /policies/{polAssoId}: + get: + operationId: ReadIndividualAMPolicyAssociation + summary: Read individual AM policy association. + tags: + - Individual AM Policy Association (Document) + parameters: + - name: polAssoId + in: path + description: Identifier of a policy association + required: true + schema: + type: string + responses: + '200': + description: OK. Resource representation is returned + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyAssociation' + '400': + $ref: 'TS29571_CommonData.yaml#/components/responses/400' + '401': + $ref: 'TS29571_CommonData.yaml#/components/responses/401' + '403': + $ref: 'TS29571_CommonData.yaml#/components/responses/403' + '404': + $ref: 'TS29571_CommonData.yaml#/components/responses/404' + '406': + $ref: 'TS29571_CommonData.yaml#/components/responses/406' + '429': + $ref: 'TS29571_CommonData.yaml#/components/responses/429' + '500': + $ref: 'TS29571_CommonData.yaml#/components/responses/500' + '503': + $ref: 'TS29571_CommonData.yaml#/components/responses/503' + default: + $ref: 'TS29571_CommonData.yaml#/components/responses/default' + delete: + operationId: DeleteIndividualAMPolicyAssociation + summary: Delete individual AM policy association. + tags: + - Individual AM Policy Association (Document) + parameters: + - name: polAssoId + in: path + description: Identifier of a policy association + required: true + schema: + type: string + responses: + '204': + description: No Content. Resource was succesfully deleted + '400': + $ref: 'TS29571_CommonData.yaml#/components/responses/400' + '401': + $ref: 'TS29571_CommonData.yaml#/components/responses/401' + '403': + $ref: 'TS29571_CommonData.yaml#/components/responses/403' + '404': + $ref: 'TS29571_CommonData.yaml#/components/responses/404' + '429': + $ref: 'TS29571_CommonData.yaml#/components/responses/429' + '500': + $ref: 'TS29571_CommonData.yaml#/components/responses/500' + '503': + $ref: 'TS29571_CommonData.yaml#/components/responses/503' + default: + $ref: 'TS29571_CommonData.yaml#/components/responses/default' + /policies/{polAssoId}/update: + post: + operationId: ReportObservedEventTriggersForIndividualAMPolicyAssociation + summary: Report obeserved event triggers and obtain updated policies for an individual AM policy association. + tags: + - Individual AM Policy Association (Document) + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyAssociationUpdateRequest' + parameters: + - name: polAssoId + in: path + description: Identifier of a policy association + required: true + schema: + type: string + responses: + '200': + description: OK. Updated policies are returned + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyUpdate' + '400': + $ref: 'TS29571_CommonData.yaml#/components/responses/400' + '401': + $ref: 'TS29571_CommonData.yaml#/components/responses/401' + '403': + $ref: 'TS29571_CommonData.yaml#/components/responses/403' + '404': + $ref: 'TS29571_CommonData.yaml#/components/responses/404' + '411': + $ref: 'TS29571_CommonData.yaml#/components/responses/411' + '413': + $ref: 'TS29571_CommonData.yaml#/components/responses/413' + '415': + $ref: 'TS29571_CommonData.yaml#/components/responses/415' + '429': + $ref: 'TS29571_CommonData.yaml#/components/responses/429' + '500': + $ref: 'TS29571_CommonData.yaml#/components/responses/500' + '503': + $ref: 'TS29571_CommonData.yaml#/components/responses/503' + default: + $ref: 'TS29571_CommonData.yaml#/components/responses/default' +components: + securitySchemes: + oAuth2ClientCredentials: + type: oauth2 + flows: + clientCredentials: + tokenUrl: '{nrfApiRoot}/oauth2/token' + scopes: + npcf-am-policy-control: Access to the Npcf_AMPolicyControl API + schemas: + PolicyAssociation: + type: object + properties: + request: + $ref: '#/components/schemas/PolicyAssociationRequest' + triggers: + type: array + items: + $ref: '#/components/schemas/RequestTrigger' + minItems: 1 + description: Request Triggers that the PCF subscribes. Only values "LOC_CH" and "PRA_CH" are permitted. + servAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/ServiceAreaRestriction' + wlServAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/WirelineServiceAreaRestriction' + rfsp: + $ref: 'TS29571_CommonData.yaml#/components/schemas/RfspIndex' + smfSelInfo: + $ref: '#/components/schemas/SmfSelectionData' + ueAmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + rgTmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + pras: + type: object + additionalProperties: + $ref: 'TS29571_CommonData.yaml#/components/schemas/PresenceInfo' + minProperties: 1 + suppFeat: + $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures' + required: + - suppFeat + PolicyAssociationRequest: + description: Information which the NF service consumer provides when requesting the creation of a policy association. The serviveName property corresponds to the serviceName in the main body of the specification. + type: object + properties: + notificationUri: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Uri' + altNotifIpv4Addrs: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ipv4Addr' + minItems: 1 + description: Alternate or backup IPv4 Address(es) where to send Notifications. + altNotifIpv6Addrs: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ipv6Addr' + minItems: 1 + description: Alternate or backup IPv6 Address(es) where to send Notifications. + supi: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Supi' + gpsi: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Gpsi' + accessType: + $ref: 'TS29571_CommonData.yaml#/components/schemas/AccessType' + accessTypes: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/AccessType' + minItems: 1 + pei: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Pei' + userLoc: + $ref: 'TS29571_CommonData.yaml#/components/schemas/UserLocation' + timeZone: + $ref: 'TS29571_CommonData.yaml#/components/schemas/TimeZone' + servingPlmn: + $ref: 'TS29571_CommonData.yaml#/components/schemas/PlmnIdNid' + ratType: + $ref: 'TS29571_CommonData.yaml#/components/schemas/RatType' + ratTypes: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/RatType' + minItems: 1 + groupIds: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/GroupId' + minItems: 1 + servAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/ServiceAreaRestriction' + wlServAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/WirelineServiceAreaRestriction' + rfsp: + $ref: 'TS29571_CommonData.yaml#/components/schemas/RfspIndex' + ueAmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + rgTmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + allowedSnssais: + description: array of allowed S-NSSAIs for the 3GPP access. + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai' + minItems: 1 + mappingSnssais: + description: mapping of each S-NSSAI of the Allowed NSSAI to the corresponding S-NSSAI of the HPLMN. + type: array + items: + $ref: 'TS29531_Nnssf_NSSelection.yaml#/components/schemas/MappingOfSnssai' + minItems: 1 + n3gAllowedSnssais: + description: array of allowed S-NSSAIs for the Non-3GPP access. + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai' + minItems: 1 + guami: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Guami' + serviveName: + $ref: 'TS29510_Nnrf_NFManagement.yaml#/components/schemas/ServiceName' + traceReq: + $ref: 'TS29571_CommonData.yaml#/components/schemas/TraceData' + suppFeat: + $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures' + required: + - notificationUri + - suppFeat + - supi + PolicyAssociationUpdateRequest: + type: object + properties: + notificationUri: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Uri' + altNotifIpv4Addrs: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ipv4Addr' + minItems: 1 + description: Alternate or backup IPv4 Address(es) where to send Notifications. + altNotifIpv6Addrs: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ipv6Addr' + minItems: 1 + description: Alternate or backup IPv6 Address(es) where to send Notifications. + triggers: + type: array + items: + $ref: '#/components/schemas/RequestTrigger' + minItems: 1 + description: Request Triggers that the NF service consumer observes. + servAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/ServiceAreaRestriction' + wlServAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/WirelineServiceAreaRestriction' + rfsp: + $ref: 'TS29571_CommonData.yaml#/components/schemas/RfspIndex' + smfSelInfo: + $ref: '#/components/schemas/SmfSelectionData' + ueAmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + rgTmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + praStatuses: + type: object + additionalProperties: + $ref: 'TS29571_CommonData.yaml#/components/schemas/PresenceInfo' + minProperties: 1 + description: Map of PRA status information. + userLoc: + $ref: 'TS29571_CommonData.yaml#/components/schemas/UserLocation' + allowedSnssais: + description: array of allowed S-NSSAIs for the 3GPP access. + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai' + minItems: 1 + mappingSnssais: + description: mapping of each S-NSSAI of the Allowed NSSAI to the corresponding S-NSSAI of the HPLMN. + type: array + items: + $ref: 'TS29531_Nnssf_NSSelection.yaml#/components/schemas/MappingOfSnssai' + minItems: 1 + accessTypes: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/AccessType' + minItems: 1 + ratTypes: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/RatType' + minItems: 1 + n3gAllowedSnssais: + description: array of allowed S-NSSAIs for the Non-3GPP access. + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai' + minItems: 1 + traceReq: + $ref: 'TS29571_CommonData.yaml#/components/schemas/TraceData' + guami: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Guami' + PolicyUpdate: + type: object + properties: + resourceUri: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Uri' + triggers: + type: array + items: + $ref: '#/components/schemas/RequestTrigger' + minItems: 1 + nullable: true + description: Request Triggers that the PCF subscribes. Only values "LOC_CH" and "PRA_CH" are permitted. + servAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/ServiceAreaRestriction' + wlServAreaRes: + $ref: 'TS29571_CommonData.yaml#/components/schemas/WirelineServiceAreaRestriction' + rfsp: + $ref: 'TS29571_CommonData.yaml#/components/schemas/RfspIndex' + smfSelInfo: + $ref: '#/components/schemas/SmfSelectionData' + ueAmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + rgTmbr: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Ambr' + pras: + type: object + additionalProperties: + $ref: 'TS29571_CommonData.yaml#/components/schemas/PresenceInfoRm' + description: Map of PRA information. + minProperties: 1 + nullable: true + required: + - resourceUri + TerminationNotification: + type: object + properties: + resourceUri: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Uri' + cause: + $ref: '#/components/schemas/PolicyAssociationReleaseCause' + required: + - resourceUri + - cause + SmfSelectionData: + type: object + properties: + unsuppDnn: + type: boolean + candidates: + type: object + additionalProperties: + $ref: '#/components/schemas/CandidateForReplacement' + minProperties: 1 + nullable: true + snssai: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai' + mappingSnssai: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai' + dnn: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Dnn' + nullable: true + CandidateForReplacement: + type: object + properties: + snssai: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai' + dnns: + type: array + items: + $ref: 'TS29571_CommonData.yaml#/components/schemas/Dnn' + minItems: 1 + nullable: true + required: + - snssai + nullable: true + RequestTrigger: +# anyOf: +# - type: string + enum: + - LOC_CH + - PRA_CH + - SERV_AREA_CH + - RFSP_CH + - ALLOWED_NSSAI_CH + - UE_AMBR_CH + - SMF_SELECT_CH + - ACCESS_TYPE_CH + - RG_TMBR_CH + type: string +# description: > +# This string provides forward-compatibility with future +# extensions to the enumeration but is not used to encode +# content defined in the present version of this API. +# description: > +# Possible values are +# - LOC_CH: Location change (tracking area). The tracking area of the UE has changed. +# - PRA_CH: Change of UE presence in PRA. The UE is entering/leaving a Presence Reporting Area. +# - SERV_AREA_CH: Service Area Restriction change. The UDM notifies the AMF that the subscribed service area restriction information has changed. +# - RFSP_CH: RFSP index change. The UDM notifies the AMF that the subscribed RFSP index has changed. +# - ALLOWED_NSSAI_CH: Allowed NSSAI change. The AMF notifies that the set of UE allowed S-NSSAIs has changed. +# - UE_AMBR_CH: UE-AMBR change. The UDM notifies the AMF that the subscribed UE-AMBR has changed. +# - SMF_SELECT_CH: SMF selection information change. The UE requested for an unsupported DNN or UE requested for a DNN within the list of DNN candidates for replacement per S-NSSAI. +# - ACCESS_TYPE_CH: Access Type change. The the AMF notifies that the access type and the RAT type combinations available in the AMF for a UE with simultaneous 3GPP and non-3GPP connectivity has changed. +# - RG_TMBR_CH: Subscribed RG-TMBR change. The UDM notifies the AMF that the subscribed RG-TMBR has changed. + PolicyAssociationReleaseCause: +# anyOf: +# - type: string + enum: + - UNSPECIFIED + - UE_SUBSCRIPTION + - INSUFFICIENT_RES + type: string +# description: > +# This string provides forward-compatibility with future +# extensions to the enumeration but is not used to encode +# content defined in the present version of this API. +# description: > +# Possible values are +# - UNSPECIFIED: This value is used for unspecified reasons. +# - UE_SUBSCRIPTION: This value is used to indicate that the session needs to be terminated because the subscription of UE has changed (e.g. was removed). +# - INSUFFICIENT_RES: This value is used to indicate that the server is overloaded and needs to abort the session. diff --git a/lib/sbi/support/modified/TS29512_Npcf_SMPolicyControl.yaml b/lib/sbi/support/modified/TS29512_Npcf_SMPolicyControl.yaml index eda11fab7..cd0127e50 100644 --- a/lib/sbi/support/modified/TS29512_Npcf_SMPolicyControl.yaml +++ b/lib/sbi/support/modified/TS29512_Npcf_SMPolicyControl.yaml @@ -598,7 +598,6 @@ components: nullable: true refUmN3gData: type: array -# items: items: type: string minItems: 1 diff --git a/lib/sbi/support/modified/TS29571_CommonData.yaml b/lib/sbi/support/modified/TS29571_CommonData.yaml index d8e7671de..f06dd2cac 100644 --- a/lib/sbi/support/modified/TS29571_CommonData.yaml +++ b/lib/sbi/support/modified/TS29571_CommonData.yaml @@ -807,87 +807,87 @@ components: - $ref: '#/components/schemas/DnaiChangeType' - $ref: '#/components/schemas/NullValue' RestrictionType: - anyOf: - - type: string +# anyOf: +# - type: string enum: - ALLOWED_AREAS - NOT_ALLOWED_AREAS - - type: string + type: string RestrictionTypeRm: anyOf: - $ref: '#/components/schemas/RestrictionType' - $ref: '#/components/schemas/NullValue' CoreNetworkType: - anyOf: - - type: string +# anyOf: +# - type: string enum: - 5GC - EPC - - type: string + type: string CoreNetworkTypeRm: anyOf: - $ref: '#/components/schemas/CoreNetworkType' - $ref: '#/components/schemas/NullValue' PresenceState: - anyOf: - - type: string +# anyOf: +# - type: string enum: - IN_AREA - OUT_OF_AREA - UNKNOWN - INACTIVE - - type: string + type: string StationaryIndication: - anyOf: - - type: string +# anyOf: +# - type: string enum: - STATIONARY - MOBILE - - type: string - description: > - This string provides forward-compatibility with future - extensions to the enumeration but is not used to encode - content defined in the present version of this API. - description: > - Possible values are - - STATIONARY: Identifies the UE is stationary - - MOBILE: Identifies the UE is mobile + type: string +# description: > +# This string provides forward-compatibility with future +# extensions to the enumeration but is not used to encode +# content defined in the present version of this API. +# description: > +# Possible values are +# - STATIONARY: Identifies the UE is stationary +# - MOBILE: Identifies the UE is mobile StationaryIndicationRm: anyOf: - $ref: '#/components/schemas/StationaryIndication' - $ref: '#/components/schemas/NullValue' ScheduledCommunicationType: - anyOf: - - type: string +# anyOf: +# - type: string enum: - DOWNLINK_ONLY - UPLINK_ONLY - BIDIRECTIONAL - - type: string + type: string ScheduledCommunicationTypeRm: anyOf: - $ref: '#/components/schemas/ScheduledCommunicationType' - $ref: '#/components/schemas/NullValue' TrafficProfile: - anyOf: - - type: string +# anyOf: +# - type: string enum: - SINGLE_TRANS_UL - SINGLE_TRANS_DL - DUAL_TRANS_UL_FIRST - DUAL_TRANS_DL_FIRST - MULTI_TRANS - - type: string - description: > - This string provides forward-compatibility with future - extensions to the enumeration but is not used to encode - content defined in the present version of this API. - description: > - Possible values are - - SINGLE_TRANS_UL: Uplink single packet transmission. - - SINGLE_TRANS_DL: Downlink single packet transmission. - - DUAL_TRANS_UL_FIRST: Dual packet transmission, firstly uplink packet transmission with subsequent downlink packet transmission. - - DUAL_TRANS_DL_FIRST: Dual packet transmission, firstly downlink packet transmission with subsequent uplink packet transmission. + type: string +# description: > +# This string provides forward-compatibility with future +# extensions to the enumeration but is not used to encode +# content defined in the present version of this API. +# description: > +# Possible values are +# - SINGLE_TRANS_UL: Uplink single packet transmission. +# - SINGLE_TRANS_DL: Downlink single packet transmission. +# - DUAL_TRANS_UL_FIRST: Dual packet transmission, firstly uplink packet transmission with subsequent downlink packet transmission. +# - DUAL_TRANS_DL_FIRST: Dual packet transmission, firstly downlink packet transmission with subsequent uplink packet transmission. TrafficProfileRm: anyOf: - $ref: '#/components/schemas/TrafficProfile' diff --git a/src/amf/amf-sm.c b/src/amf/amf-sm.c index 11c8542cd..0ed0c80f6 100644 --- a/src/amf/amf-sm.c +++ b/src/amf/amf-sm.c @@ -140,39 +140,9 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) break; DEFAULT - ogs_error("Invalid HTTP method [%s]", - sbi_message.h.method); + ogs_error("Invalid HTTP method [%s]", sbi_message.h.method); ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_FORBIDDEN, - &sbi_message, - "Invalid HTTP method", sbi_message.h.method); - END - break; - - DEFAULT - ogs_error("Invalid resource name [%s]", - sbi_message.h.resource.component[0]); - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, &sbi_message, - "Invalid resource name", - sbi_message.h.resource.component[0]); - END - break; - - CASE(OGS_SBI_SERVICE_NAME_NUDM_UECM) - SWITCH(sbi_message.h.resource.component[1]) - CASE(OGS_SBI_RESOURCE_NAME_DEREG_NOTIFY) - SWITCH(sbi_message.h.method) - CASE(OGS_SBI_HTTP_METHOD_POST) - ogs_error("Dereg-notify Not implemented"); - break; - - DEFAULT - ogs_error("Invalid HTTP method [%s]", - sbi_message.h.method); - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_FORBIDDEN, - &sbi_message, + OGS_SBI_HTTP_STATUS_FORBIDDEN, &sbi_message, "Invalid HTTP method", sbi_message.h.method); END break; @@ -239,6 +209,14 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) stream, &sbi_message); break; + /* TODO */ +#if 0 + CASE(OGS_SBI_RESOURCE_NAME_DEREG_NOTIFY) + break; + CASE(OGS_SBI_RESOURCE_NAME_AM_POLICY_NOTIFY) + break; +#endif + DEFAULT ogs_error("Invalid resource name [%s]", sbi_message.h.resource.component[1]); @@ -372,6 +350,7 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) CASE(OGS_SBI_SERVICE_NAME_NAUSF_AUTH) CASE(OGS_SBI_SERVICE_NAME_NUDM_UECM) CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM) + CASE(OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL) sbi_xact = e->sbi.data; ogs_assert(sbi_xact); @@ -507,9 +486,11 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) sbi_object = sbi_xact->sbi_object; ogs_assert(sbi_object); - switch(sbi_xact->target_nf_type) { - case OpenAPI_nf_type_AUSF: - case OpenAPI_nf_type_UDM: + ogs_assert(sbi_object->type > OGS_SBI_OBJ_BASE && + sbi_object->type < OGS_SBI_OBJ_TOP); + + switch(sbi_object->type) { + case OGS_SBI_OBJ_UE_TYPE: amf_ue = (amf_ue_t *)sbi_object; ogs_assert(amf_ue); ogs_error("[%s] Cannot receive SBI message", amf_ue->suci); @@ -517,7 +498,7 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); break; - case OpenAPI_nf_type_SMF: + case OGS_SBI_OBJ_SESS_TYPE: sess = (amf_sess_t *)sbi_object; ogs_assert(sess); ogs_error("[%d:%d] Cannot receive SBI message", @@ -533,8 +514,10 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) break; default: - ogs_fatal("Not implemented [%s]", - OpenAPI_nf_type_ToString(sbi_xact->target_nf_type)); + ogs_fatal("Not implemented [%s:%d]", + OpenAPI_nf_type_ToString(sbi_xact->target_nf_type), + sbi_object->type); + ogs_assert_if_reached(); } ogs_sbi_xact_remove(sbi_xact); diff --git a/src/amf/context.c b/src/amf/context.c index ee2b78e08..ca1f1c3cd 100644 --- a/src/amf/context.c +++ b/src/amf/context.c @@ -833,6 +833,9 @@ amf_gnb_t *amf_gnb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr) ogs_assert(gnb); memset(gnb, 0, sizeof *gnb); + /* Defaut RAT-Type */ + gnb->rat_type = OpenAPI_rat_type_NR; + gnb->sctp.sock = sock; gnb->sctp.addr = addr; gnb->sctp.type = amf_gnb_sock_type(gnb->sctp.sock); @@ -1079,6 +1082,8 @@ amf_ue_t *amf_ue_add(ran_ue_t *ran_ue) ogs_assert(amf_ue); memset(amf_ue, 0, sizeof *amf_ue); + amf_ue->sbi.type = OGS_SBI_OBJ_UE_TYPE; + ogs_list_init(&amf_ue->sess_list); /* TODO : Hard-coded */ @@ -1152,6 +1157,9 @@ void amf_ue_remove(amf_ue_t *amf_ue) ogs_free(amf_ue->msisdn[i]); } + if (amf_ue->policy_association_id) + ogs_free(amf_ue->policy_association_id); + if (amf_ue->confirmation_url_for_5g_aka) ogs_free(amf_ue->confirmation_url_for_5g_aka); @@ -1371,6 +1379,19 @@ void amf_ue_set_supi(amf_ue_t *amf_ue, char *supi) ogs_hash_set(self.supi_hash, amf_ue->supi, strlen(amf_ue->supi), amf_ue); } +OpenAPI_rat_type_e amf_ue_rat_type(amf_ue_t *amf_ue) +{ + amf_gnb_t *gnb = NULL; + ran_ue_t *ran_ue = NULL; + + ran_ue = amf_ue->ran_ue; + ogs_assert(ran_ue); + gnb = ran_ue->gnb; + ogs_assert(gnb); + + return gnb->rat_type; +} + void amf_ue_associate_ran_ue(amf_ue_t *amf_ue, ran_ue_t *ran_ue) { ogs_assert(amf_ue); @@ -1443,6 +1464,8 @@ amf_sess_t *amf_sess_add(amf_ue_t *amf_ue, uint8_t psi) ogs_assert(sess); memset(sess, 0, sizeof *sess); + sess->sbi.type = OGS_SBI_OBJ_SESS_TYPE; + sess->amf_ue = amf_ue; sess->psi = psi; @@ -1462,7 +1485,7 @@ void amf_sess_remove(amf_sess_t *sess) { ogs_assert(sess); ogs_assert(sess->amf_ue); - + ogs_list_remove(&sess->amf_ue->sess_list, sess); /* Free SBI object memory */ diff --git a/src/amf/context.h b/src/amf/context.h index 169a8a68a..9982075a1 100644 --- a/src/amf/context.h +++ b/src/amf/context.h @@ -140,6 +140,8 @@ typedef struct amf_gnb_s { } bplmn_list[OGS_MAX_NUM_OF_BPLMN]; } supported_ta_list[OGS_MAX_NUM_OF_TAI]; + OpenAPI_rat_type_e rat_type; + ogs_list_t ran_ue_list; } amf_gnb_t; @@ -265,6 +267,10 @@ struct amf_ue_s { int num_of_requested_nssai; ogs_s_nssai_t requested_nssai[OGS_MAX_NUM_OF_S_NSSAI]; + /* PCF sends the RESPONSE + * of [POST] /npcf-am-polocy-control/v1/policies */ + char *policy_association_id; + /* 5GMM Capability */ struct { bool lte_positioning_protocol_capability; @@ -497,8 +503,7 @@ void amf_ue_set_suci(amf_ue_t *amf_ue, ogs_nas_5gs_mobile_identity_t *mobile_identity); void amf_ue_set_supi(amf_ue_t *amf_ue, char *supi); -int amf_ue_have_indirect_tunnel(amf_ue_t *amf_ue); -int amf_ue_clear_indirect_tunnel(amf_ue_t *amf_ue); +OpenAPI_rat_type_e amf_ue_rat_type(amf_ue_t *amf_ue); /* * o RECV Initial UE-Message : S-TMSI diff --git a/src/amf/gmm-sm.c b/src/amf/gmm-sm.c index e0f532db0..cc4a4b266 100644 --- a/src/amf/gmm-sm.c +++ b/src/amf/gmm-sm.c @@ -26,6 +26,7 @@ #include "nausf-handler.h" #include "nsmf-handler.h" #include "nudm-handler.h" +#include "npcf-handler.h" #include "sbi-path.h" #include "amf-sm.h" @@ -700,6 +701,7 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) #endif } else { ogs_fatal("Invalid OGS_NAS_5GS[%d]", amf_ue->nas.message_type); + ogs_assert_if_reached(); } break; case OGS_NAS_5GS_SECURITY_MODE_REJECT: @@ -862,6 +864,7 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) SWITCH(sbi_message->h.resource.component[1]) CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA) + CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) if (sbi_message->res_status != OGS_SBI_HTTP_STATUS_OK) { ogs_error("[%s] HTTP response error [%d]", amf_ue->supi, sbi_message->res_status); @@ -873,7 +876,26 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) amf_nudm_sdm_handle_provisioned(amf_ue, sbi_message); break; - CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) + + DEFAULT + ogs_error("Invalid resource name [%s]", + sbi_message->h.resource.component[1]); + ogs_assert_if_reached(); + END + break; + + CASE(OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL) + SWITCH(sbi_message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_POLICIES) + rv = amf_npcf_am_policy_control_handle_create( + amf_ue, sbi_message); + if (rv != OGS_OK) { + ogs_error("amf_npcf_am_policy_control_handle_create() " + "failed"); + OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); + break; + } + /* * Issues #553 * @@ -908,7 +930,7 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) DEFAULT ogs_error("Invalid resource name [%s]", - sbi_message->h.resource.component[1]); + sbi_message->h.resource.component[0]); ogs_assert_if_reached(); END break; @@ -916,7 +938,6 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) DEFAULT ogs_error("Invalid service name [%s]", sbi_message->h.service.name); ogs_assert_if_reached(); - END break; diff --git a/src/amf/meson.build b/src/amf/meson.build index 85214eb18..bcb98212c 100644 --- a/src/amf/meson.build +++ b/src/amf/meson.build @@ -29,6 +29,9 @@ libamf_sources = files(''' nsmf-build.c nsmf-handler.c + npcf-build.c + npcf-handler.c + nnrf-handler.c namf-handler.c sbi-path.c diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c index 6b3c7a91f..32fe7d1c9 100644 --- a/src/amf/nnrf-handler.c +++ b/src/amf/nnrf-handler.c @@ -299,9 +299,10 @@ void amf_nnrf_handle_nf_discover( nf_instance = OGS_SBI_NF_INSTANCE_GET( sbi_object->nf_type_array, xact->target_nf_type); if (!nf_instance) { - switch(xact->target_nf_type) { - case OpenAPI_nf_type_AUSF: - case OpenAPI_nf_type_UDM: + ogs_assert(sbi_object->type > OGS_SBI_OBJ_BASE && + sbi_object->type < OGS_SBI_OBJ_TOP); + switch(sbi_object->type) { + case OGS_SBI_OBJ_UE_TYPE: amf_ue = (amf_ue_t *)sbi_object; ogs_assert(amf_ue); ogs_error("[%s] (NF discover) No [%s]", amf_ue->suci, @@ -309,7 +310,7 @@ void amf_nnrf_handle_nf_discover( nas_5gs_send_gmm_reject_from_sbi(amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); break; - case OpenAPI_nf_type_SMF: + case OGS_SBI_OBJ_SESS_TYPE: sess = (amf_sess_t *)sbi_object; ogs_assert(sess); ogs_error("[%d:%d] (NF discover) No [%s]", sess->psi, sess->pti, @@ -324,8 +325,10 @@ void amf_nnrf_handle_nf_discover( } break; default: - ogs_fatal("(NF discover) Not implemented [%s]", - OpenAPI_nf_type_ToString(xact->target_nf_type)); + ogs_fatal("(NF discover) Not implemented [%s:%d]", + OpenAPI_nf_type_ToString(xact->target_nf_type), + sbi_object->type); + ogs_assert_if_reached(); } } else { amf_sbi_send(nf_instance, xact); diff --git a/src/amf/npcf-build.c b/src/amf/npcf-build.c new file mode 100644 index 000000000..48c20115b --- /dev/null +++ b/src/amf/npcf-build.c @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "npcf-build.h" + +ogs_sbi_request_t *amf_npcf_am_policy_control_build_create( + amf_ue_t *amf_ue, void *data) +{ + ogs_sbi_message_t message; + ogs_sbi_header_t header; + ogs_sbi_request_t *request = NULL; + ogs_sbi_server_t *server = NULL; + + OpenAPI_policy_association_request_t PolicyAssociationRequest; + + int i, j; + OpenAPI_lnode_t *node = NULL; + + OpenAPI_list_t *AllowedSnssais = NULL; + OpenAPI_user_location_t ueLocation; + OpenAPI_ambr_t ueAmbr; + + ogs_assert(amf_ue); + ogs_assert(amf_ue->supi); + + memset(&message, 0, sizeof(message)); + message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; + message.h.service.name = + (char *)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL; + message.h.api.version = (char *)OGS_SBI_API_V1; + message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_POLICIES; + + memset(&PolicyAssociationRequest, 0, sizeof(PolicyAssociationRequest)); + + server = ogs_list_first(&ogs_sbi_self()->server_list); + ogs_assert(server); + + memset(&header, 0, sizeof(header)); + header.service.name = (char *)OGS_SBI_SERVICE_NAME_NAMF_CALLBACK; + header.api.version = (char *)OGS_SBI_API_V1; + header.resource.component[0] = amf_ue->supi; + header.resource.component[1] = + (char *)OGS_SBI_RESOURCE_NAME_AM_POLICY_NOTIFY; + PolicyAssociationRequest.notification_uri = + ogs_sbi_server_uri(server, &header); + ogs_assert(PolicyAssociationRequest.notification_uri); + + PolicyAssociationRequest.supi = amf_ue->supi; + + if (amf_ue->num_of_msisdn) { + if (amf_ue->msisdn[0]) { + PolicyAssociationRequest.gpsi = ogs_msprintf("%s-%s", + OGS_ID_GPSI_TYPE_MSISDN, amf_ue->msisdn[0]); + } + } + + PolicyAssociationRequest.access_type = amf_ue->nas.access_type; + PolicyAssociationRequest.pei = amf_ue->pei; + + memset(&ueLocation, 0, sizeof(ueLocation)); + ueLocation.nr_location = ogs_sbi_build_nr_location( + &amf_ue->tai, &amf_ue->nr_cgi); + ogs_assert(ueLocation.nr_location); + ueLocation.nr_location->ue_location_timestamp = + ogs_sbi_gmtime_string(amf_ue->ue_location_timestamp); + PolicyAssociationRequest.user_loc = &ueLocation; + + PolicyAssociationRequest.time_zone = + ogs_sbi_timezone_string(ogs_timezone()); + + PolicyAssociationRequest.serving_plmn = + ogs_sbi_build_plmn_id_nid(&amf_ue->tai.plmn_id); + + PolicyAssociationRequest.rat_type = amf_ue_rat_type(amf_ue); + + memset(&ueAmbr, 0, sizeof(ueAmbr)); + if (amf_ue->subscribed_ue_ambr.uplink) { + ueAmbr.uplink = ogs_sbi_bitrate_to_string( + amf_ue->subscribed_ue_ambr.uplink, OGS_SBI_BITRATE_KBPS); + } + if (amf_ue->subscribed_ue_ambr.downlink) { + ueAmbr.downlink = ogs_sbi_bitrate_to_string( + amf_ue->subscribed_ue_ambr.downlink, OGS_SBI_BITRATE_KBPS); + } + if (ueAmbr.downlink || ueAmbr.uplink) { + PolicyAssociationRequest.ue_ambr = &ueAmbr; + } + + AllowedSnssais = OpenAPI_list_create(); + ogs_assert(AllowedSnssais); + + for (i = 0; i < amf_self()->num_of_plmn_support; i++) { + if (memcmp(&amf_ue->tai.plmn_id, + &amf_self()->plmn_support[i].plmn_id, OGS_PLMN_ID_LEN) != 0) + continue; + for (j = 0; j < amf_self()->plmn_support[i].num_of_s_nssai; j++) { + struct OpenAPI_snssai_s *Snssai = ogs_calloc(1, sizeof(*Snssai)); + ogs_assert(Snssai); + + Snssai->sst = amf_self()->plmn_support[i].s_nssai[j].sst; + Snssai->sd = ogs_s_nssai_sd_to_string( + amf_self()->plmn_support[i].s_nssai[j].sd); + + OpenAPI_list_add(AllowedSnssais, Snssai); + } + } + + if (AllowedSnssais->count) + PolicyAssociationRequest.allowed_snssais = AllowedSnssais; + else + OpenAPI_list_free(AllowedSnssais); + + PolicyAssociationRequest.guami = ogs_sbi_build_guami(amf_ue->guami); + + PolicyAssociationRequest.supp_feat = (char *)""; + + message.PolicyAssociationRequest = &PolicyAssociationRequest; + + request = ogs_sbi_build_request(&message); + ogs_assert(request); + + ogs_free(PolicyAssociationRequest.notification_uri); + if (PolicyAssociationRequest.gpsi) + ogs_free(PolicyAssociationRequest.gpsi); + + if (ueLocation.nr_location) { + if (ueLocation.nr_location->ue_location_timestamp) + ogs_free(ueLocation.nr_location->ue_location_timestamp); + ogs_sbi_free_nr_location(ueLocation.nr_location); + } + if (PolicyAssociationRequest.time_zone) + ogs_free(PolicyAssociationRequest.time_zone); + + if (PolicyAssociationRequest.serving_plmn) + ogs_sbi_free_plmn_id_nid(PolicyAssociationRequest.serving_plmn); + + if (ueAmbr.downlink) ogs_free(ueAmbr.downlink); + if (ueAmbr.uplink) ogs_free(ueAmbr.uplink); + + OpenAPI_list_for_each(PolicyAssociationRequest.allowed_snssais, node) { + struct OpenAPI_snssai_s *Snssai = node->data; + if (Snssai) { + if (Snssai->sd) + ogs_free(Snssai->sd); + ogs_free(Snssai); + } + } + OpenAPI_list_free(PolicyAssociationRequest.allowed_snssais); + + if (PolicyAssociationRequest.guami) + ogs_sbi_free_guami(PolicyAssociationRequest.guami); + + return request; +} diff --git a/src/amf/npcf-build.h b/src/amf/npcf-build.h new file mode 100644 index 000000000..fdc278743 --- /dev/null +++ b/src/amf/npcf-build.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AMF_NPCF_BUILD_H +#define AMF_NPCF_BUILD_H + +#include "context.h" + +#ifdef __cplusplus +extern "C" { +#endif + +ogs_sbi_request_t *amf_npcf_am_policy_control_build_create( + amf_ue_t *amf_ue, void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* AMF_NPCF_BUILD_H */ diff --git a/src/amf/npcf-handler.c b/src/amf/npcf-handler.c new file mode 100644 index 000000000..a1f8b826d --- /dev/null +++ b/src/amf/npcf-handler.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "npcf-handler.h" + +#include "sbi-path.h" +#include "nas-path.h" + +int amf_npcf_am_policy_control_handle_create( + amf_ue_t *amf_ue, ogs_sbi_message_t *recvmsg) +{ + int rv; + + OpenAPI_policy_association_t *PolicyAssociation = NULL; + + ogs_sbi_message_t message; + ogs_sbi_header_t header; + + if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_CREATED) { + ogs_error("[%s] HTTP response error [%d]", + amf_ue->supi, recvmsg->res_status); + nas_5gs_send_gmm_reject_from_sbi(amf_ue, recvmsg->res_status); + return OGS_ERROR; + } + + if (!recvmsg->http.location) { + ogs_error("[%s] No http.location", amf_ue->supi); + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + return OGS_ERROR; + } + + PolicyAssociation = recvmsg->PolicyAssociation; + if (!PolicyAssociation) { + ogs_error("No PolicyAssociation"); + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + return OGS_ERROR; + } + + if (!PolicyAssociation->supp_feat) { + ogs_error("No suppFeat"); + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + return OGS_ERROR; + } + + memset(&header, 0, sizeof(header)); + header.uri = recvmsg->http.location; + + rv = ogs_sbi_parse_header(&message, &header); + if (rv != OGS_OK) { + ogs_error("[%s] Cannot parse http.location [%s]", + amf_ue->supi, recvmsg->http.location); + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + return OGS_ERROR; + } + + if (!message.h.resource.component[1]) { + ogs_error("[%s] No Assocation ID [%s]", + amf_ue->supi, recvmsg->http.location); + + ogs_sbi_header_free(&header); + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + return OGS_ERROR; + } + + if (amf_ue->policy_association_id) + ogs_free(amf_ue->policy_association_id); + amf_ue->policy_association_id = ogs_strdup(message.h.resource.component[1]); + + ogs_sbi_header_free(&header); + + return OGS_OK; +} diff --git a/src/amf/npcf-handler.h b/src/amf/npcf-handler.h new file mode 100644 index 000000000..999b74bf4 --- /dev/null +++ b/src/amf/npcf-handler.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AMF_NPCF_HANDLER_H +#define AMF_NPCF_HANDLER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "context.h" + +int amf_npcf_am_policy_control_handle_create( + amf_ue_t *amf_ue, ogs_sbi_message_t *message); + +#ifdef __cplusplus +} +#endif + +#endif /* AMF_NPCF_HANDLER_H */ diff --git a/src/amf/nudm-build.c b/src/amf/nudm-build.c index 2025ebaee..37c897286 100644 --- a/src/amf/nudm-build.c +++ b/src/amf/nudm-build.c @@ -50,17 +50,17 @@ ogs_sbi_request_t *amf_nudm_uecm_build_registration( ogs_assert(server); memset(&header, 0, sizeof(header)); - header.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDM_UECM; + header.service.name = (char *)OGS_SBI_SERVICE_NAME_NAMF_CALLBACK; header.api.version = (char *)OGS_SBI_API_V1; header.resource.component[0] = amf_ue->supi; - header.resource.component[1] = - (char *)OGS_SBI_RESOURCE_NAME_DEREG_NOTIFY; + header.resource.component[1] = (char *)OGS_SBI_RESOURCE_NAME_DEREG_NOTIFY; Amf3GppAccessRegistration.dereg_callback_uri = ogs_sbi_server_uri(server, &header); ogs_assert(Amf3GppAccessRegistration.dereg_callback_uri); Amf3GppAccessRegistration.guami = ogs_sbi_build_guami(amf_ue->guami); - Amf3GppAccessRegistration.rat_type = OpenAPI_rat_type_NR; + Amf3GppAccessRegistration.rat_type = amf_ue_rat_type(amf_ue); + ogs_assert(Amf3GppAccessRegistration.rat_type != OpenAPI_rat_type_NULL); message.Amf3GppAccessRegistration = &Amf3GppAccessRegistration; diff --git a/src/amf/nudm-handler.c b/src/amf/nudm-handler.c index 0591bc68e..28292436c 100644 --- a/src/amf/nudm-handler.c +++ b/src/amf/nudm-handler.c @@ -85,6 +85,11 @@ int amf_nudm_sdm_handle_provisioned( amf_nudm_sdm_build_get); break; + CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) + amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, amf_ue, + NULL, amf_npcf_am_policy_control_build_create); + break; + DEFAULT END diff --git a/src/amf/sbi-path.h b/src/amf/sbi-path.h index fc88401da..ded8dda50 100644 --- a/src/amf/sbi-path.h +++ b/src/amf/sbi-path.h @@ -23,6 +23,7 @@ #include "nausf-build.h" #include "nudm-build.h" #include "nsmf-build.h" +#include "npcf-build.h" #ifdef __cplusplus extern "C" { diff --git a/src/ausf/context.c b/src/ausf/context.c index f22e5384d..2f94bf544 100644 --- a/src/ausf/context.c +++ b/src/ausf/context.c @@ -36,7 +36,6 @@ 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_app()->max.ue); ogs_list_init(&self.ausf_ue_list); diff --git a/src/meson.build b/src/meson.build index be30eab26..a69b462ce 100644 --- a/src/meson.build +++ b/src/meson.build @@ -38,6 +38,7 @@ subdir('pcrf') subdir('nrf') subdir('udr') subdir('udm') +subdir('pcf') subdir('ausf') subdir('upf') subdir('smf') diff --git a/src/pcf/am-sm.c b/src/pcf/am-sm.c new file mode 100644 index 000000000..3a5a9b7fe --- /dev/null +++ b/src/pcf/am-sm.c @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sbi-path.h" +#include "nnrf-handler.h" + +#include "npcf-handler.h" +#include "nudr-handler.h" + +void pcf_am_state_initial(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_assert(s); + + OGS_FSM_TRAN(s, &pcf_am_state_operational); +} + +void pcf_am_state_final(ogs_fsm_t *s, pcf_event_t *e) +{ +} + +void pcf_am_state_operational(ogs_fsm_t *s, pcf_event_t *e) +{ + bool handled; + pcf_ue_t *pcf_ue = NULL; + + ogs_sbi_stream_t *stream = NULL; + ogs_sbi_message_t *message = NULL; + + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + pcf_ue = e->pcf_ue; + ogs_assert(pcf_ue); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + break; + + case OGS_FSM_EXIT_SIG: + break; + + case PCF_EVT_SBI_SERVER: + message = e->sbi.message; + ogs_assert(message); + stream = e->sbi.data; + ogs_assert(stream); + + SWITCH(message->h.method) + CASE(OGS_SBI_HTTP_METHOD_POST) + handled = pcf_npcf_am_policy_contrtol_handle_create( + pcf_ue, stream, message); + if (!handled) { + ogs_error("[%s] Cannot handle SBI message", pcf_ue->supi); + OGS_FSM_TRAN(s, pcf_am_state_exception); + } + break; + + DEFAULT + ogs_error("[%s] Invalid HTTP method [%s]", + pcf_ue->supi, message->h.method); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_FORBIDDEN, message, + "Invalid HTTP method", message->h.method); + END + break; + + case PCF_EVT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + stream = e->sbi.data; + ogs_assert(stream); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NUDR_DR) + SWITCH(message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA) + SWITCH(message->h.resource.component[1]) + CASE(OGS_SBI_RESOURCE_NAME_UES) + if (message->res_status != OGS_SBI_HTTP_STATUS_OK && + message->res_status != OGS_SBI_HTTP_STATUS_NO_CONTENT) { + if (message->res_status == + OGS_SBI_HTTP_STATUS_NOT_FOUND) { + ogs_warn("[%s] Cannot find SUPI [%d]", + pcf_ue->supi, message->res_status); + } else { + ogs_error("[%s] HTTP response error [%d]", + pcf_ue->supi, message->res_status); + } + ogs_sbi_server_send_error(stream, message->res_status, + NULL, "HTTP response error", pcf_ue->supi); + break; + } + + pcf_nudr_dr_handle_query_am_data(pcf_ue, stream, message); + break; + + DEFAULT + ogs_error("[%s] Invalid resource name [%s]", + pcf_ue->supi, message->h.resource.component[1]); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("[%s] Invalid resource name [%s]", + pcf_ue->supi, message->h.resource.component[0]); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("[%s] Invalid API name [%s]", + pcf_ue->supi, message->h.service.name); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, message, + "Invalid API name", message->h.resource.component[0]); + END + break; + + default: + ogs_error("[%s] Unknown event %s", pcf_ue->supi, pcf_event_get_name(e)); + break; + } +} + +void pcf_am_state_exception(ogs_fsm_t *s, pcf_event_t *e) +{ + pcf_ue_t *pcf_ue = NULL; + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + pcf_ue = e->pcf_ue; + ogs_assert(pcf_ue); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + break; + + case OGS_FSM_EXIT_SIG: + break; + + default: + ogs_error("[%s] Unknown event %s", pcf_ue->supi, pcf_event_get_name(e)); + break; + } +} diff --git a/src/pcf/app.c b/src/pcf/app.c new file mode 100644 index 000000000..fb76fb59f --- /dev/null +++ b/src/pcf/app.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "ogs-app.h" + +int app_initialize(const char *const argv[]) +{ + int rv; + + rv = pcf_initialize(); + if (rv != OGS_OK) { + ogs_error("Failed to intialize PCF"); + return rv; + } + ogs_info("PCF initialize...done"); + + return OGS_OK; +} + +void app_terminate(void) +{ + pcf_terminate(); + ogs_info("PCF terminate...done"); +} diff --git a/src/pcf/context.c b/src/pcf/context.c new file mode 100644 index 000000000..2d6f4e5c9 --- /dev/null +++ b/src/pcf/context.c @@ -0,0 +1,304 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sbi-path.h" + +static pcf_context_t self; + +int __pcf_log_domain; + +static OGS_POOL(pcf_ue_pool, pcf_ue_t); +static OGS_POOL(pcf_sess_pool, pcf_sess_t); + +static int context_initialized = 0; + +void pcf_context_init(void) +{ + ogs_assert(context_initialized == 0); + + /* Initialize PCF context */ + memset(&self, 0, sizeof(pcf_context_t)); + + ogs_log_install_domain(&__pcf_log_domain, "pcf", ogs_core()->log.level); + + ogs_pool_init(&pcf_ue_pool, ogs_app()->max.ue); + ogs_pool_init(&pcf_sess_pool, ogs_app()->pool.sess); + + ogs_list_init(&self.pcf_ue_list); + self.supi_hash = ogs_hash_make(); + + context_initialized = 1; +} + +void pcf_context_final(void) +{ + ogs_assert(context_initialized == 1); + + pcf_ue_remove_all(); + + ogs_assert(self.supi_hash); + ogs_hash_destroy(self.supi_hash); + + ogs_pool_final(&pcf_sess_pool); + ogs_pool_final(&pcf_ue_pool); + + context_initialized = 0; +} + +pcf_context_t *pcf_self(void) +{ + return &self; +} + +static int pcf_context_prepare(void) +{ + self.nf_type = OpenAPI_nf_type_PCF; + + return OGS_OK; +} + +static int pcf_context_validation(void) +{ + return OGS_OK; +} + +int pcf_context_parse_config(void) +{ + int rv; + yaml_document_t *document = NULL; + ogs_yaml_iter_t root_iter; + + document = ogs_app()->document; + ogs_assert(document); + + rv = pcf_context_prepare(); + if (rv != OGS_OK) return rv; + + ogs_yaml_iter_init(&root_iter, document); + while (ogs_yaml_iter_next(&root_iter)) { + const char *root_key = ogs_yaml_iter_key(&root_iter); + ogs_assert(root_key); + if (!strcmp(root_key, "pcf")) { + ogs_yaml_iter_t pcf_iter; + ogs_yaml_iter_recurse(&root_iter, &pcf_iter); + while (ogs_yaml_iter_next(&pcf_iter)) { + const char *pcf_key = ogs_yaml_iter_key(&pcf_iter); + ogs_assert(pcf_key); + if (!strcmp(pcf_key, "sbi")) { + /* handle config in sbi library */ + } else + ogs_warn("unknown key `%s`", pcf_key); + } + } + } + + rv = pcf_context_validation(); + if (rv != OGS_OK) return rv; + + return OGS_OK; +} + +pcf_ue_t *pcf_ue_add(char *supi) +{ + pcf_event_t e; + pcf_ue_t *pcf_ue = NULL; + + ogs_assert(supi); + + ogs_pool_alloc(&pcf_ue_pool, &pcf_ue); + ogs_assert(pcf_ue); + memset(pcf_ue, 0, sizeof *pcf_ue); + + pcf_ue->sbi.type = OGS_SBI_OBJ_UE_TYPE; + + pcf_ue->association_id = ogs_msprintf("%d", + (int)ogs_pool_index(&pcf_ue_pool, pcf_ue)); + ogs_assert(pcf_ue->association_id); + + pcf_ue->supi = ogs_strdup(supi); + ogs_assert(pcf_ue->supi); + ogs_hash_set(self.supi_hash, pcf_ue->supi, strlen(pcf_ue->supi), pcf_ue); + + memset(&e, 0, sizeof(e)); + e.pcf_ue = pcf_ue; + ogs_fsm_create(&pcf_ue->sm, pcf_am_state_initial, pcf_am_state_final); + ogs_fsm_init(&pcf_ue->sm, &e); + + ogs_list_add(&self.pcf_ue_list, pcf_ue); + + return pcf_ue; +} + +void pcf_ue_remove(pcf_ue_t *pcf_ue) +{ + pcf_event_t e; + + ogs_assert(pcf_ue); + + ogs_list_remove(&self.pcf_ue_list, pcf_ue); + + memset(&e, 0, sizeof(e)); + e.pcf_ue = pcf_ue; + ogs_fsm_fini(&pcf_ue->sm, &e); + ogs_fsm_delete(&pcf_ue->sm); + + /* Free SBI object memory */ + ogs_sbi_object_free(&pcf_ue->sbi); + + pcf_sess_remove_all(pcf_ue); + + OpenAPI_policy_association_request_free(pcf_ue->policy_association_request); + + ogs_assert(pcf_ue->association_id); + ogs_free(pcf_ue->association_id); + + ogs_assert(pcf_ue->supi); + ogs_hash_set(self.supi_hash, pcf_ue->supi, strlen(pcf_ue->supi), NULL); + ogs_free(pcf_ue->supi); + + if (pcf_ue->notification_uri) + ogs_free(pcf_ue->notification_uri); + + ogs_pool_free(&pcf_ue_pool, pcf_ue); +} + +void pcf_ue_remove_all() +{ + pcf_ue_t *pcf_ue = NULL, *next = NULL;; + + ogs_list_for_each_safe(&self.pcf_ue_list, next, pcf_ue) + pcf_ue_remove(pcf_ue); +} + +pcf_ue_t *pcf_ue_find_by_supi(char *supi) +{ + ogs_assert(supi); + return (pcf_ue_t *)ogs_hash_get(self.supi_hash, supi, strlen(supi)); +} + +pcf_ue_t *pcf_ue_find_by_association_id(char *association_id) +{ + ogs_assert(association_id); + return ogs_pool_find(&pcf_ue_pool, atoll(association_id)); +} + +pcf_sess_t *pcf_sess_add(pcf_ue_t *pcf_ue, uint8_t psi) +{ + pcf_event_t e; + pcf_sess_t *sess = NULL; + + ogs_assert(pcf_ue); + ogs_assert(psi != OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED); + + ogs_pool_alloc(&pcf_sess_pool, &sess); + ogs_assert(sess); + memset(sess, 0, sizeof *sess); + + sess->sbi.type = OGS_SBI_OBJ_SESS_TYPE; + + sess->sm_policy_id = ogs_msprintf("%d", + (int)ogs_pool_index(&pcf_sess_pool, sess)); + ogs_assert(sess->sm_policy_id); + + sess->pcf_ue = pcf_ue; + sess->psi = psi; + + sess->s_nssai.sst = 0; + sess->s_nssai.sd.v = OGS_S_NSSAI_NO_SD_VALUE; + + memset(&e, 0, sizeof(e)); + e.sess = sess; + ogs_fsm_create(&sess->sm, pcf_sm_state_initial, pcf_sm_state_final); + ogs_fsm_init(&sess->sm, &e); + + ogs_list_add(&pcf_ue->sess_list, sess); + + return sess; +} + +void pcf_sess_remove(pcf_sess_t *sess) +{ + pcf_event_t e; + + ogs_assert(sess); + ogs_assert(sess->pcf_ue); + + ogs_list_remove(&sess->pcf_ue->sess_list, sess); + + memset(&e, 0, sizeof(e)); + e.sess = sess; + ogs_fsm_fini(&sess->sm, &e); + ogs_fsm_delete(&sess->sm); + + /* Free SBI object memory */ + ogs_sbi_object_free(&sess->sbi); + + ogs_assert(sess->sm_policy_id); + ogs_free(sess->sm_policy_id); + + if (sess->dnn) + ogs_free(sess->dnn); + + if (sess->notification_uri) + ogs_free(sess->notification_uri); + + ogs_pool_free(&pcf_sess_pool, sess); +} + +void pcf_sess_remove_all(pcf_ue_t *pcf_ue) +{ + pcf_sess_t *sess = NULL, *next_sess = NULL; + + ogs_assert(pcf_ue); + + ogs_list_for_each_safe(&pcf_ue->sess_list, next_sess, sess) + pcf_sess_remove(sess); +} + +pcf_sess_t *pcf_sess_find_by_sm_policy_id(pcf_ue_t *pcf_ue, char *sm_policy_id) +{ + pcf_sess_t *sess = NULL; + + ogs_assert(sm_policy_id); + + ogs_list_for_each(&pcf_ue->sess_list, sess) + if (!strcmp(sess->sm_policy_id, sm_policy_id)) return sess; + + return NULL; +} + +pcf_sess_t *pcf_sess_find_by_psi(pcf_ue_t *pcf_ue, uint8_t psi) +{ + pcf_sess_t *sess = NULL; + + ogs_list_for_each(&pcf_ue->sess_list, sess) + if (psi == sess->psi) return sess; + + return NULL; +} + +pcf_ue_t *pcf_ue_cycle(pcf_ue_t *pcf_ue) +{ + return ogs_pool_cycle(&pcf_ue_pool, pcf_ue); +} + +pcf_sess_t *pcf_sess_cycle(pcf_sess_t *sess) +{ + return ogs_pool_cycle(&pcf_sess_pool, sess); +} diff --git a/src/pcf/context.h b/src/pcf/context.h new file mode 100644 index 000000000..500218d82 --- /dev/null +++ b/src/pcf/context.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_CONTEXT_H +#define PCF_CONTEXT_H + +#include "ogs-app.h" +#include "ogs-crypt.h" +#include "ogs-sbi.h" + +#include "pcf-sm.h" +#include "timer.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_NUM_OF_SERVED_GUAMI 8 + +extern int __pcf_log_domain; + +#undef OGS_LOG_DOMAIN +#define OGS_LOG_DOMAIN __pcf_log_domain + +typedef struct pcf_context_s { + OpenAPI_nf_type_e nf_type; + + ogs_list_t pcf_ue_list; + ogs_hash_t *supi_hash; + +} pcf_context_t; + +#define PCF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ + do { \ + ogs_assert(_nFInstance); \ + if ((_nFInstance)->reference_count == 1) { \ + ogs_info("[%s] (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ + pcf_nf_fsm_fini((_nFInstance)); \ + } else { \ + /* There is an assocation with other context */ \ + ogs_info("[%s:%d] (%s) NF suspended", \ + _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ + OGS_FSM_TRAN(&_nFInstance->sm, pcf_nf_state_de_registered); \ + ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ + } \ + ogs_sbi_nf_instance_remove(_nFInstance); \ + } while(0) + +struct pcf_ue_s { + ogs_sbi_object_t sbi; + ogs_fsm_t sm; + + OpenAPI_policy_association_request_t *policy_association_request; + + char *association_id; + char *supi; + + char *notification_uri; + + ogs_guami_t guami; + OpenAPI_rat_type_e rat_type; + + ogs_list_t sess_list; +}; + +struct pcf_sess_s { + ogs_sbi_object_t sbi; + ogs_fsm_t sm; + + char *sm_policy_id; + + uint8_t psi; /* PDU Session Identity */ + + uint8_t pdu_session_type; + char *dnn; + char *notification_uri; + ogs_s_nssai_t s_nssai; + + /* Related Context */ + pcf_ue_t *pcf_ue; +}; + +void pcf_context_init(void); +void pcf_context_final(void); +pcf_context_t *pcf_self(void); + +int pcf_context_parse_config(void); + +pcf_ue_t *pcf_ue_add(char *supi); +void pcf_ue_remove(pcf_ue_t *pcf_ue); +void pcf_ue_remove_all(void); +pcf_ue_t *pcf_ue_find_by_supi(char *supi); +pcf_ue_t *pcf_ue_find_by_association_id(char *association_id); + +pcf_sess_t *pcf_sess_add(pcf_ue_t *pcf_ue, uint8_t psi); +void pcf_sess_remove(pcf_sess_t *sess); +void pcf_sess_remove_all(pcf_ue_t *pcf_ue); +pcf_sess_t *pcf_sess_find_by_sm_policy_id(pcf_ue_t *pcf_ue, char *sm_policy_id); +pcf_sess_t *pcf_sess_find_by_psi(pcf_ue_t *pcf_ue, uint8_t psi); +pcf_sess_t *pcf_sess_find_by_dnn(pcf_ue_t *pcf_ue, char *dnn); + +pcf_ue_t *pcf_ue_cycle(pcf_ue_t *pcf_ue); +pcf_sess_t *pcf_sess_cycle(pcf_sess_t *sess); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_CONTEXT_H */ diff --git a/src/pcf/event.c b/src/pcf/event.c new file mode 100644 index 000000000..7ccee7df1 --- /dev/null +++ b/src/pcf/event.c @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "event.h" +#include "context.h" + +static OGS_POOL(pool, pcf_event_t); + +void pcf_event_init(void) +{ + ogs_pool_init(&pool, ogs_app()->pool.event); +} + +void pcf_event_final(void) +{ + ogs_pool_final(&pool); +} + +pcf_event_t *pcf_event_new(pcf_event_e id) +{ + pcf_event_t *e = NULL; + + ogs_pool_alloc(&pool, &e); + ogs_assert(e); + memset(e, 0, sizeof(*e)); + + e->id = id; + + return e; +} + +void pcf_event_free(pcf_event_t *e) +{ + ogs_assert(e); + ogs_pool_free(&pool, e); +} + +const char *pcf_event_get_name(pcf_event_t *e) +{ + if (e == NULL) + return OGS_FSM_NAME_INIT_SIG; + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + return OGS_FSM_NAME_ENTRY_SIG; + case OGS_FSM_EXIT_SIG: + return OGS_FSM_NAME_EXIT_SIG; + + case PCF_EVT_SBI_SERVER: + return "PCF_EVT_SBI_SERVER"; + case PCF_EVT_SBI_CLIENT: + return "PCF_EVT_SBI_CLIENT"; + case PCF_EVT_SBI_TIMER: + return "PCF_EVT_SBI_TIMER"; + + default: + break; + } + + return "UNKNOWN_EVENT"; +} diff --git a/src/pcf/event.h b/src/pcf/event.h new file mode 100644 index 000000000..bc2ab5006 --- /dev/null +++ b/src/pcf/event.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_EVENT_H +#define PCF_EVENT_H + +#include "ogs-core.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ogs_sbi_request_s ogs_sbi_request_t; +typedef struct ogs_sbi_response_s ogs_sbi_response_t; +typedef struct ogs_sbi_message_s ogs_sbi_message_t; +typedef struct ogs_sbi_nf_instance_s ogs_sbi_nf_instance_t; +typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; + +typedef struct pcf_ue_s pcf_ue_t; +typedef struct pcf_sess_s pcf_sess_t; + +typedef enum { + PCF_EVT_BASE = OGS_FSM_USER_SIG, + + PCF_EVT_SBI_SERVER, + PCF_EVT_SBI_CLIENT, + PCF_EVT_SBI_TIMER, + + PCF_EVT_TOP, + +} pcf_event_e; + +typedef struct pcf_event_s { + int id; + int timer_id; + + struct { + ogs_sbi_request_t *request; + ogs_sbi_response_t *response; + void *data; + + ogs_sbi_message_t *message; + } sbi; + + pcf_ue_t *pcf_ue; + pcf_sess_t *sess; + + ogs_timer_t *timer; +} pcf_event_t; + +void pcf_event_init(void); +void pcf_event_final(void); + +pcf_event_t *pcf_event_new(pcf_event_e id); +void pcf_event_free(pcf_event_t *e); + +const char *pcf_event_get_name(pcf_event_t *e); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_EVENT_H */ diff --git a/src/pcf/init.c b/src/pcf/init.c new file mode 100644 index 000000000..91e984cb2 --- /dev/null +++ b/src/pcf/init.c @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "context.h" + +static ogs_thread_t *thread; +static void pcf_main(void *data); +static int initialized = 0; + +int pcf_initialize() +{ + int rv; + + pcf_context_init(); + pcf_event_init(); + ogs_sbi_context_init(); + + rv = ogs_sbi_context_parse_config("pcf", "nrf"); + if (rv != OGS_OK) return rv; + + rv = pcf_context_parse_config(); + if (rv != OGS_OK) return rv; + + rv = ogs_log_config_domain( + ogs_app()->logger.domain, ogs_app()->logger.level); + if (rv != OGS_OK) return rv; + + thread = ogs_thread_create(pcf_main, NULL); + if (!thread) return OGS_ERROR; + + initialized = 1; + + return OGS_OK; +} + +static ogs_timer_t *t_termination_holding = NULL; + +static void event_termination(void) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + /* Sending NF Instance De-registeration to NRF */ + ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) + pcf_nf_fsm_fini(nf_instance); + + /* Starting holding timer */ + 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(ogs_app()->queue); + ogs_pollset_notify(ogs_app()->pollset); +} + +void pcf_terminate(void) +{ + if (!initialized) return; + + /* Daemon terminating */ + event_termination(); + ogs_thread_destroy(thread); + ogs_timer_delete(t_termination_holding); + + pcf_context_final(); + ogs_sbi_context_final(); + + pcf_event_final(); /* Destroy event */ +} + +static void pcf_main(void *data) +{ + ogs_fsm_t pcf_sm; + int rv; + + ogs_fsm_create(&pcf_sm, pcf_state_initial, pcf_state_final); + ogs_fsm_init(&pcf_sm, 0); + + for ( ;; ) { + 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. + * + * The reason is why ogs_timer_mgr_next() can get the corrent value + * when ogs_timer_stop() is called internally in ogs_timer_mgr_expire(). + * + * You should not use event-queue before ogs_timer_mgr_expire(). + * In this case, ogs_timer_mgr_expire() does not work + * because 'if rv == OGS_DONE' statement is exiting and + * not calling ogs_timer_mgr_expire(). + */ + ogs_timer_mgr_expire(ogs_app()->timer_mgr); + + for ( ;; ) { + pcf_event_t *e = NULL; + + rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e); + ogs_assert(rv != OGS_ERROR); + + if (rv == OGS_DONE) + goto done; + + if (rv == OGS_RETRY) + break; + + ogs_assert(e); + ogs_fsm_dispatch(&pcf_sm, e); + pcf_event_free(e); + } + } +done: + + ogs_fsm_fini(&pcf_sm, 0); + ogs_fsm_delete(&pcf_sm); +} diff --git a/src/pcf/meson.build b/src/pcf/meson.build new file mode 100644 index 000000000..56bd14254 --- /dev/null +++ b/src/pcf/meson.build @@ -0,0 +1,65 @@ +# Copyright (C) 2019,2020 by Sukchan Lee + +# This file is part of Open5GS. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +libpcf_sources = files(''' + context.c + event.c + timer.c + + nnrf-handler.c + nf-sm.c + + npcf-handler.c + + nudr-build.c + nudr-handler.c + + am-sm.c + sm-sm.c + + sbi-path.c + pcf-sm.c + + init.c +'''.split()) + +libpcf = static_library('pcf', + sources : libpcf_sources, + link_with : libipfw, + dependencies : [libapp_dep, + libcrypt_dep, + libsbi_dep], + install : false) + +libpcf_dep = declare_dependency( + link_with : libpcf, + dependencies : [libapp_dep, + libcrypt_dep, + libsbi_dep]) + +pcf_sources = files(''' + app.c + ../main.c +'''.split()) + +executable('open5gs-pcfd', + sources : pcf_sources, + c_args : '-DDEFAULT_CONFIG_FILENAME="@0@/pcf.yaml"'.format(open5gs_sysconfdir), + include_directories : srcinc, + dependencies : libpcf_dep, + install_rpath : libdir, + install : true) diff --git a/src/pcf/nf-sm.c b/src/pcf/nf-sm.c new file mode 100644 index 000000000..d64e8ef3c --- /dev/null +++ b/src/pcf/nf-sm.c @@ -0,0 +1,407 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "context.h" + +#include "sbi-path.h" +#include "nnrf-handler.h" + +void pcf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) +{ + pcf_event_t e; + + ogs_assert(nf_instance); + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_create(&nf_instance->sm, + pcf_nf_state_initial, pcf_nf_state_final); + ogs_fsm_init(&nf_instance->sm, &e); +} + +void pcf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) +{ + pcf_event_t e; + + ogs_assert(nf_instance); + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_fini(&nf_instance->sm, &e); + ogs_fsm_delete(&nf_instance->sm); +} + +void pcf_nf_state_initial(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(nf_instance->id); + + ogs_assert(nf_instance->t_registration_interval); + nf_instance->t_registration_interval->cb = + pcf_timer_nf_instance_registration_interval; + ogs_assert(nf_instance->t_heartbeat_interval); + nf_instance->t_heartbeat_interval->cb = + pcf_timer_nf_instance_heartbeat_interval; + ogs_assert(nf_instance->t_no_heartbeat); + nf_instance->t_no_heartbeat->cb = pcf_timer_nf_instance_no_heartbeat; + ogs_assert(nf_instance->t_validity); + nf_instance->t_validity->cb = pcf_timer_nf_instance_validity; + + if (NF_INSTANCE_IS_SELF(nf_instance->id)) { + OGS_FSM_TRAN(s, &pcf_nf_state_will_register); + } else { + OGS_FSM_TRAN(s, &pcf_nf_state_registered); + } +} + +void pcf_nf_state_final(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); +} + +void pcf_nf_state_will_register(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_client_t *client = NULL; + ogs_sbi_message_t *message = NULL; + ogs_sockaddr_t *addr = NULL; + + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_IS_SELF(nf_instance->id)) + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi.nf_register_interval); + + ogs_nnrf_nfm_send_nf_register(nf_instance); + break; + + case OGS_FSM_EXIT_SIG: + if (NF_INSTANCE_IS_SELF(nf_instance->id)) + ogs_timer_stop(nf_instance->t_registration_interval); + break; + + case PCF_EVT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + + if (message->res_status == OGS_SBI_HTTP_STATUS_OK || + message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { + pcf_nnrf_handle_nf_register(nf_instance, message); + OGS_FSM_TRAN(s, &pcf_nf_state_registered); + } else { + ogs_error("[%s] HTTP response error [%d]", + nf_instance->id, message->res_status); + OGS_FSM_TRAN(s, &pcf_nf_state_exception); + } + break; + + DEFAULT + ogs_error("[%s] Invalid resource name [%s]", + nf_instance->id, message->h.resource.component[0]); + END + break; + + DEFAULT + ogs_error("[%s] Invalid API name [%s]", + nf_instance->id, message->h.service.name); + END + break; + + case PCF_EVT_SBI_TIMER: + switch(e->timer_id) { + case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + client = nf_instance->client; + ogs_assert(client); + addr = client->node.addr; + ogs_assert(addr); + + ogs_warn("[%s] Retry to registration with NRF", nf_instance->id); + + if (NF_INSTANCE_IS_SELF(nf_instance->id)) + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi.nf_register_interval); + + ogs_nnrf_nfm_send_nf_register(nf_instance); + break; + + default: + ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id, + pcf_timer_get_name(e->timer_id), e->timer_id); + } + break; + + default: + ogs_error("Unknown event %s", pcf_event_get_name(e)); + break; + } +} + +void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_client_t *client = NULL; + ogs_sbi_message_t *message = NULL; + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_IS_SELF(nf_instance->id)) { + ogs_info("[%s] NF registered", nf_instance->id); + + client = nf_instance->client; + ogs_assert(client); + + if (nf_instance->time.heartbeat_interval) { + ogs_timer_start(nf_instance->t_heartbeat_interval, + ogs_time_from_sec(nf_instance->time.heartbeat_interval)); + ogs_timer_start(nf_instance->t_no_heartbeat, + ogs_time_from_sec( + nf_instance->time.heartbeat_interval + + ogs_app()->time.nf_instance.no_heartbeat_margin)); + } + + ogs_nnrf_nfm_send_nf_status_subscribe(client, + pcf_self()->nf_type, nf_instance->id); + } + + break; + + case OGS_FSM_EXIT_SIG: + if (NF_INSTANCE_IS_SELF(nf_instance->id)) { + ogs_info("[%s] NF de-registered", nf_instance->id); + + if (nf_instance->time.heartbeat_interval) { + ogs_timer_stop(nf_instance->t_heartbeat_interval); + ogs_timer_stop(nf_instance->t_no_heartbeat); + } + + if (!OGS_FSM_CHECK(&nf_instance->sm, pcf_nf_state_exception)) { + ogs_nnrf_nfm_send_nf_de_register(nf_instance); + } + } + break; + + case PCF_EVT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + + if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || + message->res_status == OGS_SBI_HTTP_STATUS_OK) { + if (nf_instance->time.heartbeat_interval) + ogs_timer_start(nf_instance->t_no_heartbeat, + ogs_time_from_sec( + nf_instance->time.heartbeat_interval + + ogs_app()->time.nf_instance. + no_heartbeat_margin)); + } else { + ogs_warn("[%s] HTTP response error [%d]", + nf_instance->id, message->res_status); + OGS_FSM_TRAN(s, &pcf_nf_state_exception); + } + + break; + + DEFAULT + ogs_error("[%s] Invalid resource name [%s]", + nf_instance->id, message->h.resource.component[0]); + END + break; + + DEFAULT + ogs_error("[%s] Invalid API name [%s]", + nf_instance->id, message->h.service.name); + END + break; + + case PCF_EVT_SBI_TIMER: + switch(e->timer_id) { + case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + if (nf_instance->time.heartbeat_interval) + ogs_timer_start(nf_instance->t_heartbeat_interval, + ogs_time_from_sec(nf_instance->time.heartbeat_interval)); + + ogs_nnrf_nfm_send_nf_update(nf_instance); + break; + + case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: + ogs_error("[%s] No heartbeat", nf_instance->id); + OGS_FSM_TRAN(s, &pcf_nf_state_will_register); + break; + + case PCF_TIMER_NF_INSTANCE_VALIDITY: + if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { + ogs_info("[%s] NF expired", nf_instance->id); + OGS_FSM_TRAN(s, &pcf_nf_state_de_registered); + } + break; + + default: + ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id, + pcf_timer_get_name(e->timer_id), e->timer_id); + break; + } + break; + + default: + ogs_error("[%s] Unknown event %s", + nf_instance->id, pcf_event_get_name(e)); + break; + } +} + +void pcf_nf_state_de_registered(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_IS_SELF(nf_instance->id)) { + ogs_info("[%s] NF de-registered", nf_instance->id); + } + break; + + case OGS_FSM_EXIT_SIG: + break; + + default: + ogs_error("[%s] Unknown event %s", + nf_instance->id, pcf_event_get_name(e)); + break; + } +} + +void pcf_nf_state_exception(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_client_t *client = NULL; + ogs_sbi_message_t *message = NULL; + ogs_sockaddr_t *addr = NULL; + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_IS_SELF(nf_instance->id)) + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi. + nf_register_interval_in_exception); + break; + + case OGS_FSM_EXIT_SIG: + if (NF_INSTANCE_IS_SELF(nf_instance->id)) + ogs_timer_stop(nf_instance->t_registration_interval); + break; + + case PCF_EVT_SBI_TIMER: + switch(e->timer_id) { + case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + client = nf_instance->client; + ogs_assert(client); + addr = client->node.addr; + ogs_assert(addr); + + ogs_warn("[%s] Retry to registration with NRF", nf_instance->id); + + OGS_FSM_TRAN(s, &pcf_nf_state_will_register); + break; + + default: + ogs_error("[%s] Unknown timer[%s:%d]", nf_instance->id, + pcf_timer_get_name(e->timer_id), e->timer_id); + break; + } + break; + + case PCF_EVT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + break; + DEFAULT + ogs_error("Invalid resource name [%s]", + message->h.resource.component[0]); + END + break; + DEFAULT + ogs_error("Invalid API name [%s]", message->h.service.name); + END + break; + + default: + ogs_error("[%s] Unknown event %s", + nf_instance->id, pcf_event_get_name(e)); + break; + } +} diff --git a/src/pcf/nnrf-handler.c b/src/pcf/nnrf-handler.c new file mode 100644 index 000000000..544669c48 --- /dev/null +++ b/src/pcf/nnrf-handler.c @@ -0,0 +1,326 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sbi-path.h" +#include "nnrf-handler.h" + +void pcf_nnrf_handle_nf_register( + ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *message) +{ + OpenAPI_nf_profile_t *NFProfile = NULL; + ogs_sbi_client_t *client = NULL; + + ogs_assert(message); + ogs_assert(nf_instance); + client = nf_instance->client; + ogs_assert(client); + + NFProfile = message->NFProfile; + if (!NFProfile) { + ogs_error("No NFProfile"); + return; + } + + /* TIME : Update heartbeat from NRF */ + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; +} + +void pcf_nnrf_handle_nf_status_subscribe( + ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *message) +{ + OpenAPI_subscription_data_t *SubscriptionData = NULL; + ogs_sbi_client_t *client = NULL; + + ogs_assert(message); + ogs_assert(subscription); + client = subscription->client; + ogs_assert(client); + + SubscriptionData = message->SubscriptionData; + if (!SubscriptionData) { + ogs_error("No SubscriptionData"); + return; + } + + if (!SubscriptionData->subscription_id) { + ogs_error("No SubscriptionId"); + return; + } + ogs_sbi_subscription_set_id( + subscription, SubscriptionData->subscription_id); + + if (SubscriptionData->validity_time) { +#define VALIDITY_MARGIN (5LL * OGS_USEC_PER_SEC) /* 5 seconds */ +#define VALIDITY_MINIMUM (3600LL * OGS_USEC_PER_SEC) /* 3600 seconds */ + ogs_time_t time, duration; + if (ogs_sbi_time_from_string( + &time, SubscriptionData->validity_time) == true) { + duration = time - ogs_time_now() - VALIDITY_MARGIN; + if (duration < VALIDITY_MINIMUM) { + duration = VALIDITY_MINIMUM; + ogs_warn("[%s] Forced to %lld seconds", subscription->id, + (long long)ogs_time_sec(VALIDITY_MINIMUM)); + } + subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, + pcf_timer_subscription_validity, subscription); + ogs_assert(subscription->t_validity); + ogs_timer_start(subscription->t_validity, duration); + } else { + ogs_error("Cannot parse validitiyTime [%s]", + SubscriptionData->validity_time); + } + } +} + +bool pcf_nnrf_handle_nf_status_notify( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *message) +{ + ogs_sbi_response_t *response = NULL; + OpenAPI_notification_data_t *NotificationData = NULL; + OpenAPI_nf_profile_t *NFProfile = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL; + bool handled; + + ogs_assert(stream); + ogs_assert(message); + + NotificationData = message->NotificationData; + if (!NotificationData) { + ogs_error("No NotificationData"); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No NotificationData", NULL); + return false; + } + + NFProfile = NotificationData->nf_profile; + if (!NFProfile) { + ogs_error("No NFProfile"); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No NFProfile", NULL); + return false; + } + + if (!NFProfile->nf_instance_id) { + ogs_error("No NFProfile.NFInstanceId"); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No NFProfile", "NFInstanceId"); + return false; + } + + if (!NFProfile->nf_instance_id) { + ogs_error("No NFProfile.NFInstanceId"); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No NFProfile", "NFInstanceId"); + return false; + } + + if (NF_INSTANCE_IS_SELF(NFProfile->nf_instance_id)) { + ogs_warn("The notification is not allowed [%s]", + NFProfile->nf_instance_id); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, + message, "The notification is not allowed", + NFProfile->nf_instance_id); + return false; + } + + if (NotificationData->event == + OpenAPI_notification_event_type_NF_REGISTERED) { + + nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); + if (!nf_instance) { + nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id); + ogs_assert(nf_instance); + + pcf_nf_fsm_init(nf_instance); + + ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id); + } else { + OGS_FSM_TRAN(&nf_instance->sm, pcf_nf_state_registered); + ogs_fsm_dispatch(&nf_instance->sm, NULL); + + ogs_warn("[%s] (NRF-notify) NF has already been added", + NFProfile->nf_instance_id); + } + + handled = ogs_sbi_nnrf_handle_nf_profile( + nf_instance, NFProfile, stream, message); + if (!handled) { + PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); + return false; + } + + ogs_info("[%s] (NRF-notify) NF Profile updated", nf_instance->id); + + handled = ogs_sbi_client_associate(nf_instance); + if (!handled) { + ogs_error("[%s] Cannot associate NF EndPoint", nf_instance->id); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "Cannot find NF EndPoint", nf_instance->id); + PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); + return false; + } + + } else if (NotificationData->event == + OpenAPI_notification_event_type_NF_DEREGISTERED) { + nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); + if (nf_instance) { + PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); + } else { + ogs_warn("[%s] (NRF-notify) Not found", NFProfile->nf_instance_id); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_NOT_FOUND, + message, "Not found", message->h.resource.component[1]); + return false; + } + } else { + char *eventstr = OpenAPI_notification_event_type_ToString( + NotificationData->event); + ogs_error("Not supported event [%d:%s]", + NotificationData->event, eventstr ? eventstr : "Unknown"); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "Not supported event", + eventstr ? eventstr : "Unknown"); + return false; + } + + response = ogs_sbi_build_response(message, OGS_SBI_HTTP_STATUS_NO_CONTENT); + ogs_assert(response); + ogs_sbi_server_send_response(stream, response); + + return true; +} + +void pcf_nnrf_handle_nf_discover( + ogs_sbi_xact_t *xact, ogs_sbi_message_t *message) +{ + ogs_sbi_object_t *sbi_object = NULL; + pcf_ue_t *pcf_ue = NULL; + pcf_sess_t *sess = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_stream_t *stream = NULL; + + OpenAPI_search_result_t *SearchResult = NULL; + OpenAPI_lnode_t *node = NULL; + bool handled; + + ogs_assert(xact); + sbi_object = xact->sbi_object; + ogs_assert(sbi_object); + stream = xact->assoc_stream; + ogs_assert(stream); + ogs_assert(message); + + SearchResult = message->SearchResult; + if (!SearchResult) { + ogs_error("No SearchResult"); + return; + } + + OpenAPI_list_for_each(SearchResult->nf_instances, node) { + OpenAPI_nf_profile_t *NFProfile = NULL; + + if (!node->data) continue; + + NFProfile = node->data; + + nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); + if (!nf_instance) { + nf_instance = ogs_sbi_nf_instance_add(NFProfile->nf_instance_id); + ogs_assert(nf_instance); + + pcf_nf_fsm_init(nf_instance); + + ogs_info("[%s] (NF-discover) NF registered", nf_instance->id); + } else { + OGS_FSM_TRAN(&nf_instance->sm, pcf_nf_state_registered); + ogs_fsm_dispatch(&nf_instance->sm, NULL); + + ogs_warn("[%s] (NF-discover) NF has already been added", + NFProfile->nf_instance_id); + } + + if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { + handled = ogs_sbi_nnrf_handle_nf_profile( + nf_instance, NFProfile, NULL, NULL); + if (!handled) { + ogs_error("[%s] ogs_sbi_nnrf_handle_nf_profile() failed", + nf_instance->id); + PCF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); + continue; + } + + handled = ogs_sbi_client_associate(nf_instance); + if (!handled) { + ogs_error("[%s] Cannot assciate NF EndPoint", nf_instance->id); + PCF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); + continue; + } + + if (!OGS_SBI_NF_INSTANCE_GET( + sbi_object->nf_type_array, nf_instance->nf_type)) + ogs_sbi_nf_instance_associate(sbi_object->nf_type_array, + nf_instance->nf_type, pcf_nf_state_registered); + + /* TIME : Update validity from NRF */ + if (SearchResult->validity_period) { + nf_instance->time.validity_duration = + SearchResult->validity_period; + + ogs_assert(nf_instance->t_validity); + ogs_timer_start(nf_instance->t_validity, + ogs_time_from_sec(nf_instance->time.validity_duration)); + + } else + ogs_warn("[%s] NF Instance validity-time should not 0", + nf_instance->id); + + ogs_info("[%s] (NF-discover) NF Profile updated", nf_instance->id); + } + } + + ogs_assert(xact->target_nf_type); + nf_instance = OGS_SBI_NF_INSTANCE_GET( + sbi_object->nf_type_array, xact->target_nf_type); + if (!nf_instance) { + ogs_assert(sbi_object->type > OGS_SBI_OBJ_BASE && + sbi_object->type < OGS_SBI_OBJ_TOP); + switch(sbi_object->type) { + case OGS_SBI_OBJ_UE_TYPE: + pcf_ue = (pcf_ue_t *)sbi_object; + ogs_assert(pcf_ue); + ogs_error("[%s] (NF discover) No [%s]", pcf_ue->supi, + OpenAPI_nf_type_ToString(xact->target_nf_type)); + break; + case OGS_SBI_OBJ_SESS_TYPE: + sess = (pcf_sess_t *)sbi_object; + ogs_assert(sess); + ogs_error("[%d] (NF discover) No [%s]", sess->psi, + OpenAPI_nf_type_ToString(xact->target_nf_type)); + break; + default: + ogs_fatal("(NF discover) Not implemented [%s:%d]", + OpenAPI_nf_type_ToString(xact->target_nf_type), + sbi_object->type); + ogs_assert_if_reached(); + } + } else { + pcf_sbi_send(nf_instance, xact); + } +} diff --git a/src/pcf/nnrf-handler.h b/src/pcf/nnrf-handler.h new file mode 100644 index 000000000..3d4b23735 --- /dev/null +++ b/src/pcf/nnrf-handler.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_NNRF_HANDLER_H +#define PCF_NNRF_HANDLER_H + +#include "context.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void pcf_nnrf_handle_nf_register( + ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *message); +void pcf_nnrf_handle_nf_status_subscribe( + ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *message); + +bool pcf_nnrf_handle_nf_status_notify( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *message); + +void pcf_nnrf_handle_nf_discover( + ogs_sbi_xact_t *xact, ogs_sbi_message_t *message); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_NNRF_HANDLER_H */ diff --git a/src/pcf/npcf-handler.c b/src/pcf/npcf-handler.c new file mode 100644 index 000000000..9b88a7247 --- /dev/null +++ b/src/pcf/npcf-handler.c @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sbi-path.h" + +#include "npcf-handler.h" + +bool pcf_npcf_am_policy_contrtol_handle_create(pcf_ue_t *pcf_ue, + ogs_sbi_stream_t *stream, ogs_sbi_message_t *message) +{ + OpenAPI_policy_association_request_t *PolicyAssociationRequest = NULL; + OpenAPI_guami_t *Guami = NULL; + + ogs_assert(pcf_ue); + ogs_assert(stream); + ogs_assert(message); + + PolicyAssociationRequest = message->PolicyAssociationRequest; + if (!PolicyAssociationRequest) { + ogs_error("[%s] No PolicyAssociationRequest", pcf_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "[%s] No PolicyAssociationRequest", pcf_ue->supi); + return false; + } + + if (!PolicyAssociationRequest->notification_uri) { + ogs_error("[%s] No notificationUri", pcf_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No notificationUri", pcf_ue->supi); + return false; + } + + if (!PolicyAssociationRequest->supi) { + ogs_error("[%s] No supi", pcf_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No supi", pcf_ue->supi); + return false; + } + + if (!PolicyAssociationRequest->supp_feat) { + ogs_error("[%s] No suppFeat", pcf_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No suppFeat", pcf_ue->supi); + return false; + } + + if (pcf_ue->notification_uri) + ogs_free(pcf_ue->notification_uri); + pcf_ue->notification_uri = ogs_strdup( + PolicyAssociationRequest->notification_uri); + + Guami = PolicyAssociationRequest->guami; + if (Guami && Guami->amf_id && + Guami->plmn_id && Guami->plmn_id->mnc && Guami->plmn_id->mcc) { + ogs_sbi_parse_guami(&pcf_ue->guami, PolicyAssociationRequest->guami); + } + + if (PolicyAssociationRequest->rat_type) + pcf_ue->rat_type = PolicyAssociationRequest->rat_type; + + pcf_ue->policy_association_request = + OpenAPI_policy_association_request_copy( + pcf_ue->policy_association_request, + message->PolicyAssociationRequest); + + pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDR, pcf_ue, stream, NULL, + pcf_nudr_dr_build_query_am_data); + + return true; +} + +bool pcf_npcf_smpolicycontrtol_handle_create(pcf_sess_t *sess, + ogs_sbi_stream_t *stream, ogs_sbi_message_t *message) +{ + char *strerror = NULL; + pcf_ue_t *pcf_ue = NULL; + + OpenAPI_sm_policy_context_data_t *SmPolicyContextData = NULL; + OpenAPI_snssai_t *sliceInfo = NULL; + + ogs_assert(sess); + pcf_ue = sess->pcf_ue; + ogs_assert(stream); + ogs_assert(message); + + SmPolicyContextData = message->SmPolicyContextData; + if (!SmPolicyContextData) { + strerror = ogs_msprintf("[%s:%d] No SmPolicyContextData", + pcf_ue->supi, sess->psi); + goto cleanup; + } + + if (!SmPolicyContextData->supi) { + strerror = ogs_msprintf("[%s:%d] No supi", pcf_ue->supi, sess->psi); + goto cleanup; + } + + if (!SmPolicyContextData->pdu_session_id) { + strerror = ogs_msprintf("[%s:%d] No pduSessionId", + pcf_ue->supi, sess->psi); + goto cleanup; + } + + if (!SmPolicyContextData->pdu_session_type) { + strerror = ogs_msprintf("[%s:%d] No pduSessionType", + pcf_ue->supi, sess->psi); + goto cleanup; + } + + if (!SmPolicyContextData->dnn) { + strerror = ogs_msprintf("[%s:%d] No dnn", pcf_ue->supi, sess->psi); + goto cleanup; + } + + if (!SmPolicyContextData->notification_uri) { + strerror = ogs_msprintf("[%s:%d] No notificationUri", + pcf_ue->supi, sess->psi); + goto cleanup; + } + + sliceInfo = SmPolicyContextData->slice_info; + if (!sliceInfo) { + strerror = ogs_msprintf("[%s:%d] No sliceInfo", + pcf_ue->supi, sess->psi); + goto cleanup; + } + + sess->pdu_session_type = SmPolicyContextData->pdu_session_type; + + if (sess->dnn) + ogs_free(sess->dnn); + sess->dnn = ogs_strdup(SmPolicyContextData->dnn); + + if (sess->notification_uri) + ogs_free(sess->notification_uri); + sess->notification_uri = ogs_strdup(SmPolicyContextData->notification_uri); + + sess->s_nssai.sst = sliceInfo->sst; + sess->s_nssai.sd = ogs_s_nssai_sd_from_string(sliceInfo->sd); + + pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_UDR, sess, stream, NULL, + pcf_nudr_dr_build_query_sm_data); + + return true; + +cleanup: + ogs_assert(strerror); + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, strerror, NULL); + ogs_free(strerror); + + return false; +} diff --git a/src/pcf/npcf-handler.h b/src/pcf/npcf-handler.h new file mode 100644 index 000000000..7e65978b8 --- /dev/null +++ b/src/pcf/npcf-handler.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_NPCF_HANDLER_H +#define PCF_NPCF_HANDLER_H + +#include "context.h" + +#ifdef __cplusplus +extern "C" { +#endif + +bool pcf_npcf_am_policy_contrtol_handle_create(pcf_ue_t *pcf_ue, + ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); + +bool pcf_npcf_smpolicycontrtol_handle_create(pcf_sess_t *sess, + ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_NPCF_HANDLER_H */ diff --git a/src/pcf/nudr-build.c b/src/pcf/nudr-build.c new file mode 100644 index 000000000..563c4016c --- /dev/null +++ b/src/pcf/nudr-build.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "nudr-build.h" + +ogs_sbi_request_t *pcf_nudr_dr_build_query_am_data( + pcf_ue_t *pcf_ue, void *data) +{ + ogs_sbi_message_t message; + ogs_sbi_request_t *request = NULL; + + ogs_assert(pcf_ue); + + memset(&message, 0, sizeof(message)); + message.h.method = (char *)OGS_SBI_HTTP_METHOD_GET; + message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDR_DR; + message.h.api.version = (char *)OGS_SBI_API_V1; + message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_POLICY_DATA; + message.h.resource.component[1] = (char *)OGS_SBI_RESOURCE_NAME_UES; + message.h.resource.component[2] = pcf_ue->supi; + message.h.resource.component[3] = (char *)OGS_SBI_RESOURCE_NAME_AM_DATA; + + request = ogs_sbi_build_request(&message); + ogs_assert(request); + + return request; +} + +ogs_sbi_request_t *pcf_nudr_dr_build_query_sm_data( + pcf_sess_t *sess, void *data) +{ + pcf_ue_t *pcf_ue = NULL; + + ogs_sbi_message_t message; + ogs_sbi_request_t *request = NULL; + + ogs_assert(sess); + pcf_ue = sess->pcf_ue; + ogs_assert(pcf_ue); + + memset(&message, 0, sizeof(message)); + message.h.method = (char *)OGS_SBI_HTTP_METHOD_GET; + message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDR_DR; + message.h.api.version = (char *)OGS_SBI_API_V1; + message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_POLICY_DATA; + message.h.resource.component[1] = (char *)OGS_SBI_RESOURCE_NAME_UES; + message.h.resource.component[2] = pcf_ue->supi; + message.h.resource.component[3] = (char *)OGS_SBI_RESOURCE_NAME_SM_DATA; + + message.param.snssai_presence = true; + memcpy(&message.param.snssai, &sess->s_nssai, sizeof(message.param.snssai)); + + if (sess->dnn) + message.param.dnn = sess->dnn; + + request = ogs_sbi_build_request(&message); + ogs_assert(request); + + return request; +} diff --git a/src/pcf/nudr-build.h b/src/pcf/nudr-build.h new file mode 100644 index 000000000..1f15e701b --- /dev/null +++ b/src/pcf/nudr-build.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_NUDR_BUILD_H +#define PCF_NUDR_BUILD_H + +#include "context.h" + +#ifdef __cplusplus +extern "C" { +#endif + +ogs_sbi_request_t *pcf_nudr_dr_build_query_am_data( + pcf_ue_t *pcf_ue, void *data); + +ogs_sbi_request_t *pcf_nudr_dr_build_query_sm_data( + pcf_sess_t *sess, void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_NUDR_BUILD_H */ diff --git a/src/pcf/nudr-handler.c b/src/pcf/nudr-handler.c new file mode 100644 index 000000000..4393410f6 --- /dev/null +++ b/src/pcf/nudr-handler.c @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "nudr-handler.h" + +bool pcf_nudr_dr_handle_query_am_data( + pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) +{ + char *strerror = NULL; + ogs_sbi_server_t *server = NULL; + + ogs_sbi_message_t sendmsg; + ogs_sbi_header_t header; + ogs_sbi_response_t *response = NULL; + + ogs_assert(pcf_ue); + ogs_assert(stream); + server = ogs_sbi_server_from_stream(stream); + ogs_assert(server); + + ogs_assert(recvmsg); + + SWITCH(recvmsg->h.resource.component[3]) + CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) + OpenAPI_policy_association_t PolicyAssociation; + + if (!recvmsg->AmPolicyData) { + strerror = ogs_msprintf("[%s] No AmPolicyData", pcf_ue->supi); + goto cleanup; + } + + if (!pcf_ue->policy_association_request) { + strerror = ogs_msprintf("[%s] No PolicyAssociationRequest", + pcf_ue->supi); + goto cleanup; + } + + memset(&PolicyAssociation, 0, sizeof(PolicyAssociation)); + PolicyAssociation.request = pcf_ue->policy_association_request; + PolicyAssociation.supp_feat = (char *)""; + + memset(&header, 0, sizeof(header)); + header.service.name = + (char *)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL; + header.api.version = (char *)OGS_SBI_API_V1; + header.resource.component[0] = + (char *)OGS_SBI_RESOURCE_NAME_POLICIES; + header.resource.component[1] = pcf_ue->association_id; + + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.PolicyAssociation = &PolicyAssociation; + sendmsg.http.location = ogs_sbi_server_uri(server, &header); + + response = ogs_sbi_build_response( + &sendmsg, OGS_SBI_HTTP_STATUS_CREATED); + ogs_assert(response); + ogs_sbi_server_send_response(stream, response); + + ogs_free(sendmsg.http.location); + + return true; + + DEFAULT + strerror = ogs_msprintf("[%s] Invalid resource name [%s]", + pcf_ue->supi, recvmsg->h.resource.component[3]); + END + +cleanup: + ogs_assert(strerror); + ogs_error("%s", strerror); + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, recvmsg, strerror, NULL); + ogs_free(strerror); + + return false; +} + +bool pcf_nudr_dr_handle_query_sm_data( + pcf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) +{ + char *strerror = NULL; + pcf_ue_t *pcf_ue = NULL; + ogs_sbi_server_t *server = NULL; + + ogs_sbi_message_t sendmsg; + ogs_sbi_header_t header; + ogs_sbi_response_t *response = NULL; + + ogs_assert(sess); + pcf_ue = sess->pcf_ue; + ogs_assert(pcf_ue); + ogs_assert(stream); + server = ogs_sbi_server_from_stream(stream); + ogs_assert(server); + + ogs_assert(recvmsg); + + SWITCH(recvmsg->h.resource.component[3]) + CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) + OpenAPI_sm_policy_decision_t SmPolicyDecision; + + if (!recvmsg->SmPolicyData) { + strerror = ogs_msprintf("[%s:%d] No SmPolicyData", + pcf_ue->supi, sess->psi); + goto cleanup; + } + + memset(&SmPolicyDecision, 0, sizeof(SmPolicyDecision)); + + memset(&header, 0, sizeof(header)); + header.service.name = (char *)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL; + header.api.version = (char *)OGS_SBI_API_V1; + header.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_POLICIES; + header.resource.component[1] = sess->sm_policy_id; + + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.SmPolicyDecision = &SmPolicyDecision; + sendmsg.http.location = ogs_sbi_server_uri(server, &header); + + response = ogs_sbi_build_response( + &sendmsg, OGS_SBI_HTTP_STATUS_CREATED); + ogs_assert(response); + ogs_sbi_server_send_response(stream, response); + + ogs_free(sendmsg.http.location); + + return true; + + DEFAULT + strerror = ogs_msprintf("[%s:%d] Invalid resource name [%s]", + pcf_ue->supi, sess->psi, recvmsg->h.resource.component[3]); + END + +cleanup: + ogs_assert(strerror); + ogs_error("%s", strerror); + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, recvmsg, strerror, NULL); + ogs_free(strerror); + + return false; +} diff --git a/src/pcf/nudr-handler.h b/src/pcf/nudr-handler.h new file mode 100644 index 000000000..a79d56697 --- /dev/null +++ b/src/pcf/nudr-handler.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_NUDR_HANDLER_H +#define PCF_NUDR_HANDLER_H + +#include "context.h" + +#ifdef __cplusplus +extern "C" { +#endif + +bool pcf_nudr_dr_handle_query_am_data( + pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); + +bool pcf_nudr_dr_handle_query_sm_data( + pcf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_NUDR_HANDLER_H */ diff --git a/src/pcf/pcf-sm.c b/src/pcf/pcf-sm.c new file mode 100644 index 000000000..d7127074c --- /dev/null +++ b/src/pcf/pcf-sm.c @@ -0,0 +1,473 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sbi-path.h" +#include "nnrf-handler.h" + +void pcf_state_initial(ogs_fsm_t *s, pcf_event_t *e) +{ + pcf_sm_debug(e); + + ogs_assert(s); + + OGS_FSM_TRAN(s, &pcf_state_operational); +} + +void pcf_state_final(ogs_fsm_t *s, pcf_event_t *e) +{ + pcf_sm_debug(e); +} + +void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e) +{ + int rv; + + ogs_sbi_stream_t *stream = NULL; + ogs_sbi_request_t *request = NULL; + + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_response_t *response = NULL; + ogs_sbi_message_t message; + + ogs_sbi_object_t *sbi_object = NULL; + ogs_sbi_xact_t *sbi_xact = NULL; + + pcf_ue_t *pcf_ue = NULL; + pcf_sess_t *sess = NULL; + + pcf_sm_debug(e); + + ogs_assert(s); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + rv = pcf_sbi_open(); + if (rv != OGS_OK) { + ogs_fatal("Can't establish SBI path"); + } + + break; + + case OGS_FSM_EXIT_SIG: + pcf_sbi_close(); + break; + + case PCF_EVT_SBI_SERVER: + request = e->sbi.request; + ogs_assert(request); + stream = e->sbi.data; + ogs_assert(stream); + + rv = ogs_sbi_parse_request(&message, request); + if (rv != OGS_OK) { + /* 'message' buffer is released in ogs_sbi_parse_request() */ + ogs_error("cannot parse HTTP message"); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + NULL, "cannot parse HTTP message", NULL); + break; + } + + if (strcmp(message.h.api.version, OGS_SBI_API_V1) != 0) { + ogs_error("Not supported version [%s]", message.h.api.version); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + &message, "Not supported version", NULL); + ogs_sbi_message_free(&message); + break; + } + + SWITCH(message.h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message.h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) + SWITCH(message.h.method) + CASE(OGS_SBI_HTTP_METHOD_POST) + pcf_nnrf_handle_nf_status_notify(stream, &message); + break; + + DEFAULT + ogs_error("Invalid HTTP method [%s]", + message.h.method); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_FORBIDDEN, &message, + "Invalid HTTP method", message.h.method); + END + break; + + DEFAULT + ogs_error("Invalid resource name [%s]", + message.h.resource.component[0]); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, &message, + "Unknown resource name", + message.h.resource.component[0]); + END + break; + + CASE(OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL) + SWITCH(message.h.method) + CASE(OGS_SBI_HTTP_METHOD_POST) + if (message.PolicyAssociationRequest && + message.PolicyAssociationRequest->supi) { + pcf_ue = pcf_ue_find_by_supi( + message.PolicyAssociationRequest->supi); + if (!pcf_ue) { + pcf_ue = pcf_ue_add( + message.PolicyAssociationRequest->supi); + ogs_assert(pcf_ue); + } + } + break; + + DEFAULT + END + + if (!pcf_ue) { + ogs_error("Not found [%s]", message.h.method); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_NOT_FOUND, + &message, "Not found", message.h.method); + break; + } + + ogs_assert(OGS_FSM_STATE(&pcf_ue->sm)); + + e->pcf_ue = pcf_ue; + e->sbi.message = &message; + ogs_fsm_dispatch(&pcf_ue->sm, e); + if (OGS_FSM_CHECK(&pcf_ue->sm, pcf_am_state_exception)) { + ogs_error("[%s] State machine exception", pcf_ue->supi); + pcf_ue_remove(pcf_ue); + } + break; + + CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) + SWITCH(message.h.method) + CASE(OGS_SBI_HTTP_METHOD_POST) + if (message.SmPolicyContextData && + message.SmPolicyContextData->supi) { + pcf_ue = pcf_ue_find_by_supi( + message.SmPolicyContextData->supi); + if (pcf_ue) { + if (message.SmPolicyContextData->pdu_session_id) { + sess = pcf_sess_find_by_psi(pcf_ue, + message.SmPolicyContextData->pdu_session_id); + if (!sess) { + sess = pcf_sess_add(pcf_ue, + message.SmPolicyContextData->pdu_session_id); + ogs_assert(sess); + } + } + } + } + break; + + DEFAULT + END + + if (!sess) { + ogs_error("Not found [%s]", message.h.method); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_NOT_FOUND, + &message, "Not found", message.h.method); + break; + } + + ogs_assert(OGS_FSM_STATE(&sess->sm)); + + e->sess = sess; + e->sbi.message = &message; + ogs_fsm_dispatch(&sess->sm, e); + if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) { + ogs_error("[%s:%d] State machine exception", + pcf_ue->supi, sess->psi); + pcf_sess_remove(sess); + } + break; + + DEFAULT + ogs_error("Invalid API name [%s]", message.h.service.name); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, &message, + "Invalid API name", message.h.service.name); + END + + /* In lib/sbi/server.c, notify_completed() releases 'request' buffer. */ + ogs_sbi_message_free(&message); + break; + + case PCF_EVT_SBI_CLIENT: + ogs_assert(e); + + response = e->sbi.response; + ogs_assert(response); + rv = ogs_sbi_parse_response(&message, response); + if (rv != OGS_OK) { + ogs_error("cannot parse HTTP response"); + ogs_sbi_message_free(&message); + ogs_sbi_response_free(response); + break; + } + + if (strcmp(message.h.api.version, OGS_SBI_API_V1) != 0) { + ogs_error("Not supported version [%s]", message.h.api.version); + ogs_sbi_message_free(&message); + ogs_sbi_response_free(response); + break; + } + + SWITCH(message.h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message.h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); + + e->sbi.message = &message; + ogs_fsm_dispatch(&nf_instance->sm, e); + break; + + CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) + subscription = e->sbi.data; + ogs_assert(subscription); + + SWITCH(message.h.method) + CASE(OGS_SBI_HTTP_METHOD_POST) + if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || + message.res_status == OGS_SBI_HTTP_STATUS_OK) { + pcf_nnrf_handle_nf_status_subscribe( + subscription, &message); + } else { + ogs_error("[%s] HTTP response error [%d]", + subscription->id, message.res_status); + } + break; + + CASE(OGS_SBI_HTTP_METHOD_DELETE) + if (message.res_status == + OGS_SBI_HTTP_STATUS_NO_CONTENT) { + ogs_sbi_subscription_remove(subscription); + } else { + ogs_error("[%s] HTTP response error [%d]", + subscription->id, message.res_status); + } + break; + + DEFAULT + ogs_error("[%s] Invalid HTTP method [%s]", + subscription->id, message.h.method); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("Invalid resource name [%s]", + message.h.resource.component[0]); + ogs_assert_if_reached(); + END + break; + + CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) + SWITCH(message.h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + sbi_xact = e->sbi.data; + ogs_assert(sbi_xact); + + SWITCH(message.h.method) + CASE(OGS_SBI_HTTP_METHOD_GET) + if (message.res_status == OGS_SBI_HTTP_STATUS_OK) + pcf_nnrf_handle_nf_discover(sbi_xact, &message); + else + ogs_error("HTTP response error [%d]", + message.res_status); + break; + + DEFAULT + ogs_error("Invalid HTTP method [%s]", message.h.method); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("Invalid resource name [%s]", + message.h.resource.component[0]); + ogs_assert_if_reached(); + END + break; + + CASE(OGS_SBI_SERVICE_NAME_NUDR_DR) + SWITCH(message.h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA) + SWITCH(message.h.resource.component[3]) + CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) + sbi_xact = e->sbi.data; + ogs_assert(sbi_xact); + + pcf_ue = (pcf_ue_t *)sbi_xact->sbi_object; + ogs_assert(pcf_ue); + pcf_ue = pcf_ue_cycle(pcf_ue); + ogs_assert(pcf_ue); + + e->pcf_ue = pcf_ue; + e->sbi.message = &message; + e->sbi.data = sbi_xact->assoc_stream; + + ogs_sbi_xact_remove(sbi_xact); + + ogs_fsm_dispatch(&pcf_ue->sm, e); + if (OGS_FSM_CHECK(&pcf_ue->sm, pcf_am_state_exception)) { + ogs_error("[%s] State machine exception", pcf_ue->supi); + pcf_ue_remove(pcf_ue); + } + break; + + CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) + sbi_xact = e->sbi.data; + ogs_assert(sbi_xact); + + sess = (pcf_sess_t *)sbi_xact->sbi_object; + ogs_assert(sess); + sess = pcf_sess_cycle(sess); + ogs_assert(sess); + + pcf_ue = sess->pcf_ue; + ogs_assert(pcf_ue); + pcf_ue = pcf_ue_cycle(pcf_ue); + ogs_assert(pcf_ue); + + e->sess = sess; + e->sbi.message = &message; + e->sbi.data = sbi_xact->assoc_stream; + + ogs_sbi_xact_remove(sbi_xact); + + ogs_fsm_dispatch(&sess->sm, e); + if (OGS_FSM_CHECK(&sess->sm, pcf_am_state_exception)) { + ogs_error("[%s:%d] State machine exception", + pcf_ue->supi, sess->psi); + pcf_sess_remove(sess); + } + break; + + DEFAULT + ogs_error("Invalid resource name [%s]", + message.h.resource.component[3]); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("Invalid resource name [%s]", + message.h.resource.component[0]); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("Invalid API name [%s]", message.h.service.name); + ogs_assert_if_reached(); + END + + ogs_sbi_message_free(&message); + ogs_sbi_response_free(response); + break; + + case PCF_EVT_SBI_TIMER: + ogs_assert(e); + + switch(e->timer_id) { + case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case PCF_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); + + ogs_fsm_dispatch(&nf_instance->sm, e); + if (OGS_FSM_CHECK(&nf_instance->sm, pcf_nf_state_exception)) + ogs_error("[%s] State machine exception [%d]", + nf_instance->id, e->timer_id); + break; + + case PCF_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->sbi.data; + ogs_assert(subscription); + + ogs_info("[%s] Subscription validity expired", subscription->id); + ogs_sbi_subscription_remove(subscription); + + ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, + pcf_self()->nf_type, subscription->nf_instance_id); + break; + + case PCF_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->sbi.data; + ogs_assert(sbi_xact); + + sbi_object = sbi_xact->sbi_object; + ogs_assert(sbi_object); + ogs_assert(sbi_object->type > OGS_SBI_OBJ_BASE && + sbi_object->type < OGS_SBI_OBJ_TOP); + + switch(sbi_object->type) { + case OGS_SBI_OBJ_UE_TYPE: + pcf_ue = (pcf_ue_t *)sbi_object; + ogs_assert(pcf_ue); + ogs_error("[%s] Cannot receive SBI message", pcf_ue->supi); + break; + + case OGS_SBI_OBJ_SESS_TYPE: + sess = (pcf_sess_t *)sbi_object; + ogs_assert(sess); + ogs_error("[%d] Cannot receive SBI message", sess->psi); + break; + + default: + ogs_fatal("Not implemented [%s:%d]", + OpenAPI_nf_type_ToString(sbi_xact->target_nf_type), + sbi_object->type); + ogs_assert_if_reached(); + } + + stream = sbi_xact->assoc_stream; + ogs_assert(stream); + + ogs_sbi_xact_remove(sbi_xact); + + ogs_error("Cannot receive SBI message"); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL, + "Cannot receive SBI message", NULL); + break; + + default: + ogs_error("Unknown timer[%s:%d]", + pcf_timer_get_name(e->timer_id), e->timer_id); + } + break; + + default: + ogs_error("No handler for event %s", pcf_event_get_name(e)); + break; + } +} diff --git a/src/pcf/pcf-sm.h b/src/pcf/pcf-sm.h new file mode 100644 index 000000000..a2929bb39 --- /dev/null +++ b/src/pcf/pcf-sm.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_SM_H +#define PCF_SM_H + +#include "event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void pcf_state_initial(ogs_fsm_t *s, pcf_event_t *e); +void pcf_state_final(ogs_fsm_t *s, pcf_event_t *e); +void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e); + +void pcf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); +void pcf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); + +void pcf_nf_state_initial(ogs_fsm_t *s, pcf_event_t *e); +void pcf_nf_state_final(ogs_fsm_t *s, pcf_event_t *e); +void pcf_nf_state_will_register(ogs_fsm_t *s, pcf_event_t *e); +void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e); +void pcf_nf_state_de_registered(ogs_fsm_t *s, pcf_event_t *e); +void pcf_nf_state_exception(ogs_fsm_t *s, pcf_event_t *e); + +void pcf_am_state_initial(ogs_fsm_t *s, pcf_event_t *e); +void pcf_am_state_final(ogs_fsm_t *s, pcf_event_t *e); +void pcf_am_state_operational(ogs_fsm_t *s, pcf_event_t *e); +void pcf_am_state_exception(ogs_fsm_t *s, pcf_event_t *e); + +void pcf_sm_state_initial(ogs_fsm_t *s, pcf_event_t *e); +void pcf_sm_state_final(ogs_fsm_t *s, pcf_event_t *e); +void pcf_sm_state_operational(ogs_fsm_t *s, pcf_event_t *e); +void pcf_sm_state_exception(ogs_fsm_t *s, pcf_event_t *e); + +#define pcf_sm_debug(__pe) \ + ogs_debug("%s(): %s", __func__, pcf_event_get_name(__pe)) + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_SM_H */ diff --git a/src/pcf/sbi-path.c b/src/pcf/sbi-path.c new file mode 100644 index 000000000..21a28d7cd --- /dev/null +++ b/src/pcf/sbi-path.c @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sbi-path.h" + +static int server_cb(ogs_sbi_request_t *request, void *data) +{ + pcf_event_t *e = NULL; + int rv; + + ogs_assert(request); + ogs_assert(data); + + e = pcf_event_new(PCF_EVT_SBI_SERVER); + ogs_assert(e); + + e->sbi.request = request; + e->sbi.data = data; + + rv = ogs_queue_push(ogs_app()->queue, e); + if (rv != OGS_OK) { + ogs_warn("ogs_queue_push() failed:%d", (int)rv); + pcf_event_free(e); + return OGS_ERROR; + } + + return OGS_OK; +} + +static int client_cb(ogs_sbi_response_t *response, void *data) +{ + pcf_event_t *e = NULL; + int rv; + + ogs_assert(response); + + e = pcf_event_new(PCF_EVT_SBI_CLIENT); + ogs_assert(e); + e->sbi.response = response; + e->sbi.data = data; + + rv = ogs_queue_push(ogs_app()->queue, e); + if (rv != OGS_OK) { + ogs_warn("ogs_queue_push() failed:%d", (int)rv); + pcf_event_free(e); + return OGS_ERROR; + } + + return OGS_OK; +} + +int pcf_sbi_open(void) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_sbi_server_start_all(server_cb); + + /* + * The connection between NF and NRF is a little special. + * + * NF and NRF share nf_instance. I get the NRF EndPoint(client) information + * the configuration file via lib/sbi/context.c. + * And, the NFService information will be transmitted to NRF. + * + * ogs_sbi_self()->nf_instance_id means NF's InstanceId. + */ + ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { + ogs_sbi_nf_service_t *service = NULL; + ogs_sbi_client_t *client = NULL; + + /* Build NF instance information. It will be transmitted to NRF. */ + ogs_sbi_nf_instance_build_default(nf_instance, pcf_self()->nf_type); + + /* Build NF service information. It will be transmitted to NRF. */ + service = ogs_sbi_nf_service_build_default(nf_instance, + (char*)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL); + ogs_assert(service); + ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, + (char*)OGS_SBI_API_V1_0_0, NULL); + + service = ogs_sbi_nf_service_build_default(nf_instance, + (char*)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL); + ogs_assert(service); + ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, + (char*)OGS_SBI_API_V1_0_0, NULL); + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + pcf_nf_fsm_init(nf_instance); + } + + return OGS_OK; +} + +void pcf_sbi_close(void) +{ + ogs_sbi_server_stop_all(); +} + +void pcf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +{ + ogs_sbi_send(nf_instance, client_cb, xact); +} + +static bool pcf_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, + ogs_sbi_object_t *sbi_object, ogs_sbi_stream_t *stream, void *data, + ogs_sbi_build_f build) +{ + ogs_sbi_xact_t *xact = NULL; + + ogs_assert(target_nf_type); + ogs_assert(sbi_object); + ogs_assert(stream); + ogs_assert(build); + + xact = ogs_sbi_xact_add(target_nf_type, sbi_object, data, + build, pcf_timer_sbi_client_wait_expire); + ogs_assert(xact); + + xact->assoc_stream = stream; + + return ogs_sbi_discover_and_send(xact, + (ogs_fsm_handler_t)pcf_nf_state_registered, client_cb); +} + +void pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, + pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data, + ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data)) +{ + if (pcf_sbi_discover_and_send( + target_nf_type, &pcf_ue->sbi, stream, data, + (ogs_sbi_build_f)build) != true) { + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL, + "Cannot discover", pcf_ue->supi); + } +} + +void pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, + pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data, + ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data)) +{ + if (pcf_sbi_discover_and_send( + target_nf_type, &sess->sbi, stream, data, + (ogs_sbi_build_f)build) != true) { + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL, + "Cannot discover", NULL); + } +} diff --git a/src/pcf/sbi-path.h b/src/pcf/sbi-path.h new file mode 100644 index 000000000..ccb2cc53f --- /dev/null +++ b/src/pcf/sbi-path.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_SBI_PATH_H +#define PCF_SBI_PATH_H + +#include "nudr-build.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if 0 +#include "nudr-build.h" +#endif + +int pcf_sbi_open(void); +void pcf_sbi_close(void); + +void pcf_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); +void pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, + pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data, + ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data)); +void pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, + pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data, + ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data)); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_SBI_PATH_H */ diff --git a/src/pcf/sm-sm.c b/src/pcf/sm-sm.c new file mode 100644 index 000000000..05720d6a1 --- /dev/null +++ b/src/pcf/sm-sm.c @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sbi-path.h" +#include "nnrf-handler.h" + +#include "npcf-handler.h" +#include "nudr-handler.h" + +void pcf_sm_state_initial(ogs_fsm_t *s, pcf_event_t *e) +{ + ogs_assert(s); + + OGS_FSM_TRAN(s, &pcf_sm_state_operational); +} + +void pcf_sm_state_final(ogs_fsm_t *s, pcf_event_t *e) +{ +} + +void pcf_sm_state_operational(ogs_fsm_t *s, pcf_event_t *e) +{ + bool handled; + pcf_ue_t *pcf_ue = NULL; + pcf_sess_t *sess = NULL; + + ogs_sbi_stream_t *stream = NULL; + ogs_sbi_message_t *message = NULL; + + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + sess = e->sess; + ogs_assert(sess); + pcf_ue = sess->pcf_ue; + ogs_assert(pcf_ue); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + break; + + case OGS_FSM_EXIT_SIG: + break; + + case PCF_EVT_SBI_SERVER: + message = e->sbi.message; + ogs_assert(message); + stream = e->sbi.data; + ogs_assert(stream); + + SWITCH(message->h.method) + CASE(OGS_SBI_HTTP_METHOD_POST) + handled = pcf_npcf_smpolicycontrtol_handle_create( + sess, stream, message); + if (!handled) { + ogs_error("[%s:%d] Cannot handle SBI message", + pcf_ue->supi, sess->psi); + OGS_FSM_TRAN(s, pcf_sm_state_exception); + } + break; + + DEFAULT + ogs_error("[%s:%d] Invalid HTTP method [%s]", + pcf_ue->supi, sess->psi, message->h.method); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_FORBIDDEN, message, + "Invalid HTTP method", message->h.method); + END + break; + + case PCF_EVT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + stream = e->sbi.data; + ogs_assert(stream); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NUDR_DR) + SWITCH(message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA) + SWITCH(message->h.resource.component[1]) + CASE(OGS_SBI_RESOURCE_NAME_UES) + if (message->res_status != OGS_SBI_HTTP_STATUS_OK && + message->res_status != OGS_SBI_HTTP_STATUS_NO_CONTENT) { + if (message->res_status == + OGS_SBI_HTTP_STATUS_NOT_FOUND) { + ogs_warn("[%s:%d] Cannot find SUPI [%d]", + pcf_ue->supi, sess->psi, message->res_status); + } else { + ogs_error("[%s:%d] HTTP response error [%d]", + pcf_ue->supi, sess->psi, message->res_status); + } + ogs_sbi_server_send_error(stream, message->res_status, + NULL, "HTTP response error", pcf_ue->supi); + break; + } + + pcf_nudr_dr_handle_query_sm_data(sess, stream, message); + break; + + DEFAULT + ogs_error("[%s:%d] Invalid resource name [%s]", + pcf_ue->supi, sess->psi, + message->h.resource.component[1]); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("[%s:%d] Invalid resource name [%s]", + pcf_ue->supi, sess->psi, + message->h.resource.component[0]); + ogs_assert_if_reached(); + END + break; + + DEFAULT + ogs_error("[%s:%d] Invalid API name [%s]", + pcf_ue->supi, sess->psi, message->h.service.name); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, message, + "Invalid API name", message->h.resource.component[0]); + END + break; + + default: + ogs_error("[%s:%d] Unknown event %s", + pcf_ue->supi, sess->psi, pcf_event_get_name(e)); + break; + } +} + +void pcf_sm_state_exception(ogs_fsm_t *s, pcf_event_t *e) +{ + pcf_ue_t *pcf_ue = NULL; + pcf_sess_t *sess = NULL; + + ogs_assert(s); + ogs_assert(e); + + pcf_sm_debug(e); + + sess = e->sess; + ogs_assert(sess); + pcf_ue = sess->pcf_ue; + ogs_assert(pcf_ue); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + break; + + case OGS_FSM_EXIT_SIG: + break; + + default: + ogs_error("[%s:%d] Unknown event %s", + pcf_ue->supi, sess->psi, pcf_event_get_name(e)); + break; + } +} diff --git a/src/pcf/timer.c b/src/pcf/timer.c new file mode 100644 index 000000000..89e81a31a --- /dev/null +++ b/src/pcf/timer.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "context.h" + +const char *pcf_timer_get_name(pcf_timer_e id) +{ + switch (id) { + case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + return "PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; + case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + return "PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; + case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: + return "PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; + case PCF_TIMER_NF_INSTANCE_VALIDITY: + return "PCF_TIMER_NF_INSTANCE_VALIDITY"; + case PCF_TIMER_SUBSCRIPTION_VALIDITY: + return "PCF_TIMER_SUBSCRIPTION_VALIDITY"; + case PCF_TIMER_SBI_CLIENT_WAIT: + return "PCF_TIMER_SBI_CLIENT_WAIT"; + default: + break; + } + + return "UNKNOWN_TIMER"; +} + +static void sbi_timer_send_event(int timer_id, void *data) +{ + int rv; + pcf_event_t *e = NULL; + ogs_assert(data); + + switch (timer_id) { + case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case PCF_TIMER_NF_INSTANCE_VALIDITY: + case PCF_TIMER_SUBSCRIPTION_VALIDITY: + case PCF_TIMER_SBI_CLIENT_WAIT: + e = pcf_event_new(PCF_EVT_SBI_TIMER); + ogs_assert(e); + e->timer_id = timer_id; + e->sbi.data = data; + break; + default: + ogs_fatal("Unknown timer id[%d]", timer_id); + ogs_assert_if_reached(); + break; + } + + rv = ogs_queue_push(ogs_app()->queue, e); + if (rv != OGS_OK) { + ogs_warn("ogs_queue_push() failed [%d] in %s", + (int)rv, pcf_timer_get_name(e->timer_id)); + pcf_event_free(e); + } +} + +void pcf_timer_nf_instance_registration_interval(void *data) +{ + sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); +} + +void pcf_timer_nf_instance_heartbeat_interval(void *data) +{ + sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); +} + +void pcf_timer_nf_instance_no_heartbeat(void *data) +{ + sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); +} + +void pcf_timer_nf_instance_validity(void *data) +{ + sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_VALIDITY, data); +} + +void pcf_timer_subscription_validity(void *data) +{ + sbi_timer_send_event(PCF_TIMER_SUBSCRIPTION_VALIDITY, data); +} + +void pcf_timer_sbi_client_wait_expire(void *data) +{ + sbi_timer_send_event(PCF_TIMER_SBI_CLIENT_WAIT, data); +} diff --git a/src/pcf/timer.h b/src/pcf/timer.h new file mode 100644 index 000000000..122315ada --- /dev/null +++ b/src/pcf/timer.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PCF_TIMER_H +#define PCF_TIMER_H + +#include "ogs-core.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* forward declaration */ +typedef enum { + PCF_TIMER_BASE = 0, + + PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, + PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, + PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT, + PCF_TIMER_NF_INSTANCE_VALIDITY, + PCF_TIMER_SUBSCRIPTION_VALIDITY, + PCF_TIMER_SBI_CLIENT_WAIT, + + MAX_NUM_OF_PCF_TIMER, + +} pcf_timer_e; + +const char *pcf_timer_get_name(pcf_timer_e id); + +void pcf_timer_nf_instance_registration_interval(void *data); +void pcf_timer_nf_instance_heartbeat_interval(void *data); +void pcf_timer_nf_instance_no_heartbeat(void *data); +void pcf_timer_nf_instance_validity(void *data); +void pcf_timer_subscription_validity(void *data); +void pcf_timer_sbi_client_wait_expire(void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* PCF_TIMER_H */ diff --git a/src/smf/context.c b/src/smf/context.c index 95876324c..f1932e861 100644 --- a/src/smf/context.c +++ b/src/smf/context.c @@ -1060,6 +1060,9 @@ void smf_sess_remove(smf_sess_t *sess) if (sess->namf.client) ogs_sbi_client_remove(sess->namf.client); + if (sess->policy_association_id) + ogs_free(sess->policy_association_id); + if (sess->dnn) ogs_free(sess->dnn); diff --git a/src/smf/context.h b/src/smf/context.h index a2192fbb7..f8a2d28d6 100644 --- a/src/smf/context.h +++ b/src/smf/context.h @@ -224,6 +224,10 @@ typedef struct smf_sess_s { ogs_sbi_client_t *client; } namf; + /* PCF sends the RESPONSE + * of [POST] /npcf-smpolocycontrol/v1/policies */ + char *policy_association_id; + /* PLMN ID & NID */ ogs_plmn_id_t plmn_id; diff --git a/src/smf/gsm-sm.c b/src/smf/gsm-sm.c index 31eef44ad..ba618bfa0 100644 --- a/src/smf/gsm-sm.c +++ b/src/smf/gsm-sm.c @@ -21,6 +21,7 @@ #include "nnrf-handler.h" #include "nsmf-handler.h" #include "nudm-handler.h" +#include "npcf-handler.h" #include "gsm-handler.h" #include "ngap-handler.h" #include "pfcp-path.h" @@ -110,11 +111,14 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e) SWITCH(sbi_message->h.resource.component[1]) CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) if (sbi_message->res_status != OGS_SBI_HTTP_STATUS_OK) { - ogs_error("[%s] HTTP response error [%d]", - smf_ue->supi, sbi_message->res_status); - ogs_sbi_server_send_error( - stream, sbi_message->res_status, - NULL, "HTTP response error", smf_ue->supi); + strerror = ogs_msprintf("[%s:%d] HTTP response error [%d]", + smf_ue->supi, sess->psi, sbi_message->res_status); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, sbi_message->res_status, + sbi_message, strerror, NULL); + ogs_free(strerror); break; } @@ -127,12 +131,49 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e) break; DEFAULT - ogs_error("Invalid resource name [%s]", + strerror = ogs_msprintf("[%s:%d] Invalid resource name [%s]", + smf_ue->supi, sess->psi, sbi_message->h.resource.component[1]); + ogs_assert(strerror); + + ogs_error("%s", strerror); ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, sbi_message, - "Invalid resource name", - sbi_message->h.resource.component[1]); + OGS_SBI_HTTP_STATUS_BAD_REQUEST, + sbi_message, strerror, NULL); + ogs_free(strerror); + END + break; + + CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) + SWITCH(sbi_message->h.resource.component[0]) + CASE(OGS_SBI_RESOURCE_NAME_SM_POLICIES) + if (sbi_message->res_status != OGS_SBI_HTTP_STATUS_CREATED) { + strerror = ogs_msprintf("[%s:%d] HTTP response error [%d]", + smf_ue->supi, sess->psi, sbi_message->res_status); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, sbi_message->res_status, + sbi_message, strerror, NULL); + ogs_free(strerror); + break; + } + + smf_npcf_smpolicycontrol_handle_create( + sess, stream, sbi_message); + break; + + DEFAULT + strerror = ogs_msprintf("[%s:%d] Invalid resource name [%s]", + smf_ue->supi, sess->psi, + sbi_message->h.resource.component[0]); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, + sbi_message, strerror, NULL); + ogs_free(strerror); END break; @@ -141,22 +182,23 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e) CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXTS) if (sbi_message->res_status != OGS_SBI_HTTP_STATUS_OK && sbi_message->res_status != OGS_SBI_HTTP_STATUS_ACCEPTED) { - ogs_error("[%s] HTTP response error [%d]", - smf_ue->supi, sbi_message->res_status); + ogs_error("[%s:%d] HTTP response error [%d]", + smf_ue->supi, sess->psi, sbi_message->res_status); break; } - break; DEFAULT - ogs_error("Invalid resource name [%s]", + ogs_error("[%s:%d] Invalid resource name [%s]", + smf_ue->supi, sess->psi, sbi_message->h.resource.component[0]); ogs_assert_if_reached(); END break; DEFAULT - ogs_error("Invalid API name [%s]", sbi_message->h.service.name); + ogs_error("[%s:%d] Invalid API name [%s]", + smf_ue->supi, sess->psi, sbi_message->h.service.name); END break; @@ -211,6 +253,7 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e) strerror = ogs_msprintf("Unknown message [%d]", nas_message->gsm.h.message_type); ogs_assert(strerror); + ogs_error("%s", strerror); ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, NULL, strerror, NULL); diff --git a/src/smf/meson.build b/src/smf/meson.build index 2ffa5ed32..4baccac6a 100644 --- a/src/smf/meson.build +++ b/src/smf/meson.build @@ -49,6 +49,8 @@ libsmf_sources = files(''' nudm-handler.h nsmf-handler.h namf-build.h + npcf-build.h + npcf-handler.h sbi-path.h gsm-build.h gsm-handler.h @@ -79,6 +81,8 @@ libsmf_sources = files(''' nudm-handler.c nsmf-handler.c namf-build.c + npcf-build.c + npcf-handler.c sbi-path.c gsm-build.c gsm-handler.c diff --git a/src/smf/npcf-build.c b/src/smf/npcf-build.c new file mode 100644 index 000000000..99756fb6d --- /dev/null +++ b/src/smf/npcf-build.c @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "npcf-build.h" + +ogs_sbi_request_t *smf_npcf_smpolicycontrol_build_create( + smf_sess_t *sess, void *data) +{ + smf_ue_t *smf_ue = NULL; + + ogs_sbi_message_t message; + ogs_sbi_header_t header; + ogs_sbi_request_t *request = NULL; + ogs_sbi_server_t *server = NULL; + + OpenAPI_sm_policy_context_data_t SmPolicyContextData; + OpenAPI_snssai_t sNssai; + + ogs_assert(sess); + ogs_assert(sess->sm_context_ref); + smf_ue = sess->smf_ue; + ogs_assert(smf_ue); + + memset(&message, 0, sizeof(message)); + message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; + message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL; + message.h.api.version = (char *)OGS_SBI_API_V1; + message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_SM_POLICIES; + + memset(&SmPolicyContextData, 0, sizeof(SmPolicyContextData)); + + ogs_assert(smf_ue->supi); + SmPolicyContextData.supi = smf_ue->supi; + ogs_assert(sess->psi); + SmPolicyContextData.pdu_session_id = sess->psi; + ogs_assert(sess->pdn.pdn_type); + SmPolicyContextData.pdu_session_type = sess->pdn.pdn_type; + ogs_assert(sess->dnn); + SmPolicyContextData.dnn = sess->dnn; + + memset(&sNssai, 0, sizeof(sNssai)); + sNssai.sst = sess->s_nssai.sst; + sNssai.sd = ogs_s_nssai_sd_to_string(sess->s_nssai.sd); + SmPolicyContextData.slice_info = &sNssai; + + server = ogs_list_first(&ogs_sbi_self()->server_list); + ogs_assert(server); + + memset(&header, 0, sizeof(header)); + header.service.name = (char *)OGS_SBI_SERVICE_NAME_NSMF_CALLBACK; + header.api.version = (char *)OGS_SBI_API_V1; + header.resource.component[0] = + (char *)OGS_SBI_RESOURCE_NAME_SM_POLICY_NOTIFY; + header.resource.component[1] = sess->sm_context_ref; + SmPolicyContextData.notification_uri = ogs_sbi_server_uri(server, &header); + ogs_assert(SmPolicyContextData.notification_uri); + + message.SmPolicyContextData = &SmPolicyContextData; + + request = ogs_sbi_build_request(&message); + ogs_assert(request); + + ogs_free(SmPolicyContextData.notification_uri); + if (SmPolicyContextData.gpsi) + ogs_free(SmPolicyContextData.gpsi); + + if (sNssai.sd) + ogs_free(sNssai.sd); + + return request; +} diff --git a/src/smf/npcf-build.h b/src/smf/npcf-build.h new file mode 100644 index 000000000..c9a39c552 --- /dev/null +++ b/src/smf/npcf-build.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SMF_NPCF_BUILD_H +#define SMF_NPCF_BUILD_H + +#include "context.h" + +#ifdef __cplusplus +extern "C" { +#endif + +ogs_sbi_request_t *smf_npcf_smpolicycontrol_build_create( + smf_sess_t *sess, void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* SMF_NPCF_BUILD_H */ diff --git a/src/smf/npcf-handler.c b/src/smf/npcf-handler.c new file mode 100644 index 000000000..816b23806 --- /dev/null +++ b/src/smf/npcf-handler.c @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "npcf-handler.h" + +#include "sbi-path.h" +#include "pfcp-path.h" +#include "nas-path.h" + +bool smf_npcf_smpolicycontrol_handle_create( + smf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) +{ + int rv; + char buf1[OGS_ADDRSTRLEN]; + char buf2[OGS_ADDRSTRLEN]; + + char *strerror = NULL; + smf_ue_t *smf_ue = NULL; + + smf_bearer_t *qos_flow = NULL; + ogs_pfcp_gtpu_resource_t *resource = NULL; + ogs_pfcp_pdr_t *dl_pdr = NULL; + ogs_pfcp_pdr_t *ul_pdr = NULL; + ogs_pfcp_qer_t *qer = NULL; + + OpenAPI_sm_policy_decision_t *SmPolicyDecision = NULL; + + ogs_sbi_message_t message; + ogs_sbi_header_t header; + + ogs_assert(sess); + ogs_assert(stream); + smf_ue = sess->smf_ue; + ogs_assert(smf_ue); + + ogs_assert(recvmsg); + + if (!recvmsg->http.location) { + strerror = ogs_msprintf("[%s:%d] No http.location", + smf_ue->supi, sess->psi); + goto cleanup; + } + + SmPolicyDecision = recvmsg->SmPolicyDecision; + if (!SmPolicyDecision) { + strerror = ogs_msprintf("[%s:%d] No SmPolicyDecision", + smf_ue->supi, sess->psi); + goto cleanup; + } + + memset(&header, 0, sizeof(header)); + header.uri = recvmsg->http.location; + + rv = ogs_sbi_parse_header(&message, &header); + if (rv != OGS_OK) { + strerror = ogs_msprintf("[%s:%d] Cannot parse http.location [%s]", + smf_ue->supi, sess->psi, recvmsg->http.location); + goto cleanup; + } + + if (!message.h.resource.component[1]) { + strerror = ogs_msprintf("[%s:%d] No Assocication ID [%s]", + smf_ue->supi, sess->psi, recvmsg->http.location); + + ogs_sbi_header_free(&header); + goto cleanup; + } + + if (sess->policy_association_id) + ogs_free(sess->policy_association_id); + sess->policy_association_id = ogs_strdup(message.h.resource.component[1]); + + ogs_sbi_header_free(&header); + + /********************************************************************* + * Send PFCP Session Establiashment Request to the UPF + *********************************************************************/ + + /* Select UPF based on UE Location Information */ + smf_sess_select_upf(sess); + + /* Check if selected UPF is associated with SMF */ + ogs_assert(sess->pfcp_node); + if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated)) { + ogs_error("[%s] No associated UPF", smf_ue->supi); + return false; + } + + /* Remove all previous QoS flow */ + smf_bearer_remove_all(sess); + + /* Setup Default QoS flow */ + qos_flow = smf_qos_flow_add(sess); + ogs_assert(qos_flow); + + /* Setup QER */ + qer = qos_flow->qer; + ogs_assert(qer); + qer->mbr.uplink = sess->pdn.ambr.uplink; + qer->mbr.downlink = sess->pdn.ambr.downlink; + + /* Setup PDR */ + dl_pdr = qos_flow->dl_pdr; + ogs_assert(dl_pdr); + ul_pdr = qos_flow->ul_pdr; + ogs_assert(ul_pdr); + + /* Set UE IP Address to the Default DL PDR */ + smf_sess_set_ue_ip(sess); + + ogs_pfcp_paa_to_ue_ip_addr(&sess->pdn.paa, + &dl_pdr->ue_ip_addr, &dl_pdr->ue_ip_addr_len); + dl_pdr->ue_ip_addr.sd = OGS_PFCP_UE_IP_DST; + + ogs_info("UE SUPI:[%s] DNN:[%s] IPv4:[%s] IPv6:[%s]", + smf_ue->supi, sess->pdn.dnn, + sess->ipv4 ? OGS_INET_NTOP(&sess->ipv4->addr, buf1) : "", + sess->ipv6 ? OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : ""); + + /* Set UPF-N3 TEID & ADDR to the Default UL PDR */ + if (sess->pfcp_node->up_function_features.ftup) { + ul_pdr->f_teid.ch = 1; + ul_pdr->f_teid_len = 1; + } else { + resource = ogs_pfcp_gtpu_resource_find( + &sess->pfcp_node->gtpu_resource_list, + sess->pdn.dnn, OGS_PFCP_INTERFACE_ACCESS); + if (resource) { + ogs_pfcp_user_plane_ip_resource_info_to_sockaddr(&resource->info, + &sess->upf_n3_addr, &sess->upf_n3_addr6); + if (resource->info.teidri) + sess->upf_n3_teid = OGS_PFCP_GTPU_INDEX_TO_TEID( + sess->index, resource->info.teidri, + resource->info.teid_range); + else + sess->upf_n3_teid = sess->index; + } else { + if (sess->pfcp_node->addr.ogs_sa_family == AF_INET) + ogs_copyaddrinfo(&sess->upf_n3_addr, &sess->pfcp_node->addr); + else if (sess->pfcp_node->addr.ogs_sa_family == AF_INET6) + ogs_copyaddrinfo(&sess->upf_n3_addr6, &sess->pfcp_node->addr); + else + ogs_assert_if_reached(); + + sess->upf_n3_teid = sess->index; + } + + ogs_assert(sess->upf_n3_addr || sess->upf_n3_addr6); + ogs_pfcp_sockaddr_to_f_teid(sess->upf_n3_addr, sess->upf_n3_addr6, + &ul_pdr->f_teid, &ul_pdr->f_teid_len); + ul_pdr->f_teid.teid = sess->upf_n3_teid; + } + + /* Default PDRs is set to lowest precedence(highest precedence value) */ + dl_pdr->precedence = 0xffffffff; + ul_pdr->precedence = 0xffffffff; + + smf_5gc_pfcp_send_session_establishment_request(sess, stream); + + return true; + +cleanup: + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, strerror, NULL); + ogs_free(strerror); + + return false; +} diff --git a/src/smf/npcf-handler.h b/src/smf/npcf-handler.h new file mode 100644 index 000000000..56c271915 --- /dev/null +++ b/src/smf/npcf-handler.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * This file is part of Open5GS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SMF_NPCF_HANDLER_H +#define SMF_NPCF_HANDLER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "context.h" + +bool smf_npcf_smpolicycontrol_handle_create( + smf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); + +#ifdef __cplusplus +} +#endif + +#endif /* SMF_NPCF_HANDLER_H */ diff --git a/src/smf/nsmf-handler.c b/src/smf/nsmf-handler.c index e562a8671..e9fcdbe81 100644 --- a/src/smf/nsmf-handler.c +++ b/src/smf/nsmf-handler.c @@ -434,11 +434,14 @@ bool smf_nsmf_handle_update_sm_context( char *strerror = ogs_msprintf("[%s:%d] Invalid upCnxState [%d]", smf_ue->supi, sess->psi, SmContextUpdateData->up_cnx_state); + ogs_assert(strerror); + ogs_error("%s", strerror); smf_sbi_send_sm_context_update_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, strerror, NULL, NULL, NULL); ogs_free(strerror); + return false; } } diff --git a/src/smf/nudm-build.c b/src/smf/nudm-build.c index 91038ab28..ac574401f 100644 --- a/src/smf/nudm-build.c +++ b/src/smf/nudm-build.c @@ -37,8 +37,9 @@ ogs_sbi_request_t *smf_nudm_sdm_build_get(smf_sess_t *sess, void *data) message.h.resource.component[0] = smf_ue->supi; message.h.resource.component[1] = data; - message.param.s_nssai_presence = true; - memcpy(&message.param.s_nssai, &sess->s_nssai, sizeof(sess->s_nssai)); + message.param.single_nssai_presence = true; + memcpy(&message.param.single_nssai, &sess->s_nssai, + sizeof(message.param.single_nssai)); if (sess->dnn) message.param.dnn = sess->dnn; diff --git a/src/smf/nudm-handler.c b/src/smf/nudm-handler.c index 6086522e6..ee997f385 100644 --- a/src/smf/nudm-handler.c +++ b/src/smf/nudm-handler.c @@ -18,29 +18,21 @@ */ #include "nudm-handler.h" -#include "pfcp-path.h" +#include "sbi-path.h" bool smf_nudm_sdm_handle_get(smf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { - char buf1[OGS_ADDRSTRLEN]; - char buf2[OGS_ADDRSTRLEN]; - + char *strerror = NULL; smf_ue_t *smf_ue = NULL; - smf_bearer_t *qos_flow = NULL; - ogs_pfcp_gtpu_resource_t *resource = NULL; - ogs_pfcp_pdr_t *dl_pdr = NULL; - ogs_pfcp_pdr_t *ul_pdr = NULL; - ogs_pfcp_qer_t *qer = NULL; + OpenAPI_sm_context_created_data_t SmContextCreatedData; ogs_sbi_server_t *server = NULL; - - ogs_sbi_message_t sendmsg; ogs_sbi_header_t header; + ogs_sbi_message_t sendmsg; ogs_sbi_response_t *response = NULL; - OpenAPI_sm_context_created_data_t SmContextCreatedData; OpenAPI_session_management_subscription_data_t *SessionManagementSubscriptionData = NULL; OpenAPI_list_t *dnnConfigurationList = NULL; @@ -66,15 +58,17 @@ bool smf_nudm_sdm_handle_get(smf_sess_t *sess, ogs_sbi_stream_t *stream, SessionManagementSubscriptionData = recvmsg->SessionManagementSubscriptionData; if (!SessionManagementSubscriptionData) { - ogs_error("[%s] No SessionManagementSubscriptionData", smf_ue->supi); - return false; + strerror = ogs_msprintf("[%s:%d] No SessionManagementSubscriptionData", + smf_ue->supi, sess->psi); + goto cleanup; } dnnConfigurationList = SessionManagementSubscriptionData->dnn_configurations; if (!dnnConfigurationList) { - ogs_error("[%s] No dnnConfigurations", smf_ue->supi); - return false; + strerror = ogs_msprintf("[%s:%d] No dnnConfigurations", + smf_ue->supi, sess->psi); + goto cleanup; } OpenAPI_list_for_each(dnnConfigurationList, node) { @@ -222,17 +216,8 @@ bool smf_nudm_sdm_handle_get(smf_sess_t *sess, ogs_sbi_stream_t *stream, } if (!strlen(sess->pdn.dnn)) { - ogs_error("[%s] No dnnConfiguration", smf_ue->supi); - return false; - } - - /* Select UPF based on UE Location Information */ - smf_sess_select_upf(sess); - - /* Check if selected UPF is associated with SMF */ - ogs_assert(sess->pfcp_node); - if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated)) { - ogs_error("[%s] No associated UPF", smf_ue->supi); + strerror = ogs_msprintf("[%s:%d] No dnnConfiguration", + smf_ue->supi, sess->psi); return false; } @@ -261,80 +246,18 @@ bool smf_nudm_sdm_handle_get(smf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_free(sendmsg.http.location); - /********************************************************************* - * Send PFCP Session Establiashment Request to the UPF - *********************************************************************/ - - /* Remove all previous QoS flow */ - smf_bearer_remove_all(sess); - - /* Setup Default QoS flow */ - qos_flow = smf_qos_flow_add(sess); - ogs_assert(qos_flow); - - /* Setup QER */ - qer = qos_flow->qer; - ogs_assert(qer); - qer->mbr.uplink = sess->pdn.ambr.uplink; - qer->mbr.downlink = sess->pdn.ambr.downlink; - - /* Setup PDR */ - dl_pdr = qos_flow->dl_pdr; - ogs_assert(dl_pdr); - ul_pdr = qos_flow->ul_pdr; - ogs_assert(ul_pdr); - - /* Set UE IP Address to the Default DL PDR */ - smf_sess_set_ue_ip(sess); - - ogs_pfcp_paa_to_ue_ip_addr(&sess->pdn.paa, - &dl_pdr->ue_ip_addr, &dl_pdr->ue_ip_addr_len); - dl_pdr->ue_ip_addr.sd = OGS_PFCP_UE_IP_DST; - - ogs_info("UE SUPI:[%s] DNN:[%s] IPv4:[%s] IPv6:[%s]", - smf_ue->supi, sess->pdn.dnn, - sess->ipv4 ? OGS_INET_NTOP(&sess->ipv4->addr, buf1) : "", - sess->ipv6 ? OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : ""); - - /* Set UPF-N3 TEID & ADDR to the Default UL PDR */ - if (sess->pfcp_node->up_function_features.ftup) { - ul_pdr->f_teid.ch = 1; - ul_pdr->f_teid_len = 1; - } else { - resource = ogs_pfcp_gtpu_resource_find( - &sess->pfcp_node->gtpu_resource_list, - sess->pdn.dnn, OGS_PFCP_INTERFACE_ACCESS); - if (resource) { - ogs_pfcp_user_plane_ip_resource_info_to_sockaddr(&resource->info, - &sess->upf_n3_addr, &sess->upf_n3_addr6); - if (resource->info.teidri) - sess->upf_n3_teid = OGS_PFCP_GTPU_INDEX_TO_TEID( - sess->index, resource->info.teidri, - resource->info.teid_range); - else - sess->upf_n3_teid = sess->index; - } else { - if (sess->pfcp_node->addr.ogs_sa_family == AF_INET) - ogs_copyaddrinfo(&sess->upf_n3_addr, &sess->pfcp_node->addr); - else if (sess->pfcp_node->addr.ogs_sa_family == AF_INET6) - ogs_copyaddrinfo(&sess->upf_n3_addr6, &sess->pfcp_node->addr); - else - ogs_assert_if_reached(); - - sess->upf_n3_teid = sess->index; - } - - ogs_assert(sess->upf_n3_addr || sess->upf_n3_addr6); - ogs_pfcp_sockaddr_to_f_teid(sess->upf_n3_addr, sess->upf_n3_addr6, - &ul_pdr->f_teid, &ul_pdr->f_teid_len); - ul_pdr->f_teid.teid = sess->upf_n3_teid; - } - - /* Default PDRs is set to lowest precedence(highest precedence value) */ - dl_pdr->precedence = 0xffffffff; - ul_pdr->precedence = 0xffffffff; - - smf_5gc_pfcp_send_session_establishment_request(sess, stream); + smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, sess, stream, NULL, + smf_npcf_smpolicycontrol_build_create); return true; + +cleanup: + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, strerror, NULL); + ogs_free(strerror); + + return false; } diff --git a/src/smf/pfcp-path.c b/src/smf/pfcp-path.c index 54e0c451b..1720a0386 100644 --- a/src/smf/pfcp-path.c +++ b/src/smf/pfcp-path.c @@ -202,13 +202,20 @@ static void sess_5gc_timeout(ogs_pfcp_xact_t *xact, void *data) case OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE: strerror = ogs_msprintf("[%s:%d] No PFCP session modification response", smf_ue->supi, sess->psi); + ogs_assert(strerror); + + ogs_error("%s", strerror); smf_sbi_send_sm_context_update_error(stream, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, strerror, NULL, NULL, NULL); + ogs_free(strerror); break; case OGS_PFCP_SESSION_DELETION_REQUEST_TYPE: strerror = ogs_msprintf("[%s:%d] No PFCP session deletion response", smf_ue->supi, sess->psi); + ogs_assert(strerror); + + ogs_error("%s", strerror); ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL, strerror, NULL); ogs_free(strerror); diff --git a/src/smf/sbi-path.h b/src/smf/sbi-path.h index 7a0681dd1..9f5155d02 100644 --- a/src/smf/sbi-path.h +++ b/src/smf/sbi-path.h @@ -24,6 +24,7 @@ #include "namf-build.h" #include "gsm-build.h" #include "nnrf-build.h" +#include "npcf-build.h" #ifdef __cplusplus extern "C" { diff --git a/src/smf/smf-sm.c b/src/smf/smf-sm.c index f6cf6de60..f34418e4c 100644 --- a/src/smf/smf-sm.c +++ b/src/smf/smf-sm.c @@ -387,6 +387,21 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e) END break; + CASE(OGS_SBI_SERVICE_NAME_NSMF_CALLBACK) + SWITCH(sbi_message.h.resource.component[1]) + CASE(OGS_SBI_RESOURCE_NAME_SM_POLICY_NOTIFY) + /* TODO */ + + DEFAULT + ogs_error("Invalid resource name [%s]", + sbi_message.h.resource.component[1]); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, &sbi_message, + "Invalid resource name", + sbi_message.h.resource.component[1]); + END + break; + DEFAULT ogs_error("Invalid API name [%s]", sbi_message.h.service.name); ogs_sbi_server_send_error(stream, @@ -508,6 +523,7 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e) break; CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM) + CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) CASE(OGS_SBI_SERVICE_NAME_NAMF_COMM) sbi_xact = e->sbi.data; ogs_assert(sbi_xact); diff --git a/src/udm/context.c b/src/udm/context.c index 5226e1d76..225ac84d2 100644 --- a/src/udm/context.c +++ b/src/udm/context.c @@ -36,7 +36,6 @@ 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_app()->max.ue); ogs_list_init(&self.udm_ue_list); diff --git a/src/udm/context.h b/src/udm/context.h index 6647ec08a..bd379cb75 100644 --- a/src/udm/context.h +++ b/src/udm/context.h @@ -73,6 +73,7 @@ struct udm_ue_s { ogs_guami_t guami; OpenAPI_auth_type_e auth_type; + OpenAPI_rat_type_e rat_type; #define UDM_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ do { \ diff --git a/src/udm/nudm-handler.c b/src/udm/nudm-handler.c index 67c8170d0..8b0c0d1d2 100644 --- a/src/udm/nudm-handler.c +++ b/src/udm/nudm-handler.c @@ -162,17 +162,55 @@ bool udm_nudm_ueau_handle_get( bool udm_nudm_ueau_handle_result_confirmation_inform( udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, ogs_sbi_message_t *message) { + OpenAPI_auth_event_t *AuthEvent = NULL; + ogs_assert(udm_ue); ogs_assert(stream); ogs_assert(message); - if (!message->AuthEvent) { + AuthEvent = message->AuthEvent; + if (!AuthEvent) { ogs_error("[%s] No AuthEvent", udm_ue->suci); ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, message, "No AuthEvent", udm_ue->suci); return false; } + if (!AuthEvent->nf_instance_id) { + ogs_error("[%s] No nfInstanceId", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No nfInstanceId", udm_ue->suci); + return false; + } + + if (!AuthEvent->success) { + ogs_error("[%s] No success", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No success", udm_ue->suci); + return false; + } + + if (!AuthEvent->time_stamp) { + ogs_error("[%s] No timeStamp", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No timeStamp", udm_ue->suci); + return false; + } + + if (!AuthEvent->auth_type) { + ogs_error("[%s] No authType", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No authType", udm_ue->suci); + return false; + } + + if (!AuthEvent->serving_network_name) { + ogs_error("[%s] No servingNetworkName", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No servingNetworkName", udm_ue->suci); + return false; + } + udm_ue->auth_event = OpenAPI_auth_event_copy( udm_ue->auth_event, message->AuthEvent); @@ -243,6 +281,13 @@ bool udm_nudm_uecm_handle_registration( return false; } + if (!Amf3GppAccessRegistration->rat_type) { + ogs_error("[%s] No RatType", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + message, "No RatType", udm_ue->supi); + return false; + } + if (udm_ue->dereg_callback_uri) ogs_free(udm_ue->dereg_callback_uri); udm_ue->dereg_callback_uri = ogs_strdup( @@ -250,6 +295,8 @@ bool udm_nudm_uecm_handle_registration( ogs_sbi_parse_guami(&udm_ue->guami, Guami); + udm_ue->rat_type = Amf3GppAccessRegistration->rat_type; + udm_ue->amf_3gpp_access_registration = OpenAPI_amf3_gpp_access_registration_copy( udm_ue->amf_3gpp_access_registration, @@ -273,7 +320,12 @@ bool udm_nudm_sdm_handle_subscription_provisioned( SWITCH(recvmsg->h.resource.component[1]) CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) + OpenAPI_ue_context_in_smf_data_t UeContextInSmfData; + + memset(&UeContextInSmfData, 0, sizeof(UeContextInSmfData)); + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.UeContextInSmfData = &UeContextInSmfData; response = ogs_sbi_build_response(&sendmsg, OGS_SBI_HTTP_STATUS_OK); ogs_assert(response); diff --git a/src/udm/nudr-build.c b/src/udm/nudr-build.c index 7d481224f..e3040fe37 100644 --- a/src/udm/nudr-build.c +++ b/src/udm/nudr-build.c @@ -171,10 +171,10 @@ ogs_sbi_request_t *udm_nudr_dr_build_query_subscription_provisioned( CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) if (recvmsg->param.dnn) sendmsg.param.dnn = recvmsg->param.dnn; - if (recvmsg->param.s_nssai_presence) { - sendmsg.param.s_nssai_presence = true; - memcpy(&sendmsg.param.s_nssai, - &recvmsg->param.s_nssai, sizeof(recvmsg->param.s_nssai)); + if (recvmsg->param.single_nssai_presence) { + sendmsg.param.single_nssai_presence = true; + memcpy(&sendmsg.param.single_nssai, &recvmsg->param.single_nssai, + sizeof(sendmsg.param.single_nssai)); } DEFAULT END diff --git a/src/udm/nudr-handler.c b/src/udm/nudr-handler.c index 586da99f4..c2df36a0f 100644 --- a/src/udm/nudr-handler.c +++ b/src/udm/nudr-handler.c @@ -22,6 +22,7 @@ bool udm_nudr_dr_handle_subscription_authentication( udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { + char *strerror = NULL; ogs_sbi_server_t *server = NULL; ogs_sbi_message_t sendmsg; @@ -69,6 +70,20 @@ bool udm_nudr_dr_handle_subscription_authentication( CASE(OGS_SBI_RESOURCE_NAME_AUTHENTICATION_SUBSCRIPTION) SWITCH(recvmsg->h.method) CASE(OGS_SBI_HTTP_METHOD_GET) + if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_OK) { + strerror = ogs_msprintf("[%s] HTTP response error [%d]", + udm_ue->suci, recvmsg->res_status); + ogs_assert(strerror); + + if (recvmsg->res_status == OGS_SBI_HTTP_STATUS_NOT_FOUND) + ogs_warn("%s", strerror); + else + ogs_error("%s", strerror); + ogs_sbi_server_send_error( + stream, recvmsg->res_status, recvmsg, strerror, NULL); + ogs_free(strerror); + return false; + } AuthenticationSubscription = recvmsg->AuthenticationSubscription; if (!AuthenticationSubscription) { @@ -149,6 +164,18 @@ bool udm_nudr_dr_handle_subscription_authentication( udm_ue->sqn, sizeof(udm_ue->sqn)); CASE(OGS_SBI_HTTP_METHOD_PATCH) + if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_OK && + recvmsg->res_status != OGS_SBI_HTTP_STATUS_NO_CONTENT) { + strerror = ogs_msprintf("[%s] HTTP response error [%d]", + udm_ue->suci, recvmsg->res_status); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error( + stream, recvmsg->res_status, recvmsg, strerror, NULL); + ogs_free(strerror); + return false; + } memset(&AuthenticationInfoResult, 0, sizeof(AuthenticationInfoResult)); @@ -207,17 +234,75 @@ bool udm_nudr_dr_handle_subscription_authentication( ogs_assert(response); ogs_sbi_server_send_response(stream, response); - return true; + break; DEFAULT ogs_error("Invalid HTTP method [%s]", recvmsg->h.method); ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, recvmsg, "Invalid HTTP method", recvmsg->h.method); + return false; END break; CASE(OGS_SBI_RESOURCE_NAME_AUTHENTICATION_STATUS) + OpenAPI_auth_event_t *AuthEvent = NULL; + + if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_NO_CONTENT) { + strerror = ogs_msprintf("[%s] HTTP response error [%d]", + udm_ue->suci, recvmsg->res_status); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error( + stream, recvmsg->res_status, recvmsg, strerror, NULL); + ogs_free(strerror); + return false; + } + + AuthEvent = udm_ue->auth_event; + if (!AuthEvent) { + ogs_error("[%s] No AuthEvent", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No AuthEvent", udm_ue->suci); + return false; + } + + if (!AuthEvent->nf_instance_id) { + ogs_error("[%s] No nfInstanceId", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No nfInstanceId", udm_ue->suci); + return false; + } + + if (!AuthEvent->success) { + ogs_error("[%s] No success", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No success", udm_ue->suci); + return false; + } + + if (!AuthEvent->time_stamp) { + ogs_error("[%s] No timeStamp", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No timeStamp", udm_ue->suci); + return false; + } + + if (!AuthEvent->auth_type) { + ogs_error("[%s] No authType", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No authType", udm_ue->suci); + return false; + } + + if (!AuthEvent->serving_network_name) { + ogs_error("[%s] No servingNetworkName", udm_ue->suci); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No servingNetworkName", udm_ue->suci); + return false; + } + memset(&sendmsg, 0, sizeof(sendmsg)); memset(&header, 0, sizeof(header)); @@ -239,20 +324,27 @@ bool udm_nudr_dr_handle_subscription_authentication( ogs_free(sendmsg.http.location); OpenAPI_auth_event_free(sendmsg.AuthEvent); - - return true; + break; DEFAULT - ogs_error("Invalid resource name [%s]", - recvmsg->h.resource.component[3]); + strerror = ogs_msprintf("[%s] Invalid resource name [%s]", + udm_ue->supi, recvmsg->h.resource.component[3]); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, strerror, NULL); + ogs_free(strerror); + return false; END - return false; + return true; } bool udm_nudr_dr_handle_subscription_context( udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { + char *strerror = NULL; ogs_sbi_server_t *server = NULL; ogs_sbi_message_t sendmsg; @@ -270,9 +362,19 @@ bool udm_nudr_dr_handle_subscription_context( ogs_assert(recvmsg); + if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_NO_CONTENT) { + ogs_error("[%s] HTTP response error [%d]", + udm_ue->supi, recvmsg->res_status); + ogs_sbi_server_send_error(stream, recvmsg->res_status, + NULL, "HTTP response error", udm_ue->supi); + return false; + } + SWITCH(recvmsg->h.resource.component[3]) CASE(OGS_SBI_RESOURCE_NAME_AMF_3GPP_ACCESS) Amf3GppAccessRegistration = udm_ue->amf_3gpp_access_registration; + OpenAPI_guami_t *Guami = NULL; + if (!Amf3GppAccessRegistration) { ogs_error("[%s] No Amf3GppAccessRegistration", udm_ue->supi); ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, @@ -287,6 +389,56 @@ bool udm_nudr_dr_handle_subscription_context( return false; } + if (!Amf3GppAccessRegistration->dereg_callback_uri) { + ogs_error("[%s] No dregCallbackUri", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No dregCallbackUri", udm_ue->supi); + return false; + } + + Guami = Amf3GppAccessRegistration->guami; + if (!Guami) { + ogs_error("[%s] No Guami", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No Guami", udm_ue->supi); + return false; + } + + if (!Guami->amf_id) { + ogs_error("[%s] No Guami.AmfId", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No Guami.AmfId", udm_ue->supi); + return false; + } + + if (!Guami->plmn_id) { + ogs_error("[%s] No PlmnId", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No PlmnId", udm_ue->supi); + return false; + } + + if (!Guami->plmn_id->mnc) { + ogs_error("[%s] No PlmnId.Mnc", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No PlmnId.Mnc", udm_ue->supi); + return false; + } + + if (!Guami->plmn_id->mcc) { + ogs_error("[%s] No PlmnId.Mcc", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No PlmnId.Mcc", udm_ue->supi); + return false; + } + + if (!Amf3GppAccessRegistration->rat_type) { + ogs_error("[%s] No RatType", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No RatType", udm_ue->supi); + return false; + } + memset(&sendmsg, 0, sizeof(sendmsg)); memset(&header, 0, sizeof(header)); @@ -320,19 +472,27 @@ bool udm_nudr_dr_handle_subscription_context( ogs_free(sendmsg.http.location); OpenAPI_amf3_gpp_access_registration_free( sendmsg.Amf3GppAccessRegistration); - return true; + break; DEFAULT - ogs_error("Invalid resource name [%s]", - recvmsg->h.resource.component[3]); + strerror = ogs_msprintf("[%s] Invalid resource name [%s]", + udm_ue->supi, recvmsg->h.resource.component[3]); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, strerror, NULL); + ogs_free(strerror); + return false; END - return false; + return true; } bool udm_nudr_dr_handle_subscription_provisioned( udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { + char *strerror = NULL; ogs_sbi_server_t *server = NULL; ogs_sbi_message_t sendmsg; @@ -347,13 +507,26 @@ bool udm_nudr_dr_handle_subscription_provisioned( SWITCH(recvmsg->h.resource.component[4]) CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) + OpenAPI_access_and_mobility_subscription_data_t + *AccessAndMobilitySubscriptionData = NULL; + + AccessAndMobilitySubscriptionData = + recvmsg->AccessAndMobilitySubscriptionData; + if (!AccessAndMobilitySubscriptionData) { + ogs_error("[%s] No AccessAndMobilitySubscriptionData", + udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No AccessAndMobilitySubscriptionData", + udm_ue->supi); + return false; + } + memset(&sendmsg, 0, sizeof(sendmsg)); - if (recvmsg->AccessAndMobilitySubscriptionData) - sendmsg.AccessAndMobilitySubscriptionData = - OpenAPI_access_and_mobility_subscription_data_copy( - sendmsg.AccessAndMobilitySubscriptionData, - recvmsg->AccessAndMobilitySubscriptionData); + sendmsg.AccessAndMobilitySubscriptionData = + OpenAPI_access_and_mobility_subscription_data_copy( + sendmsg.AccessAndMobilitySubscriptionData, + recvmsg->AccessAndMobilitySubscriptionData); response = ogs_sbi_build_response(&sendmsg, recvmsg->res_status); ogs_assert(response); @@ -364,22 +537,56 @@ bool udm_nudr_dr_handle_subscription_provisioned( break; CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA) + OpenAPI_smf_selection_subscription_data_t *SmfSelectionSubscriptionData; + + SmfSelectionSubscriptionData = recvmsg->SmfSelectionSubscriptionData; + if (!SmfSelectionSubscriptionData) { + ogs_error("[%s] No SmfSelectionSubscriptionData", udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No SmfSelectionSubscriptionData", + udm_ue->supi); + return false; + } + + memset(&SmfSelectionSubscriptionData, 0, + sizeof(SmfSelectionSubscriptionData)); + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.SmfSelectionSubscriptionData = + OpenAPI_smf_selection_subscription_data_copy( + sendmsg.SmfSelectionSubscriptionData, + recvmsg->SmfSelectionSubscriptionData); + response = ogs_sbi_build_response(&sendmsg, recvmsg->res_status); ogs_assert(response); ogs_sbi_server_send_response(stream, response); + OpenAPI_smf_selection_subscription_data_free( + sendmsg.SmfSelectionSubscriptionData); break; CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) + OpenAPI_session_management_subscription_data_t * + SessionManagementSubscriptionData = NULL; + + SessionManagementSubscriptionData = + recvmsg->SessionManagementSubscriptionData; + if (!SessionManagementSubscriptionData) { + ogs_error("[%s] No SessionManagementSubscriptionData", + udm_ue->supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No SessionManagementSubscriptionData", + udm_ue->supi); + return false; + } + memset(&sendmsg, 0, sizeof(sendmsg)); - if (recvmsg->SessionManagementSubscriptionData) - sendmsg.SessionManagementSubscriptionData = - OpenAPI_session_management_subscription_data_copy( - sendmsg.SessionManagementSubscriptionData, - recvmsg->SessionManagementSubscriptionData); + sendmsg.SessionManagementSubscriptionData = + OpenAPI_session_management_subscription_data_copy( + sendmsg.SessionManagementSubscriptionData, + recvmsg->SessionManagementSubscriptionData); response = ogs_sbi_build_response(&sendmsg, recvmsg->res_status); ogs_assert(response); @@ -391,8 +598,14 @@ bool udm_nudr_dr_handle_subscription_provisioned( break; DEFAULT - ogs_error("Invalid resource name [%s]", - recvmsg->h.resource.component[3]); + strerror = ogs_msprintf("[%s] Invalid resource name [%s]", + udm_ue->supi, recvmsg->h.resource.component[3]); + ogs_assert(strerror); + + ogs_error("%s", strerror); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, strerror, NULL); + ogs_free(strerror); return false; END diff --git a/src/udm/sbi-path.h b/src/udm/sbi-path.h index a661add52..778a29521 100644 --- a/src/udm/sbi-path.h +++ b/src/udm/sbi-path.h @@ -20,14 +20,12 @@ #ifndef UDM_SBI_PATH_H #define UDM_SBI_PATH_H -#include "context.h" +#include "nudr-build.h" #ifdef __cplusplus extern "C" { #endif -#include "nudr-build.h" - int udm_sbi_open(void); void udm_sbi_close(void); diff --git a/src/udm/ue-sm.c b/src/udm/ue-sm.c index 09457d231..1886f198a 100644 --- a/src/udm/ue-sm.c +++ b/src/udm/ue-sm.c @@ -35,7 +35,6 @@ void udm_ue_state_final(ogs_fsm_t *s, udm_event_t *e) void udm_ue_state_operational(ogs_fsm_t *s, udm_event_t *e) { - bool handled; udm_ue_t *udm_ue = NULL; ogs_sbi_stream_t *stream = NULL; @@ -174,36 +173,11 @@ void udm_ue_state_operational(ogs_fsm_t *s, udm_event_t *e) CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTION_DATA) SWITCH(message->h.resource.component[2]) CASE(OGS_SBI_RESOURCE_NAME_AUTHENTICATION_DATA) - if (message->res_status != OGS_SBI_HTTP_STATUS_OK && - message->res_status != OGS_SBI_HTTP_STATUS_NO_CONTENT) { - if (message->res_status == - OGS_SBI_HTTP_STATUS_NOT_FOUND) { - ogs_warn("[%s] Cannot find SUPI [%d]", - udm_ue->suci, message->res_status); - } else { - ogs_error("[%s] HTTP response error [%d]", - udm_ue->suci, message->res_status); - } - ogs_sbi_server_send_error( - stream, message->res_status, - NULL, "HTTP response error", udm_ue->suci); - break; - } - udm_nudr_dr_handle_subscription_authentication( udm_ue, stream, message); break; CASE(OGS_SBI_RESOURCE_NAME_CONTEXT_DATA) - if (message->res_status != OGS_SBI_HTTP_STATUS_NO_CONTENT) { - ogs_error("[%s] HTTP response error [%d]", - udm_ue->suci, message->res_status); - ogs_sbi_server_send_error( - stream, message->res_status, - NULL, "HTTP response error", udm_ue->suci); - break; - } - udm_nudr_dr_handle_subscription_context( udm_ue, stream, message); break; @@ -211,13 +185,8 @@ void udm_ue_state_operational(ogs_fsm_t *s, udm_event_t *e) DEFAULT SWITCH(message->h.resource.component[3]) CASE(OGS_SBI_RESOURCE_NAME_PROVISIONED_DATA) - handled = udm_nudr_dr_handle_subscription_provisioned( + udm_nudr_dr_handle_subscription_provisioned( udm_ue, stream, message); - if (!handled) { - ogs_sbi_server_send_error( - stream, message->res_status, - NULL, "HTTP response error", udm_ue->suci); - } break; DEFAULT diff --git a/src/udr/nudr-handler.c b/src/udr/nudr-handler.c index da839cb2b..aaea90071 100644 --- a/src/udr/nudr-handler.c +++ b/src/udr/nudr-handler.c @@ -40,7 +40,6 @@ bool udr_nudr_dr_handle_subscription_authentication( OpenAPI_authentication_subscription_t AuthenticationSubscription; OpenAPI_sequence_number_t SequenceNumber; - OpenAPI_auth_event_t *AuthEvent = NULL; OpenAPI_list_t *PatchItemList = NULL; OpenAPI_lnode_t *node = NULL; @@ -186,6 +185,8 @@ bool udr_nudr_dr_handle_subscription_authentication( CASE(OGS_SBI_RESOURCE_NAME_AUTHENTICATION_STATUS) SWITCH(recvmsg->h.method) CASE(OGS_SBI_HTTP_METHOD_PUT) + OpenAPI_auth_event_t *AuthEvent = NULL; + AuthEvent = recvmsg->AuthEvent; if (!AuthEvent) { ogs_error("[%s] No AuthEvent", supi); @@ -263,6 +264,17 @@ bool udr_nudr_dr_handle_subscription_context( CASE(OGS_SBI_RESOURCE_NAME_AMF_3GPP_ACCESS) SWITCH(recvmsg->h.method) CASE(OGS_SBI_HTTP_METHOD_PUT) + OpenAPI_amf3_gpp_access_registration_t *Amf3GppAccessRegistration; + + Amf3GppAccessRegistration = recvmsg->Amf3GppAccessRegistration; + if (!Amf3GppAccessRegistration) { + ogs_error("[%s] No Amf3GppAccessRegistration", supi); + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No Amf3GppAccessRegistration", supi); + return false; + } + memset(&sendmsg, 0, sizeof(sendmsg)); response = ogs_sbi_build_response( @@ -400,7 +412,13 @@ bool udr_nudr_dr_handle_subscription_provisioned( break; CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA) + OpenAPI_smf_selection_subscription_data_t SmfSelectionSubscriptionData; + + memset(&SmfSelectionSubscriptionData, 0, + sizeof(SmfSelectionSubscriptionData)); + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.SmfSelectionSubscriptionData = &SmfSelectionSubscriptionData; response = ogs_sbi_build_response(&sendmsg, OGS_SBI_HTTP_STATUS_OK); ogs_assert(response); @@ -423,16 +441,17 @@ bool udr_nudr_dr_handle_subscription_provisioned( OpenAPI_ip_address_t *ipAddress = NULL; OpenAPI_lnode_t *node = NULL, *node2 = NULL; - if (!recvmsg->param.s_nssai_presence) { + if (!recvmsg->param.single_nssai_presence) { ogs_error("[%s] Cannot find S_NSSAI", supi); ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, recvmsg, "Cannot find S_NSSAI", supi); return false; } - singleNSSAI.sst = recvmsg->param.s_nssai.sst; - singleNSSAI.sd = ogs_s_nssai_sd_to_string(recvmsg->param.s_nssai.sd); + singleNSSAI.sst = recvmsg->param.single_nssai.sst; + singleNSSAI.sd = ogs_s_nssai_sd_to_string( + recvmsg->param.single_nssai.sd); dnnConfigurationList = OpenAPI_list_create(); @@ -671,3 +690,215 @@ bool udr_nudr_dr_handle_subscription_provisioned( return true; } + +bool udr_nudr_dr_handle_policy_data( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) +{ + int rv, i; + + ogs_sbi_message_t sendmsg; + ogs_sbi_response_t *response = NULL; + + ogs_assert(stream); + ogs_assert(recvmsg); + + SWITCH(recvmsg->h.resource.component[1]) + CASE(OGS_SBI_RESOURCE_NAME_UES) + ogs_subscription_data_t subscription_data; + char *supi = recvmsg->h.resource.component[2]; + + if (!supi) { + ogs_error("No SUPI"); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No SUPI", NULL); + return false; + } + + if (strncmp(supi, + OGS_ID_SUPI_TYPE_IMSI, strlen(OGS_ID_SUPI_TYPE_IMSI)) != 0) { + ogs_error("[%s] Unknown SUPI Type", supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, + recvmsg, "Unknwon SUPI Type", supi); + return false; + } + + SWITCH(recvmsg->h.method) + CASE(OGS_SBI_HTTP_METHOD_GET) + OpenAPI_lnode_t *node = NULL, *node2 = NULL; + + rv = ogs_dbi_subscription_data(supi, &subscription_data); + if (rv != OGS_OK) { + ogs_error("[%s] Cannot find SUPI in DB", supi); + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_NOT_FOUND, + recvmsg, "Cannot find SUPI Type", supi); + return false; + } + + SWITCH(recvmsg->h.resource.component[3]) + CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) + OpenAPI_am_policy_data_t AmPolicyData; + + memset(&AmPolicyData, 0, sizeof(AmPolicyData)); + + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.AmPolicyData = &AmPolicyData; + + response = ogs_sbi_build_response( + &sendmsg, OGS_SBI_HTTP_STATUS_OK); + ogs_assert(response); + ogs_sbi_server_send_response(stream, response); + + return true; + + CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) + OpenAPI_sm_policy_data_t SmPolicyData; + + OpenAPI_list_t *SmPolicySnssaiDataList = NULL; + OpenAPI_map_t *SmPolicySnssaiDataMap = NULL; + OpenAPI_sm_policy_snssai_data_t *SmPolicySnssaiData = NULL; + + OpenAPI_snssai_t *sNSSAI = NULL; + + OpenAPI_list_t *SmPolicyDnnDataList = NULL; + OpenAPI_map_t *SmPolicyDnnDataMap = NULL; + OpenAPI_sm_policy_dnn_data_t *SmPolicyDnnData = NULL; + + if (!recvmsg->param.snssai_presence) { + ogs_error("[%s] Cannot find S_NSSAI", supi); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "Cannot find S_NSSAI", supi); + return false; + } + + sNSSAI = ogs_calloc(1, sizeof(*sNSSAI)); + ogs_assert(sNSSAI); + sNSSAI->sst = recvmsg->param.snssai.sst; + sNSSAI->sd = ogs_s_nssai_sd_to_string(recvmsg->param.snssai.sd); + + SmPolicyDnnDataList = OpenAPI_list_create(); + ogs_assert(SmPolicyDnnDataList); + + for (i = 0; i < subscription_data.num_of_pdn; i++) { + ogs_pdn_t *pdn = &subscription_data.pdn[i]; + ogs_assert(pdn); + + if (recvmsg->param.dnn && + ogs_strcasecmp(recvmsg->param.dnn, pdn->apn) != 0) + continue; + + SmPolicyDnnData = ogs_calloc(1, sizeof(*SmPolicyDnnData)); + ogs_assert(SmPolicyDnnData); + + SmPolicyDnnData->dnn = pdn->apn; + + SmPolicyDnnDataMap = OpenAPI_map_create( + pdn->apn, SmPolicyDnnData); + ogs_assert(SmPolicyDnnDataMap); + + OpenAPI_list_add(SmPolicyDnnDataList, SmPolicyDnnDataMap); + } + + SmPolicySnssaiData = ogs_calloc(1, sizeof(*SmPolicySnssaiData)); + ogs_assert(SmPolicySnssaiData); + + SmPolicySnssaiData->snssai = sNSSAI; + if (SmPolicyDnnDataList->count) + SmPolicySnssaiData->sm_policy_dnn_data = + SmPolicyDnnDataList; + else + OpenAPI_list_free(SmPolicyDnnDataList); + + SmPolicySnssaiDataMap = OpenAPI_map_create( + ogs_sbi_s_nssai_to_string(&recvmsg->param.snssai), + SmPolicySnssaiData); + ogs_assert(SmPolicySnssaiDataMap); + + SmPolicySnssaiDataList = OpenAPI_list_create(); + ogs_assert(SmPolicySnssaiDataList); + + OpenAPI_list_add(SmPolicySnssaiDataList, SmPolicySnssaiDataMap); + + memset(&SmPolicyData, 0, sizeof(SmPolicyData)); + + if (SmPolicySnssaiDataList->count) + SmPolicyData.sm_policy_snssai_data = SmPolicySnssaiDataList; + else + OpenAPI_list_free(SmPolicySnssaiDataList); + + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.SmPolicyData = &SmPolicyData; + + response = ogs_sbi_build_response( + &sendmsg, OGS_SBI_HTTP_STATUS_OK); + ogs_assert(response); + ogs_sbi_server_send_response(stream, response); + + SmPolicySnssaiDataList = SmPolicyData.sm_policy_snssai_data; + OpenAPI_list_for_each(SmPolicySnssaiDataList, node) { + SmPolicySnssaiDataMap = node->data; + if (SmPolicySnssaiDataMap) { + SmPolicySnssaiData = SmPolicySnssaiDataMap->value; + if (SmPolicySnssaiData) { + sNSSAI = SmPolicySnssaiData->snssai; + if (sNSSAI) { + if (sNSSAI->sd) ogs_free(sNSSAI->sd); + ogs_free(sNSSAI); + } + SmPolicyDnnDataList = + SmPolicySnssaiData->sm_policy_dnn_data; + if (SmPolicyDnnDataList) { + OpenAPI_list_for_each( + SmPolicyDnnDataList, node2) { + SmPolicyDnnDataMap = node2->data; + if (SmPolicyDnnDataMap) { + SmPolicyDnnData = + SmPolicyDnnDataMap->value; + if (SmPolicyDnnData) { + ogs_free(SmPolicyDnnData); + } + ogs_free(SmPolicyDnnDataMap); + } + } + OpenAPI_list_free(SmPolicyDnnDataList); + } + ogs_free(SmPolicySnssaiData); + } + if (SmPolicySnssaiDataMap->key) + ogs_free(SmPolicySnssaiDataMap->key); + ogs_free(SmPolicySnssaiDataMap); + } + } + OpenAPI_list_free(SmPolicySnssaiDataList); + + return true; + + DEFAULT + ogs_error("Invalid resource name [%s]", + recvmsg->h.resource.component[3]); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_MEHTOD_NOT_ALLOWED, + recvmsg, "Unknown resource name", + recvmsg->h.resource.component[3]); + END + break; + + DEFAULT + ogs_error("Invalid HTTP method [%s]", recvmsg->h.method); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_MEHTOD_NOT_ALLOWED, + recvmsg, "Invalid HTTP method", recvmsg->h.method); + END + break; + + DEFAULT + ogs_error("Invalid resource name [%s]", + recvmsg->h.resource.component[1]); + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_MEHTOD_NOT_ALLOWED, + recvmsg, "Unknown resource name", + recvmsg->h.resource.component[1]); + END + + return false; +} diff --git a/src/udr/nudr-handler.h b/src/udr/nudr-handler.h index fdb1e07e1..d0977ab08 100644 --- a/src/udr/nudr-handler.h +++ b/src/udr/nudr-handler.h @@ -33,6 +33,9 @@ bool udr_nudr_dr_handle_subscription_context( bool udr_nudr_dr_handle_subscription_provisioned( ogs_sbi_stream_t *stream, ogs_sbi_message_t *message); +bool udr_nudr_dr_handle_policy_data( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *message); + #ifdef __cplusplus } #endif diff --git a/src/udr/udr-sm.c b/src/udr/udr-sm.c index fd4fd2342..d931dff83 100644 --- a/src/udr/udr-sm.c +++ b/src/udr/udr-sm.c @@ -158,6 +158,11 @@ void udr_state_operational(ogs_fsm_t *s, udr_event_t *e) END END break; + + CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA) + udr_nudr_dr_handle_policy_data(stream, &message); + break; + DEFAULT ogs_error("Invalid resource name [%s]", message.h.resource.component[0]); diff --git a/src/upf/gtp-path.c b/src/upf/gtp-path.c index 9f70705f7..4ba14648f 100644 --- a/src/upf/gtp-path.c +++ b/src/upf/gtp-path.c @@ -237,8 +237,10 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data) dev = subnet->dev; ogs_assert(dev); - if (ogs_write(dev->fd, pkbuf->data, pkbuf->len) <= 0) - ogs_error("ogs_write() failed"); + if (ogs_write(dev->fd, pkbuf->data, pkbuf->len) <= 0) { + ogs_log_message(OGS_LOG_ERROR, + ogs_socket_errno, "ogs_write() failed"); + } } else { ogs_error("[DROP] Invalid GTPU Type [%d]", gtp_h->type); ogs_log_hexdump(OGS_LOG_ERROR, pkbuf->data, pkbuf->len); diff --git a/tests/app/5gc-init.c b/tests/app/5gc-init.c index d4b1febc7..8ff409955 100644 --- a/tests/app/5gc-init.c +++ b/tests/app/5gc-init.c @@ -22,6 +22,7 @@ static ogs_thread_t *nrf_thread = NULL; static ogs_thread_t *ausf_thread = NULL; static ogs_thread_t *udm_thread = NULL; +static ogs_thread_t *pcf_thread = NULL; static ogs_thread_t *udr_thread = NULL; static ogs_thread_t *upf_thread = NULL; static ogs_thread_t *smf_thread = NULL; @@ -52,6 +53,8 @@ int app_initialize(const char *const argv[]) if (ogs_app()->parameter.no_udr == 0) udr_thread = test_child_create("udr", argv_out); + if (ogs_app()->parameter.no_pcf == 0) + pcf_thread = test_child_create("pcf", argv_out); if (ogs_app()->parameter.no_udm == 0) udm_thread = test_child_create("udm", argv_out); if (ogs_app()->parameter.no_ausf == 0) @@ -84,6 +87,7 @@ void app_terminate(void) if (ausf_thread) ogs_thread_destroy(ausf_thread); if (udm_thread) ogs_thread_destroy(udm_thread); + if (pcf_thread) ogs_thread_destroy(pcf_thread); if (udr_thread) ogs_thread_destroy(udr_thread); if (nrf_thread) ogs_thread_destroy(nrf_thread); diff --git a/tests/app/app-init.c b/tests/app/app-init.c index 489dc1f7c..9b3afd6fd 100644 --- a/tests/app/app-init.c +++ b/tests/app/app-init.c @@ -24,6 +24,7 @@ static ogs_thread_t *pcrf_thread = NULL; static ogs_thread_t *hss_thread = NULL; static ogs_thread_t *ausf_thread = NULL; static ogs_thread_t *udm_thread = NULL; +static ogs_thread_t *pcf_thread = NULL; static ogs_thread_t *udr_thread = NULL; static ogs_thread_t *upf_thread = NULL; static ogs_thread_t *sgwc_thread = NULL; @@ -61,6 +62,8 @@ int app_initialize(const char *const argv[]) if (ogs_app()->parameter.no_udr == 0) udr_thread = test_child_create("udr", argv_out); + if (ogs_app()->parameter.no_pcf == 0) + pcf_thread = test_child_create("pcf", argv_out); if (ogs_app()->parameter.no_udm == 0) udm_thread = test_child_create("udm", argv_out); if (ogs_app()->parameter.no_ausf == 0) @@ -104,6 +107,7 @@ void app_terminate(void) if (ausf_thread) ogs_thread_destroy(ausf_thread); if (udm_thread) ogs_thread_destroy(udm_thread); + if (pcf_thread) ogs_thread_destroy(pcf_thread); if (udr_thread) ogs_thread_destroy(udr_thread); if (hss_thread) ogs_thread_destroy(hss_thread); diff --git a/tests/minimal/minimal-test.c b/tests/minimal/minimal-test.c index 16dabc16b..3f6215497 100644 --- a/tests/minimal/minimal-test.c +++ b/tests/minimal/minimal-test.c @@ -50,6 +50,10 @@ static void test1_func(abts_case *tc, void *data) "{" "\"_id\" : { \"$oid\" : \"597223158b8861d7605378c6\" }, " "\"imsi\" : \"2089300007487\", " +#if 0 + "\"msisdn\" : [\"821012345678\", \"82107654321\" ], " + "\"msisdn\" : [\"82107654321\", \"821012345678\" ], " +#endif "\"pdn\" : [" "{" "\"apn\" : \"internet\", "